Skip to content

Commit

Permalink
feat/cell finissh
Browse files Browse the repository at this point in the history
  • Loading branch information
k0t1k777 committed Aug 10, 2024
1 parent 266499b commit 0f7b488
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/pages/Main/Main.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,14 @@
.cardContainer {
display: grid;
grid-template-columns: repeat(3, 300px);
grid-template-rows: repeat(auto-fill, 127px);
gap: 24px;
position: relative;
height: 100vh;
}

.cell {
width: 100%;
border-radius: $border-radius-s;
height: 127px
}
25 changes: 23 additions & 2 deletions src/pages/Main/Main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default function Main() {
const [allCards, setAllCards] = useState<initialCardsProps[]>([]);
const [arrows, setArrows] = useState<JSX.Element[]>([]);
const numCols = 3;
const numRows = 100;
const numRows = 10;

const [busyCells, setBusyCells] = useState<string[]>([]);

Expand Down Expand Up @@ -63,6 +63,27 @@ export default function Main() {
return emptyCells.map((cellId) => {
const [col, row] = cellId.split('-').map(Number);

let backgroundColor = 'transparent';
if (busyCellIds.has('1-0')) {
// Подсвечиваем ячейки 0-1, 1-1, 2-1
if (row === 1 && col >= 0 && col <= 2) {
backgroundColor = '#EBF7FF';
} else if (row > 1 && col >= 0 && col <= 2) {
// Подсвечиваем ячейку ниже занятых
const aboveCellId = `${col}-${row - 1}`;
if (busyCellIds.has(aboveCellId)) {
backgroundColor = '#EBF7FF';
}
}
} else {
// Проверяем, если текущая ячейка под занятыми
const belowCellId = `${col}-${row + 1}`;
if (busyCellIds.has(belowCellId)) {
backgroundColor = '#EBF7FF';
}
}


return (
<div
key={cellId}
Expand All @@ -71,7 +92,7 @@ export default function Main() {
style={{
gridColumn: col + 1,
gridRow: row + 1,
backgroundColor: '#EBF7FF',
backgroundColor: backgroundColor
}}
/>
);
Expand Down

0 comments on commit 0f7b488

Please sign in to comment.