From 3d82603be1674ff2aac2049b040e7bed1d43b28c Mon Sep 17 00:00:00 2001 From: Matthew Russell Date: Fri, 30 Jun 2023 14:53:11 -0700 Subject: [PATCH] feat: adjust settings page to work for sidebar --- apps/trading/client-pages/layout/layout.tsx | 2 +- apps/trading/components/settings/settings.tsx | 55 +++++++++++-------- .../market-info/market-info-accordion.tsx | 2 +- .../src/components/switch/switch.tsx | 20 ++++++- .../toast/toast-position-setter.tsx | 44 ++++++--------- 5 files changed, 68 insertions(+), 55 deletions(-) diff --git a/apps/trading/client-pages/layout/layout.tsx b/apps/trading/client-pages/layout/layout.tsx index fcf0f62c2..339c4adfe 100644 --- a/apps/trading/client-pages/layout/layout.tsx +++ b/apps/trading/client-pages/layout/layout.tsx @@ -41,7 +41,7 @@ export const Layout = () => { {largeScreen && sidebarOpen && ( -
+
)} diff --git a/apps/trading/components/settings/settings.tsx b/apps/trading/components/settings/settings.tsx index 493428a78..b33cf5de3 100644 --- a/apps/trading/components/settings/settings.tsx +++ b/apps/trading/components/settings/settings.tsx @@ -1,39 +1,46 @@ import { t } from '@vegaprotocol/i18n'; -import { TelemetryApproval } from '../../components/welcome-dialog/telemetry-approval'; -import { - Divider, - Switch, - ThemeSwitcher, - ToastPositionSetter, -} from '@vegaprotocol/ui-toolkit'; +import { Switch, ToastPositionSetter } from '@vegaprotocol/ui-toolkit'; import { useThemeSwitcher } from '@vegaprotocol/react-helpers'; +import { useTelemetryApproval } from '../../lib/hooks/use-telemetry-approval'; +import type { ReactNode } from 'react'; export const Settings = () => { const { theme, setTheme } = useThemeSwitcher(); - const text = t(theme === 'dark' ? 'Light mode' : 'Dark mode'); + const [isApproved, setIsApproved] = useTelemetryApproval(); return (
-
-
- - -
+ setTheme()} checked={theme === 'dark'} /> -
- - - - + + + setIsApproved(isOn)} + checked={isApproved} + /> + + + + +
+ ); +}; + +const SettingsGroup = ({ + label, + children, +}: { + label: string; + children: ReactNode; +}) => { + return ( +
+ + {children}
); }; diff --git a/libs/markets/src/lib/components/market-info/market-info-accordion.tsx b/libs/markets/src/lib/components/market-info/market-info-accordion.tsx index da773ee9d..01452be03 100644 --- a/libs/markets/src/lib/components/market-info/market-info-accordion.tsx +++ b/libs/markets/src/lib/components/market-info/market-info-accordion.tsx @@ -106,7 +106,7 @@ export const MarketInfoAccordion = ({ }; return ( -
+

{t('Market data')}

diff --git a/libs/ui-toolkit/src/components/switch/switch.tsx b/libs/ui-toolkit/src/components/switch/switch.tsx index f20a0daf6..4a5225930 100644 --- a/libs/ui-toolkit/src/components/switch/switch.tsx +++ b/libs/ui-toolkit/src/components/switch/switch.tsx @@ -1,6 +1,7 @@ import type { ReactNode } from 'react'; import { forwardRef } from 'react'; import * as RootSwitch from '@radix-ui/react-switch'; +import classNames from 'classnames'; export interface SwitchProps { name?: string; @@ -15,17 +16,32 @@ export const Switch = forwardRef( { name = 'switch', labelText, onCheckedChange, checked = false, disabled }, ref ) => { + const wrapperClasses = classNames( + 'rounded-full relative outline-none cursor-default', + 'w-[41px] h-[18px]', + 'bg-vega-light-200 dark:bg-neutral-700', + 'data-[state=checked]:bg-vega-light-200 dark:data-[state=checked]:bg-neutral-700' + ); + + const thumbClasses = classNames( + 'cursor-pointer', + 'block w-[18px] h-[18px]', + 'bg-black dark:bg-white', + 'rounded-full transition-transform duration-100 translate-x-0.3 will-change-transform', + 'data-[state=checked]:translate-x-[23px]' + ); + return (
- + {labelText && (