From 7c4ffd1132807393cd77a4bc26c0beb20a7c00a7 Mon Sep 17 00:00:00 2001 From: Meierschlumpf Date: Sun, 4 Dec 2022 18:45:14 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Add=20about=20modal?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/About/AboutModal.tsx | 165 ++++++++++++++++++ .../ColorSchemeToggle/ColorSchemeToggle.tsx | 28 --- src/components/layout/Logo.tsx | 10 +- src/components/layout/header/SettingsMenu.tsx | 8 +- src/components/layout/useGradient.tsx | 12 ++ 5 files changed, 187 insertions(+), 36 deletions(-) create mode 100644 src/components/About/AboutModal.tsx delete mode 100644 src/components/ColorSchemeToggle/ColorSchemeToggle.tsx create mode 100644 src/components/layout/useGradient.tsx diff --git a/src/components/About/AboutModal.tsx b/src/components/About/AboutModal.tsx new file mode 100644 index 000000000..924134a1f --- /dev/null +++ b/src/components/About/AboutModal.tsx @@ -0,0 +1,165 @@ +import Image from 'next/image'; +import { + ActionIcon, + Badge, + Button, + createStyles, + Group, + Modal, + Table, + Text, + Title, +} from '@mantine/core'; +import { + IconBrandDiscord, + IconBrandGithub, + IconLanguage, + IconVersions, + IconVocabulary, + IconWorldWww, +} from '@tabler/icons'; +import { i18n } from 'next-i18next'; +import { ReactNode } from 'react'; +import { CURRENT_VERSION } from '../../../data/constants'; +import { usePrimaryGradient } from '../layout/useGradient'; + +interface AboutModalProps { + opened: boolean; + closeModal: () => void; +} + +export const AboutModal = ({ opened, closeModal }: AboutModalProps) => { + const { classes } = useStyles(); + const colorGradiant = usePrimaryGradient(); + const informations = useInformationTableItems(); + + return ( + closeModal()} + opened={opened} + title={ + + + + About Homarr + + + } + size="xl" + > + + Homarr is a simple and modern homepage for your server that helps you access all of your + services in one place. It integrates with the services you use to display useful information + or control them. It's easy to install and supports many different devices. + + + + Version information: + + + + + {informations.map((item, index) => ( + + + + + ))} + +
+ + + {item.icon} + + {item.label} + + {item.content}
+ + + Having trouble or questions? Connect with us! + + + + + + + +
+ ); +}; + +interface InformationTableItem { + icon: ReactNode; + label: string; + content: ReactNode; +} + +const useInformationTableItems = (): InformationTableItem[] => { + const colorGradiant = usePrimaryGradient(); + + const usedI18nNamespaces = i18n?.reportNamespaces?.getUsedNamespaces(); + const configuredi18nLocales: string[] = i18n?.options.locales; + + return [ + { + icon: , + label: 'Homarr version', + content: ( + + {CURRENT_VERSION} + + ), + }, + { + icon: , + label: 'Loaded I18n translation namespaces', + content: ( + + {usedI18nNamespaces?.length ?? 'loading'} + + ), + }, + { + icon: , + label: 'Configured I18n locales', + content: ( + + {configuredi18nLocales?.length ?? 'loading'} + + ), + }, + ]; +}; + +const useStyles = createStyles(() => ({ + informationTableColumn: { + textAlign: 'right', + }, + informationIcon: { + cursor: 'default', + }, +})); diff --git a/src/components/ColorSchemeToggle/ColorSchemeToggle.tsx b/src/components/ColorSchemeToggle/ColorSchemeToggle.tsx deleted file mode 100644 index 3fbe701ee..000000000 --- a/src/components/ColorSchemeToggle/ColorSchemeToggle.tsx +++ /dev/null @@ -1,28 +0,0 @@ -import { Box, useMantineColorScheme } from '@mantine/core'; -import { IconSun as Sun, IconMoonStars as MoonStars } from '@tabler/icons'; -import { motion } from 'framer-motion'; - -export function ColorSchemeToggle() { - const { colorScheme, toggleColorScheme } = useMantineColorScheme(); - - return ( - - toggleColorScheme()} - sx={(theme) => ({ - cursor: 'pointer', - color: theme.colorScheme === 'dark' ? theme.colors.yellow[4] : theme.colors.blue[6], - })} - > - {colorScheme === 'dark' ? : } - - - ); -} diff --git a/src/components/layout/Logo.tsx b/src/components/layout/Logo.tsx index c34bd2b81..69594133a 100644 --- a/src/components/layout/Logo.tsx +++ b/src/components/layout/Logo.tsx @@ -1,6 +1,6 @@ import { Group, Image, Text } from '@mantine/core'; import { useConfigContext } from '../../config/provider'; -import { useColorTheme } from '../../tools/color'; +import { usePrimaryGradient } from './useGradient'; interface LogoProps { size?: 'md' | 'xs'; @@ -9,7 +9,7 @@ interface LogoProps { export function Logo({ size = 'md', withoutText = false }: LogoProps) { const { config } = useConfigContext(); - const { primaryColor, secondaryColor } = useColorTheme(); + const primaryGradient = usePrimaryGradient(); return ( @@ -25,11 +25,7 @@ export function Logo({ size = 'md', withoutText = false }: LogoProps) { size={size === 'md' ? 22 : 'xs'} weight="bold" variant="gradient" - gradient={{ - from: primaryColor, - to: secondaryColor, - deg: 145, - }} + gradient={primaryGradient} > {config?.settings.customization.pageTitle || 'Homarr'} diff --git a/src/components/layout/header/SettingsMenu.tsx b/src/components/layout/header/SettingsMenu.tsx index 95e58c85c..a263fbd13 100644 --- a/src/components/layout/header/SettingsMenu.tsx +++ b/src/components/layout/header/SettingsMenu.tsx @@ -1,11 +1,13 @@ import { ActionIcon, Menu, Tooltip } from '@mantine/core'; import { useDisclosure } from '@mantine/hooks'; import { IconInfoCircle, IconMenu2, IconSettings } from '@tabler/icons'; +import { AboutModal } from '../../About/AboutModal'; import { SettingsDrawer } from '../../Settings/SettingsDrawer'; import { ColorSchemeSwitch } from './SettingsMenu/ColorSchemeSwitch'; export const SettingsMenu = () => { const [drawerOpened, drawer] = useDisclosure(false); + const [aboutModalOpened, aboutModal] = useDisclosure(false); return ( <> @@ -22,13 +24,17 @@ export const SettingsMenu = () => { } onClick={drawer.open}> Homarr Settings - } onClick={() => {}}> + } + onClick={aboutModal.open} + > About + ); }; diff --git a/src/components/layout/useGradient.tsx b/src/components/layout/useGradient.tsx new file mode 100644 index 000000000..13197673d --- /dev/null +++ b/src/components/layout/useGradient.tsx @@ -0,0 +1,12 @@ +import { MantineGradient } from '@mantine/core'; +import { useColorTheme } from '../../tools/color'; + +export const usePrimaryGradient = (): MantineGradient => { + const { primaryColor, secondaryColor } = useColorTheme(); + + return { + from: primaryColor, + to: secondaryColor, + deg: 145, + }; +};