EffectsToolbarHeader.tsx 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /**
  2. * Copyright (c) Meta Platforms, Inc. and affiliates.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. import ToolbarHeaderWrapper from '@/common/components/toolbar/ToolbarHeaderWrapper';
  17. import useVideoEffect from '@/common/components/video/editor/useVideoEffect';
  18. import {
  19. EffectIndex,
  20. effectPresets,
  21. } from '@/common/components/video/effects/Effects';
  22. import {BLUE_PINK_FILL} from '@/theme/gradientStyle';
  23. import {MagicWandFilled} from '@carbon/icons-react';
  24. import {useCallback, useRef} from 'react';
  25. import {Button} from 'react-daisyui';
  26. export default function EffectsToolbarHeader() {
  27. const preset = useRef(0);
  28. const setEffect = useVideoEffect();
  29. const handleTogglePreset = useCallback(() => {
  30. preset.current++;
  31. const [background, highlight] =
  32. effectPresets[preset.current % effectPresets.length];
  33. setEffect(background.name, EffectIndex.BACKGROUND, {
  34. variant: background.variant,
  35. });
  36. setEffect(highlight.name, EffectIndex.HIGHLIGHT, {
  37. variant: highlight.variant,
  38. });
  39. }, [setEffect]);
  40. return (
  41. <ToolbarHeaderWrapper
  42. title="Add effects"
  43. description="Apply visual effects to your selected objects and the background. Keeping clicking the same effect for different variations."
  44. bottomSection={
  45. <div className="flex mt-1">
  46. <Button
  47. color="ghost"
  48. size="md"
  49. className={`font-medium bg-black !rounded-full hover:!bg-gradient-to-br ${BLUE_PINK_FILL} border-none`}
  50. endIcon={<MagicWandFilled size={20} className="text-white " />}
  51. onClick={handleTogglePreset}>
  52. Surprise Me
  53. </Button>
  54. </div>
  55. }
  56. className="pb-4"
  57. />
  58. );
  59. }