Skip to content

Commit

Permalink
Merge pull request #110 from DuckyMomo20012/dev
Browse files Browse the repository at this point in the history
feat: add dark mode switch
  • Loading branch information
DuckyMomo20012 committed Feb 8, 2024
2 parents 4c42f53 + 10e58fc commit 5f294e1
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 30 deletions.
4 changes: 1 addition & 3 deletions src/components/elements/Feature.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
'use client';

import { Anchor, Card, Space, Stack, Text } from '@mantine/core';

const Feature = ({
Expand Down Expand Up @@ -34,7 +32,7 @@ const Feature = ({
</Text>
)}
<Space h="lg" />
<Stack className="">{children}</Stack>
<Stack>{children}</Stack>
</Card>
);
};
Expand Down
4 changes: 1 addition & 3 deletions src/components/layouts/AppShell.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
'use client';

import { Icon } from '@iconify/react/dist/iconify.js';
import { Icon } from '@iconify/react';
import {
ActionIcon,
Anchor,
Expand Down
2 changes: 0 additions & 2 deletions src/components/modules/ButtonDemo.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
'use client';

import { Icon } from '@iconify/react';
import { ActionIcon, Button } from '@mantine/core';
import { memo } from 'react';
Expand Down
2 changes: 0 additions & 2 deletions src/components/modules/ComboboxDemo.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
'use client';

import {
Autocomplete,
Group,
Expand Down
2 changes: 0 additions & 2 deletions src/components/modules/DataDisplayDemo.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
'use client';

import { Icon } from '@iconify/react';
import {
Accordion,
Expand Down
2 changes: 0 additions & 2 deletions src/components/modules/FeedbackDemo.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
'use client';

import { Alert, Notification, Progress, Skeleton } from '@mantine/core';
import { memo } from 'react';
import { Feature } from '@/components/elements/Feature';
Expand Down
2 changes: 0 additions & 2 deletions src/components/modules/InputDemo.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
'use client';

import {
Checkbox,
Chip,
Expand Down
2 changes: 0 additions & 2 deletions src/components/modules/NavigationDemo.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
'use client';

import { NavLink, Pagination, Stepper, Tabs } from '@mantine/core';
import { memo } from 'react';
import { Feature } from '@/components/elements/Feature';
Expand Down
2 changes: 0 additions & 2 deletions src/components/modules/OverlayDemo.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
'use client';

import { Button, Tooltip } from '@mantine/core';
import { memo } from 'react';
import { Feature } from '@/components/elements/Feature';
Expand Down
14 changes: 6 additions & 8 deletions src/components/modules/TypographyDemo.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
'use client';

import { Icon } from '@iconify/react';
import { Blockquote, Code, Highlight, Stack, Title } from '@mantine/core';
import { memo } from 'react';
Expand Down Expand Up @@ -68,12 +66,12 @@ const TypographyDemo = memo(function TypographyDemo({
title="Title"
url="https://mantine.dev/core/title/"
>
<Title order={1}>{label}</Title>
<Title order={2}>{label}</Title>
<Title order={3}>{label}</Title>
<Title order={4}>{label}</Title>
<Title order={5}>{label}</Title>
<Title order={6}>{label}</Title>
<Title order={1}>H1: {label}</Title>
<Title order={2}>H2: {label}</Title>
<Title order={3}>H3: {label}</Title>
<Title order={4}>H4: {label}</Title>
<Title order={5}>H5: {label}</Title>
<Title order={6}>H6: {label}</Title>
</Feature>
</>
);
Expand Down
16 changes: 14 additions & 2 deletions src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
Switch,
Text,
TextInput,
useMantineColorScheme,
useMantineTheme,
} from '@mantine/core';
import { useDeferredValue, useState } from 'react';
Expand Down Expand Up @@ -37,6 +38,8 @@ export type ControlledDemoProps = {

const HomePage = () => {
const themes = useMantineTheme();
const { setColorScheme } = useMantineColorScheme();

const [color, setColor] = useState(themes.primaryColor);
const [size, setSize] = useState<MantineSize>('sm');
const [radius, setRadius] = useState<MantineSize>('md');
Expand Down Expand Up @@ -79,7 +82,7 @@ const HomePage = () => {
<Stack className="relative">
<Stack
align="center"
className="top-[calc(var(--app-shell-header-offset,_0px)_+_var(--app-shell-padding))] z-50 w-full bg-white py-4 shadow-sm lg:sticky"
className="top-[calc(var(--app-shell-header-offset,_0px)_+_var(--app-shell-padding))] z-50 w-full bg-white p-6 shadow-sm dark:bg-dark-800 lg:sticky"
>
<SimpleGrid
className="max-w-4xl"
Expand Down Expand Up @@ -122,6 +125,15 @@ const HomePage = () => {
label="Loading"
onChange={(e) => setLoading(e.currentTarget.checked)}
/>
<Switch
label="Dark mode"
onChange={(e) =>
setColorScheme(e.currentTarget.checked ? 'dark' : 'light')
}
wrapperProps={{
'data-test-id': 'demo-color-scheme-toggle',
}}
/>
</Group>
<Stack gap="xs">
<Text component="label" htmlFor="size-slider">
Expand Down Expand Up @@ -184,7 +196,7 @@ const HomePage = () => {
<Stack gap="xs">
<Text>Color: {color}</Text>
<SimpleGrid
className="max-w-max"
className="w-full justify-items-center"
cols={{ base: 6, xs: 8, sm: 12 }}
spacing="md"
verticalSpacing="xs"
Expand Down

0 comments on commit 5f294e1

Please sign in to comment.