From d6c1ba88d40ab33aa08063ac4d0d22b030bcb5bf Mon Sep 17 00:00:00 2001 From: Ian Philips Date: Mon, 12 Sep 2022 09:19:38 -0600 Subject: [PATCH] Extract switch to switch-setting --- web/components/notification-settings.tsx | 58 +++++------------------- web/components/switch-setting.tsx | 34 ++++++++++++++ 2 files changed, 45 insertions(+), 47 deletions(-) create mode 100644 web/components/switch-setting.tsx diff --git a/web/components/notification-settings.tsx b/web/components/notification-settings.tsx index 551e4d73..5dcdf3dd 100644 --- a/web/components/notification-settings.tsx +++ b/web/components/notification-settings.tsx @@ -8,7 +8,6 @@ import { notification_destination_types, } from 'common/user' import { updatePrivateUser } from 'web/lib/firebase/users' -import { Switch } from '@headlessui/react' import { Col } from 'web/components/layout/col' import { CashIcon, @@ -26,6 +25,7 @@ import { import { WatchMarketModal } from 'web/components/contract/watch-market-modal' import { filterDefined } from 'common/util/array' import toast from 'react-hot-toast' +import { SwitchSetting } from 'web/components/switch' export function NotificationSettings(props: { navigateToSection: string | undefined @@ -218,54 +218,18 @@ export function NotificationSettings(props: { {!browserDisabled.includes(key) && ( - - - - - - In-app - - - + )} {emailsEnabled.includes(key) && ( - - - - - - Emails - - - + )} diff --git a/web/components/switch-setting.tsx b/web/components/switch-setting.tsx new file mode 100644 index 00000000..0e93c420 --- /dev/null +++ b/web/components/switch-setting.tsx @@ -0,0 +1,34 @@ +import { Switch } from '@headlessui/react' +import clsx from 'clsx' +import React from 'react' + +export const SwitchSetting = (props: { + checked: boolean + onChange: (checked: boolean) => void + label: string +}) => { + const { checked, onChange, label } = props + return ( + + + + + {label} + + + ) +}