Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
Be extremely concise. Sacrifice grammar for concision.
Frontend is partially migrated from vanilla JS to SolidJS — new components use `.tsx`, legacy code remains vanilla.
Run `pnpm run lint` when checking for linting OR typescript errors with oxlint.
Run `pnpm lint` when checking for linting OR typescript errors with oxlint.
Single test file: `pnpm vitest run path/to/test.ts`
For styling, use Tailwind CSS, class property, `cn` utility. Do not use classlist. Only colors available are those defined in Tailwind config.
In legacy code, use `i` tags with FontAwesome classes. In new code, use `Fa` component.
At the end of plan mode, give me a list of unresolved questions to answer, if any. Make them concise.
Run `pnpm lint` after making every change.
24 changes: 13 additions & 11 deletions frontend/src/ts/components/common/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ type BaseProps = {
onMouseEnter?: () => void;
onMouseLeave?: () => void;
dataset?: Record<string, string>;
active?: boolean;
};

type ButtonProps = BaseProps & {
href?: never;
sameTarget?: true;
active?: boolean;
disabled?: boolean;
};

Expand All @@ -38,6 +38,8 @@ export function Button(props: ButtonProps | AnchorProps): JSXElement {
const isActive = (): boolean =>
(!isAnchor() && !("href" in props) && props.active) ?? false;

const variant = () => props.variant ?? "button";

const content = (
<>
<Show when={props.fa !== undefined}>
Expand Down Expand Up @@ -65,16 +67,16 @@ export function Button(props: ButtonProps | AnchorProps): JSXElement {
"focus-visible:shadow-[0_0_0_0.1rem_var(--bg-color),_0_0_0_0.2rem_var(--text-color)] focus-visible:outline-none",
"bg-(--themable-button-bg) text-(--themable-button-text) hover:bg-(--themable-button-hover-bg) hover:text-(--themable-button-hover-text)",
"[--themable-button-active:var(--main-color)]",
props.variant === "text" &&
"[--themable-button-bg:transparent] [--themable-button-hover-bg:transparent] [--themable-button-hover-text:var(--text-color)] [--themable-button-text:var(--sub-color)]",
(props?.variant ?? "button") === "button" &&
"[--themable-button-bg:var(--sub-alt-color)] [--themable-button-hover-bg:var(--text-color)] [--themable-button-hover-text:var(--bg-color)] [--themable-button-text:var(--text-color)]",
(props?.variant ?? "button") === "button" &&
isActive() &&
"[--themable-button-bg:var(--main-color)] [--themable-button-hover-bg:var(--text-color)] [--themable-button-hover-text:var(--bg-color)] [--themable-button-text:var(--bg-color)]",
(props?.variant ?? "button") === "button" &&
variant() === "text" &&
"[--themable-button-bg:transparent] [--themable-button-hover-bg:transparent] [--themable-button-hover-text:var(--text-color)] [--themable-button-text:var(--sub-color)] active:text-sub",
variant() === "button" &&
"[--themable-button-bg:var(--sub-alt-color)] [--themable-button-hover-bg:var(--text-color)] [--themable-button-hover-text:var(--bg-color)] [--themable-button-text:var(--text-color)] active:bg-sub",
variant() === "button" &&
isActive() &&
"[--themable-button-bg:var(--themable-button-active)] [--themable-button-hover-bg:var(--text-color)] [--themable-button-hover-text:var(--bg-color)] [--themable-button-text:var(--bg-color)]",
variant() === "text" &&
isActive() &&
"[--themable-button-hover-text:var(--themable-button-hover-text)] [--themable-button-text:var(--themable-button-active)]",
{
"pointer-events-none opacity-[0.33]": props.disabled,
},
Expand Down Expand Up @@ -106,7 +108,7 @@ export function Button(props: ButtonProps | AnchorProps): JSXElement {
onClick={() => props.onClick?.()}
onMouseEnter={() => props.onMouseEnter?.()}
onMouseLeave={() => props.onMouseLeave?.()}
data-ui-variant={props.variant ?? "button"}
data-ui-variant={variant()}
{...props.dataset}
>
{content}
Expand All @@ -122,7 +124,7 @@ export function Button(props: ButtonProps | AnchorProps): JSXElement {
{...ariaLabel()}
{...(props["router-link"] ? { "router-link": "" } : {})}
disabled={props.disabled ?? false}
data-ui-variant={props.variant ?? "button"}
data-ui-variant={variant()}
{...props.dataset}
>
{content}
Expand Down
Loading