From 4c8d2680cccc67c7e2fc3abad1e78f471d033a32 Mon Sep 17 00:00:00 2001 From: JCNoguera <88061365+VmMad@users.noreply.github.com> Date: Wed, 13 Nov 2024 17:35:03 +0100 Subject: [PATCH 1/8] feat(explorer): add theme switcher --- .../explorer/src/components/ThemeProvider.tsx | 21 ++++++++ .../src/components/ThemedIotaLogo.tsx | 8 +++ .../explorer/src/components/footer/Footer.tsx | 12 ++--- .../explorer/src/components/header/Header.tsx | 12 +++-- .../src/components/header/ThemeSwitcher.tsx | 53 +++++++++++++++++++ apps/explorer/src/components/header/index.ts | 1 + apps/explorer/src/components/index.ts | 2 + .../explorer/src/components/layout/Layout.tsx | 9 ++-- .../src/components/layout/PageLayout.tsx | 2 +- .../components/module/PkgModulesWrapper.tsx | 2 +- .../components/object/ObjectFieldsCard.tsx | 2 +- .../explorer/src/components/search/Search.tsx | 2 +- apps/explorer/src/contexts/index.ts | 1 + apps/explorer/src/contexts/themeContext.ts | 15 ++++++ apps/explorer/src/hooks/index.ts | 1 + apps/explorer/src/hooks/useTheme.ts | 13 +++++ apps/explorer/src/index.css | 8 +++ apps/explorer/src/lib/ui/enums/index.ts | 4 ++ apps/explorer/src/lib/ui/enums/theme.enums.ts | 7 +++ apps/explorer/src/lib/ui/index.ts | 1 + apps/explorer/tailwind.config.ts | 1 + 21 files changed, 159 insertions(+), 18 deletions(-) create mode 100644 apps/explorer/src/components/ThemeProvider.tsx create mode 100644 apps/explorer/src/components/ThemedIotaLogo.tsx create mode 100644 apps/explorer/src/components/header/ThemeSwitcher.tsx create mode 100644 apps/explorer/src/contexts/themeContext.ts create mode 100644 apps/explorer/src/hooks/useTheme.ts create mode 100644 apps/explorer/src/lib/ui/enums/index.ts create mode 100644 apps/explorer/src/lib/ui/enums/theme.enums.ts diff --git a/apps/explorer/src/components/ThemeProvider.tsx b/apps/explorer/src/components/ThemeProvider.tsx new file mode 100644 index 00000000000..16dbb025c11 --- /dev/null +++ b/apps/explorer/src/components/ThemeProvider.tsx @@ -0,0 +1,21 @@ +// Copyright (c) 2024 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +import { useState, type PropsWithChildren } from 'react'; +import { ThemeContext } from '~/contexts'; +import { Theme } from '~/lib/ui'; + +export function ThemeProvider({ children }: PropsWithChildren): React.JSX.Element { + const [theme, setTheme] = useState(Theme.Light); + + return ( + + {children} + + ); +} diff --git a/apps/explorer/src/components/ThemedIotaLogo.tsx b/apps/explorer/src/components/ThemedIotaLogo.tsx new file mode 100644 index 00000000000..71a42a49a8d --- /dev/null +++ b/apps/explorer/src/components/ThemedIotaLogo.tsx @@ -0,0 +1,8 @@ +// Copyright (c) 2024 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +import { IotaLogoWeb } from '@iota/ui-icons'; + +export function ThemedIotaLogo(): React.JSX.Element { + return ; +} diff --git a/apps/explorer/src/components/footer/Footer.tsx b/apps/explorer/src/components/footer/Footer.tsx index e5f17ca794f..b9ec00af211 100644 --- a/apps/explorer/src/components/footer/Footer.tsx +++ b/apps/explorer/src/components/footer/Footer.tsx @@ -4,9 +4,9 @@ import { Divider } from '@iota/apps-ui-kit'; import { LegalLinks, LegalText } from './Legal'; -import { IotaLogoWeb } from '@iota/ui-icons'; import { Link } from '~/components/ui'; import { FOOTER_LINKS } from '~/lib/constants'; +import { ThemedIotaLogo } from '../ThemedIotaLogo'; function FooterLinks(): JSX.Element { return ( @@ -26,11 +26,11 @@ function FooterLinks(): JSX.Element { function Footer(): JSX.Element { return ( -