mirror of
https://github.com/inventree/InvenTree.git
synced 2025-08-07 04:12:11 +00:00
fix usage of ColorScheme
This commit is contained in:
@@ -7,10 +7,11 @@ import {
|
|||||||
Overlay,
|
Overlay,
|
||||||
Paper,
|
Paper,
|
||||||
Text,
|
Text,
|
||||||
rem
|
rem,
|
||||||
|
useMantineColorScheme
|
||||||
} from '@mantine/core';
|
} from '@mantine/core';
|
||||||
import { Dropzone, FileWithPath, IMAGE_MIME_TYPE } from '@mantine/dropzone';
|
import { Dropzone, FileWithPath, IMAGE_MIME_TYPE } from '@mantine/dropzone';
|
||||||
import { useColorScheme, useHover } from '@mantine/hooks';
|
import { useHover } from '@mantine/hooks';
|
||||||
import { modals } from '@mantine/modals';
|
import { modals } from '@mantine/modals';
|
||||||
import { useMemo, useState } from 'react';
|
import { useMemo, useState } from 'react';
|
||||||
|
|
||||||
@@ -158,11 +159,11 @@ function UploadModal({
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const preferredColorScheme = useColorScheme();
|
const { colorScheme } = useMantineColorScheme();
|
||||||
|
|
||||||
const primaryColor =
|
const primaryColor =
|
||||||
vars.colors.primaryColors[preferredColorScheme === 'dark' ? 4 : 6];
|
vars.colors.primaryColors[colorScheme === 'dark' ? 4 : 6];
|
||||||
const redColor = vars.colors.red[preferredColorScheme === 'dark' ? 4 : 6];
|
const redColor = vars.colors.red[colorScheme === 'dark' ? 4 : 6];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Paper style={{ height: '220px' }}>
|
<Paper style={{ height: '220px' }}>
|
||||||
|
@@ -1,6 +1,11 @@
|
|||||||
import { t } from '@lingui/macro';
|
import { t } from '@lingui/macro';
|
||||||
import { Input, darken, useMantineTheme } from '@mantine/core';
|
import {
|
||||||
import { useColorScheme, useDebouncedValue, useId } from '@mantine/hooks';
|
Input,
|
||||||
|
darken,
|
||||||
|
useMantineColorScheme,
|
||||||
|
useMantineTheme
|
||||||
|
} from '@mantine/core';
|
||||||
|
import { useDebouncedValue, useId } from '@mantine/hooks';
|
||||||
import { useQuery } from '@tanstack/react-query';
|
import { useQuery } from '@tanstack/react-query';
|
||||||
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
||||||
import {
|
import {
|
||||||
@@ -219,11 +224,11 @@ export function RelatedModelField({
|
|||||||
const theme = useMantineTheme();
|
const theme = useMantineTheme();
|
||||||
|
|
||||||
const colorschema = vars.colors.primaryColors;
|
const colorschema = vars.colors.primaryColors;
|
||||||
const [preferredColorScheme] = useColorScheme();
|
const { colorScheme } = useMantineColorScheme();
|
||||||
|
|
||||||
const colors = useMemo(() => {
|
const colors = useMemo(() => {
|
||||||
let colors: any;
|
let colors: any;
|
||||||
if (preferredColorScheme === 'dark') {
|
if (colorScheme === 'dark') {
|
||||||
colors = {
|
colors = {
|
||||||
neutral0: colorschema[6],
|
neutral0: colorschema[6],
|
||||||
neutral5: colorschema[4],
|
neutral5: colorschema[4],
|
||||||
|
@@ -8,9 +8,9 @@ import {
|
|||||||
HoverCard,
|
HoverCard,
|
||||||
Skeleton,
|
Skeleton,
|
||||||
Text,
|
Text,
|
||||||
UnstyledButton
|
UnstyledButton,
|
||||||
|
useMantineColorScheme
|
||||||
} from '@mantine/core';
|
} from '@mantine/core';
|
||||||
import { useColorScheme } from '@mantine/hooks';
|
|
||||||
import { IconLayoutSidebar } from '@tabler/icons-react';
|
import { IconLayoutSidebar } from '@tabler/icons-react';
|
||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
|
|
||||||
@@ -35,7 +35,7 @@ export function NavHoverMenu({
|
|||||||
]);
|
]);
|
||||||
const [servername] = useServerApiState((state) => [state.server.instance]);
|
const [servername] = useServerApiState((state) => [state.server.instance]);
|
||||||
const [instanceName, setInstanceName] = useState<string>();
|
const [instanceName, setInstanceName] = useState<string>();
|
||||||
const [preferredColorScheme] = useColorScheme();
|
const { colorScheme } = useMantineColorScheme();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (hostKey && hostList[hostKey]) {
|
if (hostKey && hostList[hostKey]) {
|
||||||
@@ -89,9 +89,7 @@ export function NavHoverMenu({
|
|||||||
my="sm"
|
my="sm"
|
||||||
mx="-md"
|
mx="-md"
|
||||||
color={
|
color={
|
||||||
preferredColorScheme === 'dark'
|
colorScheme === 'dark' ? vars.colors.dark[5] : vars.colors.gray[1]
|
||||||
? vars.colors.dark[5]
|
|
||||||
: vars.colors.gray[1]
|
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<MenuLinks links={onlyItems} highlighted={true} />
|
<MenuLinks links={onlyItems} highlighted={true} />
|
||||||
|
@@ -1,6 +1,12 @@
|
|||||||
import { t } from '@lingui/macro';
|
import { t } from '@lingui/macro';
|
||||||
import { Drawer, Group, LoadingOverlay, Stack, Text } from '@mantine/core';
|
import {
|
||||||
import { useColorScheme } from '@mantine/hooks';
|
Drawer,
|
||||||
|
Group,
|
||||||
|
LoadingOverlay,
|
||||||
|
Stack,
|
||||||
|
Text,
|
||||||
|
useMantineColorScheme
|
||||||
|
} from '@mantine/core';
|
||||||
import { ReactTree, ThemeSettings } from '@naisutech/react-tree';
|
import { ReactTree, ThemeSettings } from '@naisutech/react-tree';
|
||||||
import {
|
import {
|
||||||
IconChevronDown,
|
IconChevronDown,
|
||||||
@@ -75,11 +81,11 @@ export function PartCategoryTree({
|
|||||||
return open ? <IconChevronDown /> : <IconChevronRight />;
|
return open ? <IconChevronDown /> : <IconChevronRight />;
|
||||||
}
|
}
|
||||||
|
|
||||||
const [prefferedColorScheme] = useColorScheme();
|
const { colorScheme } = useMantineColorScheme();
|
||||||
|
|
||||||
const themes: ThemeSettings = useMemo(() => {
|
const themes: ThemeSettings = useMemo(() => {
|
||||||
const currentTheme =
|
const currentTheme =
|
||||||
prefferedColorScheme === 'dark'
|
colorScheme === 'dark'
|
||||||
? vars.colors.defaultColor
|
? vars.colors.defaultColor
|
||||||
: vars.colors.primaryColors;
|
: vars.colors.primaryColors;
|
||||||
|
|
||||||
@@ -161,7 +167,7 @@ export function PartCategoryTree({
|
|||||||
RenderIcon={renderIcon}
|
RenderIcon={renderIcon}
|
||||||
defaultSelectedNodes={selectedCategory ? [selectedCategory] : []}
|
defaultSelectedNodes={selectedCategory ? [selectedCategory] : []}
|
||||||
showEmptyItems={false}
|
showEmptyItems={false}
|
||||||
theme={prefferedColorScheme}
|
theme={colorScheme}
|
||||||
themes={themes}
|
themes={themes}
|
||||||
/>
|
/>
|
||||||
</Stack>
|
</Stack>
|
||||||
|
@@ -6,9 +6,9 @@ import {
|
|||||||
Space,
|
Space,
|
||||||
Stack,
|
Stack,
|
||||||
Switch,
|
Switch,
|
||||||
Text
|
Text,
|
||||||
|
useMantineColorScheme
|
||||||
} from '@mantine/core';
|
} from '@mantine/core';
|
||||||
import { useColorScheme } from '@mantine/hooks';
|
|
||||||
import { showNotification } from '@mantine/notifications';
|
import { showNotification } from '@mantine/notifications';
|
||||||
import { IconEdit } from '@tabler/icons-react';
|
import { IconEdit } from '@tabler/icons-react';
|
||||||
import { useMemo } from 'react';
|
import { useMemo } from 'react';
|
||||||
@@ -166,14 +166,12 @@ export function SettingItem({
|
|||||||
shaded: boolean;
|
shaded: boolean;
|
||||||
onChange?: () => void;
|
onChange?: () => void;
|
||||||
}) {
|
}) {
|
||||||
const [prefferedColorScheme] = useColorScheme();
|
const { colorScheme } = useMantineColorScheme();
|
||||||
|
|
||||||
const style: Record<string, string> = { paddingLeft: '8px' };
|
const style: Record<string, string> = { paddingLeft: '8px' };
|
||||||
if (shaded) {
|
if (shaded) {
|
||||||
style['backgroundColor'] =
|
style['backgroundColor'] =
|
||||||
prefferedColorScheme === 'light'
|
colorScheme === 'light' ? vars.colors.gray[1] : vars.colors.gray[9];
|
||||||
? vars.colors.gray[1]
|
|
||||||
: vars.colors.gray[9];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@@ -1,19 +1,16 @@
|
|||||||
import { Trans } from '@lingui/macro';
|
import { Trans } from '@lingui/macro';
|
||||||
import { Button, Stack, Title } from '@mantine/core';
|
import { Button, Stack, Title, useMantineColorScheme } from '@mantine/core';
|
||||||
import { useColorScheme } from '@mantine/hooks';
|
|
||||||
import { IconExternalLink } from '@tabler/icons-react';
|
import { IconExternalLink } from '@tabler/icons-react';
|
||||||
|
|
||||||
import { vars } from '../../theme';
|
import { vars } from '../../theme';
|
||||||
|
|
||||||
export default function FeedbackWidget() {
|
export default function FeedbackWidget() {
|
||||||
const [preferredColorScheme] = useColorScheme();
|
const { colorScheme } = useMantineColorScheme();
|
||||||
return (
|
return (
|
||||||
<Stack
|
<Stack
|
||||||
style={{
|
style={{
|
||||||
backgroundColor:
|
backgroundColor:
|
||||||
preferredColorScheme === 'dark'
|
colorScheme === 'dark' ? vars.colors.gray[9] : vars.colors.gray[1],
|
||||||
? vars.colors.gray[9]
|
|
||||||
: vars.colors.gray[1],
|
|
||||||
borderRadius: vars.radius.md
|
borderRadius: vars.radius.md
|
||||||
}}
|
}}
|
||||||
p={15}
|
p={15}
|
||||||
|
Reference in New Issue
Block a user