style: improve styling of items on board (#504)

style: improve styling of items on board by defining margin depending on screen size, removing general padding on card of items and reducing size of no app icon
This commit is contained in:
Meier Lukas
2024-05-16 18:48:20 +02:00
committed by GitHub
parent 333dc571fa
commit 669a79ef08
3 changed files with 54 additions and 39 deletions

View File

@@ -39,56 +39,69 @@ interface Props {
export const SectionContent = ({ items, refs }: Props) => {
const board = useRequiredBoard();
const { ref, width, height } = useElementSize<HTMLDivElement>();
return (
<>
{items.map((item) => {
return (
<div
key={item.id}
className="grid-stack-item"
data-id={item.id}
gs-x={item.xOffset}
gs-y={item.yOffset}
gs-w={item.width}
gs-h={item.height}
gs-min-w={1}
gs-min-h={1}
gs-max-w={4}
gs-max-h={4}
ref={refs.items.current[item.id] as RefObject<HTMLDivElement>}
>
<Card
ref={ref}
className={combineClasses(
classes.itemCard,
"grid-stack-item-content",
)}
withBorder
styles={{
root: {
"--opacity": board.opacity / 100,
},
}}
p={width >= 96 ? undefined : "xs"}
>
<BoardItem item={item} width={width + 32} height={height + 32} />
</Card>
</div>
);
})}
{items.map((item) => (
<BoardItem
key={item.id}
refs={refs}
item={item}
opacity={board.opacity}
/>
))}
</>
);
};
interface ItemProps {
item: Item;
refs: UseGridstackRefs;
opacity: number;
}
const BoardItem = ({ refs, item, opacity }: ItemProps) => {
const { ref, width, height } = useElementSize<HTMLDivElement>();
return (
<div
key={item.id}
className="grid-stack-item"
data-id={item.id}
gs-x={item.xOffset}
gs-y={item.yOffset}
gs-w={item.width}
gs-h={item.height}
gs-min-w={1}
gs-min-h={1}
gs-max-w={4}
gs-max-h={4}
ref={refs.items.current[item.id] as RefObject<HTMLDivElement>}
>
<Card
ref={ref}
className={combineClasses(classes.itemCard, "grid-stack-item-content")}
withBorder
styles={{
root: {
"--opacity": opacity / 100,
},
}}
p={0}
>
<BoardItemContent item={item} width={width} height={height} />
</Card>
</div>
);
};
interface ItemContentProps {
item: Item;
width: number;
height: number;
}
const BoardItem = ({ item, ...dimensions }: ItemProps) => {
const BoardItemContent = ({ item, ...dimensions }: ItemContentProps) => {
const board = useRequiredBoard();
const editMode = useAtomValue(editModeAtom);
const serverData = useServerDataFor(item.id);

View File

@@ -26,7 +26,9 @@ export const initializeGridstack = ({
newGrid.current = GridStack.init(
{
column: sectionColumnCount,
margin: 10,
margin: Math.round(
Math.max(Math.min(refs.wrapper.current.offsetWidth / 100, 10), 1),
),
cellHeight: 128,
float: true,
alwaysShowResizeHandle: true,

View File

@@ -78,7 +78,7 @@ export default function AppWidget({
return (
<Tooltip.Floating label={t("error.notFound.tooltip")}>
<Stack gap="xs" align="center" justify="center" h="100%" w="100%">
<IconDeviceDesktopX size={width >= 96 ? "2rem" : "1.5rem"} />
<IconDeviceDesktopX size={width >= 96 ? "2rem" : "1rem"} />
{width >= 96 && (
<Text ta="center" size="sm">
{t("error.notFound.label")}