Skip to content

Commit ad79f6e

Browse files
feat: separate effects for vide / image; storybook adjustments
1 parent b456a36 commit ad79f6e

File tree

6 files changed

+49
-40
lines changed

6 files changed

+49
-40
lines changed

packages/react/src/CloudinaryImage.stories.tsx

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,22 @@ export default meta;
1515
type Story = StoryObj<typeof CloudinaryImage>;
1616

1717
export const VersionV3: Story = {
18-
args: {
19-
src: 'https://res.cloudinary.com/demo/image/upload/front_face',
20-
alt: 'front face',
21-
removeBackground: true,
22-
effects: [{ type: 'sepia' }],
23-
resize: { height: 333 },
24-
format: 'auto',
25-
quality: 'auto',
26-
opacity: 100,
27-
background: { type: 'color', color: 'white' },
28-
roundCorners: 0,
29-
rotate: 0
18+
render: () => {
19+
return (
20+
<CloudinaryImage
21+
src='https://res.cloudinary.com/demo/image/upload/front_face'
22+
alt='front face'
23+
removeBackground
24+
effects={[{ type: 'sepia' }]}
25+
resize={{ height: 333 }}
26+
format='auto'
27+
quality='auto'
28+
opacity={100}
29+
background={{ type: 'color', color: 'white' }}
30+
roundCorners={0}
31+
rotate={0}
32+
/>
33+
);
3034
}
3135
};
3236

packages/react/src/CloudinaryImage.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import { parseOpacity } from './transformationParsers/parseOpacity';
2424
import { Quality } from './transformationTypes/quality';
2525
import { ImageFormat } from './transformationTypes/format';
2626
import { RemoveBackground } from './transformationTypes/removeBackground';
27-
import { Effect } from './transformationTypes/effect';
27+
import { ImageEffect } from './transformationTypes/effect';
2828
import { Background } from './transformationTypes/background';
2929
import { Rotate } from './transformationTypes/rotate';
3030
import { RoundCorners } from './transformationTypes/roundCorners';
@@ -36,7 +36,7 @@ type ImageTransformationProps = {
3636
quality?: Quality;
3737
format?: ImageFormat;
3838
removeBackground?: RemoveBackground;
39-
effects?: Effect[];
39+
effects?: ImageEffect[];
4040
background?: Background;
4141
rotate?: Rotate;
4242
roundCorners?: RoundCorners;

packages/react/src/CloudinaryVideo.stories.tsx

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,22 @@ export default meta;
2020
type Story = StoryObj<typeof CloudinaryVideo>;
2121

2222
export const Version_v3: Story = {
23-
args: {
24-
src: 'https://res.cloudinary.com/demo/video/upload/dog.mp4',
25-
resize: { height: 333 },
26-
roundCorners: 20,
27-
duration: '1%',
28-
startOffset: 0,
29-
videoCodec: 'h264',
30-
videoProps: {
31-
loop: true,
32-
autoPlay: true,
33-
muted: true
34-
}
23+
render: () => {
24+
return (
25+
<CloudinaryVideo
26+
src='https://res.cloudinary.com/demo/video/upload/dog.mp4'
27+
videoProps={{
28+
loop: true,
29+
autoPlay: true,
30+
muted: true
31+
}}
32+
resize={{ height: 333 }}
33+
roundCorners={20}
34+
duration='1%'
35+
startOffset={0}
36+
videoCodec='h264'
37+
/>
38+
)
3539
}
3640
};
3741

packages/react/src/CloudinaryVideo.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,15 @@ import { parseIgnoreAspectRatio } from './transformationParsers/parseIgnoreAspec
3232
import { parseZoom } from './transformationParsers/parseZoom';
3333
import { RemoveBackground } from './transformationTypes/removeBackground';
3434
import { parseEffects } from './transformationParsers/parseEffects';
35-
import { Effect } from './transformationTypes/effect';
35+
import { VideoEffect } from './transformationTypes/effect';
3636
import { parseRemoveBackground } from './transformationParsers/parseRemoveBackground';
3737
import { Resize } from './transformationTypes/resize';
3838

3939
export type VideoTransformationProps = {
4040
quality?: Quality;
4141
format?: VideoFormat;
4242
removeBackground?: RemoveBackground;
43-
effects?: Effect[];
43+
effects?: VideoEffect[];
4444
background?: Background;
4545
rotate?: Rotate;
4646
roundCorners?: RoundCorners;

packages/react/src/transformationParsers/parseEffects.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { Effect } from '../transformationTypes/effect';
1+
import { AnyEffect } from '../transformationTypes/effect';
22
import { parseRemoveBackground as ParseRemoveBackground } from './parseRemoveBackground';
33

4-
export const parseEffects = (parseRemoveBackground: typeof ParseRemoveBackground) => (effects: Effect[]): string => {
4+
export const parseEffects = (parseRemoveBackground: typeof ParseRemoveBackground) => (effects: AnyEffect[]): string => {
55
return effects
66
.map((effect):`e_${string}` => {
77
switch (effect.type) {
@@ -12,7 +12,7 @@ export const parseEffects = (parseRemoveBackground: typeof ParseRemoveBackground
1212
case 'fade':
1313
return `e_fade:${effect.duration}`;
1414
case 'gamma':
15-
return `e_gamma:${effect.duration}`;
15+
return `e_gamma:${effect.level}`;
1616
case 'grayscale':
1717
return 'e_grayscale';
1818
case 'light':

packages/react/src/transformationTypes/effect.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ type Gamma = {
1919
/**
2020
* @description -50 to 150
2121
*/
22-
duration: number;
22+
level: number;
2323
}
2424
// FIXME image only
2525
type Grayscale = {
@@ -72,20 +72,21 @@ type Auto = {
7272
blendPercentage?: number;
7373
}
7474

75-
type AutoColor = {
76-
type: 'autoColor';
77-
78-
}
79-
80-
export type Effect =
75+
export type ImageEffect =
8176
| Sepia
8277
| BackgroundRemoval
83-
| Fade
8478
| Gamma
8579
| Grayscale
8680
| Light
8781
| Negate
88-
| Noise
8982
| Pixelate
9083
| Blur
9184
| Auto;
85+
86+
export type VideoEffect =
87+
| Fade
88+
| Gamma
89+
| Noise
90+
| Blur;
91+
92+
export type AnyEffect = ImageEffect | VideoEffect;

0 commit comments

Comments
 (0)