From abdf1ae9f83a5214bad690eab5702637ef8ffeaa Mon Sep 17 00:00:00 2001 From: Charles de Dreuille Date: Fri, 17 May 2024 21:54:02 +0100 Subject: [PATCH] Add missing controls --- .../components/home/hero/manager/controls.tsx | 250 +++++++++++++++--- .../home/hero/manager/panel-controls.tsx | 138 +--------- 2 files changed, 212 insertions(+), 176 deletions(-) diff --git a/apps/frontpage/components/home/hero/manager/controls.tsx b/apps/frontpage/components/home/hero/manager/controls.tsx index 2b00e8f6..9bf15d4e 100644 --- a/apps/frontpage/components/home/hero/manager/controls.tsx +++ b/apps/frontpage/components/home/hero/manager/controls.tsx @@ -1,28 +1,5 @@ import { cn } from '@repo/utils'; -import type { FC } from 'react'; - -const content = [ - { - label: 'label', - description: 'Label of component', - default: 'Choose time frame', - control: 'Usage frequency', - }, - { - label: 'startTime', - description: 'Start time in 24h notation', - default: 'undefined', - control: 'Edit string', - muted: true, - }, - { - label: 'endTime', - description: 'End time in 24h notation', - default: 'undefined', - control: 'Edit string', - muted: true, - }, -]; +import type { FC, ReactNode } from 'react'; export const Controls: FC<{ isPanel?: boolean }> = ({ isPanel = false }) => { return ( @@ -35,31 +12,222 @@ export const Controls: FC<{ isPanel?: boolean }> = ({ isPanel = false }) => { > Props - {content.map((item) => ( -
-
- {item.label} -
-
- {item.description} + } + description="Button label" + isPanel={isPanel} + label="buttonLabel" + required + /> + } + description="Placeholder text" + isPanel={isPanel} + label="placeholder" + required + /> + } + description="Disable the component" + isPanel={isPanel} + label="disabled" + /> + } + description="Primary color of the component" + isPanel={isPanel} + label="primaryColor" + /> + } + isPanel={isPanel} + label="playfulness" + /> + } + defaultValue="medium" + description="Size of the prompt" + isPanel={isPanel} + label="size" + /> +
+ ); +}; + +const Line = ({ + label, + control, + required = false, + description, + defaultValue, + isPanel = false, +}: { + label: ReactNode; + control: ReactNode; + required?: boolean; + description?: string; + defaultValue?: ReactNode; + isPanel: boolean; +}) => { + return ( +
+
+ {label} + {required ? * : null} +
+ {!isPanel && ( + <> +
+ {description}
-
-
- {item.default} -
+
+ {defaultValue ? ( +
+ {defaultValue} +
+ ) : ( + '-' + )}
-
+ + )} +
+ {control} +
+
+ ); +}; + +const Input = ({ + value, + muted = false, +}: { + value: string; + muted?: boolean; +}) => { + return ( +
+ {value} +
+ ); +}; + +const Boolean = ({ value }: { value: boolean }) => { + return ( +
+
+ False +
+
+ True +
+
+
+ ); +}; + +const Color = ({ + value, + muted = false, +}: { + value: string; + muted?: boolean; +}) => { + return ( +
+
+
+ {value} +
+ + + + + + + + + + +
+ ); +}; + +const Range = ({ value }: { value: number }) => { + return ( +
+
0
+
+
+
+
+
100
+
+ ); +}; + +const Radio = () => { + return ( +
+ {[{ label: 'small' }, { label: 'medium' }, { label: 'large' }].map( + (item) => ( +
- {item.control} + {item.label === 'medium' && ( +
+ )}
+ {item.label}
-
- ))} + ), + )}
); }; diff --git a/apps/frontpage/components/home/hero/manager/panel-controls.tsx b/apps/frontpage/components/home/hero/manager/panel-controls.tsx index 5bcdb509..fba9ed49 100644 --- a/apps/frontpage/components/home/hero/manager/panel-controls.tsx +++ b/apps/frontpage/components/home/hero/manager/panel-controls.tsx @@ -1,8 +1,8 @@ -import type { FC, ReactNode } from 'react'; +import type { FC } from 'react'; import { motion } from 'framer-motion'; import { UndoIcon } from '@storybook/icons'; -import { cn } from '@repo/utils'; import { Tabs } from './tabs'; +import { Controls } from './controls'; export const PanelControls: FC = () => { return ( @@ -22,139 +22,7 @@ export const PanelControls: FC = () => {
-
- } - label="buttonLabel" - required - /> - } - label="placeholder" - required - /> - } label="disabled" /> - } label="primaryColor" /> - } label="playfulness" /> -
+ ); }; - -const Line = ({ - label, - control, - required = false, -}: { - label: ReactNode; - control: ReactNode; - required?: boolean; -}) => { - return ( -
-
- {label} - {required ? * : null} -
-
{control}
-
- ); -}; - -const Input = ({ - value, - muted = false, -}: { - value: string; - muted?: boolean; -}) => { - return ( -
- {value} -
- ); -}; - -const Boolean = ({ value }: { value: boolean }) => { - return ( -
-
- False -
-
- True -
-
-
- ); -}; - -const Color = ({ - value, - muted = false, -}: { - value: string; - muted?: boolean; -}) => { - return ( -
-
-
- {value} -
- - - - - - - - - - -
- ); -}; - -const Range = ({ value }: { value: number }) => { - return ( -
-
0
-
-
-
-
-
100
-
- ); -};