Skip to content

Commit 8681e3c

Browse files
omgovichVlad Shilov
authored andcommitted
Add a simple demo to test the iframe embedding
1 parent 9f3b876 commit 8681e3c

File tree

4 files changed

+32
-1
lines changed

4 files changed

+32
-1
lines changed

demo/src/components/DevTools.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,13 @@ export const DevTools = (): JSX.Element => {
9393
PickerComponent={HsvaStringColorPicker}
9494
initialColor="hsva(200, 25%, 50%, 0.5)"
9595
/>
96+
97+
<PickerPreview<RgbColor>
98+
frame
99+
title="RGB"
100+
PickerComponent={RgbColorPicker}
101+
initialColor={{ r: 60, g: 80, b: 120 }}
102+
/>
96103
</div>
97104
);
98105
};

demo/src/components/PickerPreview.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
import React, { useState } from "react";
2+
import Frame from "react-frame-component";
23
import { HexColorInput } from "../../../src";
34
import { ColorPickerBaseProps, AnyColor } from "../../../src/types";
45
import { PreviewContainer, PreviewDemo, PreviewOutput, PreviewTitle } from "../styles";
56

67
interface Props<T extends AnyColor> {
78
title: string;
9+
frame?: boolean;
810
PickerComponent: React.ComponentType<Partial<ColorPickerBaseProps<T>>>;
911
initialColor?: T;
1012
}
1113

1214
export function PickerPreview<T extends AnyColor>({
1315
title,
16+
frame,
1417
PickerComponent,
1518
initialColor,
1619
}: Props<T>): JSX.Element {
@@ -21,11 +24,15 @@ export function PickerPreview<T extends AnyColor>({
2124
setColor(color);
2225
};
2326

27+
const Wrapper = frame ? Frame : React.Fragment;
28+
2429
return (
2530
<PreviewContainer>
2631
<PreviewTitle>{title}</PreviewTitle>
2732
<PreviewDemo>
28-
<PickerComponent color={color} onChange={handleChange} />
33+
<Wrapper>
34+
<PickerComponent color={color} onChange={handleChange} />
35+
</Wrapper>
2936
{/* eslint-disable-next-line @typescript-eslint/ban-ts-comment */}
3037
{/* @ts-ignore */}
3138
{title === "HEX" && <HexColorInput color={color} onChange={handleChange} prefixed alpha />}

package-lock.json

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

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@
171171
"@types/jest": "^26.0.20",
172172
"@types/react": "^17.0.0",
173173
"@types/react-dom": "^17.0.0",
174+
"@types/react-frame-component": "^4.1.3",
174175
"@typescript-eslint/eslint-plugin": "^4.17.0",
175176
"@typescript-eslint/parser": "^4.17.0",
176177
"cpy-cli": "^3.1.1",
@@ -190,6 +191,7 @@
190191
"prettier": "^2.2.1",
191192
"react": "^17.0.2",
192193
"react-dom": "^17.0.2",
194+
"react-frame-component": "^5.1.0",
193195
"size-limit": "^4.10.1",
194196
"ts-jest": "^26.5.3",
195197
"typescript": "^4.2.3",

0 commit comments

Comments
 (0)