-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
30 changed files
with
809 additions
and
432 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import classes from "./style.module.scss"; | ||
|
||
import { type BoxProps, Paper, SimpleGrid, type StyleProp, Text } from "@mantine/core"; | ||
import clsx from "clsx"; | ||
import { useMemo } from "react"; | ||
import { DRIVERS } from "~/constants"; | ||
import { useIsLight } from "~/hooks/theme"; | ||
import type { CodeLang } from "~/types"; | ||
|
||
export interface DriverSelectorProps extends BoxProps { | ||
cols: StyleProp<number>; | ||
value: CodeLang; | ||
exclude?: CodeLang[]; | ||
onChange: (value: CodeLang) => void; | ||
} | ||
|
||
export function DriverSelector({ cols, value, exclude, onChange, ...other }: DriverSelectorProps) { | ||
const isLight = useIsLight(); | ||
|
||
const drivers = useMemo(() => { | ||
return DRIVERS.filter((lib) => !exclude?.includes(lib.id)); | ||
}, [exclude]); | ||
|
||
return ( | ||
<SimpleGrid | ||
cols={cols} | ||
{...other} | ||
> | ||
{drivers.map((lib) => { | ||
const Icon = lib.icon; | ||
const isActive = value === lib.id; | ||
|
||
return ( | ||
<Paper | ||
key={lib.name} | ||
radius="xl" | ||
bg={isLight ? "slate.0" : "slate.9"} | ||
className={clsx(classes.library, isActive && classes.libraryActive)} | ||
onClick={() => onChange(lib.id)} | ||
> | ||
<Icon active={isActive} /> | ||
<Text mt="xs">{lib.name}</Text> | ||
</Paper> | ||
); | ||
})} | ||
</SimpleGrid> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
.library { | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
flex-direction: column; | ||
transition: box-shadow 0.1s; | ||
cursor: pointer; | ||
aspect-ratio: 1; | ||
gap: 8; | ||
|
||
&:hover { | ||
background-color: var(--mantine-color-slate-6); | ||
} | ||
} | ||
|
||
.library-active { | ||
background: var(--surrealist-gradient) !important; | ||
box-shadow: var(--surrealist-glow); | ||
color: white; | ||
|
||
svg * { | ||
fill: white !important; | ||
} | ||
} |
Oops, something went wrong.