* feat(db): add new col: user appTheme * feat(event-types page): apply appTheme color * add appTheme for trpc * feat: mutate main page theme * feat: add english translation for app theme update section * modify keys in common (en) * add woring * Revert yarn.lock to its state before unintended changes * feat(i18n): add back the i18n string (for dark/light mode switching) * refactor: refactor ThemeLabel * fix: add new user field "appTheme" to test files * chore: modify TODO comment * chore: update common.json (en) for "theme" since we had appTheme now, I think it's better to update the wording here to avoid confusion * fix: update button's data-testid to fix e2e test error * chore: remove comment * fix: fix brand-color-not-apply bug * solve type error * fix: fix type error * fix: use correct storageKey for booker / dashboard * fix: tidy up * fix: skeleton --------- Co-authored-by: swh00tw <a6140000@gmail.com> Co-authored-by: Peer Richelsen <peeroke@gmail.com> Co-authored-by: Keith Williams <keithwillcode@gmail.com> Co-authored-by: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com> Co-authored-by: Udit Takkar <udit222001@gmail.com>
38 lines
1.2 KiB
TypeScript
38 lines
1.2 KiB
TypeScript
interface ThemeLabelProps {
|
|
variant: "light" | "dark" | "system";
|
|
value?: "light" | "dark" | null;
|
|
label: string;
|
|
defaultChecked?: boolean;
|
|
register: any;
|
|
fieldName?: string;
|
|
}
|
|
|
|
export default function ThemeLabel(props: ThemeLabelProps) {
|
|
const { variant, label, value, defaultChecked, register, fieldName = "theme" } = props;
|
|
|
|
return (
|
|
<label
|
|
className="relative mb-4 flex-1 cursor-pointer text-center last:mb-0 last:mr-0 sm:mb-0 sm:mr-4"
|
|
htmlFor={`${fieldName}-${variant}`}
|
|
data-testid={`${fieldName}-${variant}`}>
|
|
<input
|
|
className="peer absolute left-8 top-8"
|
|
type="radio"
|
|
value={value}
|
|
id={`${fieldName}-${variant}`}
|
|
defaultChecked={defaultChecked}
|
|
{...register(fieldName)}
|
|
/>
|
|
<div className="ring-inverted relative z-10 rounded-lg ring-offset-2 transition-all peer-checked:ring-2">
|
|
<img
|
|
aria-hidden="true"
|
|
className="cover w-full rounded-lg"
|
|
src={`/theme-${variant}.svg`}
|
|
alt={`theme ${variant}`}
|
|
/>
|
|
</div>
|
|
<p className="peer-checked:text-emphasis text-default mt-2 text-sm font-medium">{label}</p>
|
|
</label>
|
|
);
|
|
}
|