@reactberry/system 2.0.0-beta
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/README.md +48 -0
- package/package.json +74 -0
- package/src/blocks/Accordion/index.tsx +158 -0
- package/src/blocks/AnimatedCarousel/index.tsx +188 -0
- package/src/blocks/AppleGlow/index.tsx +144 -0
- package/src/blocks/Avatar/index.tsx +167 -0
- package/src/blocks/Await/index.tsx +45 -0
- package/src/blocks/Cards/AnimatedCard/index.tsx +175 -0
- package/src/blocks/Cards/FluorescentCard/index.tsx +180 -0
- package/src/blocks/Cards/InfoCard/index.tsx +206 -0
- package/src/blocks/Cards/TickerCard/index.tsx +125 -0
- package/src/blocks/Carousel/index.tsx +216 -0
- package/src/blocks/Checkbox/index.tsx +101 -0
- package/src/blocks/Collection/index.tsx +59 -0
- package/src/blocks/Container/index.tsx +55 -0
- package/src/blocks/Controls/Control.tsx +67 -0
- package/src/blocks/Controls/index.tsx +11 -0
- package/src/blocks/CyclingNumber/index.tsx +78 -0
- package/src/blocks/DisplaySet/index.tsx +42 -0
- package/src/blocks/Divider/index.tsx +14 -0
- package/src/blocks/Draggable/index.tsx +266 -0
- package/src/blocks/Drawer/index.tsx +136 -0
- package/src/blocks/DynamicIsland/DynamicIsland.tsx +89 -0
- package/src/blocks/DynamicIsland/index.tsx +2 -0
- package/src/blocks/Fader/index.tsx +145 -0
- package/src/blocks/FamilyDrawer/README.md +116 -0
- package/src/blocks/FamilyDrawer/example.tsx +108 -0
- package/src/blocks/FamilyDrawer/index.tsx +119 -0
- package/src/blocks/FamilyDrawer/views/DefaultView.tsx +93 -0
- package/src/blocks/FamilyDrawer/views/KeyView.tsx +129 -0
- package/src/blocks/FamilyDrawer/views/PhraseView.tsx +129 -0
- package/src/blocks/FamilyDrawer/views/RemoveView.tsx +81 -0
- package/src/blocks/FieldSet/index.tsx +173 -0
- package/src/blocks/Filesystem/index.tsx +198 -0
- package/src/blocks/Gallery/Carousel/index.tsx +257 -0
- package/src/blocks/Gallery/Modal/index.tsx +83 -0
- package/src/blocks/Gallery/index.tsx +57 -0
- package/src/blocks/Gallery/utils/animationVariants.ts +18 -0
- package/src/blocks/Gallery/utils/aspectRatio.ts +14 -0
- package/src/blocks/Gallery/utils/downloadPhoto.ts +24 -0
- package/src/blocks/Gallery/utils/range.ts +11 -0
- package/src/blocks/GradientMesh/index.tsx +106 -0
- package/src/blocks/Group/index.tsx +152 -0
- package/src/blocks/Heading/index.tsx +111 -0
- package/src/blocks/HorizontalScroller/index.tsx +135 -0
- package/src/blocks/Icon/index.tsx +45 -0
- package/src/blocks/Indicator/index.tsx +27 -0
- package/src/blocks/InlineEditor/index.tsx +216 -0
- package/src/blocks/List/index.tsx +657 -0
- package/src/blocks/Main/index.tsx +17 -0
- package/src/blocks/Marquee/index.tsx +116 -0
- package/src/blocks/MaskedField/index.tsx +199 -0
- package/src/blocks/Menu/MenuContent.tsx +246 -0
- package/src/blocks/Menu/MenuContext.tsx +34 -0
- package/src/blocks/Menu/MenuItem.tsx +104 -0
- package/src/blocks/Menu/index.tsx +60 -0
- package/src/blocks/Modal/index.tsx +268 -0
- package/src/blocks/MorphingPopover/index.tsx +294 -0
- package/src/blocks/Overlay/Backdrop.tsx +48 -0
- package/src/blocks/Overlay/OverscrollGuard.tsx +36 -0
- package/src/blocks/Overlay/index.ts +2 -0
- package/src/blocks/Parallax/index.tsx +117 -0
- package/src/blocks/ParallaxSection/index.tsx +61 -0
- package/src/blocks/Placeholder/index.tsx +48 -0
- package/src/blocks/Popover/index.tsx +402 -0
- package/src/blocks/Progress/getProgressColor.ts +61 -0
- package/src/blocks/Progress/index.tsx +179 -0
- package/src/blocks/ProgressiveBlur/index.tsx +75 -0
- package/src/blocks/README.md +15 -0
- package/src/blocks/RenderAsset/index.tsx +18 -0
- package/src/blocks/ScrollContainer/index.tsx +93 -0
- package/src/blocks/ShinyText/index.tsx +72 -0
- package/src/blocks/Skeleton/index.tsx +71 -0
- package/src/blocks/Slider/SliderControls.tsx +119 -0
- package/src/blocks/Slider/index.tsx +140 -0
- package/src/blocks/Slider/useSlider.ts +126 -0
- package/src/blocks/Slideshow/index.tsx +177 -0
- package/src/blocks/Spotlight/index.tsx +144 -0
- package/src/blocks/Steps/StepIndicator.tsx +149 -0
- package/src/blocks/Steps/StepProgress.tsx +164 -0
- package/src/blocks/Steps/Steps.tsx +197 -0
- package/src/blocks/Steps/StepsNav.tsx +30 -0
- package/src/blocks/Steps/StepsTracker.tsx +80 -0
- package/src/blocks/Steps/hooks.ts +71 -0
- package/src/blocks/Steps/index.tsx +16 -0
- package/src/blocks/Steps/types.ts +71 -0
- package/src/blocks/StickySectionStack/index.tsx +136 -0
- package/src/blocks/Switch/index.tsx +85 -0
- package/src/blocks/SystemNotice/index.tsx +81 -0
- package/src/blocks/Table/README.md +251 -0
- package/src/blocks/Table/Table.tsx +207 -0
- package/src/blocks/Table/TablePagination.tsx +189 -0
- package/src/blocks/Table/index.ts +33 -0
- package/src/blocks/Table/useTableControls.ts +331 -0
- package/src/blocks/Tag/index.tsx +27 -0
- package/src/blocks/TextBreak/index.tsx +96 -0
- package/src/blocks/TextReveal/index.tsx +104 -0
- package/src/blocks/Thumbnail/index.tsx +26 -0
- package/src/blocks/Ticker/index.tsx +112 -0
- package/src/blocks/Toast/index.tsx +77 -0
- package/src/blocks/Tooltip/index.tsx +174 -0
- package/src/blocks/Underlay/index.tsx +104 -0
- package/src/blocks/Upload/Dropzone.tsx +92 -0
- package/src/blocks/Upload/UploadBtn.tsx +38 -0
- package/src/blocks/Upload/index.tsx +61 -0
- package/src/blocks/Upload/types.ts +37 -0
- package/src/blocks/VideoMarquee/index.tsx +511 -0
- package/src/blocks/index.ts +119 -0
- package/src/blocks/pagination/Pagination.tsx +148 -0
- package/src/blocks/pagination/PaginationList.tsx +41 -0
- package/src/blocks/pagination/index.ts +2 -0
- package/src/charts/BarChart.tsx +63 -0
- package/src/charts/PieChart.tsx +39 -0
- package/src/charts/index.ts +3 -0
- package/src/charts/utils.ts +103 -0
- package/src/docs/README.md +373 -0
- package/src/docs/reference/README.md +299 -0
- package/src/elements/box.ts +163 -0
- package/src/elements/button.ts +49 -0
- package/src/elements/field.ts +129 -0
- package/src/elements/index.ts +8 -0
- package/src/elements/text.ts +47 -0
- package/src/elements/utils.js +97 -0
- package/src/hooks/use-copy-to-clipboard.tsx +33 -0
- package/src/hooks/use-enter-submit.tsx +23 -0
- package/src/hooks/use-local-storage.ts +42 -0
- package/src/hooks/use-sidebar.tsx +109 -0
- package/src/hooks/useAnimatedText.ts +32 -0
- package/src/hooks/useAutosizeTextArea.ts +45 -0
- package/src/hooks/useBreakpoint.tsx +123 -0
- package/src/hooks/useClickOutside.tsx +38 -0
- package/src/hooks/useHover.tsx +33 -0
- package/src/hooks/useHoverList.tsx +17 -0
- package/src/hooks/useKeyboardShortcuts.ts +91 -0
- package/src/hooks/useKeypress.ts +27 -0
- package/src/hooks/useOverlay.ts +32 -0
- package/src/hooks/useReducedMotion.ts +25 -0
- package/src/hooks/useStandaloneMode.ts +35 -0
- package/src/hooks/useTouchDevice.ts +34 -0
- package/src/icons/index.tsx +129 -0
- package/src/index.ts +12 -0
- package/src/providers/DesignSystemProvider.tsx +35 -0
- package/src/providers/StyledComponentsRegistry.tsx +30 -0
- package/src/providers/index.ts +2 -0
- package/src/themes/README.md +30 -0
- package/src/themes/default/assets/badge-avatar.tsx +45 -0
- package/src/themes/default/assets/logo.tsx +42 -0
- package/src/themes/default/global.ts +138 -0
- package/src/themes/default/modes/dark/config.js +49 -0
- package/src/themes/default/modes/dark/skins.js +631 -0
- package/src/themes/default/modes/dark/theme.js +87 -0
- package/src/themes/default/modes/light/config.js +48 -0
- package/src/themes/default/modes/light/skins.js +1026 -0
- package/src/themes/default/modes/light/theme.js +74 -0
- package/src/themes/default/tokens/controls.js +53 -0
- package/src/themes/default/tokens/shadows.js +63 -0
- package/src/themes/default/tokens/shapes.js +37 -0
- package/src/themes/default/tokens/space.js +143 -0
- package/src/themes/default/tokens/spectre.js +16 -0
- package/src/themes/default/utils.js +523 -0
- package/src/themes/index.ts +11 -0
- package/src/types.ts +394 -0
- package/src/utils/overlayTheme.ts +61 -0
- package/src/utils/pickColor.ts +15 -0
- package/tsconfig.json +24 -0
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
import Box, { BoxProps } from "@/design-system/elements/box"
|
|
3
|
+
import React from "react"
|
|
4
|
+
import styled, { css } from "styled-components"
|
|
5
|
+
|
|
6
|
+
interface GroupProps extends BoxProps {
|
|
7
|
+
type?: "buttons" | "avatars" | "tabs"
|
|
8
|
+
vertical?: boolean
|
|
9
|
+
children?: React.ReactNode
|
|
10
|
+
className?: string
|
|
11
|
+
[key: string]: any
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const HorizontalButtons = css`
|
|
15
|
+
> .button {
|
|
16
|
+
text-align: center;
|
|
17
|
+
border-radius: 0;
|
|
18
|
+
margin: 0;
|
|
19
|
+
align-items: center;
|
|
20
|
+
margin-left: -1px;
|
|
21
|
+
z-index: 1;
|
|
22
|
+
}
|
|
23
|
+
.dropdown > :first-child {
|
|
24
|
+
text-align: center;
|
|
25
|
+
border-radius: 0;
|
|
26
|
+
margin: 0;
|
|
27
|
+
align-items: center;
|
|
28
|
+
margin-left: -1px;
|
|
29
|
+
z-index: 1;
|
|
30
|
+
}
|
|
31
|
+
> :first-child {
|
|
32
|
+
border-top-left-radius: 8px;
|
|
33
|
+
border-bottom-left-radius: 8px;
|
|
34
|
+
margin-left: 0;
|
|
35
|
+
}
|
|
36
|
+
.dropdown:first-child {
|
|
37
|
+
> :first-child {
|
|
38
|
+
border-top-left-radius: 8px;
|
|
39
|
+
border-bottom-left-radius: 8px;
|
|
40
|
+
margin-left: 0;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
> :last-child {
|
|
44
|
+
border-top-right-radius: 8px;
|
|
45
|
+
border-bottom-right-radius: 8px;
|
|
46
|
+
}
|
|
47
|
+
.dropdown:last-child {
|
|
48
|
+
> :first-child {
|
|
49
|
+
border-top-right-radius: 8px;
|
|
50
|
+
border-bottom-right-radius: 8px;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
> :hover {
|
|
54
|
+
z-index: 2;
|
|
55
|
+
}
|
|
56
|
+
`
|
|
57
|
+
|
|
58
|
+
const VerticalButtons = css`
|
|
59
|
+
> * {
|
|
60
|
+
justify-content: center;
|
|
61
|
+
}
|
|
62
|
+
> *:first-child {
|
|
63
|
+
border-radius: 8px 8px 0 0;
|
|
64
|
+
}
|
|
65
|
+
> *:last-child {
|
|
66
|
+
border-radius: 0 0 8px 8px;
|
|
67
|
+
}
|
|
68
|
+
`
|
|
69
|
+
|
|
70
|
+
const HorizontalTabs = css`
|
|
71
|
+
> * {
|
|
72
|
+
text-align: center;
|
|
73
|
+
align-items: center;
|
|
74
|
+
border: 1px solid transparent;
|
|
75
|
+
}
|
|
76
|
+
> *:first-child {
|
|
77
|
+
border-radius: 8px 0 0 0;
|
|
78
|
+
}
|
|
79
|
+
`
|
|
80
|
+
|
|
81
|
+
const VerticalTabs = css`
|
|
82
|
+
> * {
|
|
83
|
+
width: 100%;
|
|
84
|
+
}
|
|
85
|
+
> *:first-child {
|
|
86
|
+
border-radius: 0;
|
|
87
|
+
}
|
|
88
|
+
`
|
|
89
|
+
|
|
90
|
+
const HorizontalAvatars = css`
|
|
91
|
+
flex-direction: row-reverse;
|
|
92
|
+
> div {
|
|
93
|
+
/*border: 2px solid transparent;*/
|
|
94
|
+
margin-right: -0.75em;
|
|
95
|
+
transition: 0.125s ease-in-out;
|
|
96
|
+
z-index: 0;
|
|
97
|
+
}
|
|
98
|
+
&:hover {
|
|
99
|
+
> div {
|
|
100
|
+
&:hover {
|
|
101
|
+
/*border: 2px solid transparent;*/
|
|
102
|
+
transform: scale(1.05);
|
|
103
|
+
z-index: 1;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
`
|
|
108
|
+
|
|
109
|
+
const VerticalAvatars = css`
|
|
110
|
+
justify-content: center;
|
|
111
|
+
`
|
|
112
|
+
|
|
113
|
+
const StyledBox = styled(Box)<GroupProps>`
|
|
114
|
+
${(props) => props.type === "buttons" && HorizontalButtons};
|
|
115
|
+
${(props) => props.type === "avatars" && HorizontalAvatars};
|
|
116
|
+
${(props) => props.type === "tabs" && HorizontalTabs};
|
|
117
|
+
${(props) =>
|
|
118
|
+
props.vertical
|
|
119
|
+
? css`
|
|
120
|
+
display: flex;
|
|
121
|
+
flex-direction: column;
|
|
122
|
+
justify-content: start;
|
|
123
|
+
align-items: start;
|
|
124
|
+
${props.type === "buttons" && VerticalButtons};
|
|
125
|
+
${props.type === "avatars" && VerticalAvatars};
|
|
126
|
+
${props.type === "tabs" && VerticalTabs};
|
|
127
|
+
`
|
|
128
|
+
: ""};
|
|
129
|
+
`
|
|
130
|
+
|
|
131
|
+
const Group: React.FC<GroupProps> = ({
|
|
132
|
+
children,
|
|
133
|
+
className,
|
|
134
|
+
type,
|
|
135
|
+
vertical,
|
|
136
|
+
...props
|
|
137
|
+
}) => {
|
|
138
|
+
return (
|
|
139
|
+
<StyledBox
|
|
140
|
+
className={className}
|
|
141
|
+
type={type}
|
|
142
|
+
vertical={vertical}
|
|
143
|
+
display="flex"
|
|
144
|
+
alignItems="center"
|
|
145
|
+
{...props}
|
|
146
|
+
>
|
|
147
|
+
{children}
|
|
148
|
+
</StyledBox>
|
|
149
|
+
)
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
export default Group
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import Text, { TextProps } from "@/design-system/elements/text";
|
|
3
|
+
import { ThemeContext } from "styled-components";
|
|
4
|
+
import React, { useContext } from "react";
|
|
5
|
+
|
|
6
|
+
type HeadingElements = {
|
|
7
|
+
title?: TextProps;
|
|
8
|
+
subtitle?: TextProps;
|
|
9
|
+
strap?: any;
|
|
10
|
+
[key: string]: any;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
type HeadingProps = TextProps & {
|
|
14
|
+
children?: React.ReactNode;
|
|
15
|
+
title: string | React.ReactNode;
|
|
16
|
+
subtitle?: string | React.ReactNode;
|
|
17
|
+
strap?: any;
|
|
18
|
+
meta?: React.ReactNode;
|
|
19
|
+
elementProps?: HeadingElements;
|
|
20
|
+
props?: any;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export default function Heading({
|
|
24
|
+
children,
|
|
25
|
+
title = "Page Title",
|
|
26
|
+
subtitle,
|
|
27
|
+
strap,
|
|
28
|
+
meta,
|
|
29
|
+
$size = "medium",
|
|
30
|
+
color = "primary",
|
|
31
|
+
elementProps = {},
|
|
32
|
+
...props
|
|
33
|
+
}: HeadingProps) {
|
|
34
|
+
const theme: any = useContext(ThemeContext);
|
|
35
|
+
|
|
36
|
+
const headingSize: any = {
|
|
37
|
+
xsmall: {
|
|
38
|
+
title: "medium",
|
|
39
|
+
subtitle: "small",
|
|
40
|
+
},
|
|
41
|
+
small: {
|
|
42
|
+
title: "large",
|
|
43
|
+
subtitle: "small",
|
|
44
|
+
},
|
|
45
|
+
medium: {
|
|
46
|
+
title: "xlarge",
|
|
47
|
+
subtitle: "small",
|
|
48
|
+
},
|
|
49
|
+
large: {
|
|
50
|
+
title: "xlarge",
|
|
51
|
+
subtitle: "medium",
|
|
52
|
+
},
|
|
53
|
+
xlarge: {
|
|
54
|
+
title: "xxlarge",
|
|
55
|
+
subtitle: "medium",
|
|
56
|
+
},
|
|
57
|
+
xxlarge: {
|
|
58
|
+
title: "xxxlarge",
|
|
59
|
+
subtitle: "xlarge",
|
|
60
|
+
},
|
|
61
|
+
xxxlarge: {
|
|
62
|
+
title: "xxxlarge",
|
|
63
|
+
subtitle: "xlarge",
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
return (
|
|
68
|
+
<Text as="header" {...theme?.heading?.container} {...props}>
|
|
69
|
+
{strap && (
|
|
70
|
+
<Text
|
|
71
|
+
as="div"
|
|
72
|
+
m="0"
|
|
73
|
+
fontSize={headingSize[$size].subtitle}
|
|
74
|
+
fontWeight="600"
|
|
75
|
+
color="secondary"
|
|
76
|
+
{...theme?.heading?.strap}
|
|
77
|
+
{...elementProps.strap}
|
|
78
|
+
>
|
|
79
|
+
{strap}
|
|
80
|
+
</Text>
|
|
81
|
+
)}
|
|
82
|
+
<Text
|
|
83
|
+
as="h1"
|
|
84
|
+
m="0"
|
|
85
|
+
fontSize={headingSize[$size].title}
|
|
86
|
+
fontWeight="inherit"
|
|
87
|
+
lineHeight="1.5"
|
|
88
|
+
color={color}
|
|
89
|
+
{...theme?.heading?.title}
|
|
90
|
+
{...elementProps.title}
|
|
91
|
+
>
|
|
92
|
+
{title}
|
|
93
|
+
</Text>
|
|
94
|
+
{subtitle && (
|
|
95
|
+
<Text
|
|
96
|
+
as="p"
|
|
97
|
+
m="0"
|
|
98
|
+
fontSize={headingSize[$size].subtitle}
|
|
99
|
+
fontWeight="400"
|
|
100
|
+
color="tertiary"
|
|
101
|
+
{...theme?.heading?.subtitle}
|
|
102
|
+
{...elementProps.subtitle}
|
|
103
|
+
>
|
|
104
|
+
{subtitle}
|
|
105
|
+
</Text>
|
|
106
|
+
)}
|
|
107
|
+
{meta && meta}
|
|
108
|
+
{children}
|
|
109
|
+
</Text>
|
|
110
|
+
);
|
|
111
|
+
}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Box, Text } from "@/design-system/elements";
|
|
3
|
+
import {
|
|
4
|
+
animate,
|
|
5
|
+
motion,
|
|
6
|
+
MotionValue,
|
|
7
|
+
useMotionValue,
|
|
8
|
+
useMotionValueEvent,
|
|
9
|
+
useScroll,
|
|
10
|
+
} from "motion/react";
|
|
11
|
+
import { useRef, ReactNode } from "react";
|
|
12
|
+
|
|
13
|
+
interface HorizontalScrollerProps {
|
|
14
|
+
items: any[]; // Array of items to scroll through
|
|
15
|
+
renderItem: (item: any, index: number) => ReactNode; // Function to render each item
|
|
16
|
+
gap?: number | string; // Gap between items
|
|
17
|
+
progressIndicator?: boolean; // Whether to show progress indicator
|
|
18
|
+
withMask?: boolean; // Whether to apply gradient mask
|
|
19
|
+
title?: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export default function HorizontalScroller({
|
|
23
|
+
items,
|
|
24
|
+
renderItem,
|
|
25
|
+
gap = "small",
|
|
26
|
+
title,
|
|
27
|
+
progressIndicator = true,
|
|
28
|
+
withMask = true,
|
|
29
|
+
}: HorizontalScrollerProps) {
|
|
30
|
+
const containerRef = useRef(null);
|
|
31
|
+
const { scrollXProgress } = useScroll({ container: containerRef });
|
|
32
|
+
const maskImage = useScrollOverflowMask(scrollXProgress);
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<Box width="100%" position="relative" maxWidth="100%" overflow="hidden">
|
|
36
|
+
<Box
|
|
37
|
+
position="relative"
|
|
38
|
+
display="flex"
|
|
39
|
+
alignItems={"center"}
|
|
40
|
+
justifyContent={"space-between"}
|
|
41
|
+
py="xsmall"
|
|
42
|
+
>
|
|
43
|
+
{title && (
|
|
44
|
+
<Text as="h3" m="0">
|
|
45
|
+
{title}
|
|
46
|
+
</Text>
|
|
47
|
+
)}
|
|
48
|
+
{progressIndicator && (
|
|
49
|
+
<Box
|
|
50
|
+
as={motion.svg}
|
|
51
|
+
color="brand"
|
|
52
|
+
size="2rem"
|
|
53
|
+
viewBox="0 0 100 100"
|
|
54
|
+
transform="rotate(-90deg)"
|
|
55
|
+
zIndex="1"
|
|
56
|
+
>
|
|
57
|
+
<circle
|
|
58
|
+
cx="50"
|
|
59
|
+
cy="50"
|
|
60
|
+
r="30"
|
|
61
|
+
pathLength="1"
|
|
62
|
+
stroke="rgba(255,255,255,0.2)"
|
|
63
|
+
strokeWidth="10%"
|
|
64
|
+
fill="none"
|
|
65
|
+
/>
|
|
66
|
+
<motion.circle
|
|
67
|
+
cx="50"
|
|
68
|
+
cy="50"
|
|
69
|
+
r="30"
|
|
70
|
+
stroke="currentColor"
|
|
71
|
+
strokeWidth="10%"
|
|
72
|
+
fill="none"
|
|
73
|
+
style={{ pathLength: scrollXProgress }}
|
|
74
|
+
/>
|
|
75
|
+
</Box>
|
|
76
|
+
)}
|
|
77
|
+
</Box>
|
|
78
|
+
|
|
79
|
+
<Box
|
|
80
|
+
as={motion.div}
|
|
81
|
+
ref={containerRef}
|
|
82
|
+
display="flex"
|
|
83
|
+
overflowX="scroll"
|
|
84
|
+
pb="medium"
|
|
85
|
+
gap={gap}
|
|
86
|
+
width="100%"
|
|
87
|
+
position="relative"
|
|
88
|
+
zIndex="2"
|
|
89
|
+
style={withMask ? { maskImage } : undefined}
|
|
90
|
+
>
|
|
91
|
+
{items.map((item, index) => (
|
|
92
|
+
<Box key={index}>{renderItem(item, index)}</Box>
|
|
93
|
+
))}
|
|
94
|
+
</Box>
|
|
95
|
+
</Box>
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// Gradient mask function
|
|
100
|
+
const left = `0%`;
|
|
101
|
+
const right = `100%`;
|
|
102
|
+
const leftInset = `20%`;
|
|
103
|
+
const rightInset = `80%`;
|
|
104
|
+
const transparent = `#0000`;
|
|
105
|
+
const opaque = `#000`;
|
|
106
|
+
|
|
107
|
+
function useScrollOverflowMask(scrollXProgress: MotionValue<number>) {
|
|
108
|
+
const maskImage = useMotionValue(
|
|
109
|
+
`linear-gradient(90deg, ${opaque}, ${opaque} ${left}, ${opaque} ${rightInset}, ${transparent})`
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
useMotionValueEvent(scrollXProgress, "change", (value) => {
|
|
113
|
+
if (value === 0) {
|
|
114
|
+
animate(
|
|
115
|
+
maskImage,
|
|
116
|
+
`linear-gradient(90deg, ${opaque}, ${opaque} ${left}, ${opaque} ${rightInset}, ${transparent})`
|
|
117
|
+
);
|
|
118
|
+
} else if (value === 1) {
|
|
119
|
+
animate(
|
|
120
|
+
maskImage,
|
|
121
|
+
`linear-gradient(90deg, ${transparent}, ${opaque} ${leftInset}, ${opaque} ${right}, ${opaque})`
|
|
122
|
+
);
|
|
123
|
+
} else if (
|
|
124
|
+
scrollXProgress.getPrevious() === 0 ||
|
|
125
|
+
scrollXProgress.getPrevious() === 1
|
|
126
|
+
) {
|
|
127
|
+
animate(
|
|
128
|
+
maskImage,
|
|
129
|
+
`linear-gradient(90deg, ${transparent}, ${opaque} ${leftInset}, ${opaque} ${rightInset}, ${transparent})`
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
return maskImage;
|
|
135
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { designSystemIcons, type DesignSystemIconName } from "@/design-system/icons";
|
|
4
|
+
import { Box } from "@/design-system/elements";
|
|
5
|
+
import { useMemo } from "react";
|
|
6
|
+
|
|
7
|
+
interface IconComponentProps {
|
|
8
|
+
icon: string;
|
|
9
|
+
width?: string | number;
|
|
10
|
+
height?: string | number;
|
|
11
|
+
color?: string;
|
|
12
|
+
size?: string | number | object;
|
|
13
|
+
[key: string]: any;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const Icon: React.FC<IconComponentProps> = ({
|
|
17
|
+
icon,
|
|
18
|
+
width = "24px",
|
|
19
|
+
height = "24px",
|
|
20
|
+
size = "24px",
|
|
21
|
+
color = "currentColor",
|
|
22
|
+
...props
|
|
23
|
+
}) => {
|
|
24
|
+
const LazyIcon = useMemo(
|
|
25
|
+
() => designSystemIcons[icon as DesignSystemIconName] ?? null,
|
|
26
|
+
[icon],
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
if (!LazyIcon) {
|
|
30
|
+
console.warn(`Icon ${icon} not found in design-system/icons`);
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<Box
|
|
36
|
+
as={LazyIcon}
|
|
37
|
+
width={size || width}
|
|
38
|
+
height={size || height}
|
|
39
|
+
color={color}
|
|
40
|
+
{...props}
|
|
41
|
+
/>
|
|
42
|
+
);
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export default Icon;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Text } from "@/design-system/elements";
|
|
2
|
+
|
|
3
|
+
type IndicatorProps = {
|
|
4
|
+
[key: string]: any;
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
export const Indicator = ({ children, ...props }: IndicatorProps) => {
|
|
8
|
+
return (
|
|
9
|
+
<Text
|
|
10
|
+
as="div"
|
|
11
|
+
display="flex"
|
|
12
|
+
alignItems="center"
|
|
13
|
+
justifyContent="center"
|
|
14
|
+
p="6px"
|
|
15
|
+
fontSize="0.75rem"
|
|
16
|
+
lineHeight="0.5rem"
|
|
17
|
+
fontWeight="700"
|
|
18
|
+
shape="pill"
|
|
19
|
+
// width="fit-content"
|
|
20
|
+
// height="fit-content"
|
|
21
|
+
flex="none"
|
|
22
|
+
{...props}
|
|
23
|
+
>
|
|
24
|
+
{children}
|
|
25
|
+
</Text>
|
|
26
|
+
);
|
|
27
|
+
};
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
import { IconPencil } from "@/design-system/icons"
|
|
3
|
+
import { Box, Text, Button, Field } from "@/design-system/elements"
|
|
4
|
+
import React, { useState, useRef, useEffect } from "react"
|
|
5
|
+
import Textarea from "react-textarea-autosize"
|
|
6
|
+
import Group from "../Group"
|
|
7
|
+
import {
|
|
8
|
+
MaskedField,
|
|
9
|
+
maskPresets,
|
|
10
|
+
type MaskPresetType,
|
|
11
|
+
} from "../MaskedField"
|
|
12
|
+
|
|
13
|
+
import { IconDCheck, IconERemove } from "@/design-system/icons"
|
|
14
|
+
|
|
15
|
+
type InlineEditorProps = {
|
|
16
|
+
id: string | number
|
|
17
|
+
initialText?: string | undefined | null
|
|
18
|
+
placeholder?: string
|
|
19
|
+
onSave: (id: string, text: string) => Promise<void>
|
|
20
|
+
label?: string | React.ReactNode
|
|
21
|
+
editLabel?: string
|
|
22
|
+
isDisabled?: boolean
|
|
23
|
+
fieldProps?: Record<string, any>
|
|
24
|
+
containerProps?: Record<string, any>
|
|
25
|
+
headerProps?: Record<string, any>
|
|
26
|
+
controlSize?: string
|
|
27
|
+
buttonConfig?: any
|
|
28
|
+
maskPreset?: string
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const InlineEditor: React.FC<InlineEditorProps> = ({
|
|
32
|
+
id = "",
|
|
33
|
+
initialText,
|
|
34
|
+
placeholder = "",
|
|
35
|
+
onSave,
|
|
36
|
+
label,
|
|
37
|
+
editLabel,
|
|
38
|
+
isDisabled = false,
|
|
39
|
+
fieldProps = {},
|
|
40
|
+
containerProps = {},
|
|
41
|
+
headerProps = {},
|
|
42
|
+
controlSize = "small",
|
|
43
|
+
buttonConfig = {
|
|
44
|
+
edit: {
|
|
45
|
+
variant: "ghost",
|
|
46
|
+
},
|
|
47
|
+
save: {
|
|
48
|
+
variant: "success",
|
|
49
|
+
},
|
|
50
|
+
cancel: {
|
|
51
|
+
variant: "default",
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
maskPreset,
|
|
55
|
+
}) => {
|
|
56
|
+
const [isEditing, setIsEditing] = useState<boolean>(false)
|
|
57
|
+
const [tempText, setTempText] = useState(initialText || "")
|
|
58
|
+
const [isLoading, setIsLoading] = useState<boolean>(false)
|
|
59
|
+
const textAreaRef = useRef<HTMLTextAreaElement>(null)
|
|
60
|
+
|
|
61
|
+
const handleEditClick = () => {
|
|
62
|
+
setTempText(initialText || "")
|
|
63
|
+
setIsEditing(true)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const handleSaveClick = async () => {
|
|
67
|
+
setIsLoading(true)
|
|
68
|
+
try {
|
|
69
|
+
await onSave(String(id), String(tempText))
|
|
70
|
+
setIsEditing(false)
|
|
71
|
+
} catch (error) {
|
|
72
|
+
console.error("Error saving text:", error)
|
|
73
|
+
} finally {
|
|
74
|
+
setIsLoading(false)
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const handleCancelClick = () => {
|
|
79
|
+
setIsEditing(false)
|
|
80
|
+
setTempText(initialText || "")
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const handleChange = (
|
|
84
|
+
e: React.ChangeEvent<HTMLTextAreaElement | HTMLInputElement>
|
|
85
|
+
) => {
|
|
86
|
+
setTempText(e.target.value)
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const validMaskPreset =
|
|
90
|
+
maskPreset && maskPreset in maskPresets
|
|
91
|
+
? (maskPreset as MaskPresetType)
|
|
92
|
+
: null
|
|
93
|
+
|
|
94
|
+
useEffect(() => {
|
|
95
|
+
if (isEditing && !validMaskPreset && textAreaRef.current) {
|
|
96
|
+
textAreaRef.current.focus()
|
|
97
|
+
}
|
|
98
|
+
setTempText(initialText || "")
|
|
99
|
+
}, [initialText, isEditing, validMaskPreset])
|
|
100
|
+
|
|
101
|
+
return (
|
|
102
|
+
<Text
|
|
103
|
+
as="div"
|
|
104
|
+
display={"flex"}
|
|
105
|
+
flexDirection={"column"}
|
|
106
|
+
gap="xxsmall"
|
|
107
|
+
py="xxsmall"
|
|
108
|
+
fontSize="s"
|
|
109
|
+
{...containerProps}
|
|
110
|
+
>
|
|
111
|
+
<Group
|
|
112
|
+
justifyContent={"space-between"}
|
|
113
|
+
width="100%"
|
|
114
|
+
py="xxsmall"
|
|
115
|
+
gap="xxsmall"
|
|
116
|
+
color="secondary"
|
|
117
|
+
{...headerProps}
|
|
118
|
+
>
|
|
119
|
+
{label && (
|
|
120
|
+
<Text fontWeight={600}>
|
|
121
|
+
{label} {isLoading && "(Wait...)"}
|
|
122
|
+
</Text>
|
|
123
|
+
)}
|
|
124
|
+
<Group flex="none" gap="xs" ml="auto">
|
|
125
|
+
{isEditing ? (
|
|
126
|
+
<>
|
|
127
|
+
<Button
|
|
128
|
+
$size={controlSize}
|
|
129
|
+
gap="xxsmall"
|
|
130
|
+
variant="ghost"
|
|
131
|
+
onClick={handleCancelClick}
|
|
132
|
+
{...buttonConfig.cancel}
|
|
133
|
+
>
|
|
134
|
+
<Box as={IconERemove} size="1em" />
|
|
135
|
+
</Button>
|
|
136
|
+
<Button
|
|
137
|
+
$size={controlSize}
|
|
138
|
+
gap="xxsmall"
|
|
139
|
+
variant="outline.dark"
|
|
140
|
+
onClick={handleSaveClick}
|
|
141
|
+
{...buttonConfig.save}
|
|
142
|
+
>
|
|
143
|
+
<Box as={IconDCheck} size="1.125em" />
|
|
144
|
+
</Button>
|
|
145
|
+
</>
|
|
146
|
+
) : (
|
|
147
|
+
<Button
|
|
148
|
+
variant="ghost"
|
|
149
|
+
disabled={isDisabled}
|
|
150
|
+
onClick={handleEditClick}
|
|
151
|
+
$size={controlSize}
|
|
152
|
+
{...buttonConfig.edit}
|
|
153
|
+
>
|
|
154
|
+
<Box as={IconPencil} size="1em" /> {editLabel && editLabel}
|
|
155
|
+
</Button>
|
|
156
|
+
)}
|
|
157
|
+
</Group>
|
|
158
|
+
</Group>
|
|
159
|
+
{isEditing ? (
|
|
160
|
+
<Box
|
|
161
|
+
minWidth="0"
|
|
162
|
+
bg={isEditing ? "transparent.brand.3" : "transparent"}
|
|
163
|
+
>
|
|
164
|
+
{validMaskPreset ? (
|
|
165
|
+
<MaskedField
|
|
166
|
+
autoFocus
|
|
167
|
+
preset={validMaskPreset}
|
|
168
|
+
value={tempText || ""}
|
|
169
|
+
onChange={handleChange}
|
|
170
|
+
placeholder={placeholder}
|
|
171
|
+
disabled={isDisabled}
|
|
172
|
+
variant="ghost"
|
|
173
|
+
$size=""
|
|
174
|
+
width="100%"
|
|
175
|
+
{...fieldProps}
|
|
176
|
+
/>
|
|
177
|
+
) : (
|
|
178
|
+
<Field
|
|
179
|
+
autoFocus
|
|
180
|
+
as={Textarea}
|
|
181
|
+
ref={textAreaRef}
|
|
182
|
+
placeholder={placeholder}
|
|
183
|
+
value={tempText}
|
|
184
|
+
onChange={handleChange}
|
|
185
|
+
disabled={isDisabled}
|
|
186
|
+
flex="auto"
|
|
187
|
+
variant="ghost"
|
|
188
|
+
$size=""
|
|
189
|
+
minHeight={"2.25rem"}
|
|
190
|
+
maxHeight={"25rem"}
|
|
191
|
+
overflowY={"scroll"}
|
|
192
|
+
//p="xxsmall"
|
|
193
|
+
width="100%"
|
|
194
|
+
style={{ resize: "none" }}
|
|
195
|
+
{...fieldProps}
|
|
196
|
+
/>
|
|
197
|
+
)}
|
|
198
|
+
</Box>
|
|
199
|
+
) : (
|
|
200
|
+
<Box minHeight={"auto"} border="1px solid transparent" minWidth="0">
|
|
201
|
+
{initialText ? (
|
|
202
|
+
<Text style={{ whiteSpace: "pre-wrap", overflowWrap: "anywhere" }}>
|
|
203
|
+
{initialText}
|
|
204
|
+
</Text>
|
|
205
|
+
) : (
|
|
206
|
+
<Text color="secondary" fontStyle="italic">
|
|
207
|
+
{placeholder}
|
|
208
|
+
</Text>
|
|
209
|
+
)}
|
|
210
|
+
</Box>
|
|
211
|
+
)}
|
|
212
|
+
</Text>
|
|
213
|
+
)
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
export default InlineEditor
|