From 0907d154c764770151b133fa3ef9c9154ca4c7d4 Mon Sep 17 00:00:00 2001 From: Jeroen Reumkens Date: Wed, 14 Sep 2022 09:15:13 +0200 Subject: [PATCH] feat: 4232 - new theme toggle design. (#4371) Co-authored-by: Peer Richelsen Co-authored-by: Joe Au-Yeung <65426560+joeauyeung@users.noreply.github.com> --- .../v2/settings/my-account/appearance.tsx | 116 ++++++++++-------- apps/web/public/static/locales/en/common.json | 5 + apps/web/public/theme-dark.svg | 40 ++++++ apps/web/public/theme-light.svg | 39 ++++++ apps/web/public/theme-system.svg | 61 +++++++++ 5 files changed, 211 insertions(+), 50 deletions(-) create mode 100644 apps/web/public/theme-dark.svg create mode 100644 apps/web/public/theme-light.svg create mode 100644 apps/web/public/theme-system.svg diff --git a/apps/web/pages/v2/settings/my-account/appearance.tsx b/apps/web/pages/v2/settings/my-account/appearance.tsx index dfa4d386a6..011fe61d4a 100644 --- a/apps/web/pages/v2/settings/my-account/appearance.tsx +++ b/apps/web/pages/v2/settings/my-account/appearance.tsx @@ -1,5 +1,4 @@ import { GetServerSidePropsContext } from "next"; -import { Trans } from "next-i18next"; import { Controller, useForm } from "react-hook-form"; import { useLocale } from "@calcom/lib/hooks/useLocale"; @@ -10,7 +9,6 @@ import { Button } from "@calcom/ui/v2/core/Button"; import Meta from "@calcom/ui/v2/core/Meta"; import Switch from "@calcom/ui/v2/core/Switch"; import ColorPicker from "@calcom/ui/v2/core/colorpicker"; -import Select from "@calcom/ui/v2/core/form/Select"; import { Form } from "@calcom/ui/v2/core/form/fields"; import { getLayout } from "@calcom/ui/v2/core/layouts/SettingsLayout"; import showToast from "@calcom/ui/v2/core/notifications"; @@ -31,11 +29,6 @@ const AppearanceView = (props: inferSSRProps) => { }, }); - const themeOptions = [ - { value: "light", label: t("light") }, - { value: "dark", label: t("dark") }, - ]; - const formMethods = useForm(); return ( @@ -44,50 +37,41 @@ const AppearanceView = (props: inferSSRProps) => { handleSubmit={(values) => { mutation.mutate({ ...values, - theme: values.theme.value, + // Radio values don't support null as values, therefore we convert an empty string + // back to null here. + theme: values.theme || null, }); }}> - ( - <> -
-
-

{t("follow_system_preferences")}

-

- - Automatically adjust theme based on invitee system preferences. Note: This only applies to - the booking pages. - -

-
-
- - formMethods.setValue("theme", checked ? null : themeOptions[0]) - } - checked={!value} - /> -
-
-
- +
+ +
+

{label}

+ + ); +}; diff --git a/apps/web/public/static/locales/en/common.json b/apps/web/public/static/locales/en/common.json index 17abcc3044..19ebed1c33 100644 --- a/apps/web/public/static/locales/en/common.json +++ b/apps/web/public/static/locales/en/common.json @@ -1204,6 +1204,11 @@ "add_new_form": "Add new form", "form_description": "Create your form to route a booker", "copy_link_to_form": "Copy link to form", + "theme": "Theme", + "theme_applies_note": "This only applies to your public booking pages", + "theme_light": "Light", + "theme_dark": "Dark", + "theme_system": "System default", "add_a_team": "Add a team", "saml_config": "SAML Config", "add_webhook_description": "Receive meeting data in real-time when something happens in Cal.com", diff --git a/apps/web/public/theme-dark.svg b/apps/web/public/theme-dark.svg new file mode 100644 index 0000000000..9dda6fd95b --- /dev/null +++ b/apps/web/public/theme-dark.svg @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/apps/web/public/theme-light.svg b/apps/web/public/theme-light.svg new file mode 100644 index 0000000000..19123b67bd --- /dev/null +++ b/apps/web/public/theme-light.svg @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/apps/web/public/theme-system.svg b/apps/web/public/theme-system.svg new file mode 100644 index 0000000000..8ad2de749d --- /dev/null +++ b/apps/web/public/theme-system.svg @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file