Skip to content

Commit

Permalink
style: run prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
martapanc committed Aug 27, 2023
1 parent 4a8aeba commit 95972ab
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 38 deletions.
22 changes: 12 additions & 10 deletions src/app/(public)/layout-client.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
'use client';

import {ThemeProvider as NextThemeProvider, } from 'next-themes';
import type {PropsWithChildren} from 'react';
import { ThemeProvider as NextThemeProvider } from 'next-themes';
import type { PropsWithChildren } from 'react';

import MuiThemeProvider from "@/components/helpers/MuiThemeProvider";
import MuiThemeProvider from '@/components/helpers/MuiThemeProvider';
import Footer from '@/components/layout/Footer';
import Header from '@/components/layout/Header';

export default function LayoutClient({children}: PropsWithChildren) {

export default function LayoutClient({ children }: PropsWithChildren) {
return (
<NextThemeProvider attribute='class' defaultTheme='light' enableSystem={false}>
<MuiThemeProvider >

<Header/>
<NextThemeProvider
attribute='class'
defaultTheme='light'
enableSystem={false}
>
<MuiThemeProvider>
<Header />

<main id='content'>{children}</main>

<Footer/>
<Footer />
</MuiThemeProvider>
</NextThemeProvider>
);
Expand Down
2 changes: 1 addition & 1 deletion src/components/atoms/LanguageSwitcher/LanguageSwitcher.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ const LanguageSwitcher = ({ languages }: LanguageSwitcherProps) => {
>
{lang.label}
</MenuItem>
)
),
)}
</Select>
</FormControl>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,5 @@ export const SampleStory = (args: LanguageSwitcherProps) => {
return <LanguageSwitcher {...args} />;
};
SampleStory.args = {
languages
}
languages,
};
26 changes: 15 additions & 11 deletions src/components/buttons/ModeToggleButton.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import clsx from 'clsx';
import {useTheme} from 'next-themes';
import { useTheme } from 'next-themes';
import * as React from 'react';
import {useEffect, useState} from 'react';
import {FiMoon, FiSun} from 'react-icons/fi';
import { useEffect, useState } from 'react';
import { FiMoon, FiSun } from 'react-icons/fi';

type ThemeButtonProps = React.ComponentPropsWithoutRef<'button'>;

export default function ModeToggleButton({
className,
...rest
}: ThemeButtonProps) {
const {theme, setTheme} = useTheme();
className,
...rest
}: ThemeButtonProps) {
const { theme, setTheme } = useTheme();
const [mounted, setMounted] = useState(false);

useEffect(() => setMounted(true), []);
Expand All @@ -20,18 +20,22 @@ export default function ModeToggleButton({
}

return (
<div className="p-2">
<div className='p-2'>
<button
className={clsx(
'flex items-center justify-center rounded-md border-2 ' +
'border-grey-300 ring-grey-300 bg-transparent p-2 transition-all hover:ring-2 hover:ring-offset-2 ' +
'dark:border-grey-700 dark:ring-grey-200 dark:bg-transparent dark:hover:ring-2 dark:hover:ring-offset-2',
'border-grey-300 ring-grey-300 bg-transparent p-2 transition-all hover:ring-2 hover:ring-offset-2 ' +
'dark:border-grey-700 dark:ring-grey-200 dark:bg-transparent dark:hover:ring-2 dark:hover:ring-offset-2',
className,
)}
{...rest}
onClick={toggleMode}
>
{mounted ? <>{theme === 'light' ? <FiMoon/> : <FiSun/>}</> : <FiSun/>}
{mounted ? (
<>{theme === 'light' ? <FiMoon /> : <FiSun />}</>
) : (
<FiSun />
)}
</button>
</div>
);
Expand Down
18 changes: 8 additions & 10 deletions src/components/helpers/MuiThemeProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
import { GlobalStyles } from "@mui/material";
import { CssBaseline, ThemeProvider } from "@mui/material";
import { useTheme } from "next-themes";
import { FC, useEffect, useState } from "react";
import { GlobalStyles } from '@mui/material';
import { CssBaseline, ThemeProvider } from '@mui/material';
import { useTheme } from 'next-themes';
import { FC, useEffect, useState } from 'react';

import { darkTheme, globalStyles, lightTheme } from "@/theme";
import { darkTheme, globalStyles, lightTheme } from '@/theme';

const MUIThemeProvider: FC<{ children: React.ReactNode }> = ({
children,
}) => {
const MUIThemeProvider: FC<{ children: React.ReactNode }> = ({ children }) => {
const { resolvedTheme } = useTheme();
const [currentTheme, setCurrentTheme] = useState(lightTheme);

useEffect(() => {
resolvedTheme === "light"
resolvedTheme === 'light'
? setCurrentTheme(lightTheme)
: setCurrentTheme(darkTheme);
}, [resolvedTheme]);
Expand All @@ -21,7 +19,7 @@ const MUIThemeProvider: FC<{ children: React.ReactNode }> = ({
<ThemeProvider theme={currentTheme}>
<CssBaseline />
<GlobalStyles styles={globalStyles} />
{children}
{children}
</ThemeProvider>
);
};
Expand Down
6 changes: 4 additions & 2 deletions src/components/layout/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ import { AiFillCaretDown, AiFillCaretUp } from 'react-icons/ai';
import { useOnKeyDown } from '@/hooks/useOnKeyDown';

import { BurgerIcon } from '@/components/atoms/BurgerIcon';
import LanguageSwitcher, {LanguageDef} from "@/components/atoms/LanguageSwitcher/LanguageSwitcher";
import LanguageSwitcher, {
LanguageDef,
} from '@/components/atoms/LanguageSwitcher/LanguageSwitcher';
import ModeToggleButton from '@/components/buttons/ModeToggleButton';
import UnstyledLink from '@/components/links/UnstyledLink';
import { MobileMenu } from '@/components/molecules/MobileMenu/MobileMenu';
Expand Down Expand Up @@ -121,7 +123,7 @@ export default function Header() {
</ul>

<div className='hidden md:flex md:flex-row'>
<LanguageSwitcher languages={languageDefs}/>
<LanguageSwitcher languages={languageDefs} />

<ModeToggleButton />
</div>
Expand Down
4 changes: 2 additions & 2 deletions src/theme/createEmotionCache.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import createCache from "@emotion/cache";
import createCache from '@emotion/cache';

// prepend: true moves MUI styles to the top of the <head> so they're loaded first.
// It allows developers to easily override MUI styles with other styling solutions, like CSS modules.
export default function createEmotionCache() {
return createCache({ key: "css", prepend: true });
return createCache({ key: 'css', prepend: true });
}

0 comments on commit 95972ab

Please sign in to comment.