pentatrion-design 0.0.1

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.
Files changed (208) hide show
  1. package/.storybook/main.ts +33 -0
  2. package/.storybook/manager.ts +8 -0
  3. package/.storybook/preview-head.html +2 -0
  4. package/.storybook/preview.ts +26 -0
  5. package/.storybook/public/bg-map.jpg +0 -0
  6. package/.storybook/public/favicon-32x32.png +0 -0
  7. package/.storybook/public/favicon.svg +28 -0
  8. package/.storybook/public/movies.json +2153 -0
  9. package/.storybook/public/population.json +1178 -0
  10. package/.storybook/public/town-74.geojson +8995 -0
  11. package/.storybook/public/town-74.json +4062 -0
  12. package/.storybook/theme.ts +14 -0
  13. package/Makefile +14 -0
  14. package/README.md +40 -0
  15. package/TODO.md +5 -0
  16. package/dist/index.d.ts +1110 -0
  17. package/dist/index.js +3707 -0
  18. package/dist/redux/index.d.ts +43 -0
  19. package/dist/redux/index.js +583 -0
  20. package/dist/types.d-DlHa_IaW.d.ts +14 -0
  21. package/images/logo-shadow.svg +173 -0
  22. package/images/logo.svg +76 -0
  23. package/package.json +85 -0
  24. package/postcss.config.js +7 -0
  25. package/src/components/autocomplete/Autocomplete.stories.tsx +89 -0
  26. package/src/components/autocomplete/Autocomplete.tsx +316 -0
  27. package/src/components/autocomplete/AutocompleteOption.tsx +35 -0
  28. package/src/components/autocomplete/LazyAutocomplete.tsx +130 -0
  29. package/src/components/autocomplete/SimpleAutocomplete.tsx +74 -0
  30. package/src/components/autocomplete/index.ts +6 -0
  31. package/src/components/autocomplete/useAutocompleteContext.ts +20 -0
  32. package/src/components/autocomplete/util.ts +19 -0
  33. package/src/components/badge/Badge.stories.tsx +72 -0
  34. package/src/components/badge/Badge.tsx +70 -0
  35. package/src/components/button/Button.stories.tsx +189 -0
  36. package/src/components/button/Button.test.tsx +20 -0
  37. package/src/components/button/Button.tsx +200 -0
  38. package/src/components/button/ButtonGroup.stories.tsx +46 -0
  39. package/src/components/button/ButtonGroup.tsx +29 -0
  40. package/src/components/button/index.ts +2 -0
  41. package/src/components/card/Card.stories.tsx +21 -0
  42. package/src/components/card/config.ts +4 -0
  43. package/src/components/card/index.ts +1 -0
  44. package/src/components/code/Code.tsx +15 -0
  45. package/src/components/context-menu/ContextMenu.stories.tsx +22 -0
  46. package/src/components/context-menu/ContextMenu.tsx +175 -0
  47. package/src/components/context-menu/ContextMenuItem.tsx +34 -0
  48. package/src/components/context-menu/index.ts +2 -0
  49. package/src/components/dialog/Dialog.stories.tsx +270 -0
  50. package/src/components/dialog/Dialog.tsx +46 -0
  51. package/src/components/dialog/index.ts +1 -0
  52. package/src/components/dialog/util.ts +29 -0
  53. package/src/components/dropdown-menu/DropdownMenu.stories.tsx +19 -0
  54. package/src/components/dropdown-menu/DropdownMenu.tsx +12 -0
  55. package/src/components/dropdown-menu/DropdownMenuContent.tsx +46 -0
  56. package/src/components/dropdown-menu/DropdownMenuItem.tsx +33 -0
  57. package/src/components/dropdown-menu/DropdownMenuTrigger.tsx +42 -0
  58. package/src/components/dropdown-menu/index.ts +7 -0
  59. package/src/components/dropdown-menu/interface.d.ts +13 -0
  60. package/src/components/dropdown-menu/useDropdownMenu.tsx +115 -0
  61. package/src/components/dropdown-menu/useDropdownMenuContext.ts +16 -0
  62. package/src/components/dropdown-menu-nested/DropdownMenuNested.stories.tsx +33 -0
  63. package/src/components/dropdown-menu-nested/DropdownMenuNested.tsx +19 -0
  64. package/src/components/dropdown-menu-nested/MenuContext.ts +15 -0
  65. package/src/components/dropdown-menu-nested/MenuItem.tsx +43 -0
  66. package/src/components/dropdown-menu-nested/MenuItemWithChildren.tsx +204 -0
  67. package/src/components/dropdown-menu-nested/index.ts +3 -0
  68. package/src/components/flash/Flash.stories.tsx +34 -0
  69. package/src/components/flash/Flash.tsx +24 -0
  70. package/src/components/highlight/Highlight.stories.tsx +128 -0
  71. package/src/components/highlight/Highlight.tsx +29 -0
  72. package/src/components/href/Href.stories.tsx +55 -0
  73. package/src/components/href/Href.tsx +18 -0
  74. package/src/components/input/Checkbox.stories.tsx +52 -0
  75. package/src/components/input/Checkbox.tsx +41 -0
  76. package/src/components/input/Input.stories.tsx +103 -0
  77. package/src/components/input/Input.test.tsx +10 -0
  78. package/src/components/input/Input.tsx +60 -0
  79. package/src/components/input/RadioGroup.stories.tsx +76 -0
  80. package/src/components/input/RadioGroup.tsx +84 -0
  81. package/src/components/input/Toggle.stories.tsx +29 -0
  82. package/src/components/input/Toggle.tsx +35 -0
  83. package/src/components/input/index.ts +4 -0
  84. package/src/components/input-field/InputField.stories.tsx +227 -0
  85. package/src/components/input-field/InputField.tsx +62 -0
  86. package/src/components/loader/Loader.stories.tsx +37 -0
  87. package/src/components/loader/Loader.tsx +54 -0
  88. package/src/components/modal/Components.tsx +58 -0
  89. package/src/components/modal/Modal.stories.tsx +113 -0
  90. package/src/components/modal/Modal.tsx +13 -0
  91. package/src/components/modal/ModalContent.tsx +46 -0
  92. package/src/components/modal/ModalTrigger.tsx +41 -0
  93. package/src/components/modal/index.ts +7 -0
  94. package/src/components/modal/interface.d.ts +10 -0
  95. package/src/components/modal/useModal.ts +48 -0
  96. package/src/components/modal/useModalContext.ts +16 -0
  97. package/src/components/notification/Notification.stories.tsx +51 -0
  98. package/src/components/notification/NotificationsContext.ts +79 -0
  99. package/src/components/notification/NotificationsProvider.tsx +58 -0
  100. package/src/components/notification/index.ts +2 -0
  101. package/src/components/popover/Components.tsx +45 -0
  102. package/src/components/popover/Popover.stories.tsx +46 -0
  103. package/src/components/popover/Popover.test.tsx +21 -0
  104. package/src/components/popover/Popover.tsx +12 -0
  105. package/src/components/popover/PopoverContent.tsx +46 -0
  106. package/src/components/popover/PopoverTrigger.tsx +42 -0
  107. package/src/components/popover/index.ts +7 -0
  108. package/src/components/popover/interface.d.ts +13 -0
  109. package/src/components/popover/usePopover.tsx +80 -0
  110. package/src/components/popover/usePopoverContext.ts +16 -0
  111. package/src/components/portal/Portal.tsx +12 -0
  112. package/src/components/quick-settings/QuickSettings.stories.tsx +182 -0
  113. package/src/components/resize-area/ResizeArea.stories.css +40 -0
  114. package/src/components/resize-area/ResizeArea.stories.tsx +30 -0
  115. package/src/components/resize-area/ResizeArea.tsx +79 -0
  116. package/src/components/scroll/Scroll.stories.tsx +81 -0
  117. package/src/components/scroll/Scroll.tsx +111 -0
  118. package/src/components/select/Select.stories.tsx +248 -0
  119. package/src/components/select/Select.tsx +362 -0
  120. package/src/components/select/SelectOption.tsx +29 -0
  121. package/src/components/select/SelectSelection.tsx +13 -0
  122. package/src/components/select/index.ts +5 -0
  123. package/src/components/select/interface.d.ts +36 -0
  124. package/src/components/select/useSelectContext.ts +19 -0
  125. package/src/components/select/util.ts +12 -0
  126. package/src/components/snack/Snack.stories.tsx +33 -0
  127. package/src/components/snack/Snack.tsx +47 -0
  128. package/src/components/sortable/Sortable.stories.tsx +98 -0
  129. package/src/components/sortable/Sortable.tsx +37 -0
  130. package/src/components/sortable/index.ts +2 -0
  131. package/src/components/sortable/types.d.ts +12 -0
  132. package/src/components/steps/Step.tsx +41 -0
  133. package/src/components/steps/Steps.stories.tsx +141 -0
  134. package/src/components/steps/Steps.tsx +49 -0
  135. package/src/components/steps/index.ts +3 -0
  136. package/src/components/steps/util.ts +3 -0
  137. package/src/components/table/Table.stories.tsx +36 -0
  138. package/src/components/table/Table.tsx +13 -0
  139. package/src/components/table/TableBody.tsx +9 -0
  140. package/src/components/table/TableCell.tsx +16 -0
  141. package/src/components/table/TableFooter.tsx +9 -0
  142. package/src/components/table/TableHeader.tsx +14 -0
  143. package/src/components/table/TableHeaderCell.tsx +14 -0
  144. package/src/components/table/TableRow.tsx +14 -0
  145. package/src/components/table/index.ts +7 -0
  146. package/src/components/tabs/Tabs.stories.tsx +66 -0
  147. package/src/components/tabs/Tabs.tsx +80 -0
  148. package/src/components/tooltip/SimpleTooltip.tsx +17 -0
  149. package/src/components/tooltip/Tooltip.stories.tsx +129 -0
  150. package/src/components/tooltip/Tooltip.test.tsx +18 -0
  151. package/src/components/tooltip/Tooltip.tsx +13 -0
  152. package/src/components/tooltip/TooltipContent.tsx +41 -0
  153. package/src/components/tooltip/TooltipTrigger.tsx +36 -0
  154. package/src/components/tooltip/index.ts +6 -0
  155. package/src/components/tooltip/interface.d.ts +15 -0
  156. package/src/components/tooltip/useTooltip.ts +87 -0
  157. package/src/components/tooltip/useTooltipContext.ts +16 -0
  158. package/src/env.d.ts +27 -0
  159. package/src/hooks/index.ts +13 -0
  160. package/src/hooks/useCombinedRefs.test.tsx +42 -0
  161. package/src/hooks/useCombinedRefs.ts +21 -0
  162. package/src/hooks/useCopyToClipboard.ts +28 -0
  163. package/src/hooks/useDebounce.ts +59 -0
  164. package/src/hooks/useEventCallback.ts +13 -0
  165. package/src/hooks/useEventListener.ts +86 -0
  166. package/src/hooks/useFetch.tsx +21 -0
  167. package/src/hooks/useIsClosing.ts +25 -0
  168. package/src/hooks/useIsMounted.tsx +16 -0
  169. package/src/hooks/useIsomorphicLayoutEffect.ts +4 -0
  170. package/src/hooks/useNotifications.tsx +13 -0
  171. package/src/hooks/useOnClickOutside.ts +35 -0
  172. package/src/hooks/usePrevious.ts +9 -0
  173. package/src/hooks/useRipple.test.tsx +52 -0
  174. package/src/hooks/useRipple.tsx +79 -0
  175. package/src/index.css +14 -0
  176. package/src/index.ts +39 -0
  177. package/src/lib/arrUtil.ts +8 -0
  178. package/src/lib/error.ts +18 -0
  179. package/src/lib/fetch.test.ts +107 -0
  180. package/src/lib/fetch.ts +115 -0
  181. package/src/lib/index.ts +3 -0
  182. package/src/lib/tailwindVariants.ts +35 -0
  183. package/src/redux/index.ts +1 -0
  184. package/src/redux/notification/components/NotificationConsumer.tsx +52 -0
  185. package/src/redux/notification/errorCatcherMiddleware.ts +17 -0
  186. package/src/redux/notification/hooks/useNotification.ts +26 -0
  187. package/src/redux/notification/index.ts +5 -0
  188. package/src/redux/notification/notificationSlice.ts +68 -0
  189. package/src/styles/Animation.stories.tsx +43 -0
  190. package/src/styles/Shadow.stories.tsx +43 -0
  191. package/src/styles/Themes.stories.tsx +31 -0
  192. package/src/styles/Typography.stories.tsx +101 -0
  193. package/src/tailwind/base.css +188 -0
  194. package/src/tailwind/components-input-outline.css +62 -0
  195. package/src/tailwind/components-resize-area.css +112 -0
  196. package/src/tailwind/components-step.css +161 -0
  197. package/src/tailwind/components.css +51 -0
  198. package/src/tailwind/keyframes.ts +69 -0
  199. package/src/tailwind/pentatrionTw.ts +147 -0
  200. package/src/tailwind/utilities-dialog.css +103 -0
  201. package/src/tailwind/utilities.css +3 -0
  202. package/src/types.d.ts +12 -0
  203. package/tailwind.config.js +18 -0
  204. package/tests/README.md +32 -0
  205. package/tests/setup.ts +1 -0
  206. package/tsconfig.json +14 -0
  207. package/tsup.config.ts +23 -0
  208. package/vite.config.ts +24 -0
@@ -0,0 +1,115 @@
1
+ export type CustomFetchOptions = Omit<RequestInit, "body"> & {
2
+ body?: BodyInit | { [key: string]: unknown };
3
+ urlParams?: {
4
+ [key: string]: string | number;
5
+ };
6
+ query?: {
7
+ [key: string]: unknown;
8
+ };
9
+ };
10
+
11
+ export async function fetchAPI(
12
+ urlObjOrString: string | URL,
13
+ enhancedOptions: CustomFetchOptions = {},
14
+ baseUrl?: string,
15
+ baseOptions?: RequestInit,
16
+ ) {
17
+ const { urlParams, query, body, ...rest } = enhancedOptions;
18
+
19
+ let options: RequestInit = rest;
20
+
21
+ let url: URL;
22
+
23
+ if (urlObjOrString instanceof URL) {
24
+ url = urlObjOrString;
25
+ } else {
26
+ const origin = baseUrl ? new URL(baseUrl).origin : window.location.origin;
27
+ let prefix = baseUrl ? new URL(baseUrl).pathname : "";
28
+ if (prefix === "/") {
29
+ prefix = "";
30
+ }
31
+ url = new URL(`${prefix}${urlObjOrString}`, origin);
32
+ }
33
+
34
+ if (urlParams) {
35
+ for (const [name, value] of Object.entries(urlParams)) {
36
+ // %7B -> `{`
37
+ // %7D -> `}`
38
+ url.pathname = url.pathname.replace(`%7B${name}%7D`, value.toString());
39
+ }
40
+ }
41
+
42
+ if (query) {
43
+ for (const [name, value] of Object.entries(query)) {
44
+ url.searchParams.set(
45
+ name,
46
+ typeof value === "object" ? JSON.stringify(value) : (value as any).toString(),
47
+ );
48
+ }
49
+ }
50
+
51
+ if (body && typeof body !== "string" && !(body instanceof FormData)) {
52
+ options.headers = {
53
+ ...(options.headers = {}),
54
+ "Content-Type": "application/json",
55
+ };
56
+ options.body = JSON.stringify(body);
57
+ }
58
+
59
+ if (baseOptions) {
60
+ const { headers: baseHeaders = {}, ...baseRest } = baseOptions;
61
+ options = {
62
+ ...baseRest,
63
+ ...options,
64
+ headers: {
65
+ ...baseHeaders,
66
+ ...options.headers,
67
+ },
68
+ };
69
+ }
70
+
71
+ const response = await fetch(url.toString(), options);
72
+
73
+ if (response.status === 204) {
74
+ return null;
75
+ }
76
+
77
+ const contentType = response.headers.get("content-type");
78
+
79
+ if (contentType?.includes("application/json") || contentType?.includes("application/geo+json")) {
80
+ const dataJson = await response.json();
81
+
82
+ if (response.ok) {
83
+ return dataJson;
84
+ }
85
+
86
+ let errorMessage = "request Error";
87
+
88
+ if (dataJson.message) {
89
+ errorMessage = dataJson.message;
90
+ }
91
+ if (dataJson.error?.message) {
92
+ errorMessage = dataJson.error?.message;
93
+ }
94
+ throw new FetchError(errorMessage, response.status, dataJson);
95
+ }
96
+
97
+ const dataText = await response.text();
98
+
99
+ if (response.ok) {
100
+ return dataText;
101
+ }
102
+
103
+ throw new FetchError(`${response.status} ${response.statusText}`, response.status, dataText);
104
+ }
105
+
106
+ export class FetchError extends Error {
107
+ constructor(
108
+ message: string,
109
+ public status: number,
110
+ public data?: unknown,
111
+ ) {
112
+ super(message);
113
+ this.name = "FetchError";
114
+ }
115
+ }
@@ -0,0 +1,3 @@
1
+ export * from "./arrUtil";
2
+ export * from "./fetch";
3
+ export * from "./error";
@@ -0,0 +1,35 @@
1
+ import { ThemeColor } from "../types.d";
2
+
3
+ type Variant = {
4
+ border: string;
5
+ text: string;
6
+ };
7
+
8
+ export const colorVariants: {
9
+ [key in ThemeColor]: Variant;
10
+ } = {
11
+ yellow: {
12
+ border: "border-yellow-3",
13
+ text: "text-yellow-4",
14
+ },
15
+ gray: {
16
+ border: "border-gray-3",
17
+ text: "text-gray-4",
18
+ },
19
+ red: {
20
+ border: "border-red-3",
21
+ text: "text-red-4",
22
+ },
23
+ orange: {
24
+ border: "border-orange-3",
25
+ text: "text-orange-4",
26
+ },
27
+ green: {
28
+ border: "border-green-3",
29
+ text: "text-green-4",
30
+ },
31
+ blue: {
32
+ border: "border-blue-3",
33
+ text: "text-blue-4",
34
+ },
35
+ };
@@ -0,0 +1 @@
1
+ export * from "./notification";
@@ -0,0 +1,52 @@
1
+ import { ReactNode, useEffect, useRef } from "react";
2
+ import { createPortal } from "react-dom";
3
+ import { useDispatch, useSelector } from "react-redux";
4
+ import { messageRemoved, selectMessages } from "../notificationSlice";
5
+ import { nanoid } from "@reduxjs/toolkit";
6
+ import Snack from "~/components/snack/Snack";
7
+ import { Message } from "~/types.d";
8
+
9
+ interface Props {
10
+ children: ReactNode;
11
+ }
12
+
13
+ export default function NotificationConsumer({ children }: Props) {
14
+ const container = useRef<HTMLDivElement>(null!);
15
+ if (!container.current) {
16
+ container.current = document.createElement("div");
17
+ container.current.id = nanoid();
18
+ container.current.classList.add("ll-snack-bar");
19
+ document.body.append(container.current);
20
+ }
21
+
22
+ if (!container.current.parentElement) {
23
+ console.log("NotificationConsumer n'a pas de parent !!", container);
24
+ document.body.append(container.current);
25
+ }
26
+
27
+ useEffect(() => {
28
+ return () => {
29
+ container.current && container.current.remove();
30
+ };
31
+ }, []);
32
+
33
+ const messages = useSelector(selectMessages) as Message[];
34
+ const dispatch = useDispatch();
35
+ return (
36
+ <>
37
+ {children}
38
+ {createPortal(
39
+ <div className="snack-bar-inner">
40
+ {messages.map((message) => (
41
+ <Snack
42
+ key={message.id}
43
+ {...message}
44
+ onRemove={() => dispatch(messageRemoved(message.id))}
45
+ />
46
+ ))}
47
+ </div>,
48
+ container.current,
49
+ )}
50
+ </>
51
+ );
52
+ }
@@ -0,0 +1,17 @@
1
+ import { Action, Middleware } from "@reduxjs/toolkit";
2
+ import { messageAdded } from "./notificationSlice";
3
+ import { parseError } from "~/lib";
4
+
5
+ export const errorCatcherMiddleware: Middleware =
6
+ ({ dispatch }) =>
7
+ (next) =>
8
+ async (action) => {
9
+ if (typeof action !== "function" && (action as Action).type.endsWith("/rejected")) {
10
+ const errorMessage = parseError((action as any).error || {});
11
+ if (errorMessage) {
12
+ dispatch(messageAdded(...errorMessage));
13
+ }
14
+ }
15
+
16
+ return next(action);
17
+ };
@@ -0,0 +1,26 @@
1
+ import { parseError } from "~/lib";
2
+ import { MessageOptions } from "~/types.d";
3
+
4
+ import { messageAdded } from "../notificationSlice";
5
+ import { useDispatch } from "react-redux";
6
+
7
+ export default function useNotification() {
8
+ const dispatch = useDispatch();
9
+
10
+ const notify = (content: string, options?: MessageOptions) => {
11
+ dispatch(messageAdded(content, options));
12
+ };
13
+
14
+ const notifyError = (err: unknown) => {
15
+ const errorMessage = parseError(err);
16
+ if (errorMessage) {
17
+ dispatch(messageAdded(...errorMessage));
18
+ } else {
19
+ throw err;
20
+ }
21
+ };
22
+ return {
23
+ notify,
24
+ notifyError,
25
+ };
26
+ }
@@ -0,0 +1,5 @@
1
+ export * from "./notificationSlice";
2
+ export { default as notificationSlice } from "./notificationSlice";
3
+ export * from "./errorCatcherMiddleware";
4
+ export { default as NotificationConsumer } from "./components/NotificationConsumer";
5
+ export { default as useNotification } from "./hooks/useNotification";
@@ -0,0 +1,68 @@
1
+ import { createSlice, nanoid, PayloadAction } from "@reduxjs/toolkit";
2
+ import { parseError } from "~/lib";
3
+ import { Message, MessageOptions } from "~/types.d";
4
+
5
+ type NotificationState = {
6
+ messages: Message[];
7
+ };
8
+
9
+ const initialState: NotificationState = {
10
+ messages: [],
11
+ };
12
+
13
+ const notificationSlice = createSlice({
14
+ name: "notification",
15
+ initialState,
16
+ reducers: {
17
+ errorAdded: {
18
+ reducer(state, action: PayloadAction<Message>) {
19
+ state.messages.push(action.payload);
20
+ },
21
+ prepare(err: any) {
22
+ const errorMessage = parseError(err);
23
+ if (errorMessage) {
24
+ const [content, options] = errorMessage;
25
+ const {
26
+ expiration = 5000,
27
+ color = "red",
28
+ canClose = true,
29
+ withLoader = false,
30
+ } = options || {};
31
+ const id = nanoid();
32
+ return {
33
+ payload: { id, content, expiration, color, canClose, withLoader },
34
+ };
35
+ } else {
36
+ throw err;
37
+ }
38
+ },
39
+ },
40
+ messageAdded: {
41
+ reducer(state, action: PayloadAction<Message>) {
42
+ state.messages.push(action.payload);
43
+ },
44
+ prepare(content: string, options?: MessageOptions) {
45
+ const {
46
+ expiration = 5000,
47
+ color = "yellow",
48
+ canClose = true,
49
+ withLoader = false,
50
+ } = options || {};
51
+ const id = nanoid();
52
+ return {
53
+ payload: { id, content, expiration, color, canClose, withLoader },
54
+ };
55
+ },
56
+ },
57
+ messageRemoved(state, action: PayloadAction<string>) {
58
+ const messageId = action.payload;
59
+ state.messages = state.messages.filter((m) => m.id !== messageId);
60
+ },
61
+ },
62
+ });
63
+
64
+ export default notificationSlice.reducer;
65
+
66
+ export const { messageAdded, messageRemoved, errorAdded } = notificationSlice.actions;
67
+
68
+ export const selectMessages: (state: any) => Message[] = (state) => state.notification.messages;
@@ -0,0 +1,43 @@
1
+ import { useState } from "react";
2
+ import { Button, useIsClosing } from "..";
3
+ import clsx from "clsx";
4
+
5
+ export default {
6
+ title: "Styles/Animation",
7
+ };
8
+
9
+ export const Basic = () => {
10
+ const [isOpen, setIsOpen] = useState(false);
11
+
12
+ return (
13
+ <div>
14
+ <div>
15
+ <Button onClick={() => setIsOpen((v) => !v)}>{isOpen ? "Masquer" : "Afficher"}</Button>
16
+ </div>
17
+ {isOpen && (
18
+ <div className="shadow-xl w-[300px] h-[300px] animate-fade-in origin-top-left flex-center">
19
+ Modal
20
+ </div>
21
+ )}
22
+ </div>
23
+ );
24
+ };
25
+
26
+ export const InOut = () => {
27
+ const { isOpen, isClosing, setIsOpen } = useIsClosing(false);
28
+ const classNames = clsx([
29
+ "shadow-xl w-[300px] h-[300px]",
30
+ "origin-top-left",
31
+ "flex-center",
32
+ isClosing ? "animate-fade-out" : "animate-fade-in",
33
+ ]);
34
+
35
+ return (
36
+ <div>
37
+ <div>
38
+ <Button onClick={() => setIsOpen(!isOpen)}>{isOpen ? "Masquer" : "Afficher"}</Button>
39
+ </div>
40
+ {isOpen && <div className={classNames}>Modal</div>}
41
+ </div>
42
+ );
43
+ };
@@ -0,0 +1,43 @@
1
+ import Code from "../components/code/Code";
2
+
3
+ export default {
4
+ title: "Styles",
5
+ };
6
+
7
+ export const Shadow = () => {
8
+ const shadows = [
9
+ "shadow-sm",
10
+ "shadow",
11
+ "shadow-md",
12
+ "shadow-lg",
13
+ "shadow-xl",
14
+ "shadow-2xl",
15
+ "shadow-inner",
16
+ ];
17
+
18
+ return (
19
+ <div
20
+ style={{
21
+ display: "grid",
22
+ gap: "2rem",
23
+ marginBottom: "2rem",
24
+ gridTemplateColumns: "repeat(auto-fit, minmax(100px, 1fr))",
25
+ }}
26
+ >
27
+ {shadows.map((s) => (
28
+ <div
29
+ key={s}
30
+ className={`${s} dark:shadow-dark`}
31
+ style={{
32
+ height: "200px",
33
+ display: "flex",
34
+ justifyContent: "center",
35
+ alignItems: "center",
36
+ }}
37
+ >
38
+ <Code className="text-xs">.{s}</Code>
39
+ </div>
40
+ ))}
41
+ </div>
42
+ );
43
+ };
@@ -0,0 +1,31 @@
1
+ export default {
2
+ title: "Styles/Themes",
3
+ };
4
+
5
+ export const TextColors = () => {
6
+ const colors = ["gray", "yellow", "green", "blue", "orange", "red"];
7
+
8
+ return (
9
+ <div className="grid mt-4 grid-cols-[repeat(auto-fit,minmax(8rem,1fr))] sm:grid-cols-1 gap-8">
10
+ {colors.map((color) => (
11
+ <div key={color}>
12
+ <div className="text-sm font-semibold">{color}</div>
13
+ <div className="grid mt-2 grid-cols-1 sm:grid-cols-5 gap-2">
14
+ {[1, 2, 3, 4, 5].map((variant) => (
15
+ <div className="">
16
+ <div
17
+ className="h-10 w-10 sm:w-full rounded"
18
+ style={{ backgroundColor: `rgb(var(--color-${color}-${variant}))` }}
19
+ ></div>
20
+ <div className="px-0.5">
21
+ <div className="w-6 font-medium text-xs">{variant}</div>
22
+ <div className="text-xs font-mono">{`--color-${color}-${variant}`}</div>
23
+ </div>
24
+ </div>
25
+ ))}
26
+ </div>
27
+ </div>
28
+ ))}
29
+ </div>
30
+ );
31
+ };
@@ -0,0 +1,101 @@
1
+ import Href from "../components/href/Href";
2
+ import Code from "../components/code/Code";
3
+ import {
4
+ Table,
5
+ TableBody,
6
+ TableCell,
7
+ TableHeader,
8
+ TableHeaderCell,
9
+ TableRow,
10
+ } from "../components/table";
11
+
12
+ export default {
13
+ title: "Styles/Typography",
14
+ };
15
+
16
+ type HeaderTag = "h1" | "h2" | "h3" | "h4" | "h5" | "h6";
17
+
18
+ export const Headers = () => (
19
+ <Table>
20
+ <TableHeader>
21
+ <TableRow>
22
+ <TableHeaderCell>Usage</TableHeaderCell>
23
+ <TableHeaderCell>Example</TableHeaderCell>
24
+ </TableRow>
25
+ </TableHeader>
26
+ <TableBody>
27
+ {[1, 2, 3, 4, 5, 6].map((level) => {
28
+ const HeaderTag = `h${level}` as HeaderTag;
29
+ return (
30
+ <TableRow key={level}>
31
+ <TableCell label="Usage">
32
+ <Code>{`h${level}`}</Code>
33
+ </TableCell>
34
+ <TableCell label="Example">
35
+ <HeaderTag>Lorem ipsum</HeaderTag>
36
+ </TableCell>
37
+ </TableRow>
38
+ );
39
+ })}
40
+ </TableBody>
41
+ </Table>
42
+ );
43
+
44
+ export const TextSizes = () => (
45
+ <Table>
46
+ <TableHeader>
47
+ <TableRow>
48
+ <TableHeaderCell>Usage</TableHeaderCell>
49
+ <TableHeaderCell>Example</TableHeaderCell>
50
+ </TableRow>
51
+ </TableHeader>
52
+ <TableBody>
53
+ {[
54
+ "text-5xl",
55
+ "text-4xl",
56
+ "text-3xl",
57
+ "text-2xl",
58
+ "text-xl",
59
+ "text-lg",
60
+ "text-base",
61
+ "text-sm",
62
+ "text-xs",
63
+ ].map((sizeClass) => {
64
+ return (
65
+ <TableRow key={sizeClass}>
66
+ <TableCell label="Usage">
67
+ <Code>{`.${sizeClass}`}</Code>
68
+ </TableCell>
69
+ <TableCell label="Example">
70
+ <span className={sizeClass}>Lorem ipsum</span>
71
+ </TableCell>
72
+ </TableRow>
73
+ );
74
+ })}
75
+ </TableBody>
76
+ </Table>
77
+ );
78
+
79
+ export const Content = () => (
80
+ <div>
81
+ <p>
82
+ Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has
83
+ been the industry's standard <a href="#">dummy text</a> ever since the 1500s, when an unknown
84
+ printer took a galley of type and scrambled it to make a type specimen book. It has survived.
85
+ Visit the Lonlat website, not only five centuries, but also the leap into electronic
86
+ typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release
87
+ of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing
88
+ software like Aldus PageMaker including versions of Lorem Ipsum.
89
+ </p>
90
+ <p>
91
+ There is a{" "}
92
+ <Href ghost={true} href="#">
93
+ ghost
94
+ </Href>{" "}
95
+ link.
96
+ </p>
97
+ <p>
98
+ Click <span className="can-copy">HERE</span> to copy to clipboard
99
+ </p>
100
+ </div>
101
+ );