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;
@@ -6,7 +6,7 @@ export interface UserTheme {
primaryColor: string;
whiteColor: string;
blackColor: string;
radius: UiSizeType;
radius: MantineRadius;
loader: string;
}

View File

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

View File

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