Skip to content

Commit 6049f89

Browse files
fix: simplified image story;
fixed children types; removed demo.tsx (no longer relevant); removed serve dependencies and serve script
1 parent 4860de4 commit 6049f89

File tree

7 files changed

+15
-205
lines changed

7 files changed

+15
-205
lines changed

packages/react/package-lock.json

Lines changed: 0 additions & 42 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/react/package.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
},
1515
"scripts": {
1616
"build": "npm run build --prefix ../html && tsc && rollup -c && cp package.json ./dist",
17-
"serve": "rollup -w -c rollup-serve.config.js",
1817
"lint": "eslint ./src",
1918
"typecheck": "tsc --noEmit --skipLibCheck --project ./tsconfig.json",
2019
"test": "mocha src/**/*.test.*",
@@ -71,8 +70,6 @@
7170
"react": "^16.13.1",
7271
"react-dom": "^16.13.1",
7372
"rollup": "^2.66.1",
74-
"rollup-plugin-inject-process-env": "^1.3.1",
75-
"rollup-plugin-serve": "^1.1.1",
7673
"storybook": "^8.4.7",
7774
"ts-node": "^10.9.2",
7875
"tslib": "^2.8.1",

packages/react/rollup-serve.config.js

Lines changed: 0 additions & 39 deletions
This file was deleted.

packages/react/src/CloudinaryImage.stories.tsx

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,30 @@
11
import type { Meta, StoryObj } from '@storybook/react';
2-
import type { ComponentType } from 'react';
3-
import { CloudinaryImage, CloudinaryImageProps } from './CloudinaryImage';
2+
import { CloudinaryImage } from './CloudinaryImage';
43
import { Cloudinary } from '@cloudinary/url-gen';
54
import { backgroundRemoval, sepia } from '@cloudinary/url-gen/actions/effect';
65
import { scale } from '@cloudinary/url-gen/actions/resize';
76
import { format, quality } from '@cloudinary/url-gen/actions/delivery';
87

9-
// FIXME `Meta` cant handle discriminated union or `forwardRef`
10-
const meta: Meta<ComponentType<CloudinaryImageProps>>= {
8+
const meta: Meta<typeof CloudinaryImage>= {
119
component: CloudinaryImage,
1210
};
1311

1412
export default meta;
15-
// FIXME `StoryObj` cant handle discriminated union
16-
type V3Story = StoryObj<ComponentType<Extract<CloudinaryImageProps, {src: string}>>>;
13+
type Story = StoryObj<typeof CloudinaryImage>;
1714

18-
export const VersionV3: V3Story = {
15+
export const VersionV3: Story = {
1916
args: {
2017
src: 'https://res.cloudinary.com/demo/image/upload/front_face',
2118
alt: 'front face',
2219
removeBackground: true,
2320
effects: [{ type: 'sepia' }],
2421
resize: { height: 333 },
2522
format: 'auto',
26-
quality: 'auto'
23+
quality: 'auto',
24+
opacity: 100,
25+
background: { type: 'color', color: 'white' },
26+
roundCorners: 0,
27+
rotate: 0,
2728
}
2829
};
2930

@@ -40,7 +41,7 @@ const cloudinaryImageObject = cloudinary
4041
.delivery(format('auto'))
4142
.delivery(quality('auto'));
4243

43-
export const VersionV2 = {
44+
export const VersionV2: Story = {
4445
args: {
4546
cldImg: cloudinaryImageObject,
4647
}

packages/react/src/CloudinaryImage.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,13 @@ type ImageV3Props = {
4848
cldImg?: never
4949
src: string;
5050
alt: string;
51+
children?: never;
5152
} & ImageTransformationProps;
5253

5354
interface ImageV2Props {
5455
src?: never;
5556
cldImg: UrlGenCloudinaryImage;
57+
children?: never;
5658
}
5759

5860
export type CloudinaryImageProps = ImageV3Props | ImageV2Props;

packages/react/src/CloudinaryVideo.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { forwardRef } from 'react';
1+
import React, { forwardRef, ReactNode } from 'react';
22
import { type CloudinaryVideo as UrlGenCloudinaryVideo } from '@cloudinary/url-gen/assets/CloudinaryVideo';
33
import { parseCloudinaryUrlToParts } from './parseCloudinaryUrlToParts';
44
import { parseFormat } from './transformationParsers/parseFormat';
@@ -55,11 +55,13 @@ type VideoV3Props = {
5555
cldVid?: never;
5656
src: string;
5757
videoProps?: React.HTMLProps<HTMLVideoElement>
58+
children?: never;
5859
} & VideoTransformationProps;
5960

6061
interface VideoV2Props extends React.HTMLProps<HTMLVideoElement> {
6162
src?: never;
6263
cldVid: UrlGenCloudinaryVideo;
64+
children?: never;
6365
}
6466

6567
export type CloudinaryVideoProps = VideoV3Props | VideoV2Props;

packages/react/src/demo.tsx

Lines changed: 0 additions & 111 deletions
This file was deleted.

0 commit comments

Comments
 (0)