feat: better layout

This commit is contained in:
TrèsAbhi committed 2024-08-06 14:05:16 -05:00
1 parent ca39b8e215
commit 4b2367699a
3 files changed
+69 -80

No files matched your search

+4 -3
View File
@@ -28,9 +28,10 @@ const robotoFlex = Roboto_Flex({
export default function RootLayout({ children }: RootLayoutProps) { export default function RootLayout({ children }: RootLayoutProps) {
const pathname = usePathname(); const pathname = usePathname();
const hideNav = // const hideNav =
pathname.startsWith('/tools/embed/host') || // pathname.startsWith('/tools/embed/host') ||
pathname.startsWith('/tools/embed/customize'); // pathname.startsWith('/tools/embed/customize');
const hideNav = false;
const isRoot = pathname === '/'; const isRoot = pathname === '/';
return ( return (
+61 -76
View File
@@ -1,9 +1,9 @@
import * as radixColors from '@radix-ui/colors'; import * as radixColors from '@radix-ui/colors';
import { import {
DragHandleDots2Icon, BorderSolidIcon,
EnterFullScreenIcon, Cross1Icon,
ExitFullScreenIcon,
ImageIcon, ImageIcon,
SquareIcon,
} from '@radix-ui/react-icons'; } from '@radix-ui/react-icons';
import { import {
Box, Box,
@@ -47,6 +47,9 @@ import {
radixTextWeights, radixTextWeights,
} from '../app/tools/embed/types'; } from '../app/tools/embed/types';
import { toColorVar, toRadiusVar } from '../app/tools/embed/utilities'; 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 { interface EmbedConfigInputsProps {
config: EmbedConfig; config: EmbedConfig;
@@ -61,10 +64,7 @@ export function EmbedConfigInputs({
setState, setState,
children, children,
}: EmbedConfigInputsProps) { }: EmbedConfigInputsProps) {
const [expanded, setExpanded] = useState(true); const [backgroundImage, setBackgroundImage] = useState(imgur('SO13zur'));
const [backgroundImage, setBackgroundImage] = useState(
'https://upload.wikimedia.org/wikipedia/commons/f/f6/Swiss_National_Park_131.JPG',
);
const mutateState = useCallback( const mutateState = useCallback(
(recipe: (draft: ExtractEmbedConfigType<EmbedConfig>) => void) => { (recipe: (draft: ExtractEmbedConfigType<EmbedConfig>) => void) => {
setState(produce(recipe)); setState(produce(recipe));
@@ -99,65 +99,13 @@ export function EmbedConfigInputs({
}, []); }, []);
return ( return (
<Flex <PageWrapper padding="0" size={1028 + 640}>
width="100vw" <Flex>
height="100vh"
align="center"
justify="center"
overflow="hidden"
style={{
background: `url(${backgroundImage}) center / cover no-repeat`,
}}
>
<Card
style={{ position: 'fixed', top: 32, right: 32, minWidth: 320 }}
ref={wrapper}
>
<Inset mb="4">
<Flex
align="center"
justify="center"
p="2"
mb={expanded ? '2' : '0'}
position="relative"
style={{
backgroundColor: 'var(--color-panel-translucent)',
cursor: 'grab',
}}
onPointerDown={(event) => {
event.preventDefault();
window.addEventListener('pointermove', handlePointerMove);
window.addEventListener('pointerup', handlePointerUp);
}}
>
<Text color="gray" trim="end">
<DragHandleDots2Icon style={{ transform: 'rotate(90deg)' }} />
</Text>
<Box
position="absolute"
right="0"
top="50%"
pr="2"
style={{ transform: 'translateY(-25%)' }}
>
<IconButton
variant="ghost"
color="gray"
onClick={() => setExpanded((expanded) => !expanded)}
>
{expanded ? <ExitFullScreenIcon /> : <EnterFullScreenIcon />}
</IconButton>
</Box>
</Flex>
</Inset>
{expanded && (
<ScrollArea <ScrollArea
scrollbars="vertical" scrollbars="vertical"
style={{ height: '100%', maxHeight: 640 }} style={{ height: '100%', maxWidth: 320 }}
> >
<Flex direction="column" gap="2"> <Flex direction="column" gap="2" p="4">
<Button <Button
variant="outline" variant="outline"
color="gray" color="gray"
@@ -350,9 +298,7 @@ export function EmbedConfigInputs({
value={state[key] as string} value={state[key] as string}
onChange={(event) => { onChange={(event) => {
mutateState((draft) => { mutateState((draft) => {
draft[key] = ( draft[key] = (event.target as HTMLInputElement).value;
event.target as HTMLInputElement
).value;
}); });
}} }}
/> />
@@ -510,8 +456,7 @@ export function EmbedConfigInputs({
width: '50%', width: '50%',
height: '100%', height: '100%',
backgroundColor: toColorVar({ backgroundColor: toColorVar({
base: (state[key] as RadixColor) base: (state[key] as RadixColor).base,
.base,
variant, variant,
}), }),
}} }}
@@ -622,18 +567,58 @@ export function EmbedConfigInputs({
})} })}
</Flex> </Flex>
</ScrollArea> </ScrollArea>
)}
{!expanded && ( <Box
<Flex justify="center"> p="4"
<Text size="2" color="gray"> flexGrow="1"
Expand to configure position="sticky"
</Text> top={`${NAVBAR_HEIGHT}px`}
height={`calc(100vh - ${NAVBAR_HEIGHT}px)`}
>
<Card style={{ height: '100%' }}>
<Flex direction="column" gap="2" height="100%">
<Inset style={{ borderRadius: 0 }}>
<Flex
justify="between"
p="2"
px="3"
style={{
backgroundColor: 'var(--color-panel-translucent)',
}}
>
<Text color="gray">Streaming software</Text>
<Flex align="center" gap="3">
<IconButton color="gray" disabled size="1" variant="ghost">
<BorderSolidIcon />
</IconButton>
<IconButton color="gray" disabled size="1" variant="ghost">
<SquareIcon />
</IconButton>
<IconButton color="gray" disabled size="1" variant="ghost">
<Cross1Icon />
</IconButton>
</Flex> </Flex>
)} </Flex>
</Card> </Inset>
<Flex
mt="4"
flexGrow="1"
style={{
borderRadius: toRadiusVar('3'),
overflow: 'hidden',
background: `url(${backgroundImage}) center / cover no-repeat`,
}}
align="center"
justify="center"
>
{children} {children}
</Flex> </Flex>
</Flex>
</Card>
</Box>
</Flex>
</PageWrapper>
); );
} }
+4 -1
View File
@@ -1,5 +1,6 @@
import { Flex, FlexProps, Theme } from '@radix-ui/themes'; import { Flex, FlexProps, Theme } from '@radix-ui/themes';
import { ComponentProps } from 'react'; import { ComponentProps } from 'react';
import { RadixSize } from '../app/tools/embed/types';
type PageWrapperProps = FlexProps & { type PageWrapperProps = FlexProps & {
color?: ComponentProps<typeof Theme>['accentColor']; color?: ComponentProps<typeof Theme>['accentColor'];
@@ -7,6 +8,7 @@ type PageWrapperProps = FlexProps & {
noMaxWidth?: boolean; noMaxWidth?: boolean;
containerProps?: ComponentProps<typeof Theme>; containerProps?: ComponentProps<typeof Theme>;
noFlex1?: boolean; noFlex1?: boolean;
padding?: RadixSize;
}; };
export default function PageWrapper({ export default function PageWrapper({
@@ -17,6 +19,7 @@ export default function PageWrapper({
noMaxWidth = false, noMaxWidth = false,
noFlex1 = false, noFlex1 = false,
containerProps, containerProps,
padding = '4',
...props ...props
}: PageWrapperProps) { }: PageWrapperProps) {
return ( return (
@@ -33,7 +36,7 @@ export default function PageWrapper({
<Flex <Flex
direction="column" direction="column"
gap="4" gap="4"
p="4" p={padding}
style={{ style={{
width: '100%', width: '100%',
maxWidth: noMaxWidth ? undefined : size, maxWidth: noMaxWidth ? undefined : size,