diff --git a/liberica/src/assets/themes.json b/liberica/src/assets/themes.json index 8e6b7cd..2b5bcee 100644 --- a/liberica/src/assets/themes.json +++ b/liberica/src/assets/themes.json @@ -1,11 +1,28 @@ { + "Rosé Pine Dawn": { + "base": "#faf4ed", + "surface": "#fffaf3", + "muted": "#9893a5", + "primary": "#d7827e", + "secondary": "#286983", + + "onBase": "#575279", + "onSurface": "@onBase", + "onMuted": "@onBase", + "onPrimary": "@base", + "onSecondary": "@base" + }, "Rosé Pine": { - "base": "#faf4ed", - "surface": "#fffaf3", - "muted": "#9893a5", - "text": "#575279", - "primary": "#d7827e", - "secondary": "#286983", - "accent": "#ea9d34" + "base": "#191724", + "surface": "#1f1d2e", + "muted": "#6e6a86", + "primary": "#ebbcba", + "secondary": "#31748f", + + "onBase": "#e0def4", + "onSurface": "@onBase", + "onMuted": "@onBase", + "onPrimary": "@base", + "onSecondary": "@base" } } diff --git a/liberica/src/components/InputElements.tsx b/liberica/src/components/InputElements.tsx index 1128c47..04a417e 100644 --- a/liberica/src/components/InputElements.tsx +++ b/liberica/src/components/InputElements.tsx @@ -1,3 +1,5 @@ +import { Select } from "./lila/select"; + export const TextInput = ({ className, onTextChange, @@ -28,17 +30,15 @@ export const TextInput = ({ }; export function DropDown({ - className, items, onItemChange, ...props -}: React.SelectHTMLAttributes & { +}: React.ComponentProps<"select"> & { items: T[]; onItemChange?: (item: T) => void; }) { return ( - + ); } - -export const Button = (props: React.ComponentProps<"button">) => { - return ( - - ); -}; diff --git a/liberica/src/components/Navbar.tsx b/liberica/src/components/Navbar.tsx index 5227761..c3debf8 100644 --- a/liberica/src/components/Navbar.tsx +++ b/liberica/src/components/Navbar.tsx @@ -1,19 +1,11 @@ import { PropsWithChildren } from "react"; -import { Button } from "./InputElements"; import { FaHome } from "react-icons/fa"; import { useNavigate } from "react-router-dom"; +import { Button } from "components/lila/button"; export function Navbar(props: PropsWithChildren) { return ( -
+
{props.children}
); @@ -23,7 +15,7 @@ export function HomeButton() { const navigate = useNavigate(); return ( - ); diff --git a/liberica/src/components/TeamCard.tsx b/liberica/src/components/TeamCard.tsx index 347a18b..d8b7ff6 100644 --- a/liberica/src/components/TeamCard.tsx +++ b/liberica/src/components/TeamCard.tsx @@ -8,19 +8,18 @@ export function TeamCard(props: { const team = props.team; const states = { - selected: "outline outline-solid outline-2 outline-slate-300", - default: "", + selected: + "flex w-full items-center rounded-xl cursor-pointer bg-muted/20", + default: + "flex w-full items-center rounded-xl cursor-pointer hover:bg-muted/10", }; const state = props.selected ? "selected" : "default"; return ( -
+
diff --git a/liberica/src/components/lila/button.tsx b/liberica/src/components/lila/button.tsx index 4943abf..f25b06e 100644 --- a/liberica/src/components/lila/button.tsx +++ b/liberica/src/components/lila/button.tsx @@ -1,19 +1,22 @@ +import { classes } from "components/lila"; + const BASE = - "select-none transition-all font-sans disabled:pointer-events-none disabled:opacity-50 disabled:shadow-none "; + "select-none transition-all font-sans disabled:pointer-events-none active:opacity-[0.85] disabled:opacity-50 disabled:shadow-none "; export const BUTTON_VARIANTS = { - filled: BASE + "bg-secondary text-contrast rounded-xl font-bold", - tonal: - BASE + - "bg-muted/10 text-contrast rounded-xl font-bold hover:bg-muted/20 animate-entry text-text", - text: BASE + " py-0 px-0 font-bold uppercase text-primary", + primary: + "bg-primary text-on-primary rounded-xl font-bold hover:bg-primary/90 animate-entry", + secondary: + "bg-secondary text-on-secondary rounded-xl font-bold hover:bg-secondary/90 animate-entry", + muted: "bg-muted/10 text-on-muted rounded-xl font-bold hover:bg-muted/20 animate-entry", }; export const BUTTON_SIZES = { sm: "py-1 px-4 text-xs", md: "py-2 px-5 text-xs", lg: "py-2.5 px-7 text-sm", - "sm-wide": "w-full py-1 text-xs", + "sm-wide": "w-full py-1 text-sm", + "md-wide": "w-full py-2 text-md", }; export type ButtonVariant = keyof typeof BUTTON_VARIANTS; @@ -27,14 +30,14 @@ export interface ButtonPropsExt { export type ButtonProps = Omit, "className"> & ButtonPropsExt; -export function BaseButton(props: ButtonProps) { +export function Button(props: ButtonProps) { return (
@@ -119,7 +123,7 @@ export function Map( = THEMES_JSON; export interface Theme { base: string; surface: string; - text: string; + muted: string; primary: string; secondary: string; - accent: string; + + onBase: string; + onSurface: string; + onPrimary: string; + onSecondary: string; + onMuted: string; } export function applyTheme(theme: Theme) { const style = document.documentElement.style; - for (const [name, color] of Object.entries(theme)) { - const { h, s, l } = HexToHSL(color as string); - style.setProperty( - `--color-${name}`, - `${h.toString()} ${s.toString()}% ${l.toString()}%`, - ); + + for (const [name, val] of Object.entries(theme) as [ + keyof Theme, + string, + ][]) { + let color = val; + + if (val.startsWith("@")) { + const link = val.substring(1) as keyof Theme; + color = theme[link]; + console.log(name, "links to " + link + " --> " + color); + } + + const { h, s, l } = HexToHSL(color); + const hsl = `${h.toString()} ${s.toString()}% ${l.toString()}%`; + + console.log(name, fromCamelToKebabCase(name)); + style.setProperty("--color-" + fromCamelToKebabCase(name), hsl); } } diff --git a/liberica/src/lib/util.ts b/liberica/src/lib/util.ts index 029da71..c23eb51 100644 --- a/liberica/src/lib/util.ts +++ b/liberica/src/lib/util.ts @@ -21,3 +21,6 @@ export const getContrastingTextColor = (bg: string) => { export const clamp = (x: number, min: number, max: number) => { return Math.min(Math.max(x, min), max); }; + +export const fromCamelToKebabCase = (input: string) => + input.replace(/[A-Z]/g, (letter) => "-" + letter.toLowerCase()); diff --git a/liberica/src/page/CreateTeam.tsx b/liberica/src/page/CreateTeam.tsx index 4bc4e41..2e9163f 100644 --- a/liberica/src/page/CreateTeam.tsx +++ b/liberica/src/page/CreateTeam.tsx @@ -1,4 +1,6 @@ -import { Button, DropDown, TextInput } from "components/InputElements"; +import { DropDown } from "components/InputElements"; +import { Button } from "components/lila/button"; +import { TextInput } from "components/lila/input"; import { defaultErrorHandler, postCreateTeam } from "lib/api"; import { TeamKind } from "lib/bindings"; import { FormEvent, useState } from "react"; @@ -39,12 +41,15 @@ export function CreateTeam() { style={{ backgroundColor: color }} >

{t("CreateTeam")}

- + setName(e.target.value)} + placeholder="Lila pause" + /> onItemChange={setKind} @@ -62,13 +67,24 @@ export function CreateTeam() { ))}
- +
); diff --git a/liberica/src/page/Debug.tsx b/liberica/src/page/Debug.tsx index 712551b..f7a4fb0 100644 --- a/liberica/src/page/Debug.tsx +++ b/liberica/src/page/Debug.tsx @@ -1,10 +1,12 @@ import { BUTTON_SIZES, BUTTON_VARIANTS, - BaseButton, + Button, ButtonSize, ButtonVariant, } from "components/lila/button"; +import { TextInput } from "components/lila/input"; +import { THEMES, applyTheme } from "lib/theme"; import { useState } from "react"; export function Debug() { @@ -14,13 +16,17 @@ export function Debug() { const [text, setText] = useState("Test"); return ( -
- + setText(e.target.value || "Test")} - > + > + + @@ -41,12 +47,12 @@ export function Debug() { ))} diff --git a/liberica/src/page/Game.tsx b/liberica/src/page/Game.tsx index ca1a4c2..70e6546 100644 --- a/liberica/src/page/Game.tsx +++ b/liberica/src/page/Game.tsx @@ -5,7 +5,7 @@ import { WebSocketApi } from "lib/websockets"; import { useEffect, useState } from "react"; import { useLocation } from "react-router-dom"; import { HomeButton, Navbar } from "components/Navbar"; -import { Button } from "components/InputElements"; +import { Button } from "components/lila/button"; import { useTranslation } from "react-i18next"; export function Game() { @@ -67,7 +67,7 @@ export function Game() { }, [ws]); const Game = ( -
+
)} - @@ -104,12 +109,12 @@ export function Game() { ); const LandingPage = ( -
+
- + {t("ConnectionLost")} - {t("Reconnect")} + {t("Reconnect")}
); diff --git a/liberica/src/page/Replay.tsx b/liberica/src/page/Replay.tsx index d00255c..3ab8358 100644 --- a/liberica/src/page/Replay.tsx +++ b/liberica/src/page/Replay.tsx @@ -1,7 +1,7 @@ import { useRef, useState } from "react"; import { useInterval } from "use-interval"; import { GameStateContext, Map } from "components/map/Map"; -import { Button } from "components/InputElements"; +import { Button } from "components/lila"; import { HomeButton, Navbar } from "components/Navbar"; import { GameState } from "lib/bindings"; import { clamp } from "lib/util"; @@ -203,6 +203,7 @@ export function Replay() {
+ + {t("CreateTeam")} + +
); diff --git a/liberica/src/style/main.css b/liberica/src/style/main.css index a090dbb..0f6bcbe 100644 --- a/liberica/src/style/main.css +++ b/liberica/src/style/main.css @@ -1,25 +1,12 @@ @tailwind base; +@layer base { + html { + @apply text-on-base; + } +} @tailwind components; @tailwind utilities; -body,html { - margin: 0; - padding: 0 -} - -.h-max { - height: 100vh; -} - -.w-max { - width: 100vw; -} - -.flex-center { - justify-content: center; - align-items: center; -} - .leaflet-center { position: absolute; left: 50%; diff --git a/liberica/tailwind.config.js b/liberica/tailwind.config.js index 1e6f551..8bf6e6b 100644 --- a/liberica/tailwind.config.js +++ b/liberica/tailwind.config.js @@ -3,14 +3,18 @@ export default { content: ["./index.html", "./src/**/*.{js,ts,jsx,tsx}"], theme: { colors: { - "surface": "hsl(var(--color-surface) / )", - "overlay": "hsl(var(--color-overlay) / )", - "muted": "hsl(var(--color-muted) / )", - "text": "hsl(var(--color-text) / )", - "contrast": "hsl(var(--color-surface) / )", - "primary": "hsl(var(--color-primary) / )", - "secondary": "hsl(var(--color-secondary) / )", - "accent": "hsl(var(--color-accent) / )" + base: "hsl(var(--color-base) / )", + surface: "hsl(var(--color-surface) / )", + muted: "hsl(var(--color-muted) / )", + primary: "hsl(var(--color-primary) / )", + secondary: "hsl(var(--color-secondary) / )", + on: { + base: "hsl(var(--color-on-base) / )", + surface: "hsl(var(--color-on-surface) / )", + muted: "hsl(var(--color-on-muted) / )", + primary: "hsl(var(--color-on-primary) / )", + secondary: "hsl(var(--color-on-secondary) / )", + } }, }, plugins: [],
{variant} {size} - {text} - +