diff --git a/pkgs/clan-app/ui/src/components/Logo/Logo.tsx b/pkgs/clan-app/ui/src/components/Logo/Logo.tsx index 6e45e1a47..dfc35fee5 100644 --- a/pkgs/clan-app/ui/src/components/Logo/Logo.tsx +++ b/pkgs/clan-app/ui/src/components/Logo/Logo.tsx @@ -1,7 +1,8 @@ import Clan from "@/logos/clan.svg"; import { Dynamic } from "solid-js/web"; -import { Color, fgClass } from "@/src/components/colors"; -import { JSX, splitProps } from "solid-js"; +import { Color } from "@/src/components/colors"; +import colorsStyles from "../colors.module.css"; +import { JSX, mergeProps } from "solid-js"; import cx from "classnames"; const logos = { @@ -11,26 +12,19 @@ const logos = { export type LogoVariant = keyof typeof logos; export interface LogoProps extends JSX.SvgSVGAttributes { - class?: string; variant: LogoVariant; color?: Color; inverted?: boolean; } export const Logo = (props: LogoProps) => { - const [local, iconProps] = splitProps(props, [ - "variant", - "color", - "class", - "inverted", - ]); - + const local = mergeProps({ color: "primary" } as const, props); const Logo = logos[local.variant]; return ( diff --git a/pkgs/clan-app/ui/src/components/MachineStatus/MachineStatus.css b/pkgs/clan-app/ui/src/components/MachineStatus/MachineStatus.module.css similarity index 86% rename from pkgs/clan-app/ui/src/components/MachineStatus/MachineStatus.css rename to pkgs/clan-app/ui/src/components/MachineStatus/MachineStatus.module.css index 6024be9bd..0c7235d89 100644 --- a/pkgs/clan-app/ui/src/components/MachineStatus/MachineStatus.css +++ b/pkgs/clan-app/ui/src/components/MachineStatus/MachineStatus.module.css @@ -1,4 +1,4 @@ -span.machine-status { +.machineStatus { @apply flex items-center gap-1.5; .indicator { @@ -13,7 +13,7 @@ span.machine-status { background-color: theme(colors.fg.semantic.error.1); } - &.out-of-sync > .indicator { + &.outOfSync > .indicator { background-color: theme(colors.fg.inv.3); } } diff --git a/pkgs/clan-app/ui/src/components/MachineStatus/MachineStatus.tsx b/pkgs/clan-app/ui/src/components/MachineStatus/MachineStatus.tsx index 1ce76b4c0..dd06e05ad 100644 --- a/pkgs/clan-app/ui/src/components/MachineStatus/MachineStatus.tsx +++ b/pkgs/clan-app/ui/src/components/MachineStatus/MachineStatus.tsx @@ -1,5 +1,4 @@ -import "./MachineStatus.css"; - +import styles from "./MachineStatus.module.css"; import { Badge } from "@kobalte/core/badge"; import cx from "classnames"; import { Match, Show, Switch } from "solid-js"; @@ -14,8 +13,7 @@ export interface MachineStatusProps { } export const MachineStatus = (props: MachineStatusProps) => { - const status = () => props.status; - + // FIXME: this will break i18n in the future // remove the '_' from the enum // we will use css transform in the typography component to capitalize const statusText = () => props.status?.replaceAll("_", " "); @@ -25,15 +23,17 @@ export const MachineStatus = (props: MachineStatusProps) => { return ( - + - + {props.label && ( { )} } > -
+
diff --git a/pkgs/clan-app/ui/src/components/Tag/Tag.css b/pkgs/clan-app/ui/src/components/Tag/Tag.module.css similarity index 81% rename from pkgs/clan-app/ui/src/components/Tag/Tag.css rename to pkgs/clan-app/ui/src/components/Tag/Tag.module.css index 719db1a73..fd033249e 100644 --- a/pkgs/clan-app/ui/src/components/Tag/Tag.css +++ b/pkgs/clan-app/ui/src/components/Tag/Tag.module.css @@ -1,4 +1,4 @@ -span.tag { +.tag { @apply flex items-center gap-1 w-fit px-2 py-[0.1875rem] rounded-full; @apply bg-def-4; @@ -17,11 +17,11 @@ span.tag { @apply bg-inv-1; } - &.has-action { + &.hasAction { @apply pr-1.5; } - &.is-interactive { + &.interactive { &:hover { @apply bg-def-acc-3; } @@ -30,10 +30,7 @@ span.tag { @apply bg-inv-acc-3; } } - - & > .icon { - &:hover { - @apply cursor-pointer; - } + .action { + @apply cursor-pointer; } } diff --git a/pkgs/clan-app/ui/src/components/Tag/Tag.tsx b/pkgs/clan-app/ui/src/components/Tag/Tag.tsx index d065aa06b..a79b525e5 100644 --- a/pkgs/clan-app/ui/src/components/Tag/Tag.tsx +++ b/pkgs/clan-app/ui/src/components/Tag/Tag.tsx @@ -1,8 +1,8 @@ -import "./Tag.css"; +import styles from "./Tag.module.css"; import cx from "classnames"; import { Typography } from "@/src/components/Typography/Typography"; -import { createSignal, JSX } from "solid-js"; +import { createSignal, JSX, mergeProps, Show } from "solid-js"; interface IconActionProps { inverted: boolean; @@ -14,11 +14,10 @@ export interface TagProps extends JSX.HTMLAttributes { icon?: (state: IconActionProps) => JSX.Element; inverted?: boolean; interactive?: boolean; - class?: string; } export const Tag = (props: TagProps) => { - const inverted = () => props.inverted || false; + const local = mergeProps({ inverted: false }, props); const [isActive, setIsActive] = createSignal(false); @@ -27,23 +26,27 @@ export const Tag = (props: TagProps) => { setTimeout(() => setIsActive(false), 150); }; + const icon = () => + props.icon?.({ + inverted: local.inverted, + handleActionClick, + }); + return ( - + {props.children} - {props.icon?.({ - inverted: inverted(), - handleActionClick, - })} + + {icon()} + ); }; diff --git a/pkgs/clan-app/ui/src/components/TagGroup/TagGroup.css b/pkgs/clan-app/ui/src/components/TagGroup/TagGroup.module.css similarity index 73% rename from pkgs/clan-app/ui/src/components/TagGroup/TagGroup.css rename to pkgs/clan-app/ui/src/components/TagGroup/TagGroup.module.css index 59fef1eae..db4f3aa43 100644 --- a/pkgs/clan-app/ui/src/components/TagGroup/TagGroup.css +++ b/pkgs/clan-app/ui/src/components/TagGroup/TagGroup.module.css @@ -1,3 +1,3 @@ -div.tag-group { +.tagGroup { @apply flex flex-wrap gap-x-1.5 gap-y-2; } diff --git a/pkgs/clan-app/ui/src/components/TagGroup/TagGroup.tsx b/pkgs/clan-app/ui/src/components/TagGroup/TagGroup.tsx index 3dd2ca4cf..9ef282241 100644 --- a/pkgs/clan-app/ui/src/components/TagGroup/TagGroup.tsx +++ b/pkgs/clan-app/ui/src/components/TagGroup/TagGroup.tsx @@ -1,21 +1,20 @@ -import "./TagGroup.css"; +import styles from "./TagGroup.module.css"; import cx from "classnames"; -import { For } from "solid-js"; +import { For, mergeProps } from "solid-js"; import { Tag } from "@/src/components/Tag/Tag"; export interface TagGroupProps { - class?: string; labels: string[]; inverted?: boolean; } export const TagGroup = (props: TagGroupProps) => { - const inverted = () => props.inverted || false; + const local = mergeProps({ inverted: false } as const, props); return ( -
+
- {(label) => {label}} + {(label) => {label}}
); diff --git a/pkgs/clan-app/ui/src/components/colors.ts b/pkgs/clan-app/ui/src/components/colors.ts index 22007c91f..14bb10621 100644 --- a/pkgs/clan-app/ui/src/components/colors.ts +++ b/pkgs/clan-app/ui/src/components/colors.ts @@ -14,32 +14,3 @@ export const AllColors: Color[] = [ "error", "inherit", ]; - -const colorMap: Record = { - primary: "fg-def-1", - secondary: "fg-def-2", - tertiary: "fg-def-3", - quaternary: "fg-def-4", - error: "fg-semantic-error-4", - inherit: "text-inherit", -}; - -const invertedColorMap: Record = { - primary: "fg-inv-1", - secondary: "fg-inv-2", - tertiary: "fg-inv-3", - quaternary: "fg-inv-4", - error: "fg-semantic-error-1", - inherit: "text-inherit", -}; - -export const fgClass = ( - color: Color | "inherit" = "primary", - inverted = false, -) => { - if (color === "inherit") { - return "text-inherit"; - } - - return inverted ? invertedColorMap[color] : colorMap[color]; -};