refactor: css variables for colors and shadows
This commit is contained in:
@ -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"}
|
||||||
|
|||||||
@ -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;
|
||||||
|
|
||||||
|
|||||||
@ -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);
|
||||||
|
|||||||
@ -9,5 +9,5 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.header {
|
.header {
|
||||||
border-bottom: solid blue 3px;
|
border-bottom: solid dodgerblue 3px;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -46,14 +46,14 @@ const useBoardsContextState = () => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (selectedBoard) {
|
if (!selectedBoard) return;
|
||||||
let newBoard = boards.find(board => board.id === selectedBoard.id);
|
|
||||||
|
|
||||||
if (!newBoard && boards.length > 0) {
|
let newBoard = boards.find(board => board.id === selectedBoard.id);
|
||||||
newBoard = boards[0];
|
|
||||||
}
|
if (!newBoard && boards.length > 0) {
|
||||||
setSelectedBoard(newBoard ?? null);
|
newBoard = boards[0];
|
||||||
}
|
}
|
||||||
|
setSelectedBoard(newBoard ?? null);
|
||||||
}, [boards]);
|
}, [boards]);
|
||||||
|
|
||||||
const { onCreateBoard, onUpdateBoard, onDeleteBoard } = useBoardsOperations(
|
const { onCreateBoard, onUpdateBoard, onDeleteBoard } = useBoardsOperations(
|
||||||
|
|||||||
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -62,40 +62,39 @@ 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 activeIndex: number = items.findIndex(
|
|
||||||
({ id }) => id === activeItem.id
|
|
||||||
);
|
|
||||||
|
|
||||||
let leftIndex = overIndex;
|
|
||||||
let rightIndex = overIndex + 1;
|
|
||||||
if (overIndex < activeIndex) {
|
|
||||||
leftIndex = overIndex - 1;
|
|
||||||
rightIndex = overIndex;
|
|
||||||
}
|
|
||||||
|
|
||||||
const leftLexorank: LexoRank | null =
|
|
||||||
leftIndex >= 0
|
|
||||||
? LexoRank.parse(items[leftIndex].lexorank)
|
|
||||||
: null;
|
|
||||||
const rightLexorank: LexoRank | null =
|
|
||||||
rightIndex < items.length
|
|
||||||
? LexoRank.parse(items[rightIndex].lexorank)
|
|
||||||
: null;
|
|
||||||
|
|
||||||
const newLexorank = getNewLexorank(
|
|
||||||
leftLexorank,
|
|
||||||
rightLexorank
|
|
||||||
).toString();
|
|
||||||
|
|
||||||
items[activeIndex].lexorank = newLexorank;
|
|
||||||
onDragEnd(items[activeIndex].id, newLexorank);
|
|
||||||
const sortedItems = sortByLexorank(items);
|
|
||||||
setItems([...sortedItems]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const overIndex: number = items.findIndex(({ id }) => id === over.id);
|
||||||
|
const activeIndex: number = items.findIndex(
|
||||||
|
({ id }) => id === activeItem.id
|
||||||
|
);
|
||||||
|
|
||||||
|
let leftIndex = overIndex;
|
||||||
|
let rightIndex = overIndex + 1;
|
||||||
|
if (overIndex < activeIndex) {
|
||||||
|
leftIndex = overIndex - 1;
|
||||||
|
rightIndex = overIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
const leftLexorank: LexoRank | null =
|
||||||
|
leftIndex >= 0 ? LexoRank.parse(items[leftIndex].lexorank) : null;
|
||||||
|
const rightLexorank: LexoRank | null =
|
||||||
|
rightIndex < items.length
|
||||||
|
? LexoRank.parse(items[rightIndex].lexorank)
|
||||||
|
: null;
|
||||||
|
|
||||||
|
const newLexorank = getNewLexorank(
|
||||||
|
leftLexorank,
|
||||||
|
rightLexorank
|
||||||
|
).toString();
|
||||||
|
|
||||||
|
items[activeIndex].lexorank = newLexorank;
|
||||||
|
onDragEnd(items[activeIndex].id, newLexorank);
|
||||||
|
const sortedItems = sortByLexorank(items);
|
||||||
|
setItems([...sortedItems]);
|
||||||
setActive(null);
|
setActive(null);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -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;
|
||||||
|
|||||||
@ -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;
|
||||||
|
|||||||
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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;
|
||||||
|
|||||||
Reference in New Issue
Block a user