@datalayer/primer-addons 0.3.0 → 0.3.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.
- package/lib/components/card/Card.d.ts +1 -1
- package/lib/components/card/Card.js +2 -2
- package/lib/components/card/stories/Card.stories.js +3 -3
- package/lib/components/closeable-flash/CloseableFlash.d.ts +1 -1
- package/lib/components/closeable-flash/CloseableFlash.js +2 -2
- package/lib/components/closeable-flash/stories/CloseableFlash.stories.js +2 -2
- package/lib/components/overlay/Overlay.d.ts +9 -5
- package/lib/components/overlay/Overlay.js +13 -9
- package/lib/components/overlay/stories/Overlay.stories.d.ts +4 -1
- package/lib/components/overlay/stories/Overlay.stories.js +12 -8
- package/lib/index.d.ts +0 -1
- package/lib/index.js +0 -1
- package/package.json +22 -22
- package/lib/components/toolbar/Toolbar.d.ts +0 -15
- package/lib/components/toolbar/Toolbar.js +0 -16
- package/lib/components/toolbar/stories/Toolbar.stories.d.ts +0 -14
- package/lib/components/toolbar/stories/Toolbar.stories.js +0 -36
|
@@ -8,7 +8,7 @@ export type CardProps = Omit<BoxProps, 'border'> & {
|
|
|
8
8
|
export type CardHeaderProps = {
|
|
9
9
|
title?: string;
|
|
10
10
|
description?: string;
|
|
11
|
-
|
|
11
|
+
leadingVisual?: React.ElementType;
|
|
12
12
|
action?: React.ReactNode;
|
|
13
13
|
};
|
|
14
14
|
export type CardImageProps = {
|
|
@@ -34,8 +34,8 @@ export const Card = (props) => {
|
|
|
34
34
|
}, ...otherProps, children: children }));
|
|
35
35
|
};
|
|
36
36
|
Card.Header = (props) => {
|
|
37
|
-
const { title, description,
|
|
38
|
-
return _jsxs(Box, { display: "flex", alignItems: "center", sx: { p: 3 }, children: [
|
|
37
|
+
const { title, description, leadingVisual, action } = props;
|
|
38
|
+
return _jsxs(Box, { display: "flex", alignItems: "center", sx: { p: 3 }, children: [leadingVisual && _jsx(Box, { sx: { mr: 3 }, children: _jsx(Octicon, { size: "medium", icon: leadingVisual }) }), _jsxs(Box, { sx: { flexGrow: 1 }, children: [_jsx(Text, { display: "block", children: title }), _jsx(Text, { display: "block", color: "fg.muted", children: description })] }), action && _jsx(Box, { children: action })] });
|
|
39
39
|
};
|
|
40
40
|
Card.Image = ({ url, image, svg, height }) => {
|
|
41
41
|
return (_jsxs(Box, { display: "block", width: "100%", height: `${height}px`, backgroundImage: `url(${url})`, sx: {
|
|
@@ -23,7 +23,7 @@ export const CardDay = {
|
|
|
23
23
|
border: true,
|
|
24
24
|
sx: { maxWidth: 360 }
|
|
25
25
|
},
|
|
26
|
-
render: (args) => _jsxs(ThemedCard, { ...args, colorMode: "day", children: [_jsx(Card.Header, {
|
|
26
|
+
render: (args) => _jsxs(ThemedCard, { ...args, colorMode: "day", children: [_jsx(Card.Header, { leadingVisual: ProjectIcon, title: "Shrimp and Chorizo Paella", description: "September 14, 2016", action: _jsx(IconButton, { "aria-label": "Menu", onClick: () => alert("Menu"), icon: ThreeBarsIcon }) }), _jsx(Card.Image, { height: 200, url: "https://images.unsplash.com/photo-1623961990059-28356e226a77?ixlib=rb-4.0.3&q=85&fm=jpg&crop=entropy&cs=srgb&dl=douglas-lopez-4B0cLMtJxWw-unsplash.jpg&w=640" }), _jsxs(Card.Content, { children: [_jsx(Text, { display: "block", fontSize: 22, children: "Paella" }), _jsx(Text, { color: "fg.muted", children: "This impressive paella is a perfect party dish and a fun meal to cook together with your guests. Add 1 cup of frozen peas along with the mussels, if you like." })] }), _jsx(Card.Actions, { children: _jsxs(ButtonGroup, { children: [_jsx(Button, { variant: 'invisible', onClick: () => alert("Share it on Socials!"), children: "Share" }), _jsx(Button, { variant: 'invisible', onClick: () => alert("Learn more about Paella"), children: "Learn More" })] }) })] })
|
|
27
27
|
};
|
|
28
28
|
const SVG = `
|
|
29
29
|
<svg viewBox="0 0 220 100" xmlns="http://www.w3.org/2000/svg">
|
|
@@ -38,7 +38,7 @@ export const CardDaySvg = {
|
|
|
38
38
|
border: true,
|
|
39
39
|
sx: { maxWidth: 360 }
|
|
40
40
|
},
|
|
41
|
-
render: (args) => _jsxs(ThemedCard, { ...args, colorMode: "day", children: [_jsx(Card.Header, {
|
|
41
|
+
render: (args) => _jsxs(ThemedCard, { ...args, colorMode: "day", children: [_jsx(Card.Header, { leadingVisual: ProjectIcon, title: "Shrimp and Chorizo Paella", description: "September 14, 2016", action: _jsx(IconButton, { "aria-label": "Menu", onClick: () => alert("Menu"), icon: ThreeBarsIcon }) }), _jsx(Card.Image, { height: 200, svg: SVG }), _jsxs(Card.Content, { children: [_jsx(Text, { display: "block", fontSize: 22, children: "Paella" }), _jsx(Text, { color: "fg.muted", children: "This impressive paella is a perfect party dish and a fun meal to cook together with your guests. Add 1 cup of frozen peas along with the mussels, if you like." })] }), _jsx(Card.Actions, { children: _jsxs(ButtonGroup, { children: [_jsx(Button, { variant: 'invisible', onClick: () => alert("Share it on Socials!"), children: "Share" }), _jsx(Button, { variant: 'invisible', onClick: () => alert("Learn more about Paella"), children: "Learn More" })] }) })] })
|
|
42
42
|
};
|
|
43
43
|
export const CardNight = {
|
|
44
44
|
args: {
|
|
@@ -47,5 +47,5 @@ export const CardNight = {
|
|
|
47
47
|
border: true,
|
|
48
48
|
sx: { maxWidth: 360 }
|
|
49
49
|
},
|
|
50
|
-
render: (args) => _jsxs(ThemedCard, { ...args, colorMode: "night", children: [_jsx(Card.Header, {
|
|
50
|
+
render: (args) => _jsxs(ThemedCard, { ...args, colorMode: "night", children: [_jsx(Card.Header, { leadingVisual: ProjectIcon, title: "Shrimp and Chorizo Paella", description: "September 14, 2016", action: _jsx(IconButton, { "aria-label": "Menu", onClick: () => alert("Menu"), icon: ThreeBarsIcon }) }), _jsx(Card.Image, { height: 200, url: "https://images.unsplash.com/photo-1623961990059-28356e226a77?ixlib=rb-4.0.3&q=85&fm=jpg&crop=entropy&cs=srgb&dl=douglas-lopez-4B0cLMtJxWw-unsplash.jpg&w=640" }), _jsxs(Card.Content, { children: [_jsx(Text, { display: "block", fontSize: 22, children: "Paella" }), _jsx(Text, { color: "fg.muted", children: "This impressive paella is a perfect party dish and a fun meal to cook together with your guests. Add 1 cup of frozen peas along with the mussels, if you like." })] }), _jsx(Card.Actions, { children: _jsxs(ButtonGroup, { children: [_jsx(Button, { variant: 'invisible', onClick: () => alert("Share it on Socials!"), children: "Share" }), _jsx(Button, { variant: 'invisible', onClick: () => alert("Learn more about Paella"), children: "Learn More" })] }) })] })
|
|
51
51
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { FC } from "react";
|
|
2
2
|
import { FlashProps } from "@primer/react";
|
|
3
3
|
export type CloseableFlashProps = FlashProps & {
|
|
4
|
-
|
|
4
|
+
leadingVisual?: React.ElementType;
|
|
5
5
|
onClose?: () => void;
|
|
6
6
|
};
|
|
7
7
|
export declare const CloseableFlash: FC<CloseableFlashProps>;
|
|
@@ -3,7 +3,7 @@ import { useState } from "react";
|
|
|
3
3
|
import { Box, Flash, Octicon, Text } from "@primer/react";
|
|
4
4
|
import { XIcon } from "@primer/octicons-react";
|
|
5
5
|
export const CloseableFlash = (props) => {
|
|
6
|
-
const {
|
|
6
|
+
const { leadingVisual, variant, onClose, ...otherProps } = props;
|
|
7
7
|
const [isVisible, setIsVisible] = useState(true);
|
|
8
8
|
const handleClose = () => {
|
|
9
9
|
if (onClose) {
|
|
@@ -14,5 +14,5 @@ export const CloseableFlash = (props) => {
|
|
|
14
14
|
if (!isVisible) {
|
|
15
15
|
return null;
|
|
16
16
|
}
|
|
17
|
-
return (_jsx(Flash, { variant: variant, ...otherProps, children: _jsxs(Box, { display: "flex", justifyContent: "space-between", alignItems: "center", children: [_jsxs(Box, { sx: { flexGrow: 1 }, children: [
|
|
17
|
+
return (_jsx(Flash, { variant: variant, ...otherProps, children: _jsxs(Box, { display: "flex", justifyContent: "space-between", alignItems: "center", children: [_jsxs(Box, { sx: { flexGrow: 1 }, children: [leadingVisual && _jsx(Octicon, { icon: leadingVisual }), _jsx(Text, { color: `${variant === "default" ? "accent" : (variant === "warning" ? "attention" : variant)}.fg`, children: props.children })] }), _jsx(Box, { onClick: handleClose, sx: { cursor: "pointer" }, children: _jsx(XIcon, { size: 20 }) })] }) }));
|
|
18
18
|
};
|
|
@@ -19,7 +19,7 @@ const ThemedCloseableFlash = (props) => {
|
|
|
19
19
|
export const CloseableFlashDay = {
|
|
20
20
|
args: {
|
|
21
21
|
variant: "success",
|
|
22
|
-
|
|
22
|
+
leadingVisual: CheckIcon,
|
|
23
23
|
onClose: () => window.alert("closed")
|
|
24
24
|
},
|
|
25
25
|
render: (args) => _jsx(ThemedCloseableFlash, { ...args, colorMode: "day", children: "Success Flash" })
|
|
@@ -27,7 +27,7 @@ export const CloseableFlashDay = {
|
|
|
27
27
|
export const CloseableFlashNight = {
|
|
28
28
|
args: {
|
|
29
29
|
variant: "success",
|
|
30
|
-
|
|
30
|
+
leadingVisual: CheckIcon,
|
|
31
31
|
onClose: () => window.alert("closed")
|
|
32
32
|
},
|
|
33
33
|
render: (args) => _jsx(ThemedCloseableFlash, { ...args, colorMode: "night", children: "Success Flash" })
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
export interface OverlayProps {
|
|
3
|
+
closeButtonRef?: React.RefObject<HTMLButtonElement>;
|
|
4
|
+
content: JSX.Element;
|
|
3
5
|
direction: 'left' | 'right';
|
|
6
|
+
headingRef?: React.RefObject<HTMLHeadingElement>;
|
|
4
7
|
isOpen?: boolean;
|
|
8
|
+
openButtonRef?: React.RefObject<HTMLButtonElement>;
|
|
5
9
|
setIsOpen?: React.Dispatch<React.SetStateAction<boolean>>;
|
|
6
|
-
|
|
7
|
-
buttonRef?: React.RefObject<HTMLButtonElement>;
|
|
8
|
-
confirmButtonRef?: React.RefObject<HTMLButtonElement>;
|
|
9
|
-
headingRef?: React.RefObject<HTMLHeadingElement>;
|
|
10
|
+
width: number | string;
|
|
10
11
|
}
|
|
11
|
-
export declare const Overlay:
|
|
12
|
+
export declare const Overlay: {
|
|
13
|
+
(props: OverlayProps): import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
defaultProps: Partial<OverlayProps>;
|
|
15
|
+
};
|
|
12
16
|
export default Overlay;
|
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { useEffect, useState } from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import { Box, IconButton, Overlay as PrimerOverlay } from "@primer/react";
|
|
4
|
+
import { XIcon } from "@primer/octicons-react";
|
|
4
5
|
const PrimerAddonOverlay = (props) => {
|
|
5
|
-
const {
|
|
6
|
+
const { closeButtonRef, content, headingRef, isOpen, openButtonRef, setIsOpen, width, } = props;
|
|
6
7
|
const [direction, _] = useState(props.direction);
|
|
7
8
|
const [top, setTop] = useState(0);
|
|
8
9
|
useEffect(() => {
|
|
9
10
|
setTop(headingRef?.current?.getBoundingClientRect().bottom ?? 0);
|
|
10
11
|
}, [headingRef]);
|
|
11
12
|
const closeOverlay = () => setIsOpen(false);
|
|
12
|
-
return (
|
|
13
|
+
return (closeButtonRef && openButtonRef ?
|
|
13
14
|
_jsx(_Fragment, { children: isOpen ?
|
|
14
15
|
direction === 'left' ?
|
|
15
|
-
_jsx(PrimerOverlay, { initialFocusRef:
|
|
16
|
+
_jsx(PrimerOverlay, { initialFocusRef: closeButtonRef, returnFocusRef: openButtonRef, ignoreClickRefs: [openButtonRef], onEscape: closeOverlay, onClickOutside: closeOverlay, width: "auto", anchorSide: "inside-right", top: top, children: _jsxs(Box, { sx: {
|
|
16
17
|
/* We need to remove the padding */
|
|
17
18
|
height: `calc(100vh - ${top}px - 8px)`,
|
|
18
|
-
width
|
|
19
|
+
width,
|
|
19
20
|
display: 'flex',
|
|
20
21
|
flexDirection: 'column',
|
|
21
22
|
alignItems: 'center',
|
|
@@ -24,12 +25,12 @@ const PrimerAddonOverlay = (props) => {
|
|
|
24
25
|
display: 'flex',
|
|
25
26
|
justifyContent: 'right',
|
|
26
27
|
width: '100%'
|
|
27
|
-
}, children: _jsx(
|
|
28
|
+
}, children: _jsx(IconButton, { variant: 'invisible', ref: closeButtonRef, onClick: closeOverlay, icon: XIcon, "aria-labelledby": "close" }) }), content] }) })
|
|
28
29
|
:
|
|
29
|
-
_jsx(PrimerOverlay, { initialFocusRef:
|
|
30
|
+
_jsx(PrimerOverlay, { initialFocusRef: closeButtonRef, returnFocusRef: openButtonRef, ignoreClickRefs: [openButtonRef], onEscape: closeOverlay, onClickOutside: closeOverlay, width: "auto", anchorSide: 'inside-left', right: 0, position: "fixed", top: top, children: _jsxs(Box, { sx: {
|
|
30
31
|
/* We need to remove the padding */
|
|
31
32
|
height: `calc(100vh - ${top}px - 8px)`,
|
|
32
|
-
width
|
|
33
|
+
width,
|
|
33
34
|
display: 'flex',
|
|
34
35
|
flexDirection: 'column',
|
|
35
36
|
alignItems: 'center',
|
|
@@ -38,7 +39,7 @@ const PrimerAddonOverlay = (props) => {
|
|
|
38
39
|
display: 'flex',
|
|
39
40
|
justifyContent: 'right',
|
|
40
41
|
width: '100%'
|
|
41
|
-
}, children: _jsx(
|
|
42
|
+
}, children: _jsx(IconButton, { variant: 'invisible', ref: closeButtonRef, onClick: closeOverlay, icon: XIcon, "aria-labelledby": "close" }) }), content] }) })
|
|
42
43
|
: _jsx(_Fragment, {}) })
|
|
43
44
|
:
|
|
44
45
|
_jsx(_Fragment, {}));
|
|
@@ -46,4 +47,7 @@ const PrimerAddonOverlay = (props) => {
|
|
|
46
47
|
export const Overlay = (props) => {
|
|
47
48
|
return (_jsx(PrimerAddonOverlay, { ...props }));
|
|
48
49
|
};
|
|
50
|
+
Overlay.defaultProps = {
|
|
51
|
+
width: '500px',
|
|
52
|
+
};
|
|
49
53
|
export default Overlay;
|
|
@@ -2,7 +2,10 @@ import type { StoryObj } from '@storybook/react';
|
|
|
2
2
|
import { OverlayProps } from './../Overlay';
|
|
3
3
|
declare const meta: {
|
|
4
4
|
title: string;
|
|
5
|
-
component:
|
|
5
|
+
component: {
|
|
6
|
+
(props: OverlayProps): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
defaultProps: Partial<OverlayProps>;
|
|
8
|
+
};
|
|
6
9
|
tags: string[];
|
|
7
10
|
parameters: {
|
|
8
11
|
layout: string;
|
|
@@ -15,38 +15,42 @@ const meta = {
|
|
|
15
15
|
export default meta;
|
|
16
16
|
const ThemedOverlay = (props) => {
|
|
17
17
|
const [isOpen, setIsOpen] = useState(false);
|
|
18
|
-
const
|
|
19
|
-
const
|
|
18
|
+
const openButtonRef = useRef(null);
|
|
19
|
+
const closeButtonRef = useRef(null);
|
|
20
20
|
const headingRef = useRef(null);
|
|
21
|
-
return (_jsx(ThemeProvider, { colorMode: props.colorMode, children: _jsx(BaseStyles, { children: _jsx(Box, { p: 3, bg: "canvas.default", children: _jsxs(Box, { children: [_jsx(Box, { sx: { width: '100%', bg: 'darkgray' }, children: _jsx(Heading, { ref: headingRef, children: "Header" }) }), _jsxs(Box, { children: [_jsx(Button, { ref:
|
|
21
|
+
return (_jsx(ThemeProvider, { colorMode: props.colorMode, children: _jsx(BaseStyles, { children: _jsx(Box, { p: 3, bg: "canvas.default", children: _jsxs(Box, { children: [_jsx(Box, { sx: { width: '100%', bg: 'darkgray' }, children: _jsx(Heading, { ref: headingRef, children: "Header" }) }), _jsxs(Box, { children: [_jsx(Button, { ref: openButtonRef, onClick: () => {
|
|
22
22
|
setIsOpen(!isOpen);
|
|
23
|
-
}, children: "Open overlay" }), _jsx(Overlay, { ...props, isOpen: isOpen, setIsOpen: setIsOpen,
|
|
23
|
+
}, children: "Open overlay" }), _jsx(Overlay, { ...props, isOpen: isOpen, setIsOpen: setIsOpen, openButtonRef: openButtonRef, closeButtonRef: closeButtonRef, headingRef: props.direction === 'left' ? headingRef : undefined })] })] }) }) }) }));
|
|
24
24
|
};
|
|
25
25
|
export const OverlayDayLeft = {
|
|
26
26
|
args: {
|
|
27
|
-
direction: "left",
|
|
28
27
|
content: _jsx(Text, { children: "\uD83D\uDC48 Look, left aligned, no heading." }),
|
|
28
|
+
direction: "left",
|
|
29
|
+
width: '500px',
|
|
29
30
|
},
|
|
30
31
|
render: (args) => _jsx(ThemedOverlay, { ...args, colorMode: "day" })
|
|
31
32
|
};
|
|
32
33
|
export const OverlayDayRight = {
|
|
33
34
|
args: {
|
|
34
|
-
direction: "right",
|
|
35
35
|
content: _jsx(Text, { children: "Look, right aligned, on heading \uD83D\uDC49" }),
|
|
36
|
+
direction: "right",
|
|
37
|
+
width: '500px',
|
|
36
38
|
},
|
|
37
39
|
render: (args) => _jsx(ThemedOverlay, { ...args, colorMode: "day" })
|
|
38
40
|
};
|
|
39
41
|
export const OverlayNightLeft = {
|
|
40
42
|
args: {
|
|
41
|
-
direction: "left",
|
|
42
43
|
content: _jsx(Text, { children: "\uD83D\uDC48 Look, left aligned, no heading." }),
|
|
44
|
+
direction: "left",
|
|
45
|
+
width: '300px',
|
|
43
46
|
},
|
|
44
47
|
render: (args) => _jsx(ThemedOverlay, { ...args, colorMode: "night" })
|
|
45
48
|
};
|
|
46
49
|
export const OverlayNightRight = {
|
|
47
50
|
args: {
|
|
51
|
+
content: _jsx(Text, { children: "Look, right aligned, on heading \uD83D\uDC49" }),
|
|
48
52
|
direction: "right",
|
|
49
|
-
|
|
53
|
+
width: '300px',
|
|
50
54
|
},
|
|
51
55
|
render: (args) => _jsx(ThemedOverlay, { ...args, colorMode: "night" })
|
|
52
56
|
};
|
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@datalayer/primer-addons",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"license": "BSD-3-Clause",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"dev": "vite",
|
|
@@ -23,35 +23,35 @@
|
|
|
23
23
|
},
|
|
24
24
|
"homepage": "https://primer-addons.datalayer.tech",
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@datalayer/icons-react": "0.3.
|
|
27
|
-
"@primer/octicons-react": "19.6.0",
|
|
28
|
-
"@primer/
|
|
29
|
-
"react": "
|
|
30
|
-
"react
|
|
31
|
-
"react-
|
|
32
|
-
"
|
|
26
|
+
"@datalayer/icons-react": "^0.3.2",
|
|
27
|
+
"@primer/octicons-react": "^19.6.0",
|
|
28
|
+
"@primer/primitives": "^8.2.3",
|
|
29
|
+
"@primer/react": "^36.25.0",
|
|
30
|
+
"react": "^18.2.0",
|
|
31
|
+
"react-dom": "^18.2.0",
|
|
32
|
+
"react-loading-skeleton": "^3.3.1",
|
|
33
|
+
"styled-components": "^5.3.10"
|
|
33
34
|
},
|
|
34
35
|
"devDependencies": {
|
|
35
|
-
"@storybook/addon-essentials": "^
|
|
36
|
-
"@storybook/addon-interactions": "^
|
|
37
|
-
"@storybook/addon-links": "^
|
|
38
|
-
"@storybook/blocks": "^
|
|
39
|
-
"@storybook/react": "^
|
|
40
|
-
"@storybook/react-vite": "^
|
|
41
|
-
"@storybook/testing-library": "^0.
|
|
42
|
-
"@types/react": "18.2.12",
|
|
43
|
-
"@types/react-dom": "18.2.5",
|
|
36
|
+
"@storybook/addon-essentials": "^8.0.10",
|
|
37
|
+
"@storybook/addon-interactions": "^8.0.10",
|
|
38
|
+
"@storybook/addon-links": "^8.0.10",
|
|
39
|
+
"@storybook/blocks": "^8.0.10",
|
|
40
|
+
"@storybook/react": "^8.0.10",
|
|
41
|
+
"@storybook/react-vite": "^8.0.10",
|
|
42
|
+
"@storybook/testing-library": "^0.2.2",
|
|
43
|
+
"@types/react": "^18.2.12",
|
|
44
|
+
"@types/react-dom": "^18.2.5",
|
|
44
45
|
"@typescript-eslint/eslint-plugin": "^5.57.1",
|
|
45
46
|
"@typescript-eslint/parser": "^5.57.1",
|
|
46
|
-
"@vitejs/plugin-react": "4.2.1",
|
|
47
|
+
"@vitejs/plugin-react": "^4.2.1",
|
|
47
48
|
"eslint": "^8.38.0",
|
|
48
49
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
49
50
|
"eslint-plugin-react-refresh": "^0.3.4",
|
|
50
51
|
"eslint-plugin-storybook": "^0.6.12",
|
|
51
52
|
"prop-types": "^15.8.1",
|
|
52
|
-
"storybook": "^
|
|
53
|
+
"storybook": "^8.0.10",
|
|
53
54
|
"typescript": "^5.0.2",
|
|
54
|
-
"vite": "^
|
|
55
|
-
}
|
|
56
|
-
"packageManager": "yarn@3.5.0"
|
|
55
|
+
"vite": "^5.2.7"
|
|
56
|
+
}
|
|
57
57
|
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
export interface ToolbarProps {
|
|
3
|
-
align?: "center" | "flex-start" | "flex-end" | "space-evenly" | "space-around" | "space-between";
|
|
4
|
-
gap?: string;
|
|
5
|
-
height?: string;
|
|
6
|
-
padding?: string;
|
|
7
|
-
heading?: React.ReactNode;
|
|
8
|
-
backgroundColor?: string;
|
|
9
|
-
borderBottomHeight?: number;
|
|
10
|
-
borderBottomColor?: string;
|
|
11
|
-
border?: boolean;
|
|
12
|
-
children: React.ReactNode | React.ReactNode[];
|
|
13
|
-
}
|
|
14
|
-
export declare const Toolbar: ({ align, height, gap, padding, heading, backgroundColor, borderBottomHeight, borderBottomColor, border, children, }: ToolbarProps) => import("react/jsx-runtime").JSX.Element;
|
|
15
|
-
export default Toolbar;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Box } from "@primer/react";
|
|
3
|
-
export const Toolbar = ({ align = "flex-start", height = "5vh", gap = "0.1rem", padding, heading, backgroundColor, borderBottomHeight = 1, borderBottomColor, border = false, children, }) => {
|
|
4
|
-
return (_jsxs(Box, { display: "flex", alignItems: "center", sx: {
|
|
5
|
-
backgroundColor: backgroundColor ? backgroundColor : "pageHeaderBg",
|
|
6
|
-
height: height,
|
|
7
|
-
width: "100%",
|
|
8
|
-
padding: padding,
|
|
9
|
-
borderBottomWidth: borderBottomHeight,
|
|
10
|
-
borderBottomStyle: border ? "solid" : "none",
|
|
11
|
-
borderColor: borderBottomColor ? borderBottomColor : "border.default",
|
|
12
|
-
}, children: [_jsx(Box, { display: "flex", children: heading != null && heading != undefined ? heading : _jsx(_Fragment, {}) }), _jsx(Box, { display: "flex", flexGrow: 1, alignItems: "center", justifyContent: align, sx: {
|
|
13
|
-
gap: gap,
|
|
14
|
-
}, children: children })] }));
|
|
15
|
-
};
|
|
16
|
-
export default Toolbar;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { StoryObj } from '@storybook/react';
|
|
2
|
-
import { ToolbarProps } from '../../../index';
|
|
3
|
-
declare const meta: {
|
|
4
|
-
title: string;
|
|
5
|
-
component: ({ align, height, gap, padding, heading, backgroundColor, borderBottomHeight, borderBottomColor, border, children, }: ToolbarProps) => import("react/jsx-runtime").JSX.Element;
|
|
6
|
-
tags: string[];
|
|
7
|
-
parameters: {
|
|
8
|
-
layout: string;
|
|
9
|
-
};
|
|
10
|
-
};
|
|
11
|
-
export default meta;
|
|
12
|
-
type Story = StoryObj<typeof meta>;
|
|
13
|
-
export declare const ToolbarDay: Story;
|
|
14
|
-
export declare const ToolbarNight: Story;
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { ThemeProvider, BaseStyles, Box, Text, IconButton, } from "@primer/react";
|
|
3
|
-
import { SearchIcon, ThreeBarsIcon, GearIcon } from "@primer/octicons-react";
|
|
4
|
-
import { Toolbar } from '../../../index';
|
|
5
|
-
const meta = {
|
|
6
|
-
title: 'Components/Toolbar',
|
|
7
|
-
component: Toolbar,
|
|
8
|
-
// This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/react/writing-docs/autodocs
|
|
9
|
-
tags: ['autodocs'],
|
|
10
|
-
parameters: {
|
|
11
|
-
// More on how to position stories at: https://storybook.js.org/docs/react/configure/story-layout
|
|
12
|
-
layout: 'fullscreen',
|
|
13
|
-
},
|
|
14
|
-
};
|
|
15
|
-
export default meta;
|
|
16
|
-
const ThemedToolbar = (props) => _jsx(ThemeProvider, { colorMode: props.colorMode, children: _jsx(BaseStyles, { children: _jsxs(Toolbar, { ...props, heading: _jsxs(Box, { display: "flex", alignItems: "center", sx: { gap: "0.5rem" }, children: [_jsx(IconButton, { "aria-label": "Search", icon: ThreeBarsIcon, size: "small", variant: "invisible" }), _jsx(Text, { children: "Datalayer Toolbar" })] }), children: [_jsx(IconButton, { "aria-label": "Search", icon: SearchIcon, size: "small" }), _jsx(Text, { children: "Action1" }), _jsx(Text, { children: "Action2" }), _jsx(Text, { children: "Action3" }), _jsx(IconButton, { "aria-label": "Search", icon: GearIcon, size: "small", variant: "invisible" })] }) }) });
|
|
17
|
-
export const ToolbarDay = {
|
|
18
|
-
args: {
|
|
19
|
-
align: "flex-end",
|
|
20
|
-
border: true,
|
|
21
|
-
gap: "1rem",
|
|
22
|
-
padding: "0 1rem",
|
|
23
|
-
children: [],
|
|
24
|
-
},
|
|
25
|
-
render: (args) => _jsx(ThemedToolbar, { ...args, colorMode: "day" })
|
|
26
|
-
};
|
|
27
|
-
export const ToolbarNight = {
|
|
28
|
-
args: {
|
|
29
|
-
align: "flex-end",
|
|
30
|
-
border: true,
|
|
31
|
-
gap: "1rem",
|
|
32
|
-
padding: "0 1rem",
|
|
33
|
-
children: [],
|
|
34
|
-
},
|
|
35
|
-
render: (args) => _jsx(ThemedToolbar, { ...args, colorMode: "night" })
|
|
36
|
-
};
|