refactor: css variables for colors and shadows

This commit is contained in:
2025-08-14 18:18:24 +04:00
parent 28004dc2a0
commit 43355b6ce3
12 changed files with 79 additions and 69 deletions

View File

@ -17,7 +17,7 @@ const Board: FC<Props> = ({ board }) => {
const { onUpdateBoard } = useBoardsContext(); const { onUpdateBoard } = useBoardsContext();
return ( return (
<Flex> <Flex p={"lg"}>
<SmallPageBlock active={selectedBoard?.id === board.id}> <SmallPageBlock active={selectedBoard?.id === board.id}>
<Group <Group
px={"md"} px={"md"}

View File

@ -1,7 +1,7 @@
.container { .container {
flex-wrap: nowrap; flex-wrap: nowrap;
border-bottom: solid blue 3px; border-bottom: solid dodgerblue 3px;
margin-bottom: 3px; margin-bottom: 3px;
cursor: pointer; cursor: pointer;

View File

@ -1,7 +1,7 @@
.container { .container {
@mixin light { @mixin light {
background-color: #e0f0f4; background-color: var(--color-light-aqua);
} }
@mixin dark { @mixin dark {
background-color: var(--mantine-color-dark-7); background-color: var(--mantine-color-dark-7);

View File

@ -9,5 +9,5 @@
} }
.header { .header {
border-bottom: solid blue 3px; border-bottom: solid dodgerblue 3px;
} }

View File

@ -46,14 +46,14 @@ const useBoardsContextState = () => {
return; return;
} }
if (selectedBoard) { if (!selectedBoard) return;
let newBoard = boards.find(board => board.id === selectedBoard.id); let newBoard = boards.find(board => board.id === selectedBoard.id);
if (!newBoard && boards.length > 0) { if (!newBoard && boards.length > 0) {
newBoard = boards[0]; newBoard = boards[0];
} }
setSelectedBoard(newBoard ?? null); setSelectedBoard(newBoard ?? null);
}
}, [boards]); }, [boards]);
const { onCreateBoard, onUpdateBoard, onDeleteBoard } = useBoardsOperations( const { onCreateBoard, onUpdateBoard, onDeleteBoard } = useBoardsOperations(

View File

@ -1,7 +1,20 @@
@import "tailwindcss"; @import "tailwindcss";
:root {
/* Colors */
--color-light-gray-blue: #f4f7fd;
--color-light-aqua: #e0f0f4;
--color-light-whitesmoke: #fcfdff;
--mantine-color-dark-7-5: #212121;
/* Shadows */
--light-shadow: 2px 2px 5px darkgray;
--light-thick-shadow: 4px 4px 10px darkgray;
--dark-shadow: 1px 1px 10px 1px var(--mantine-color-dark-6);
--dark-thick-shadow: 5px 5px 10px 1px var(--mantine-color-dark-6);
}
body { body {
@mixin light { @mixin light {
background-color: #f4f7fd; background-color: var(--color-light-gray-blue);
} }
} }

View File

@ -5,10 +5,10 @@
@media (max-width: 48em) { @media (max-width: 48em) {
@mixin dark { @mixin dark {
box-shadow: 2px 2px 15px 1px var(--mantine-color-dark-6); box-shadow: var(--dark-shadow);
} }
@mixin light { @mixin light {
box-shadow: 2px 2px 12px rgba(0, 0, 0, 0.16); box-shadow: var(--light-shadow);
} }
} }
} }

View File

@ -62,10 +62,12 @@ const SortableDnd = <T extends BaseItem>({
const sensors = useDndSensors(); const sensors = useDndSensors();
const onDragEndLocal = ({ active, over }: DragEndEvent) => { const onDragEndLocal = ({ active, over }: DragEndEvent) => {
if (over && active.id !== over?.id && activeItem) { if (!over || active.id === over?.id || !activeItem) {
const overIndex: number = items.findIndex( setActive(null);
({ id }) => id === over.id return;
); }
const overIndex: number = items.findIndex(({ id }) => id === over.id);
const activeIndex: number = items.findIndex( const activeIndex: number = items.findIndex(
({ id }) => id === activeItem.id ({ id }) => id === activeItem.id
); );
@ -78,9 +80,7 @@ const SortableDnd = <T extends BaseItem>({
} }
const leftLexorank: LexoRank | null = const leftLexorank: LexoRank | null =
leftIndex >= 0 leftIndex >= 0 ? LexoRank.parse(items[leftIndex].lexorank) : null;
? LexoRank.parse(items[leftIndex].lexorank)
: null;
const rightLexorank: LexoRank | null = const rightLexorank: LexoRank | null =
rightIndex < items.length rightIndex < items.length
? LexoRank.parse(items[rightIndex].lexorank) ? LexoRank.parse(items[rightIndex].lexorank)
@ -95,7 +95,6 @@ const SortableDnd = <T extends BaseItem>({
onDragEnd(items[activeIndex].id, newLexorank); onDragEnd(items[activeIndex].id, newLexorank);
const sortedItems = sortByLexorank(items); const sortedItems = sortByLexorank(items);
setItems([...sortedItems]); setItems([...sortedItems]);
}
setActive(null); setActive(null);
}; };

View File

@ -7,14 +7,13 @@
} }
@media (min-width: 48em) { @media (min-width: 48em) {
padding: rem(35); padding: var(--mantine-spacing-md);
border-radius: rem(20);
@mixin dark { @mixin dark {
box-shadow: 5px 5px 30px 1px var(--mantine-color-dark-6); box-shadow: var(--dark-thick-shadow);
} }
@mixin light { @mixin light {
box-shadow: 5px 5px 24px rgba(0, 0, 0, 0.16); box-shadow: var(--light-thick-shadow);
} }
} }
} }
@ -22,17 +21,16 @@
.mobile-padding-height { .mobile-padding-height {
height: 100% !important; height: 100% !important;
@media (min-width: 48em) { @media (min-width: 48em) {
padding: rem(40);
height: 89vh; height: 89vh;
} }
} }
.container-full-height { .container-full-height {
min-height: calc(100vh - (rem(20) * 2)); min-height: calc(100vh - (var(--mantine-spacing-md) * 2));
} }
.container-full-height-fixed { .container-full-height-fixed {
height: calc(100vh - (rem(20) * 2)); height: calc(100vh - (var(--mantine-spacing-md) * 2));
} }
.container-no-border-radius { .container-no-border-radius {
@ -45,7 +43,6 @@
height: 100vh; height: 100vh;
width: 100vw; width: 100vw;
border-radius: 0 !important; border-radius: 0 !important;
padding: rem(40) rem(20) rem(20);
position: fixed; position: fixed;
top: 0; top: 0;
left: 0; left: 0;

View File

@ -1,6 +1,7 @@
import { CSSProperties, FC, ReactNode } from "react"; import { CSSProperties, FC, ReactNode } from "react";
import classNames from "classnames"; import classNames from "classnames";
import styles from "./PageBlock.module.css"; import styles from "./PageBlock.module.css";
import { Box } from "@mantine/core";
type Props = { type Props = {
children: ReactNode; children: ReactNode;
@ -24,7 +25,8 @@ const PageBlock: FC<Props> = ({
transparent = false, transparent = false,
}) => { }) => {
return ( return (
<div <Box
bdrs={"lg"}
style={style} style={style}
className={classNames( className={classNames(
styles.container, styles.container,
@ -36,7 +38,7 @@ const PageBlock: FC<Props> = ({
styles[className] styles[className]
)}> )}>
{children} {children}
</div> </Box>
); );
}; };
export default PageBlock; export default PageBlock;

View File

@ -1,36 +1,33 @@
.container { .container {
border-radius: 20px;
margin: 18px;
@mixin dark { @mixin dark {
background-color: #212121; background-color: var(--mantine-color-dark-7-5);
box-shadow: 1px 1px 10px 1px var(--mantine-color-dark-6); box-shadow: var(--dark-shadow);
} }
@mixin light { @mixin light {
background-color: #fcfdff; background-color: var(--color-light-whitesmoke);
box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.04); box-shadow: var(--light-shadow);
} }
} }
.container-active { .container-active {
@mixin dark { @mixin dark {
background-color: var(--mantine-color-dark-8); background-color: var(--mantine-color-dark-8);
box-shadow: 5px 5px 20px 1px var(--mantine-color-dark-6); box-shadow: var(--dark-thick-shadow);
} }
@mixin light { @mixin light {
background-color: white; background-color: white;
box-shadow: 5px 5px 20px rgba(0, 0, 0, 0.16); box-shadow: var(--light-thick-shadow);
} }
} }
.container:hover { .container:hover {
@mixin dark { @mixin dark {
background-color: var(--mantine-color-dark-8); background-color: var(--mantine-color-dark-8);
box-shadow: 5px 5px 20px 1px var(--mantine-color-dark-6); box-shadow: var(--dark-thick-shadow);
} }
@mixin light { @mixin light {
background-color: white; background-color: white;
box-shadow: 5px 5px 20px rgba(0, 0, 0, 0.16); box-shadow: var(--light-thick-shadow);
} }
} }

View File

@ -1,6 +1,7 @@
import { CSSProperties, FC, ReactNode } from "react"; import { CSSProperties, FC, ReactNode } from "react";
import classNames from "classnames"; import classNames from "classnames";
import styles from "@/components/layout/SmallPageBlock/SmallPageBlock.module.css"; import styles from "@/components/layout/SmallPageBlock/SmallPageBlock.module.css";
import { Box } from "@mantine/core";
type Props = { type Props = {
children: ReactNode; children: ReactNode;
@ -10,14 +11,15 @@ type Props = {
const SmallPageBlock: FC<Props> = ({ children, style, active = false }) => { const SmallPageBlock: FC<Props> = ({ children, style, active = false }) => {
return ( return (
<div <Box
bdrs={"lg"}
className={classNames( className={classNames(
styles.container, styles.container,
active && styles["container-active"] active && styles["container-active"]
)} )}
style={style}> style={style}>
{children} {children}
</div> </Box>
); );
}; };
export default SmallPageBlock; export default SmallPageBlock;