2023-12-13 11:59:37 -06:00
|
|
|
import {
|
|
|
|
|
Button,
|
|
|
|
|
ContextMenu,
|
|
|
|
|
Dialog,
|
|
|
|
|
DropdownMenu,
|
|
|
|
|
Flex,
|
|
|
|
|
Heading,
|
|
|
|
|
TextField,
|
|
|
|
|
} from '@radix-ui/themes';
|
2023-12-13 11:46:36 -06:00
|
|
|
import { createColors } from 'bepaint';
|
2023-12-13 11:59:37 -06:00
|
|
|
import { useRef, useState } from 'react';
|
2023-12-03 10:43:42 -06:00
|
|
|
import {
|
|
|
|
|
ACCENT_COLORS,
|
|
|
|
|
AccentColor,
|
|
|
|
|
GRAY_COLORS,
|
|
|
|
|
GrayColor,
|
2023-12-13 11:46:36 -06:00
|
|
|
PALETTES,
|
2023-12-03 10:43:42 -06:00
|
|
|
} from '../../../../constants/radixColors';
|
2023-10-08 17:34:02 -05:00
|
|
|
import { useSession } from '../../../../stores/session';
|
|
|
|
|
import { CustomColumn } from './CustomColumn';
|
|
|
|
|
|
|
|
|
|
interface ContextMenuProps {
|
|
|
|
|
Builder: typeof DropdownMenu | typeof ContextMenu;
|
2023-10-14 12:04:11 -05:00
|
|
|
reset: () => void;
|
2023-10-08 17:34:02 -05:00
|
|
|
}
|
|
|
|
|
|
2023-10-14 12:04:11 -05:00
|
|
|
export function Menu({ Builder, reset }: ContextMenuProps) {
|
2023-10-08 17:34:02 -05:00
|
|
|
const session = useSession();
|
2023-12-13 11:46:36 -06:00
|
|
|
const [showTitleEditor, setShowTitleEditor] = useState(false);
|
2023-12-13 11:59:37 -06:00
|
|
|
const titleInput = useRef<HTMLInputElement>(null);
|
2023-10-08 17:34:02 -05:00
|
|
|
|
|
|
|
|
return (
|
2023-12-13 11:59:37 -06:00
|
|
|
<>
|
|
|
|
|
<Dialog.Root open={showTitleEditor} onOpenChange={setShowTitleEditor}>
|
|
|
|
|
<Dialog.Content>
|
|
|
|
|
<Flex direction="column" gap="4">
|
|
|
|
|
<Heading size="4">Edit title</Heading>
|
2023-12-03 10:43:42 -06:00
|
|
|
|
2023-12-13 11:59:37 -06:00
|
|
|
<Flex gap="2" style={{ width: '100%' }}>
|
|
|
|
|
<TextField.Root style={{ flex: 1 }}>
|
|
|
|
|
<TextField.Input
|
|
|
|
|
ref={titleInput}
|
|
|
|
|
defaultValue={session.title}
|
|
|
|
|
placeholder="Enter title..."
|
|
|
|
|
onKeyDown={(event) => {
|
|
|
|
|
if (event.key === 'Enter' && titleInput.current) {
|
|
|
|
|
setShowTitleEditor(false);
|
|
|
|
|
useSession.setState({ title: titleInput.current!.value });
|
|
|
|
|
}
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
</TextField.Root>
|
2023-12-03 10:43:42 -06:00
|
|
|
|
2023-12-13 11:59:37 -06:00
|
|
|
<Dialog.Close>
|
|
|
|
|
<Button
|
|
|
|
|
onClick={() =>
|
|
|
|
|
useSession.setState({ title: titleInput.current!.value })
|
|
|
|
|
}
|
|
|
|
|
>
|
|
|
|
|
Set
|
|
|
|
|
</Button>
|
|
|
|
|
</Dialog.Close>
|
|
|
|
|
</Flex>
|
|
|
|
|
</Flex>
|
|
|
|
|
</Dialog.Content>
|
|
|
|
|
</Dialog.Root>
|
2023-12-03 10:43:42 -06:00
|
|
|
|
2023-12-13 11:59:37 -06:00
|
|
|
<Builder.Content>
|
|
|
|
|
<Builder.Sub>
|
|
|
|
|
<Builder.SubTrigger>Accent color</Builder.SubTrigger>
|
2023-10-08 17:34:02 -05:00
|
|
|
|
2023-12-13 11:59:37 -06:00
|
|
|
<Builder.SubContent>
|
|
|
|
|
<Builder.RadioGroup
|
|
|
|
|
value={session.color}
|
|
|
|
|
onValueChange={(value) =>
|
|
|
|
|
useSession.setState({ color: value as AccentColor | GrayColor })
|
|
|
|
|
}
|
|
|
|
|
>
|
|
|
|
|
{[...ACCENT_COLORS, ...GRAY_COLORS].map((color) => (
|
|
|
|
|
<Builder.RadioItem value={color} key={color}>
|
|
|
|
|
<Flex gap="2" align="center">
|
|
|
|
|
<div
|
|
|
|
|
style={{
|
|
|
|
|
backgroundColor: createColors(PALETTES[color])
|
|
|
|
|
.solidBackground,
|
|
|
|
|
width: 16,
|
|
|
|
|
height: 16,
|
|
|
|
|
borderRadius: '100%',
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
{`${color.charAt(0).toUpperCase()}${color.slice(1)}`}
|
|
|
|
|
</Flex>
|
|
|
|
|
</Builder.RadioItem>
|
|
|
|
|
))}
|
|
|
|
|
</Builder.RadioGroup>
|
|
|
|
|
</Builder.SubContent>
|
|
|
|
|
</Builder.Sub>
|
2023-10-08 17:34:02 -05:00
|
|
|
|
2023-12-13 11:59:37 -06:00
|
|
|
<Builder.Separator />
|
2023-10-14 12:04:11 -05:00
|
|
|
|
2023-12-13 11:59:37 -06:00
|
|
|
<Builder.Item onClick={() => setShowTitleEditor(true)}>
|
|
|
|
|
Edit title...
|
|
|
|
|
</Builder.Item>
|
|
|
|
|
<CustomColumn Builder={Builder} column={0} />
|
|
|
|
|
<CustomColumn Builder={Builder} column={1} />
|
|
|
|
|
<CustomColumn Builder={Builder} column={2} />
|
|
|
|
|
<CustomColumn Builder={Builder} column={3} />
|
2023-10-14 12:04:11 -05:00
|
|
|
|
2023-12-13 11:59:37 -06:00
|
|
|
<Builder.Separator />
|
|
|
|
|
|
|
|
|
|
<Builder.CheckboxItem
|
|
|
|
|
checked={session.showTotal}
|
|
|
|
|
onCheckedChange={(checked) =>
|
|
|
|
|
useSession.setState({ showTotal: checked })
|
|
|
|
|
}
|
|
|
|
|
>
|
|
|
|
|
Show total
|
|
|
|
|
</Builder.CheckboxItem>
|
|
|
|
|
<Builder.CheckboxItem
|
|
|
|
|
checked={session.showCareer}
|
|
|
|
|
onCheckedChange={(checked) =>
|
|
|
|
|
useSession.setState({ showCareer: checked })
|
|
|
|
|
}
|
|
|
|
|
>
|
|
|
|
|
Show career
|
|
|
|
|
</Builder.CheckboxItem>
|
|
|
|
|
|
|
|
|
|
<Builder.Separator />
|
|
|
|
|
|
|
|
|
|
<Builder.Item color="red" onClick={reset}>
|
|
|
|
|
Reset
|
|
|
|
|
</Builder.Item>
|
|
|
|
|
</Builder.Content>
|
|
|
|
|
</>
|
2023-10-08 17:34:02 -05:00
|
|
|
);
|
|
|
|
|
}
|