From 4b2367699a765a7f7b8fe17663170621e52e072e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=C3=A8sAbhi?= <43380238+tresabhi@users.noreply.github.com> Date: Tue, 6 Aug 2024 14:05:16 -0500 Subject: [PATCH] feat: better layout --- src/app/layout.tsx | 7 +- src/components/EmbedConfigInputs.tsx | 927 +++++++++++++-------------- src/components/PageWrapper.tsx | 5 +- 3 files changed, 464 insertions(+), 475 deletions(-) diff --git a/src/app/layout.tsx b/src/app/layout.tsx index 6d716bb70..c1ba92f11 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -28,9 +28,10 @@ const robotoFlex = Roboto_Flex({ export default function RootLayout({ children }: RootLayoutProps) { const pathname = usePathname(); - const hideNav = - pathname.startsWith('/tools/embed/host') || - pathname.startsWith('/tools/embed/customize'); + // const hideNav = + // pathname.startsWith('/tools/embed/host') || + // pathname.startsWith('/tools/embed/customize'); + const hideNav = false; const isRoot = pathname === '/'; return ( diff --git a/src/components/EmbedConfigInputs.tsx b/src/components/EmbedConfigInputs.tsx index e853c0111..b710e2983 100644 --- a/src/components/EmbedConfigInputs.tsx +++ b/src/components/EmbedConfigInputs.tsx @@ -1,9 +1,9 @@ import * as radixColors from '@radix-ui/colors'; import { - DragHandleDots2Icon, - EnterFullScreenIcon, - ExitFullScreenIcon, + BorderSolidIcon, + Cross1Icon, ImageIcon, + SquareIcon, } from '@radix-ui/react-icons'; import { Box, @@ -47,6 +47,9 @@ import { radixTextWeights, } from '../app/tools/embed/types'; import { toColorVar, toRadiusVar } from '../app/tools/embed/utilities'; +import { imgur } from '../core/blitzkit/imgur'; +import { NAVBAR_HEIGHT } from './Navbar'; +import PageWrapper from './PageWrapper'; interface EmbedConfigInputsProps { config: EmbedConfig; @@ -61,10 +64,7 @@ export function EmbedConfigInputs({ setState, children, }: EmbedConfigInputsProps) { - const [expanded, setExpanded] = useState(true); - const [backgroundImage, setBackgroundImage] = useState( - 'https://upload.wikimedia.org/wikipedia/commons/f/f6/Swiss_National_Park_131.JPG', - ); + const [backgroundImage, setBackgroundImage] = useState(imgur('SO13zur')); const mutateState = useCallback( (recipe: (draft: ExtractEmbedConfigType) => void) => { setState(produce(recipe)); @@ -99,444 +99,53 @@ export function EmbedConfigInputs({ }, []); return ( - - - - { - event.preventDefault(); - window.addEventListener('pointermove', handlePointerMove); - window.addEventListener('pointerup', handlePointerUp); - }} - > - - - - - + + + + - {expanded && ( - - - + {Object.entries(config).map(([key, setting]) => { + let control: ReactNode; - {Object.entries(config).map(([key, setting]) => { - let control: ReactNode; + switch (setting.type) { + case EmbedConfigType.Boolean: { + control = ( + + mutateState((draft) => { + draft[key] = checked; + }) + } + /> + ); + break; + } - switch (setting.type) { - case EmbedConfigType.Boolean: { - control = ( - + case EmbedConfigType.FullTextControl: { + control = ( + <> + ).color}`} + onValueChange={(value) => { mutateState((draft) => { - draft[key] = checked; - }) - } - /> - ); - break; - } - - case EmbedConfigType.FullTextControl: { - control = ( - <> - ).color}`} - onValueChange={(value) => { - mutateState((draft) => { - ( - draft[ - key - ] as EmbedConfigItemType - ).color = value as RadixTextColor; - }); - }} - > - - - - {' '} - White - - - {' '} - Gray - - {Object.entries(radixColors) - .filter( - ([key]) => - !key.endsWith('A') && - !key.endsWith('P3') && - !key.endsWith('Dark') && - !radixGrays.includes(key), - ) - .map(([key]) => ( - - {' '} - {capitalize(key)} - - ))} - - - - ).size - } - onValueChange={(value) => { - mutateState((draft) => { - ( - draft[ - key - ] as EmbedConfigItemType - ).size = value as RadixSizeNo0; - }); - }} - > - - - {times(9, (index) => ( - - Size {index + 1} - - ))} - - - - ).weight - } - onValueChange={(value) => { - mutateState((draft) => { - ( - draft[ - key - ] as EmbedConfigItemType - ).weight = value as RadixTextWeight; - }); - }} - > - - - {radixTextWeights.map((weight) => ( - - {startCase(weight)} - - ))} - - - - ); - break; - } - - case EmbedConfigType.Number: { - control = ( - { - mutateState((draft) => { - draft[key] = ( - event.target as HTMLInputElement - ).valueAsNumber; - }); - }} - > - {setting.unit && ( - px - )} - - ); - break; - } - - case EmbedConfigType.String: { - control = ( - { - mutateState((draft) => { - draft[key] = ( - event.target as HTMLInputElement - ).value; - }); - }} - /> - ); - break; - } - - case EmbedConfigType.SizeNo0: - case EmbedConfigType.Size: { - control = ( - { - mutateState((draft) => { - draft[key] = value as RadixSize; - }); - }} - > - - - {times(10, (index) => - setting.type === EmbedConfigType.SizeNo0 && - index === 0 ? null : ( - - {index} - - ), - )} - - - ); - break; - } - - case EmbedConfigType.Radius: { - control = ( - { - mutateState((draft) => { - draft[key] = value as RadixRadius; - }); - }} - > - - - {times(5, (index) => ( - - {index} - - ))} - Full - - - ); - break; - } - - case EmbedConfigType.Color: { - control = ( - <> - { - mutateState((draft) => { - (draft[key] as RadixColor).base = - value as RadixColorBase; - }); - }} - > - - - {Object.entries(radixColors) - .filter( - ([key]) => - !key.endsWith('A') && - !key.endsWith('P3') && - !key.endsWith('Dark'), - ) - .map(([key]) => ( - - {' '} - {capitalize(key)} - - ))} - - - - { - mutateState((draft) => { - (draft[key] as RadixColor).variant = - value as RadixColorVariant; - }); - }} - > - - - {times(12, (index) => { - const variant = - `${index + 1}` as RadixColorVariantRaw; - - return ( - <> - - {' '} - {variant} - - - - - {' '} - {variant} translucent - - - ); - })} - - - - ); - break; - } - - case EmbedConfigType.TextColor: { - control = ( - { - mutateState((draft) => { - draft[key] = value as RadixTextColor; + ).color = value as RadixTextColor; }); }} > @@ -596,44 +205,420 @@ export function EmbedConfigInputs({ ))} - ); - break; - } + + ).size + } + onValueChange={(value) => { + mutateState((draft) => { + ( + draft[ + key + ] as EmbedConfigItemType + ).size = value as RadixSizeNo0; + }); + }} + > + + + {times(9, (index) => ( + + Size {index + 1} + + ))} + + + + ).weight + } + onValueChange={(value) => { + mutateState((draft) => { + ( + draft[ + key + ] as EmbedConfigItemType + ).weight = value as RadixTextWeight; + }); + }} + > + + + {radixTextWeights.map((weight) => ( + + {startCase(weight)} + + ))} + + + + ); + break; } - return ( - - - {capitalize(startCase(key))} + case EmbedConfigType.Number: { + control = ( + { + mutateState((draft) => { + draft[key] = ( + event.target as HTMLInputElement + ).valueAsNumber; + }); + }} + > + {setting.unit && ( + px + )} + + ); + break; + } + + case EmbedConfigType.String: { + control = ( + { + mutateState((draft) => { + draft[key] = (event.target as HTMLInputElement).value; + }); + }} + /> + ); + break; + } + + case EmbedConfigType.SizeNo0: + case EmbedConfigType.Size: { + control = ( + { + mutateState((draft) => { + draft[key] = value as RadixSize; + }); + }} + > + + + {times(10, (index) => + setting.type === EmbedConfigType.SizeNo0 && + index === 0 ? null : ( + + {index} + + ), + )} + + + ); + break; + } + + case EmbedConfigType.Radius: { + control = ( + { + mutateState((draft) => { + draft[key] = value as RadixRadius; + }); + }} + > + + + {times(5, (index) => ( + + {index} + + ))} + Full + + + ); + break; + } + + case EmbedConfigType.Color: { + control = ( + <> + { + mutateState((draft) => { + (draft[key] as RadixColor).base = + value as RadixColorBase; + }); + }} + > + + + {Object.entries(radixColors) + .filter( + ([key]) => + !key.endsWith('A') && + !key.endsWith('P3') && + !key.endsWith('Dark'), + ) + .map(([key]) => ( + + {' '} + {capitalize(key)} + + ))} + + + + { + mutateState((draft) => { + (draft[key] as RadixColor).variant = + value as RadixColorVariant; + }); + }} + > + + + {times(12, (index) => { + const variant = + `${index + 1}` as RadixColorVariantRaw; + + return ( + <> + + {' '} + {variant} + + + + + {' '} + {variant} translucent + + + ); + })} + + + + ); + break; + } + + case EmbedConfigType.TextColor: { + control = ( + { + mutateState((draft) => { + draft[key] = value as RadixTextColor; + }); + }} + > + + + + {' '} + White + + + {' '} + Gray + + {Object.entries(radixColors) + .filter( + ([key]) => + !key.endsWith('A') && + !key.endsWith('P3') && + !key.endsWith('Dark') && + !radixGrays.includes(key), + ) + .map(([key]) => ( + + {' '} + {capitalize(key)} + + ))} + + + ); + break; + } + } + + return ( + + + {capitalize(startCase(key))} + + {control && {control}} + {!control && ( + + Immutable - {control && {control}} - {!control && ( - - Immutable - - )} - - ); - })} - - - )} - - {!expanded && ( - - - Expand to configure - + )} + + ); + })} - )} - + - {children} - + + + + + + Streaming software + + + + + + + + + + + + + + + + + {children} + + + + + + ); } diff --git a/src/components/PageWrapper.tsx b/src/components/PageWrapper.tsx index ea3b1676f..ee94cf614 100644 --- a/src/components/PageWrapper.tsx +++ b/src/components/PageWrapper.tsx @@ -1,5 +1,6 @@ import { Flex, FlexProps, Theme } from '@radix-ui/themes'; import { ComponentProps } from 'react'; +import { RadixSize } from '../app/tools/embed/types'; type PageWrapperProps = FlexProps & { color?: ComponentProps['accentColor']; @@ -7,6 +8,7 @@ type PageWrapperProps = FlexProps & { noMaxWidth?: boolean; containerProps?: ComponentProps; noFlex1?: boolean; + padding?: RadixSize; }; export default function PageWrapper({ @@ -17,6 +19,7 @@ export default function PageWrapper({ noMaxWidth = false, noFlex1 = false, containerProps, + padding = '4', ...props }: PageWrapperProps) { return ( @@ -33,7 +36,7 @@ export default function PageWrapper({