kelt-ui-kit-react 1.7.6 → 1.7.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "kelt-ui-kit-react",
3
3
  "type": "module",
4
- "version": "1.7.6",
4
+ "version": "1.7.8",
5
5
  "private": false,
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -1,4 +1,4 @@
1
- import { useEffect, useMemo, useState } from "react";
1
+ import { CSSProperties, useEffect, useMemo, useState } from "react";
2
2
  import "./damier.css";
3
3
  import { DamierCell } from "./damierCell/DamierCell";
4
4
  import { DamierCellInterface } from "./damierCell/damierCell.interface";
@@ -17,7 +17,7 @@ export const Damier = ({
17
17
  onClick,
18
18
  }: DamierProps) => {
19
19
  const nbCols = useMemo(() => cols ?? 9, [cols]);
20
- const nbRows = useMemo(() => rows ?? 9, [rows]);
20
+ const nbRows = useMemo(() => Math.max(1, rows ?? 9), [rows]);
21
21
  const [currentPage, setCurrentPage] = useState(1);
22
22
  useEffect(() => {
23
23
  setCurrentPage(page);
@@ -30,26 +30,35 @@ export const Damier = ({
30
30
  for (let col = 0; col < nbCols; col++) {
31
31
  const position = col + row * nbCols;
32
32
  const cell = damierCells?.find(
33
- (cell) => cell.position === position + 1
33
+ (cell) => cell.position === position + 1,
34
34
  );
35
35
  if (!cell) {
36
36
  colsArray.push(
37
- <div key={`${row}-${col}`} className="cell cell--empty"></div>
37
+ <div key={`${row}-${col}`} className="cell cell--empty"></div>,
38
38
  );
39
39
  } else {
40
40
  colsArray.push(
41
- <DamierCell onClick={onClick} key={`${row}-${col}`} cell={cell} />
41
+ <DamierCell onClick={onClick} key={`${row}-${col}`} cell={cell} />,
42
42
  );
43
43
  }
44
44
  }
45
45
  rowsArray.push(
46
46
  <div key={row} className="row">
47
47
  {colsArray}
48
- </div>
48
+ </div>,
49
49
  );
50
50
  }
51
51
  return rowsArray;
52
52
  }, [nbCols, nbRows, currentPage]);
53
53
 
54
- return <div className="damier">{grid}</div>;
54
+ const damierStyle = useMemo(
55
+ () => ({ "--rows": String(nbRows) }) as CSSProperties,
56
+ [nbRows],
57
+ );
58
+
59
+ return (
60
+ <div className="damier" style={damierStyle}>
61
+ {grid}
62
+ </div>
63
+ );
55
64
  };
@@ -5,10 +5,12 @@
5
5
  margin-bottom: 1rem;
6
6
  width: 100%;
7
7
  --sizeDamier: 630;
8
+ --rows: 9;
9
+
8
10
  .row {
9
11
  display: flex;
10
12
  height: 90px;
11
- width: calc(var(--sizeDamier) / 9);
13
+ width: calc(var(--sizeDamier) / var(--rows));
12
14
  min-height: 40px;
13
15
  }
14
16
 
@@ -22,9 +24,11 @@
22
24
  align-items: center;
23
25
  justify-content: center;
24
26
  background-color: #fff;
27
+
25
28
  &.cell--empty {
26
29
  background: #f9f9f9;
27
30
  }
31
+
28
32
  &:not(.cell--empty) {
29
33
  cursor: pointer;
30
34
  }
@@ -34,11 +38,13 @@
34
38
  @media (min-width: 768px) {
35
39
  .damier {
36
40
  --sizeDamier: 990;
41
+
37
42
  .row {
38
- height: calc(100vh / 9.6);
43
+ height: calc(100vh / var(--rows));
39
44
  }
45
+
40
46
  .cell {
41
- height: calc(100vh / 9) - 1;
47
+ height: calc((100vh / var(--rows)) - 1px);
42
48
  }
43
49
  }
44
- }
50
+ }