kelt-ui-kit-react 2.0.6 → 2.0.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/dist/index.js +357 -354
- package/dist/style.css +1 -1
- package/dist/toaster/store/useToasterStore.d.ts +4 -0
- package/package.json +1 -1
- package/src/expands/expand/expand.tsx +191 -191
- package/src/grid/Grid.tsx +34 -34
- package/src/grid/col/Col.tsx +24 -24
- package/src/grid/col/col.css +3 -3
- package/src/grid/col/colStyled/ColStyled.tsx +59 -59
- package/src/grid/row/Row.tsx +49 -49
- package/src/toaster/Toaster.tsx +2 -1
- package/src/toaster/store/useToasterStore.tsx +11 -0
- package/src/toaster/toaster.css +13 -0
package/src/grid/row/Row.tsx
CHANGED
|
@@ -1,49 +1,49 @@
|
|
|
1
|
-
import { createContext } from "react";
|
|
2
|
-
import { GridResponsive } from "../grid.interface";
|
|
3
|
-
import "./row.css";
|
|
4
|
-
|
|
5
|
-
export type GridGap = boolean | number | string;
|
|
6
|
-
|
|
7
|
-
export const RowResponsiveContext = createContext<GridResponsive>("app");
|
|
8
|
-
|
|
9
|
-
type RowProps = {
|
|
10
|
-
children: React.ReactNode;
|
|
11
|
-
className?: string;
|
|
12
|
-
scroll?: boolean;
|
|
13
|
-
/** true (défaut) : gap par défaut, false : pas de gap, number : px, string : valeur CSS ("1rem") */
|
|
14
|
-
gap?: GridGap;
|
|
15
|
-
/** Largeur sur laquelle se basent les breakpoints des Col (défaut : "app") */
|
|
16
|
-
responsive?: GridResponsive;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
const getGutter = (gap: GridGap) => {
|
|
20
|
-
if (gap === true) return undefined; // garde la valeur par défaut du CSS
|
|
21
|
-
if (gap === false) return "0px";
|
|
22
|
-
return typeof gap === "number" ? `${gap}px` : gap;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
export const Row: React.FC<RowProps> = ({
|
|
26
|
-
children,
|
|
27
|
-
className,
|
|
28
|
-
scroll,
|
|
29
|
-
gap = true,
|
|
30
|
-
responsive = "app",
|
|
31
|
-
}) => {
|
|
32
|
-
const gutter = getGutter(gap);
|
|
33
|
-
return (
|
|
34
|
-
<RowResponsiveContext.Provider value={responsive}>
|
|
35
|
-
<div
|
|
36
|
-
className={`grid-row ${className ?? ""} ${scroll ? "scroll" : ""} ${
|
|
37
|
-
responsive === "row" ? "grid-row--responsive" : ""
|
|
38
|
-
}`}
|
|
39
|
-
style={
|
|
40
|
-
gutter
|
|
41
|
-
? ({ "--grid-gutter": gutter } as React.CSSProperties)
|
|
42
|
-
: undefined
|
|
43
|
-
}
|
|
44
|
-
>
|
|
45
|
-
{children}
|
|
46
|
-
</div>
|
|
47
|
-
</RowResponsiveContext.Provider>
|
|
48
|
-
);
|
|
49
|
-
};
|
|
1
|
+
import { createContext } from "react";
|
|
2
|
+
import { GridResponsive } from "../grid.interface";
|
|
3
|
+
import "./row.css";
|
|
4
|
+
|
|
5
|
+
export type GridGap = boolean | number | string;
|
|
6
|
+
|
|
7
|
+
export const RowResponsiveContext = createContext<GridResponsive>("app");
|
|
8
|
+
|
|
9
|
+
type RowProps = {
|
|
10
|
+
children: React.ReactNode;
|
|
11
|
+
className?: string;
|
|
12
|
+
scroll?: boolean;
|
|
13
|
+
/** true (défaut) : gap par défaut, false : pas de gap, number : px, string : valeur CSS ("1rem") */
|
|
14
|
+
gap?: GridGap;
|
|
15
|
+
/** Largeur sur laquelle se basent les breakpoints des Col (défaut : "app") */
|
|
16
|
+
responsive?: GridResponsive;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const getGutter = (gap: GridGap) => {
|
|
20
|
+
if (gap === true) return undefined; // garde la valeur par défaut du CSS
|
|
21
|
+
if (gap === false) return "0px";
|
|
22
|
+
return typeof gap === "number" ? `${gap}px` : gap;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const Row: React.FC<RowProps> = ({
|
|
26
|
+
children,
|
|
27
|
+
className,
|
|
28
|
+
scroll,
|
|
29
|
+
gap = true,
|
|
30
|
+
responsive = "app",
|
|
31
|
+
}) => {
|
|
32
|
+
const gutter = getGutter(gap);
|
|
33
|
+
return (
|
|
34
|
+
<RowResponsiveContext.Provider value={responsive}>
|
|
35
|
+
<div
|
|
36
|
+
className={`grid-row ${className ?? ""} ${scroll ? "scroll" : ""} ${
|
|
37
|
+
responsive === "row" ? "grid-row--responsive" : ""
|
|
38
|
+
}`}
|
|
39
|
+
style={
|
|
40
|
+
gutter
|
|
41
|
+
? ({ "--grid-gutter": gutter } as React.CSSProperties)
|
|
42
|
+
: undefined
|
|
43
|
+
}
|
|
44
|
+
>
|
|
45
|
+
{children}
|
|
46
|
+
</div>
|
|
47
|
+
</RowResponsiveContext.Provider>
|
|
48
|
+
);
|
|
49
|
+
};
|
package/src/toaster/Toaster.tsx
CHANGED
|
@@ -14,6 +14,7 @@ export const Toaster = () => {
|
|
|
14
14
|
duration,
|
|
15
15
|
hideToast,
|
|
16
16
|
close,
|
|
17
|
+
position,
|
|
17
18
|
} = useToasterStore();
|
|
18
19
|
const onClose = useCallback(() => {
|
|
19
20
|
hideToast();
|
|
@@ -32,7 +33,7 @@ export const Toaster = () => {
|
|
|
32
33
|
if (!toasterRoot) return null;
|
|
33
34
|
|
|
34
35
|
return ReactDOM.createPortal(
|
|
35
|
-
<div className={`toaster toaster-${severity}`}>
|
|
36
|
+
<div className={`toaster toaster-${severity} toaster--${position}`}>
|
|
36
37
|
{close && (
|
|
37
38
|
<button
|
|
38
39
|
type="button"
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { create } from "zustand";
|
|
2
2
|
|
|
3
|
+
export type ToasterPosition =
|
|
4
|
+
| "top-right"
|
|
5
|
+
| "top-center"
|
|
6
|
+
| "bottom-right"
|
|
7
|
+
| "bottom-center";
|
|
8
|
+
|
|
3
9
|
type ToasterState = {
|
|
4
10
|
title: string;
|
|
5
11
|
description?: string;
|
|
@@ -8,6 +14,7 @@ type ToasterState = {
|
|
|
8
14
|
visible: boolean;
|
|
9
15
|
duration: number;
|
|
10
16
|
close?: boolean;
|
|
17
|
+
position: ToasterPosition;
|
|
11
18
|
showToast: (
|
|
12
19
|
title: string,
|
|
13
20
|
options?: {
|
|
@@ -16,6 +23,8 @@ type ToasterState = {
|
|
|
16
23
|
duration?: number;
|
|
17
24
|
children?: React.ReactNode;
|
|
18
25
|
close?: boolean;
|
|
26
|
+
/** Position à l'écran (défaut : "top-right") */
|
|
27
|
+
position?: ToasterPosition;
|
|
19
28
|
}
|
|
20
29
|
) => void;
|
|
21
30
|
hideToast: () => void;
|
|
@@ -28,6 +37,7 @@ export const useToasterStore = create<ToasterState>((set) => ({
|
|
|
28
37
|
visible: false,
|
|
29
38
|
duration: 2500,
|
|
30
39
|
close: true,
|
|
40
|
+
position: "top-right",
|
|
31
41
|
children: null,
|
|
32
42
|
showToast: (title, options = {}) =>
|
|
33
43
|
set(() => ({
|
|
@@ -38,6 +48,7 @@ export const useToasterStore = create<ToasterState>((set) => ({
|
|
|
38
48
|
visible: true,
|
|
39
49
|
children: options.children || null,
|
|
40
50
|
close: options.close ?? true,
|
|
51
|
+
position: options.position ?? "top-right",
|
|
41
52
|
})),
|
|
42
53
|
hideToast: () => set(() => ({ visible: false })),
|
|
43
54
|
}));
|
package/src/toaster/toaster.css
CHANGED
|
@@ -11,6 +11,19 @@
|
|
|
11
11
|
width: 300px;
|
|
12
12
|
border-radius: 4px;
|
|
13
13
|
border: 1px solid #dede;
|
|
14
|
+
&.toaster--bottom-right,
|
|
15
|
+
&.toaster--bottom-center {
|
|
16
|
+
top: auto;
|
|
17
|
+
bottom: 0.5rem;
|
|
18
|
+
}
|
|
19
|
+
&.toaster--top-center,
|
|
20
|
+
&.toaster--bottom-center {
|
|
21
|
+
right: auto;
|
|
22
|
+
left: 50%;
|
|
23
|
+
transform: translateX(-50%);
|
|
24
|
+
max-width: calc(100vw - 1rem);
|
|
25
|
+
box-sizing: border-box;
|
|
26
|
+
}
|
|
14
27
|
.toaster--close {
|
|
15
28
|
position: absolute;
|
|
16
29
|
top: 2px;
|