2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-09-16 15:41:34 +00:00

Fix user defined radius (#10327)

- Observe correct radius values
- Closes https://github.com/inventree/InvenTree/issues/10322
This commit is contained in:
Oliver
2025-09-16 10:20:23 +10:00
committed by GitHub
parent bb40b92896
commit 5727999d4d
3 changed files with 14 additions and 14 deletions

View File

@@ -1,4 +1,4 @@
import type { MantineSize } from '@mantine/core'; import type { MantineRadius, MantineSize } from '@mantine/core';
export type UiSizeType = MantineSize | string | number; export type UiSizeType = MantineSize | string | number;
@@ -6,7 +6,7 @@ export interface UserTheme {
primaryColor: string; primaryColor: string;
whiteColor: string; whiteColor: string;
blackColor: string; blackColor: string;
radius: UiSizeType; radius: MantineRadius;
loader: string; loader: string;
} }

View File

@@ -1,4 +1,4 @@
import type { MantineSize } from '@mantine/core'; import type { MantineRadius } from '@mantine/core';
export const emptyServerAPI = { export const emptyServerAPI = {
server: null, server: null,
@@ -26,7 +26,7 @@ export const emptyServerAPI = {
export interface SiteMarkProps { export interface SiteMarkProps {
value: number; value: number;
label: MantineSize; label: MantineRadius;
} }
export const SizeMarks: SiteMarkProps[] = [ export const SizeMarks: SiteMarkProps[] = [

View File

@@ -40,19 +40,19 @@ export function UserTheme({ height }: Readonly<{ height: number }>) {
); );
// radius // radius
function getMark(value: number) { function getRadiusFromValue(value: number) {
const obj = SizeMarks.find((mark) => mark.value === value); const obj = SizeMarks.find((mark) => mark.value === value);
if (obj) return obj; if (obj) return obj.label;
return SizeMarks[0]; return 'sm';
} }
function getDefaultRadius() {
const value = Number.parseInt(userTheme.radius.toString()); const [radius, setRadius] = useState(25);
return SizeMarks.some((mark) => mark.value === value) ? value : 50;
}
const [radius, setRadius] = useState(getDefaultRadius());
function changeRadius(value: number) { function changeRadius(value: number) {
const r = getRadiusFromValue(value);
setRadius(value); setRadius(value);
setTheme([{ key: 'radius', value: value.toString() }]);
setTheme([{ key: 'radius', value: r.toString() }]);
} }
return ( return (
@@ -163,7 +163,7 @@ export function UserTheme({ height }: Readonly<{ height: number }>) {
</Table.Td> </Table.Td>
<Table.Td> <Table.Td>
<Slider <Slider
label={(val) => getMark(val).label} label={(val) => getRadiusFromValue(val)}
defaultValue={50} defaultValue={50}
step={25} step={25}
marks={SizeMarks} marks={SizeMarks}