2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-04-28 11:36:44 +00:00

[UI] Reactive Details Columns (#8883)

* Adapt details column count

- Based on element width

* Pin minimum size of thumbnail

* Cleaner implementation

* Revert again

- Use element size, not screen size
This commit is contained in:
Oliver 2025-01-12 14:58:52 +11:00 committed by GitHub
parent e8c1417b15
commit b06b762895
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 2 deletions

View File

@ -1,10 +1,16 @@
import { Paper, SimpleGrid } from '@mantine/core'; import { Paper, SimpleGrid } from '@mantine/core';
import { useElementSize } from '@mantine/hooks';
import type React from 'react'; import type React from 'react';
import { useMemo } from 'react';
export function ItemDetailsGrid(props: React.PropsWithChildren<{}>) { export function ItemDetailsGrid(props: React.PropsWithChildren<{}>) {
const { ref, width } = useElementSize();
const cols = useMemo(() => (width > 700 ? 2 : 1), [width]);
return ( return (
<Paper p='xs'> <Paper p='xs'>
<SimpleGrid cols={2} spacing='xs' verticalSpacing='xs'> <SimpleGrid cols={cols} spacing='xs' verticalSpacing='xs' ref={ref}>
{props.children} {props.children}
</SimpleGrid> </SimpleGrid>
</Paper> </Paper>

View File

@ -66,7 +66,13 @@ export function PageDetail({
<Group justify='space-between' wrap='nowrap'> <Group justify='space-between' wrap='nowrap'>
<Group justify='left' wrap='nowrap'> <Group justify='left' wrap='nowrap'>
{imageUrl && ( {imageUrl && (
<ApiImage src={imageUrl} radius='sm' mah={42} maw={42} /> <ApiImage
src={imageUrl}
radius='sm'
miw={42}
mah={42}
maw={42}
/>
)} )}
<Stack gap='xs'> <Stack gap='xs'>
{title && <StylishText size='lg'>{title}</StylishText>} {title && <StylishText size='lg'>{title}</StylishText>}