@valbuild/ui 0.26.0 → 0.28.0

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 (145) hide show
  1. package/dist/valbuild-ui.cjs.js +41 -15
  2. package/dist/valbuild-ui.esm.js +41 -15
  3. package/package.json +7 -3
  4. package/server/.tmp/assets/index-18cfa26c.css +1 -0
  5. package/server/.tmp/assets/index-513f7a9c.js +197 -0
  6. package/{index.html → server/.tmp/index.html} +3 -1
  7. package/server/dist/style.css +0 -3
  8. package/server/dist/valbuild-ui-main.cjs.js +60 -34
  9. package/server/dist/valbuild-ui-main.esm.js +60 -34
  10. package/server/dist/valbuild-ui-server.cjs.js +1 -1
  11. package/server/dist/valbuild-ui-server.esm.js +1 -1
  12. package/.babelrc.json +0 -10
  13. package/.storybook/main.js +0 -25
  14. package/.storybook/preview-head.html +0 -6
  15. package/.storybook/preview.js +0 -33
  16. package/.storybook/theme.css +0 -34
  17. package/CHANGELOG.md +0 -0
  18. package/components.json +0 -16
  19. package/fix-server-hack.js +0 -54
  20. package/fullscreen.vite.config.ts +0 -9
  21. package/jest.config.js +0 -4
  22. package/postcss.config.js +0 -6
  23. package/rollup.config.js +0 -23
  24. package/server.vite.config.ts +0 -31
  25. package/src/App.tsx +0 -73
  26. package/src/assets/icons/Bold.tsx +0 -23
  27. package/src/assets/icons/Chevron.tsx +0 -28
  28. package/src/assets/icons/FontColor.tsx +0 -30
  29. package/src/assets/icons/ImageIcon.tsx +0 -29
  30. package/src/assets/icons/Italic.tsx +0 -24
  31. package/src/assets/icons/Logo.tsx +0 -103
  32. package/src/assets/icons/Section.tsx +0 -41
  33. package/src/assets/icons/Strikethrough.tsx +0 -22
  34. package/src/assets/icons/TextIcon.tsx +0 -20
  35. package/src/assets/icons/Underline.tsx +0 -22
  36. package/src/assets/icons/Undo.tsx +0 -20
  37. package/src/components/Button.tsx +0 -68
  38. package/src/components/Checkbox.tsx +0 -51
  39. package/src/components/DraggableList.stories.tsx +0 -20
  40. package/src/components/DraggableList.tsx +0 -95
  41. package/src/components/Dropdown.tsx +0 -101
  42. package/src/components/EditButton.tsx +0 -10
  43. package/src/components/ErrorText.tsx +0 -3
  44. package/src/components/ExpandLogo.tsx +0 -72
  45. package/src/components/Grid.stories.tsx +0 -43
  46. package/src/components/Grid.tsx +0 -139
  47. package/src/components/RichTextEditor/ContentEditable.tsx +0 -117
  48. package/src/components/RichTextEditor/Nodes/ImageNode.tsx +0 -100
  49. package/src/components/RichTextEditor/Plugins/AutoFocus.tsx +0 -12
  50. package/src/components/RichTextEditor/Plugins/ImagePlugin.tsx +0 -45
  51. package/src/components/RichTextEditor/Plugins/LinkEditorPlugin.tsx +0 -58
  52. package/src/components/RichTextEditor/Plugins/Toolbar.tsx +0 -412
  53. package/src/components/RichTextEditor/RichTextEditor.tsx +0 -105
  54. package/src/components/UploadModal.tsx +0 -109
  55. package/src/components/User.tsx +0 -17
  56. package/src/components/ValFormField.tsx +0 -574
  57. package/src/components/ValFullscreen.tsx +0 -1278
  58. package/src/components/ValMenu.tsx +0 -92
  59. package/src/components/ValOverlay.tsx +0 -488
  60. package/src/components/ValOverlayContext.tsx +0 -80
  61. package/src/components/ValWindow.stories.tsx +0 -146
  62. package/src/components/ValWindow.tsx +0 -220
  63. package/src/components/dashboard/DashboardButton.tsx +0 -25
  64. package/src/components/dashboard/DashboardDropdown.tsx +0 -59
  65. package/src/components/dashboard/Dropdown.stories.tsx +0 -11
  66. package/src/components/dashboard/Dropdown.tsx +0 -70
  67. package/src/components/dashboard/FormGroup.stories.tsx +0 -37
  68. package/src/components/dashboard/FormGroup.tsx +0 -42
  69. package/src/components/dashboard/Grid2.stories.tsx +0 -56
  70. package/src/components/dashboard/Grid2.tsx +0 -72
  71. package/src/components/dashboard/Tree.stories.tsx +0 -91
  72. package/src/components/dashboard/Tree.tsx +0 -72
  73. package/src/components/dashboard/ValDashboardEditor.tsx +0 -269
  74. package/src/components/dashboard/ValDashboardGrid.tsx +0 -142
  75. package/src/components/dashboard/ValTreeNavigator.tsx +0 -253
  76. package/src/components/forms/Form.tsx +0 -126
  77. package/src/components/forms/FormContainer.tsx +0 -24
  78. package/src/components/forms/ImageForm.tsx +0 -195
  79. package/src/components/forms/TextArea.tsx +0 -24
  80. package/src/components/ui/accordion.tsx +0 -58
  81. package/src/components/ui/alert-dialog.tsx +0 -139
  82. package/src/components/ui/avatar.tsx +0 -48
  83. package/src/components/ui/button.tsx +0 -56
  84. package/src/components/ui/calendar.tsx +0 -62
  85. package/src/components/ui/card.tsx +0 -86
  86. package/src/components/ui/checkbox.tsx +0 -28
  87. package/src/components/ui/command.tsx +0 -153
  88. package/src/components/ui/dialog.tsx +0 -120
  89. package/src/components/ui/dropdown-menu.tsx +0 -198
  90. package/src/components/ui/form.tsx +0 -177
  91. package/src/components/ui/input.tsx +0 -24
  92. package/src/components/ui/label.tsx +0 -24
  93. package/src/components/ui/popover.tsx +0 -29
  94. package/src/components/ui/progress.tsx +0 -26
  95. package/src/components/ui/radio-group.tsx +0 -42
  96. package/src/components/ui/scroll-area.tsx +0 -51
  97. package/src/components/ui/select.tsx +0 -119
  98. package/src/components/ui/switch.tsx +0 -27
  99. package/src/components/ui/tabs.tsx +0 -53
  100. package/src/components/ui/toggle.tsx +0 -43
  101. package/src/components/ui/tooltip.tsx +0 -28
  102. package/src/components/usePatch.ts +0 -86
  103. package/src/components/useTheme.ts +0 -45
  104. package/src/dto/SerializedSchema.ts +0 -69
  105. package/src/dto/Session.ts +0 -12
  106. package/src/dto/SessionMode.ts +0 -5
  107. package/src/dto/Tree.ts +0 -18
  108. package/src/exports.ts +0 -6
  109. package/src/index.css +0 -115
  110. package/src/index.tsx +0 -14
  111. package/src/lib/IValStore.ts +0 -6
  112. package/src/lib/utils.ts +0 -6
  113. package/src/main.jsx +0 -10
  114. package/src/richtext/conversion/conversion.test.ts +0 -146
  115. package/src/richtext/conversion/lexicalToRichTextSource.test.ts +0 -89
  116. package/src/richtext/conversion/lexicalToRichTextSource.ts +0 -285
  117. package/src/richtext/conversion/parseRichTextSource.test.ts +0 -469
  118. package/src/richtext/conversion/parseRichTextSource.ts +0 -233
  119. package/src/richtext/conversion/richTextSourceToLexical.test.ts +0 -381
  120. package/src/richtext/conversion/richTextSourceToLexical.ts +0 -293
  121. package/src/richtext/shadowRootPolyFill.js +0 -115
  122. package/src/server.ts +0 -70
  123. package/src/stories/Button.stories.tsx +0 -20
  124. package/src/stories/Checkbox.stories.tsx +0 -14
  125. package/src/stories/Dropdown.stories.tsx +0 -23
  126. package/src/stories/Introduction.mdx +0 -221
  127. package/src/stories/RichTextEditor.stories.tsx +0 -24
  128. package/src/stories/assets/code-brackets.svg +0 -1
  129. package/src/stories/assets/colors.svg +0 -1
  130. package/src/stories/assets/comments.svg +0 -1
  131. package/src/stories/assets/direction.svg +0 -1
  132. package/src/stories/assets/flow.svg +0 -1
  133. package/src/stories/assets/plugin.svg +0 -1
  134. package/src/stories/assets/repo.svg +0 -1
  135. package/src/stories/assets/stackalt.svg +0 -1
  136. package/src/utils/Remote.ts +0 -15
  137. package/src/utils/imageMimeType.ts +0 -23
  138. package/src/utils/readImage.ts +0 -54
  139. package/src/utils/resolvePath.ts +0 -32
  140. package/src/vite-env.d.ts +0 -1
  141. package/src/vite-index.tsx +0 -7
  142. package/src/vite-server.ts +0 -42
  143. package/tailwind.config.js +0 -83
  144. package/tsconfig.json +0 -19
  145. package/vite.config.ts +0 -43
@@ -1,20 +0,0 @@
1
- import { FC } from "react";
2
-
3
- const TextIcon: FC<{ className?: string }> = ({ className }) => {
4
- return (
5
- <svg
6
- width="9"
7
- height="10"
8
- viewBox="0 0 9 10"
9
- fill="currentColor"
10
- xmlns="http://www.w3.org/2000/svg"
11
- className={className}
12
- >
13
- <g clipPath="url(#clip0_1229_1625)">
14
- <path d="M0.0145513 0.5H8.98545L9 3.18569H8.57074C8.43007 2.2276 8.02749 1.57948 7.36298 1.24133C6.98949 1.05491 6.43169 0.953035 5.68957 0.935694V7.94581C5.68957 8.43569 5.78416 8.76084 5.97332 8.92124C6.16734 9.08165 6.5675 9.16185 7.17381 9.16185V9.5H1.86257V9.16185C2.44462 9.16185 2.83023 9.08165 3.0194 8.92124C3.21342 8.7565 3.31043 8.43136 3.31043 7.94581V0.935694C2.58286 0.953035 2.02506 1.05491 1.63703 1.24133C0.92401 1.58815 0.521423 2.23627 0.429264 3.18569H0L0.0145513 0.5Z" />
15
- </g>
16
- </svg>
17
- );
18
- };
19
-
20
- export default TextIcon;
@@ -1,22 +0,0 @@
1
- import { FC } from "react";
2
-
3
- const Underline: FC<{ className?: string }> = ({ className }) => {
4
- return (
5
- <svg
6
- xmlns="http://www.w3.org/2000/svg"
7
- viewBox="0 0 24 24"
8
- fill="none"
9
- stroke="currentColor"
10
- strokeWidth="2"
11
- strokeLinecap="round"
12
- strokeLinejoin="round"
13
- className={className}
14
- width={12}
15
- height={12}
16
- >
17
- <path d="M18 4V11C18 14.3137 15.3137 17 12 17C8.68629 17 6 14.3137 6 11V4M4 21H20" />
18
- </svg>
19
- );
20
- };
21
-
22
- export default Underline;
@@ -1,20 +0,0 @@
1
- import { FC } from "react";
2
-
3
- const Undo: FC<{ className?: string }> = ({ className }) => {
4
- return (
5
- <svg
6
- width="25"
7
- height="25"
8
- viewBox="0 0 256 256"
9
- xmlns="http://www.w3.org/2000/svg"
10
- className={className}
11
- >
12
- <path
13
- d="M55.265 167.072c-.975-1.973-3.388-2.796-5.372-1.847L42 169s22.5 53.5 85.5 56c60-1.5 96.627-48.626 97-96.5.373-47.874-37-95.5-95.5-96-57.5-1-79.556 45.004-79.556 45.004-1.073 1.93-1.944 1.698-1.944-.501V51.997a4 4 0 0 0-4-3.997H37c-2.209 0-4 1.8-4 4.008v48.984A3.998 3.998 0 0 0 36.998 105h50.504a3.995 3.995 0 0 0 3.998-3.993v-6.014c0-2.205-1.79-4.02-4.008-4.053l-25.484-.38c-2.214-.033-3.223-1.679-2.182-3.628C59.826 86.932 78 45 128.5 45.5c49 .5 82.751 41.929 82.5 83.242C208 184 166 211 127.5 210c-54.5 0-72.235-42.928-72.235-42.928z"
14
- fillRule="evenodd"
15
- />
16
- </svg>
17
- );
18
- };
19
-
20
- export default Undo;
@@ -1,68 +0,0 @@
1
- import classNames from "classnames";
2
- import { FC, SVGProps } from "react";
3
-
4
- export interface ButtonProps
5
- extends React.ButtonHTMLAttributes<HTMLButtonElement> {
6
- variant?: "primary" | "secondary";
7
- icon?: React.ReactElement<SVGProps<SVGSVGElement>>;
8
- active?: boolean;
9
- disabled?: boolean;
10
- }
11
-
12
- /**
13
- *
14
- * @deprecated Use ui/Button
15
- */
16
- export function PrimaryButton({
17
- children,
18
- onClick,
19
- }: {
20
- children: React.ReactNode;
21
- onClick?: () => void;
22
- }) {
23
- return (
24
- <button
25
- onClick={onClick}
26
- className="px-4 py-[2px] font-serif border rounded-sm border-border bg-fill text-primary hover:dark:bg-yellow hover:bg-warm-black hover:dark:text-dark-gray hover:text-white focus-visible:border-highlight focus:outline-none"
27
- >
28
- {children}
29
- </button>
30
- );
31
- }
32
-
33
- const Button: FC<ButtonProps> = ({
34
- variant = "primary",
35
- onClick,
36
- children,
37
- icon,
38
- // active = false,
39
- disabled = false,
40
- }) => {
41
- return (
42
- <button
43
- disabled={disabled}
44
- className={classNames(
45
- "font-sans font-[12px] tracking-[0.04em] py-1 px-2 rounded whitespace-nowrap group relative text-primary",
46
- {
47
- "font-bold": variant === "primary",
48
- "bg-background hover:bg-background text-fill disabled:bg-fill disabled:text-background":
49
- variant === "primary",
50
- "bg-transparent border border-primary text-primary hover:border-highlight hover:text-highlight disabled:bg-fill disabled:text-background":
51
- variant !== "primary",
52
- }
53
- )}
54
- onClick={onClick}
55
- >
56
- <span className="flex flex-row items-center justify-center gap-2">
57
- {icon && icon}
58
- {children}
59
- </span>
60
- </button>
61
- );
62
- };
63
-
64
- /**
65
- *
66
- * @deprecated Use ui/Button
67
- */
68
- export default Button;
@@ -1,51 +0,0 @@
1
- import classNames from "classnames";
2
- import { FC } from "react";
3
-
4
- export interface CheckboxProps {
5
- label: string;
6
- checked: boolean;
7
- setChecked: React.Dispatch<React.SetStateAction<boolean>>;
8
- }
9
-
10
- const Checkbox: FC<CheckboxProps> = ({ label, checked, setChecked }) => {
11
- const handleChange = (checked: boolean) => {
12
- setChecked(checked);
13
- };
14
-
15
- return (
16
- <div>
17
- <label className="flex items-center">
18
- <input
19
- type="checkbox"
20
- checked={checked}
21
- onChange={(event) => handleChange(event.target.checked)}
22
- className="hidden"
23
- />
24
- <span
25
- className={classNames(
26
- "w-[14px] h-[14px] border rounded border-gray-400 flex items-center justify-center",
27
- {
28
- "bg-highlight": checked,
29
- "bg-fill": !checked,
30
- }
31
- )}
32
- >
33
- {checked && (
34
- <svg
35
- width="10"
36
- height="7"
37
- viewBox="0 0 10 7"
38
- fill="none"
39
- xmlns="http://www.w3.org/2000/svg"
40
- >
41
- <path d="M1 1L5 6L9 1" stroke="#1A1A1A" stroke-linecap="square" />
42
- </svg>
43
- )}
44
- </span>
45
- <span className="ml-2 font-mono text-primary">{label}</span>
46
- </label>
47
- </div>
48
- );
49
- };
50
-
51
- export default Checkbox;
@@ -1,20 +0,0 @@
1
- import type { Meta, StoryObj } from "@storybook/react";
2
-
3
- import { DraggableList } from "./DraggableList";
4
-
5
- const meta: Meta<typeof DraggableList> = { component: DraggableList };
6
-
7
- export default meta;
8
- type Story = StoryObj<typeof DraggableList>;
9
-
10
- export const Default: Story = {
11
- args: {
12
- children: [
13
- <div className="p-4 bg-white w-fit">test 1</div>,
14
- <div className="p-4 bg-white w-fit">test 2</div>,
15
- <div className="p-4 bg-white w-fit">test 3</div>,
16
- <div className="p-4 bg-white w-fit">test 4</div>,
17
- <div className="p-4 bg-white w-fit">test 5</div>,
18
- ],
19
- },
20
- };
@@ -1,95 +0,0 @@
1
- import classNames from "classnames";
2
- import { createRef, useEffect, useState } from "react";
3
-
4
- export type DraggableResult = {
5
- from: number;
6
- to: number;
7
- };
8
-
9
- export type DraggableListProps = {
10
- children: React.ReactNode | React.ReactNode[];
11
- onDragEnd?: (result: DraggableResult) => void;
12
- };
13
-
14
- export const DraggableList = ({
15
- children: rawChildren,
16
- onDragEnd,
17
- }: DraggableListProps): React.ReactElement => {
18
- const [from, setFrom] = useState<number | undefined>();
19
- const [dragOver, setDragOver] = useState<number | undefined>();
20
- const [children, setChildren] = useState<React.ReactNode[]>([]);
21
- const [dropHappened, setDropHappened] = useState<boolean>(false);
22
- useEffect(() => {
23
- setChildren(Array.isArray(rawChildren) ? rawChildren : [rawChildren]);
24
- }, [rawChildren]);
25
-
26
- return (
27
- <div className="bg-transparent">
28
- {[...children, <div className="h-[1px]"></div>].map((child, idx) => {
29
- const ref = createRef<HTMLDivElement>();
30
- return (
31
- <div key={idx} className="relative">
32
- {dragOver === idx && (
33
- <div className="flex items-center">
34
- <div className="border-[2px] border-yellow w-3 h-3 rounded-full" />
35
- <div className="bg-yellow border-yellow w-full h-[1px]" />
36
- <div className="border-[2px] border-yellow w-3 h-3 rounded-full" />
37
- </div>
38
- )}
39
- <div
40
- ref={ref}
41
- draggable
42
- className={classNames("cursor-grab transition-opacity")}
43
- onDragStart={(ev) => {
44
- ev.dataTransfer.setDragImage(new Image(), 0, 0);
45
- setFrom(idx);
46
- }}
47
- onDragOver={(ev) => {
48
- ev.preventDefault();
49
- setDragOver(idx);
50
- }}
51
- onDragEnd={(ev) => {
52
- ev.preventDefault();
53
- if (
54
- from !== undefined &&
55
- !dropHappened &&
56
- dragOver !== undefined
57
- ) {
58
- const copy = [...children];
59
- const end = Math.min(dragOver, children.length - 1);
60
- copy.splice(from, 1);
61
- copy.splice(end, 0, children[from]);
62
- setChildren(copy);
63
- if (onDragEnd) {
64
- onDragEnd({ from: from, to: end });
65
- }
66
- }
67
- setDropHappened(false);
68
- setFrom(undefined);
69
- setDragOver(undefined);
70
- }}
71
- onDrop={(ev) => {
72
- ev.preventDefault();
73
- if (from !== undefined) {
74
- const copy = [...children];
75
- copy.splice(from, 1);
76
- const end = Math.min(idx, children.length - 1);
77
- copy.splice(end, 0, children[from]);
78
- if (onDragEnd) {
79
- onDragEnd({ from: from, to: end });
80
- }
81
- setChildren(copy);
82
- setDragOver(undefined);
83
- setFrom(undefined);
84
- setDropHappened(true);
85
- }
86
- }}
87
- >
88
- {child}
89
- </div>
90
- </div>
91
- );
92
- })}
93
- </div>
94
- );
95
- };
@@ -1,101 +0,0 @@
1
- import React, { SVGProps, useEffect, useRef, useState } from "react";
2
- import Chevron from "../assets/icons/Chevron";
3
- import Button from "./Button";
4
- import { useValOverlayContext } from "./ValOverlayContext";
5
-
6
- export interface DropdownProps {
7
- options: string[];
8
- label: string;
9
- onChange: (selectedOption: string) => void;
10
- icon?: React.ReactElement<SVGProps<SVGSVGElement>>;
11
- variant?: "primary" | "secondary";
12
- }
13
-
14
- const Dropdown: React.FC<DropdownProps> = ({
15
- options,
16
- onChange,
17
- label,
18
- icon,
19
- }) => {
20
- const [isOpen, setIsOpen] = useState<boolean>(false);
21
- const dropdownRef = useRef<HTMLDivElement>(null);
22
- const [selectedOption, setSelectedOption] = useState<number>(0);
23
- const { windowSize } = useValOverlayContext();
24
-
25
- const handleToggle = () => {
26
- setIsOpen(!isOpen);
27
- };
28
-
29
- const handleSelect = (option: string, idx: number) => {
30
- setSelectedOption(idx);
31
- onChange(option);
32
- setIsOpen(false);
33
- };
34
-
35
- useEffect(() => {
36
- const handleOutsideClick = (event: MouseEvent) => {
37
- if (
38
- isOpen &&
39
- dropdownRef.current &&
40
- !dropdownRef.current.contains(event.target as Node)
41
- ) {
42
- setIsOpen(false);
43
- }
44
- };
45
- document.addEventListener("click", handleOutsideClick);
46
- return () => {
47
- document.removeEventListener("click", handleOutsideClick);
48
- };
49
- }, []);
50
-
51
- return (
52
- <div className="text-[12px]" ref={dropdownRef}>
53
- <Button
54
- onClick={(ev) => {
55
- ev.preventDefault();
56
- handleToggle();
57
- }}
58
- icon={
59
- <Chevron
60
- className={`rotate-[-90deg] transition-transform duration-150 ease-in-out ${
61
- isOpen ? "" : "rotate-[90deg]"
62
- }`}
63
- />
64
- }
65
- >
66
- <div className="relative">
67
- <span className="flex flex-row items-center justify-center gap-1">
68
- {label}
69
- {icon && icon}
70
- </span>
71
- {isOpen && (
72
- <div
73
- className="absolute -top-[4px] overflow-scroll shadow-lg -left-2 text-primary bg-border w-fit z-overlay"
74
- style={{ maxHeight: windowSize?.innerHeight }}
75
- >
76
- <div className="flex flex-col ">
77
- {options?.map((option, idx) => (
78
- <button
79
- key={option}
80
- onClick={(ev) => {
81
- ev.preventDefault();
82
- handleSelect(option, idx);
83
- }}
84
- className={`text-left px-2 py-1 hover:bg-background hover:text-highlight ${
85
- idx === selectedOption &&
86
- "font-bold bg-background hover:bg-background truncate"
87
- }`}
88
- >
89
- {option}
90
- </button>
91
- ))}
92
- </div>
93
- </div>
94
- )}
95
- </div>
96
- </Button>
97
- </div>
98
- );
99
- };
100
-
101
- export default Dropdown;
@@ -1,10 +0,0 @@
1
- export function EditButton({ onClick }: { onClick: () => void }) {
2
- return (
3
- <button
4
- className="px-[24px] py-4 font-serif text-lg font-semibold border-2 rounded-md text-warm-black dark:border-white border-warm-black bg-highlight"
5
- onClick={onClick}
6
- >
7
- Edit page
8
- </button>
9
- );
10
- }
@@ -1,3 +0,0 @@
1
- export function ErrorText({ children }: { children: React.ReactNode }) {
2
- return <div className="p-4 text-red bg-yellow">{children}</div>;
3
- }
@@ -1,72 +0,0 @@
1
- import { FC } from "react";
2
-
3
- const ExpandLogo: FC<{ expanded: boolean; className?: string }> = ({
4
- expanded,
5
- className,
6
- }) => {
7
- return (
8
- <div>
9
- {expanded ? (
10
- <svg
11
- width="11"
12
- height="11"
13
- viewBox="0 0 11 11"
14
- xmlns="http://www.w3.org/2000/svg"
15
- className={className}
16
- >
17
- <path
18
- fillRule="evenodd"
19
- clipRule="evenodd"
20
- d="M0.606061 9.39394V6.25H0V10H3.75V9.39394H0.606061Z"
21
- />
22
- <path
23
- fillRule="evenodd"
24
- clipRule="evenodd"
25
- d="M9.4319 0.644146L9.4319 3.78809L10.038 3.78809L10.038 0.0380859L6.28796 0.0380863L6.28796 0.644146L9.4319 0.644146Z"
26
- />
27
- <path
28
- fillRule="evenodd"
29
- clipRule="evenodd"
30
- d="M3.11371e-05 9.59583L3.34602 6.24995L3.78796 6.6919L0.441965 10.0378L3.11371e-05 9.59583Z"
31
- />
32
- <path
33
- fillRule="evenodd"
34
- clipRule="evenodd"
35
- d="M10.0379 0.441766L6.69194 3.78764L6.25001 3.3457L9.596 -0.000183055L10.0379 0.441766Z"
36
- />
37
- </svg>
38
- ) : (
39
- <svg
40
- width="11"
41
- height="11"
42
- viewBox="0 0 11 11"
43
- fill="none"
44
- xmlns="http://www.w3.org/2000/svg"
45
- className={className}
46
- >
47
- <path
48
- fillRule="evenodd"
49
- clipRule="evenodd"
50
- d="M3.14394 6.85606L3.14394 10L3.75 10L3.75 6.25L-3.27835e-07 6.25L-2.74852e-07 6.85606L3.14394 6.85606Z"
51
- />
52
- <path
53
- fillRule="evenodd"
54
- clipRule="evenodd"
55
- d="M6.89402 3.18203V0.0380859L6.28796 0.0380859L6.28796 3.78809L10.038 3.78809V3.18203L6.89402 3.18203Z"
56
- />
57
- <path
58
- fillRule="evenodd"
59
- clipRule="evenodd"
60
- d="M3.11371e-05 9.59583L3.34602 6.24995L3.78796 6.6919L0.441965 10.0378L3.11371e-05 9.59583Z"
61
- />
62
- <path
63
- fillRule="evenodd"
64
- clipRule="evenodd"
65
- d="M10.0379 0.441766L6.69194 3.78764L6.25001 3.3457L9.596 -0.000183055L10.0379 0.441766Z"
66
- />
67
- </svg>
68
- )}
69
- </div>
70
- );
71
- };
72
- export default ExpandLogo;
@@ -1,43 +0,0 @@
1
- import type { Meta, StoryObj } from "@storybook/react";
2
- import { Grid } from "./Grid";
3
- import { Tree } from "./dashboard/Tree";
4
- import { Dropdown } from "./dashboard/Dropdown";
5
-
6
- const meta: Meta<typeof Grid> = { component: Grid };
7
-
8
- export default meta;
9
- type Story = StoryObj<typeof Grid>;
10
- export const Default: Story = {
11
- render: () => (
12
- <Grid>
13
- <Dropdown options={["/blogs", "/journals"]} />
14
- <Tree>
15
- <Tree.Node path="Main nav" type="section" />
16
- <Tree.Node path="H1" type="string">
17
- <Tree.Node path="Section 3" type="string" />
18
- <Tree.Node path="Section 4" type="section">
19
- <Tree.Node path="Section 5" type="string" />
20
- <Tree.Node path="Section 6" type="section">
21
- <Tree.Node path="Section 7" type="string" />
22
- </Tree.Node>
23
- </Tree.Node>
24
- </Tree.Node>
25
- </Tree>
26
- <div className="flex items-center justify-between w-full h-full px-3 font-serif text-xs text-white">
27
- <p>Content</p>
28
- <button className="flex justify-between flex-shrink-0 gap-1">
29
- <span className="w-fit">+</span>
30
- <span className="w-fit">Add item</span>
31
- </button>
32
- </div>
33
- <div>
34
- <div>Object 1</div>
35
- <div>Object 2</div>
36
- <div>Object 3</div>
37
- <div>Object 4</div>
38
- </div>
39
- <div className="text-white">History</div>
40
- <div className="text-white">hey</div>
41
- </Grid>
42
- ),
43
- };
@@ -1,139 +0,0 @@
1
- import classNames from "classnames";
2
- import { Children, useEffect, useRef } from "react";
3
- import { ScrollArea } from "./ui/scroll-area";
4
-
5
- type GridProps = {
6
- children: React.ReactNode | React.ReactNode[];
7
- };
8
-
9
- export function Grid({ children }: GridProps): React.ReactElement {
10
- const leftColRef = useRef<HTMLDivElement>(null);
11
- const rightColRef = useRef<HTMLDivElement>(null);
12
-
13
- const isResizing = useRef(false);
14
- const x = useRef(0);
15
- const dragRef = useRef<"left" | "right" | null>(null);
16
- const originalWidth = useRef(0);
17
-
18
- const handleMouseUp = () => {
19
- isResizing.current = false;
20
- dragRef.current = null;
21
- x.current = 0;
22
- originalWidth.current = 0;
23
- };
24
-
25
- const handleMouseMove = (event: MouseEvent) => {
26
- event.preventDefault();
27
- const targetRef = dragRef.current === "left" ? leftColRef : rightColRef;
28
- if (targetRef.current && isResizing.current) {
29
- const dx =
30
- dragRef.current === "left"
31
- ? event.screenX - x.current
32
- : x.current - event.screenX;
33
- targetRef.current.style.width = `${Math.max(
34
- originalWidth.current + dx,
35
- 150
36
- )}px`;
37
- }
38
- };
39
-
40
- const handleMouseDown =
41
- (column: "left" | "right") =>
42
- (event: React.MouseEvent<HTMLDivElement, MouseEvent>) => {
43
- const target = event.target as HTMLDivElement;
44
- if (target) {
45
- const columnRef =
46
- column === "left"
47
- ? leftColRef
48
- : column === "right"
49
- ? rightColRef
50
- : null;
51
- isResizing.current = true;
52
- if (columnRef && columnRef.current) {
53
- x.current = event.screenX;
54
- dragRef.current = column;
55
- if (columnRef.current) {
56
- originalWidth.current = columnRef.current.offsetWidth;
57
- }
58
- }
59
- }
60
- };
61
-
62
- const [header1, body1, header2, body2, header3, body3] =
63
- Children.toArray(children);
64
- useEffect(() => {
65
- document.addEventListener("mouseup", handleMouseUp);
66
- document.addEventListener("mousemove", handleMouseMove);
67
-
68
- return () => {
69
- document.removeEventListener("mouseup", handleMouseUp);
70
- document.removeEventListener("mousemove", handleMouseMove);
71
- };
72
- }, []);
73
-
74
- return (
75
- <div className="flex h-screen">
76
- <div
77
- ref={leftColRef}
78
- className="relative border-r border-border"
79
- style={{ width: 300 }}
80
- >
81
- <Grid.Column>
82
- {header1}
83
- <ScrollArea style={{ height: "calc(100vh - 50px)" }}>
84
- {body1}
85
- </ScrollArea>
86
- </Grid.Column>
87
- <div
88
- className="absolute inset-y-0 right-0 cursor-col-resize w-[1px] hover:w-[3px] h-full hover:bg-border"
89
- onMouseDown={handleMouseDown("left")}
90
- ></div>
91
- </div>
92
- <div
93
- className={classNames("", {
94
- "w-full": !header3 && !body3,
95
- })}
96
- >
97
- <Grid.Column>
98
- {header2}
99
- <ScrollArea style={{ height: "calc(100vh - 50px)" }}>
100
- {body2}
101
- </ScrollArea>
102
- </Grid.Column>
103
- </div>
104
- {header3 ||
105
- (body3 && (
106
- <div
107
- ref={rightColRef}
108
- className="relative h-screen border-l border-border"
109
- style={{ width: 300 }}
110
- >
111
- <Grid.Column>
112
- {header3}
113
- <ScrollArea style={{ height: "calc(100vh - 50px)" }}>
114
- {body3}
115
- </ScrollArea>
116
- </Grid.Column>
117
- <div
118
- onMouseDown={handleMouseDown("right")}
119
- className="absolute inset-y-0 left-0 cursor-col-resize w-[1px] bg-border hover:w-[3px] hover:bg-border"
120
- ></div>
121
- </div>
122
- ))}
123
- </div>
124
- );
125
- }
126
-
127
- type GridChildProps = {
128
- children: React.ReactNode | React.ReactNode[];
129
- };
130
-
131
- Grid.Column = ({ children }: GridChildProps): React.ReactElement => {
132
- const [header, body] = Children.toArray(children);
133
- return (
134
- <div className="flex flex-col">
135
- <div className="flex items-center border-b border-border">{header}</div>
136
- {body}
137
- </div>
138
- );
139
- };