pentatrion-design 0.0.10 → 0.0.12

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/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## 0.0.12
2
+ fix notificationsConsumer pointer event none
3
+
4
+ ## 0.0.11
5
+
6
+ add input/button color
7
+ fix notificationsProvider pointer event none
8
+
1
9
  ## 0.0.10
2
10
 
3
11
  add textarea
@@ -0,0 +1,18 @@
1
+ import { Meta } from "@storybook/react";
2
+ import { Color } from "./Color";
3
+
4
+ const meta = {
5
+ title: "Components/Input/Color",
6
+ component: Color,
7
+ } satisfies Meta<typeof Color>;
8
+ export default meta;
9
+
10
+ export const Basic = () => {
11
+ return (
12
+ <div className="flex flex-col items-start gap-2">
13
+ <Color value="#fecdba" />
14
+ <Color value="#fecdba" label="300" />
15
+ <Color value="#fecdba" showValue={true} />
16
+ </div>
17
+ );
18
+ };
@@ -0,0 +1,61 @@
1
+ import { ComponentProps, forwardRef, useImperativeHandle, useRef } from "react";
2
+ import type { ThemeColor } from "../../types.d";
3
+ import clsx from "clsx";
4
+ import { useRipple } from "../../hooks";
5
+
6
+ export interface ColorProps extends ComponentProps<"button"> {
7
+ withRipple?: boolean;
8
+
9
+ value?: string;
10
+ color?: ThemeColor;
11
+ label?: string;
12
+ showValue?: boolean;
13
+ className?: string;
14
+ }
15
+
16
+ export const Color = forwardRef<HTMLButtonElement, ColorProps>(
17
+ (
18
+ {
19
+ value,
20
+ withRipple = true,
21
+ color = "yellow",
22
+ label,
23
+ showValue = false,
24
+ className,
25
+ ...rest
26
+ },
27
+ ref,
28
+ ) => {
29
+ const valueToShow = label ?? (showValue ? value : null);
30
+
31
+ const buttonRef = useRef<HTMLButtonElement>(null);
32
+
33
+ useImperativeHandle<HTMLButtonElement | null, HTMLButtonElement | null>(
34
+ ref,
35
+ () => buttonRef.current,
36
+ );
37
+
38
+ const ripples = useRipple(buttonRef);
39
+
40
+ return (
41
+ <button
42
+ ref={buttonRef}
43
+ data-color={color}
44
+ className="p8n-input-text relative flex h-8 overflow-clip rounded-2xl p-1 outline-offset-[-1px]"
45
+ {...rest}
46
+ >
47
+ {withRipple && ripples}
48
+ <span
49
+ className={clsx(
50
+ "flex items-center justify-center rounded-2xl px-2",
51
+ valueToShow === null && "min-w-12",
52
+ className,
53
+ )}
54
+ style={{ backgroundColor: value }}
55
+ >
56
+ {valueToShow}
57
+ </span>
58
+ </button>
59
+ );
60
+ },
61
+ );
@@ -3,3 +3,4 @@ export { Checkbox } from "./Checkbox";
3
3
  export { RadioGroup, Radio } from "./RadioGroup";
4
4
  export { Toggle } from "./Toggle";
5
5
  export { Range } from "./Range";
6
+ export { Color } from "./Color";
@@ -46,6 +46,11 @@ export const Context = () => {
46
46
  <Button onClick={handleClick}>Show info notification</Button>
47
47
  <Button onClick={throwError}>Throw custom error</Button>
48
48
  <Button onClick={handle404Error}>Throw 404 fetch error</Button>
49
+ <div className="mt-96">
50
+ <a href="#" className="link">
51
+ link
52
+ </a>
53
+ </div>
49
54
  </div>
50
55
  );
51
56
  };
@@ -25,6 +25,7 @@ export function NotificationsProvider({ children }: Props) {
25
25
  "left-0",
26
26
  "right-0",
27
27
  "z-notification",
28
+ "pointer-events-none",
28
29
  );
29
30
  document.body.append(container.current);
30
31
  }
@@ -32,7 +32,10 @@ export function Snack({
32
32
 
33
33
  return (
34
34
  <Dialog
35
- className={clsx("motion-safe:animate-fade-in", "ll-snack")}
35
+ className={clsx(
36
+ "pointer-events-auto motion-safe:animate-fade-in",
37
+ "ll-snack",
38
+ )}
36
39
  placement="top"
37
40
  color={color}
38
41
  >
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pentatrion-design",
3
- "version": "0.0.10",
3
+ "version": "0.0.12",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "author": "Hugues Tavernier",
@@ -15,7 +15,14 @@ export function NotificationConsumer({ children }: Props) {
15
15
  if (!container.current) {
16
16
  container.current = document.createElement("div");
17
17
  container.current.id = nanoid();
18
- container.current.classList.add("fixed", "bottom-0", "left-0", "right-0", "z-notification");
18
+ container.current.classList.add(
19
+ "fixed",
20
+ "bottom-0",
21
+ "left-0",
22
+ "right-0",
23
+ "z-notification",
24
+ "pointer-events-none",
25
+ );
19
26
  document.body.append(container.current);
20
27
  }
21
28
 
@@ -36,7 +43,7 @@ export function NotificationConsumer({ children }: Props) {
36
43
  <>
37
44
  {children}
38
45
  {createPortal(
39
- <div className="mb-4 flex flex-col gap-4 items-center">
46
+ <div className="mb-4 flex flex-col items-center gap-4">
40
47
  {messages.map((message) => (
41
48
  <Snack
42
49
  key={message.id}
@@ -1,73 +0,0 @@
1
- import { ReactNode, useEffect, useRef, useState } from "react";
2
- import { createPortal } from "react-dom";
3
- import {
4
- NotificationsContext,
5
- createNotificationsManager,
6
- type NotificationsManager,
7
- } from "./NotificationsContext";
8
- import { Snack } from "../snack";
9
- import { Message } from "../../types.d";
10
-
11
- interface Props {
12
- children: ReactNode;
13
- }
14
-
15
- export function NotificationsProvider({ children }: Props) {
16
- const [notifications, setNotifications] = useState<Message[]>([]);
17
- const container = useRef<HTMLDivElement>(null!);
18
- const [isMounted, setIsMounted] = useState(false);
19
-
20
- useEffect(() => {
21
- if (!container.current) {
22
- container.current = document.createElement("div");
23
- container.current.id = Math.floor(Math.random() * 100000).toString();
24
- /* .ll-snack-bar */
25
- container.current.classList.add(
26
- "fixed",
27
- "bottom-0",
28
- "left-0",
29
- "right-0",
30
- "z-notification",
31
- );
32
- document.body.append(container.current);
33
- }
34
- setIsMounted(true);
35
- return () => {
36
- container.current && container.current.remove();
37
- };
38
- }, []);
39
-
40
- const managerRef = useRef<NotificationsManager>();
41
-
42
- if (typeof window === "undefined") {
43
- return null;
44
- }
45
-
46
- if (!managerRef.current) {
47
- managerRef.current = createNotificationsManager(setNotifications);
48
- }
49
-
50
- const manager = managerRef.current;
51
-
52
- return (
53
- <>
54
- <NotificationsContext.Provider value={manager}>
55
- {children}
56
- </NotificationsContext.Provider>
57
- {isMounted &&
58
- createPortal(
59
- /* snack-bar-inner */
60
- <div className="mx-4 mb-4 flex flex-col items-center gap-4">
61
- {notifications.map((props) => (
62
- <Snack
63
- {...props}
64
- key={props.id}
65
- onRemove={() => manager.removeNotification(props.id)}
66
- />
67
- ))}
68
- </div>,
69
- container.current,
70
- )}
71
- </>
72
- );
73
- }