Skip to content
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

Amsterdam/theme #272

Draft
wants to merge 7 commits into
base: development
Choose a base branch
from
Draft
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
31 changes: 31 additions & 0 deletions pwa/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions pwa/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,10 @@
"vis-network": "^9.1.2"
},
"devDependencies": {
"@amsterdam/asc-assets": "0.38.0",
"@material-ui/core": "^4.12.4",
"@material-ui/lab": "^4.11.3-deprecations.1",
"@nl-design-system-unstable/amsterdam-design-tokens": "1.0.0-alpha.100",
"@nl-design-system-unstable/rotterdam-design-tokens": "1.0.0-alpha.88",
"@types/dateformat": "^5.0.0",
"@types/dedent": "^0.7.0",
Expand Down
1 change: 1 addition & 0 deletions pwa/src/data/themes.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export const themes = [
{ label: "Rotterdam", value: "rotterdam", className: "rotterdam-theme" },
{ label: "Utrecht", value: "utrecht", className: "utrecht-theme" },
{ label: "Amsterdam", value: "amsterdam", className: "amsterdam-theme amsterdam-theme--responsive" },
];
2 changes: 2 additions & 0 deletions pwa/src/styling/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
/* TODO: Load themes on-demand */
@import "../../node_modules/@nl-design-system-unstable/rotterdam-design-tokens/dist/index.css";
@import "../../node_modules/@utrecht/design-tokens/dist/theme.css";
@import "../../node_modules/@nl-design-system-unstable/amsterdam-design-tokens/dist/index.css";
@import "../../node_modules/@nl-design-system-unstable/amsterdam-design-tokens/dist/font.css";

/* Package includes */
@import "react-loading-skeleton/dist/skeleton.css";
Expand Down
24 changes: 14 additions & 10 deletions pwa/src/styling/themeProvider/ThemeProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import "./../../styling/design-tokens/component-overrides.css";
import { useForm } from "react-hook-form";
import { themes } from "../../data/themes";
import { FormFieldInput } from "@gemeente-denhaag/form-field";
import { SelectSingle } from "@conduction/components";
import { Document } from "@utrecht/component-library-react/dist/css-module";
import { FormField, FormLabel } from "@utrecht/component-library-react/dist/css-module";
import { Select, SelectOption } from "@utrecht/component-library-react";

export const ThemeProvider = ({ children }: React.PropsWithChildren<object>): JSX.Element => {
const [theme, setTheme] = React.useState<string>("rotterdam");
Expand Down Expand Up @@ -48,17 +48,16 @@ const ThemeSwitcher: React.FC<ThemeSwitcherProps> = ({ setTheme }) => {
const {
register,
watch,
control,
formState: { errors },
} = useForm();

React.useEffect(() => {
const subscription = watch(({ themeSwitcher }) => {
setTheme(themeSwitcher?.value);
setTheme(themeSwitcher);
});

return () => subscription.unsubscribe();
});
}, [watch]);

return (
<div className={styles.themeSwitcherContainer}>
Expand All @@ -68,13 +67,18 @@ const ThemeSwitcher: React.FC<ThemeSwitcherProps> = ({ setTheme }) => {
<span className={styles.label}>Thema aanpasssen:</span>
</FormLabel>
<div className={styles.selectBorder}>
<SelectSingle
<Select
id="themeChangerForm"
name="themeSwitcher"
defaultValue={themes[0]}
options={themes}
{...{ errors, control, register }}
/>
defaultValue={themes[0].value}
invalid={errors["themeSwitcher"]}
{...register("themeSwitcher")}
>
{themes.map(({ label, value }) => (
<SelectOption value={value} key={label}>
{label}
</SelectOption>
))}
</Select>
</div>
</FormFieldInput>
</FormField>
Expand Down
6 changes: 6 additions & 0 deletions pwa/static/images/LogoAmsterdam.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading