feat: session toolbar

This commit is contained in:
TresAbhi committed 2023-09-18 22:32:21 +00:00
1 parent 350434cc5a
commit 33b4ea04b4
7 files changed
+165 -65

No files matched your search

+39 -52
View File
@@ -48,67 +48,54 @@ export default function Page() {
return ( return (
<PageWrapper> <PageWrapper>
<SearchBar ref={input} />
<div <div
style={{ style={{
width: '100%',
padding: 16,
display: 'flex', display: 'flex',
flexDirection: 'column',
gap: 16, gap: 16,
boxSizing: 'border-box', flexWrap: 'wrap',
}} }}
> >
<SearchBar ref={input} /> <Search
input={input}
<div list={TOOLS.map(
style={{ (tool) =>
display: 'flex', ({
gap: 16, node: (
flexWrap: 'wrap', <Link
}} href={`/tools/${tool.id}`}
> className={styles.tool}
<Search style={{
input={input} backgroundImage: `url(/assets/banners/${tool.id}.png)`,
list={TOOLS.map( }}
(tool) => >
({ <span
node: (
<Link
href={`/tools/${tool.id}`}
className={styles.tool}
style={{ style={{
backgroundImage: `url(/assets/banners/${tool.id}.png)`, fontSize: 32,
color: theme.colors.textHighContrast,
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
}} }}
> >
<span {tool.title}
style={{ <CaretRightIcon style={{ width: '1em', height: '1em' }} />
fontSize: 32, </span>
color: theme.colors.textHighContrast, <span
display: 'flex', style={{
alignItems: 'center', color: theme.colors.textLowContrast,
justifyContent: 'center', fontSize: 16,
}} }}
> >
{tool.title} {tool.description}
<CaretRightIcon </span>
style={{ width: '1em', height: '1em' }} </Link>
/> ),
</span> query: `${tool.title} ${tool.description}`,
<span }) satisfies SearchItem,
style={{ )}
color: theme.colors.textLowContrast, />
fontSize: 16,
}}
>
{tool.description}
</span>
</Link>
),
query: `${tool.title} ${tool.description}`,
}) satisfies SearchItem,
)}
/>
</div>
</div> </div>
</PageWrapper> </PageWrapper>
); );
+23
View File
@@ -0,0 +1,23 @@
import { style } from '@vanilla-extract/css';
export const toolBar = style({
'@media': {
'screen and (min-width: 640px)': {
flexDirection: 'row',
},
},
flexDirection: 'column',
display: 'flex',
gap: 8,
});
export const button = style({
'@media': {
'screen and (min-width: 640px)': {
flex: 0,
},
},
flex: 1,
});
+27 -1
View File
@@ -1,3 +1,29 @@
'use client';
import { CopyIcon, ListBulletIcon, ReloadIcon } from '@radix-ui/react-icons';
import { Button } from '../../../components/Button';
import PageWrapper from '../../../components/PageWrapper';
import { SearchBar } from '../../../components/SearchBar';
import * as styles from './page.css';
export default function Page() { export default function Page() {
return 'inner'; return (
<PageWrapper>
<div className={styles.toolBar}>
<SearchBar style={{ flex: 1 }} placeholder="Search for a player..." />
<div style={{ display: 'flex', gap: 8 }}>
<Button className={styles.button} color="dangerous">
<ReloadIcon /> Reset
</Button>
<Button className={styles.button}>
<CopyIcon /> Embed
</Button>
<Button className={styles.button}>
<ListBulletIcon /> Options
</Button>
</div>
</div>
</PageWrapper>
);
} }
+39
View File
@@ -0,0 +1,39 @@
import { ComponentProps } from 'react';
import { theme } from '../stitches.config';
type ButtonColor = 'default' | 'dangerous' | 'recommended';
interface ButtonProps extends ComponentProps<'button'> {
color?: ButtonColor;
}
const BUTTON_COLORS = {
default: '',
dangerous: '_red',
recommended: '_blue',
} as const satisfies Record<ButtonColor, string>;
export function Button({ color, style, ...props }: ButtonProps) {
color = color ?? 'default';
return (
<button
style={{
color: theme.colors[`textHighContrast${BUTTON_COLORS[color]}`],
backgroundColor:
theme.colors[`componentInteractive${BUTTON_COLORS[color]}`],
borderRadius: 4,
border: theme.borderStyles[`interactive${BUTTON_COLORS[color]}`],
cursor: 'pointer',
padding: 8,
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
gap: 4,
...style,
}}
{...props}
/>
);
}
+20 -9
View File
@@ -1,13 +1,24 @@
import { ReactNode } from 'react'; import { ComponentProps } from 'react';
interface PageWrapperProps { export default function PageWrapper({
children: ReactNode; style,
} ...props
}: ComponentProps<'div'>) {
export default function PageWrapper({ children }: PageWrapperProps) {
return ( return (
<div style={{ maxWidth: 780, margin: 'auto', display: 'block' }}> <div
{children} style={{
</div> width: '100%',
maxWidth: 780,
margin: 'auto',
display: 'flex',
padding: 16,
flexDirection: 'column',
gap: 16,
boxSizing: 'border-box',
...style,
}}
{...props}
/>
); );
} }
+4 -1
View File
@@ -3,7 +3,7 @@ import { ComponentProps, forwardRef, useImperativeHandle, useRef } from 'react';
import { theme } from '../stitches.config'; import { theme } from '../stitches.config';
export const SearchBar = forwardRef<HTMLInputElement, ComponentProps<'input'>>( export const SearchBar = forwardRef<HTMLInputElement, ComponentProps<'input'>>(
(props, ref) => { ({ style, ...props }, ref) => {
const input = useRef<HTMLInputElement>(null); const input = useRef<HTMLInputElement>(null);
useImperativeHandle(ref, () => input.current!); useImperativeHandle(ref, () => input.current!);
@@ -22,10 +22,13 @@ export const SearchBar = forwardRef<HTMLInputElement, ComponentProps<'input'>>(
justifyContent: 'center', justifyContent: 'center',
gap: 8, gap: 8,
cursor: 'text', cursor: 'text',
...style,
}} }}
onClick={() => input.current?.focus()} onClick={() => input.current?.focus()}
> >
<MagnifyingGlassIcon style={{ width: '1em', height: '1em' }} /> <MagnifyingGlassIcon style={{ width: '1em', height: '1em' }} />
<input <input
{...props} {...props}
ref={input} ref={input}
+13 -2
View File
@@ -1,4 +1,10 @@
import { amberDark, blueDark, slate, slateDark } from '@radix-ui/colors'; import {
amberDark,
blueDark,
slate,
slateDark,
tomatoDark,
} from '@radix-ui/colors';
import { createBorderStyles, createColors, createSpaces } from 'bepaint'; import { createBorderStyles, createColors, createSpaces } from 'bepaint';
// this isn't really a stitches config, but the object is compliant // this isn't really a stitches config, but the object is compliant
@@ -11,9 +17,14 @@ export const theme = {
...createColors(amberDark, 'amber'), ...createColors(amberDark, 'amber'),
...createColors(blueDark, 'blue'), ...createColors(blueDark, 'blue'),
...createColors(tomatoDark, 'red'),
}, },
borderStyles: createBorderStyles(slateDark), borderStyles: {
...createBorderStyles(slateDark),
...createBorderStyles(blueDark, undefined, 'blue'),
...createBorderStyles(tomatoDark, undefined, 'red'),
},
durations: { durations: {
regular: '0.2s', regular: '0.2s',