-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement Theming and add basic Component lib #37
Draft
Comeza
wants to merge
19
commits into
main
Choose a base branch
from
themes
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
64eb936
Theme setup
Comeza 7798ae3
Generate shades using value.js
Comeza de77709
Please the linter
Comeza 040a258
Theming tailwind integration
Comeza 65b8d53
Rebase main
Comeza e3a5bb6
Rename Home.tsx to SelectTeam.tsx
Comeza 1d05d30
Allow color linking for themes
Comeza 33ec963
Fix bg-white
Comeza c65b75f
Apply suggestions
Comeza 1ae2d2d
Allow restrict-template-expressions for numbers
Comeza ef9f754
Make themes persistent
Comeza a995a32
Remove debug statements
Comeza 4ed8cd3
Please the linter
Comeza b25b470
Use shadow realm Web APIs to sync Themes between tabs
Comeza 32bd722
Hacky drawer navbar, might revert later
Comeza d90f9fc
Revert drawer navbar
Comeza c01e698
Setup select element
Comeza 57d6f7f
Update deps
Comeza 58ea324
Update react-refresh for lila
Comeza File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file not shown.
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,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": "#191724", | ||
"surface": "#1f1d2e", | ||
"muted": "#6e6a86", | ||
"primary": "#ebbcba", | ||
"secondary": "#31748f", | ||
|
||
"onBase": "#e0def4", | ||
"onSurface": "@onBase", | ||
"onMuted": "@onBase", | ||
"onPrimary": "@base", | ||
"onSecondary": "@base" | ||
} | ||
} |
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 |
---|---|---|
@@ -1,30 +1,9 @@ | ||
import { PropsWithChildren } from "react"; | ||
import { Button } from "./InputElements"; | ||
import { FaHome } from "react-icons/fa"; | ||
import { useNavigate } from "react-router-dom"; | ||
|
||
export function Navbar(props: PropsWithChildren) { | ||
return ( | ||
<div | ||
className="absolute bottom-0 flex w-max gap-3 bg-white p-2" | ||
style={{ | ||
position: "fixed", | ||
justifyContent: "space-between", | ||
alignItems: "center", | ||
zIndex: 1000, | ||
}} | ||
> | ||
<div className="fixed bottom-0 z-auto flex max-h-14 w-dvw items-center justify-between gap-3 rounded-t-2xl bg-base p-2"> | ||
{props.children} | ||
</div> | ||
); | ||
} | ||
|
||
export function HomeButton() { | ||
const navigate = useNavigate(); | ||
|
||
return ( | ||
<Button onClick={() => navigate("/")}> | ||
<FaHome /> | ||
</Button> | ||
); | ||
} | ||
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 @@ | ||
/** eslint-disable react-refresh/only-export-components */ // This element does not have a state, so react-refresh is not needed | ||
|
||
import { classes } from "components/lila"; | ||
|
||
const BASE = | ||
"select-none transition-all font-sans disabled:pointer-events-none active:opacity-[0.85] disabled:opacity-50 disabled:shadow-none "; | ||
|
||
const BUTTON_VARIANTS = { | ||
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", | ||
}; | ||
|
||
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-sm", | ||
"md-wide": "w-full py-2 text-md", | ||
}; | ||
|
||
export type ButtonVariant = keyof typeof BUTTON_VARIANTS; | ||
export type ButtonSize = keyof typeof BUTTON_SIZES; | ||
|
||
export interface ButtonPropsExt { | ||
variant: ButtonVariant; | ||
size?: ButtonSize; | ||
} | ||
|
||
export type ButtonProps = Omit<React.ComponentProps<"button">, "className"> & | ||
ButtonPropsExt; | ||
|
||
export function Button(props: ButtonProps) { | ||
return ( | ||
<button | ||
className={classes( | ||
BASE, | ||
BUTTON_VARIANTS[props.variant], | ||
BUTTON_SIZES[props.size ?? "sm"], | ||
)} | ||
{...props} | ||
> | ||
{props.children} | ||
</button> | ||
); | ||
} |
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,9 @@ | ||
import { Button } from "./button"; | ||
import { TextInput } from "./input.tsx"; | ||
|
||
// eslint-disable-next-line react-refresh/only-export-components | ||
export function classes(...inputs: string[]): string { | ||
return inputs.join(" "); | ||
} | ||
|
||
export { Button, TextInput }; |
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,16 @@ | ||
export type TextInputProps = Omit< | ||
React.ComponentProps<"input">, | ||
"className" | "type" | ||
>; | ||
|
||
export function TextInput(props: TextInputProps) { | ||
return ( | ||
<input | ||
{...props} | ||
type="text" | ||
className="text-text rounded-xl bg-muted/20 px-6 py-3 outline-none ring-muted focus:ring-2" | ||
> | ||
{props.children} | ||
</input> | ||
); | ||
} |
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,26 @@ | ||
import { classes } from "components/lila"; | ||
|
||
export type SelectProps = Omit< | ||
React.ComponentProps<"select">, | ||
"className" | "size" | ||
> & | ||
SelectPropsExt; | ||
export interface SelectPropsExt { | ||
size?: keyof typeof INPUT_SIZES; | ||
noLogo?: boolean; | ||
} | ||
|
||
const BASE = | ||
"text-on-muted rounded-xl bg-muted/20 outline-none ring-muted focus:ring-2"; | ||
|
||
const INPUT_SIZES = { | ||
lg: "px-6 py-3 text-md", | ||
}; | ||
|
||
export function Select(props: SelectProps) { | ||
return ( | ||
<select className={classes(BASE, INPUT_SIZES[props.size ?? "lg"])}> | ||
{props.children} | ||
</select> | ||
); | ||
} |
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 |
---|---|---|
|
@@ -12,7 +12,6 @@ import { | |
import { createContext, useContext, useEffect, useState } from "react"; | ||
import { useTranslation } from "react-i18next"; | ||
import { MrXIcon, TrainIcon, DetectiveIcon } from "components/MapIcons"; | ||
import { Button } from "components/InputElements"; | ||
import { Marker } from "./Marker"; | ||
import { GameState, Stop, TeamState, Train } from "lib/bindings"; | ||
import { getStops } from "lib/api"; | ||
|
@@ -28,25 +27,10 @@ const CENTER: [number, number] = [49.0046, 8.403]; | |
const DEFAULT_ZOOM = 15; | ||
|
||
export type MapProps = React.PropsWithChildren<{ | ||
tileProps?: Partial<TileLayerProps>; | ||
containerProps?: Partial<MapContainerProps>; | ||
tileProps?: Omit<Partial<TileLayerProps>, "className">; | ||
containerProps?: Omit<Partial<MapContainerProps>, "className">; | ||
}>; | ||
|
||
function ResetMapViewButton() { | ||
const map = useMap(); | ||
const { t } = useTranslation(); | ||
|
||
return ( | ||
<div className="leaflet-top leaflet-center"> | ||
<div className="leaflet-control leaflet-bar"> | ||
<Button onClick={() => map.setView(CENTER, DEFAULT_ZOOM)}> | ||
{t("ResetMapView")} | ||
</Button> | ||
</div> | ||
</div> | ||
); | ||
} | ||
Comment on lines
-35
to
-48
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why? I find it pretty useful. |
||
|
||
function TrainMarker(props: { | ||
train: Train; | ||
onClick?: (train: Train) => void; | ||
|
@@ -119,7 +103,7 @@ export function Map( | |
<MapContainer | ||
center={CENTER} | ||
zoom={DEFAULT_ZOOM} | ||
className="h-max w-max" | ||
className="z-0 h-dvh w-dvw" | ||
{...props.containerProps} | ||
> | ||
<TileLayer | ||
|
@@ -173,7 +157,7 @@ export function Map( | |
</LayerGroup> | ||
</LayersControl.Overlay> | ||
</LayersControl> | ||
<ResetMapViewButton /> | ||
|
||
{props.children} | ||
</MapContainer> | ||
); | ||
|
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why remove the home button?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am currently experimenting with the Navbar and couldn't find space for it (It also didn't fit the theme). I will put it back sometime later.