@datalayer/primer-addons 0.0.12 → 0.0.14
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 +23 -2
- package/lib/App.d.ts +1 -2
- package/lib/components/card/Card.d.ts +25 -1
- package/lib/components/card/Card.js +29 -13
- package/lib/components/card/stories/Card.stories.d.ts +21 -0
- package/lib/components/card/stories/Card.stories.js +51 -0
- package/lib/components/closeable-flash/CloseableFlash.d.ts +4 -5
- package/lib/components/closeable-flash/CloseableFlash.js +4 -2
- package/lib/components/closeable-flash/stories/CloseableFlash.stories.d.ts +15 -0
- package/lib/components/closeable-flash/stories/CloseableFlash.stories.js +34 -0
- package/lib/components/slider/Slider.d.ts +1 -2
- package/lib/components/slider/stories/Slider.stories.d.ts +14 -0
- package/lib/components/slider/stories/Slider.stories.js +47 -0
- package/lib/components/toolbar/Toolbar.d.ts +1 -1
- package/lib/components/toolbar/stories/Toolbar.stories.d.ts +14 -0
- package/lib/components/toolbar/stories/Toolbar.stories.js +36 -0
- package/package.json +12 -5
- package/lib/components/closeableflash/CloseableFlash.d.ts +0 -9
- package/lib/components/closeableflash/CloseableFlash.js +0 -16
package/README.md
CHANGED
|
@@ -14,8 +14,9 @@ This project has been [shared in a discussion](https://github.com/primer/react/d
|
|
|
14
14
|
|
|
15
15
|
## Current Addons
|
|
16
16
|
|
|
17
|
-
- [ ]
|
|
18
|
-
- [
|
|
17
|
+
- [ ] Backdrop
|
|
18
|
+
- [x] Card
|
|
19
|
+
- [x] ClosableFlash
|
|
19
20
|
- [ ] MasonryBox
|
|
20
21
|
- [ ] Skeleton
|
|
21
22
|
- [x] Slider
|
|
@@ -25,6 +26,26 @@ This project has been [shared in a discussion](https://github.com/primer/react/d
|
|
|
25
26
|
<img alt="Primer React Addons" src="https://datalayer-examples.s3.amazonaws.com/primer-addons-example.png" />
|
|
26
27
|
</div>
|
|
27
28
|
|
|
29
|
+
## Develop
|
|
30
|
+
|
|
31
|
+
Install the dependencies.
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
yarn
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Start the storybook.
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
yarn storybook
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Start the playground.
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
yarn dev
|
|
47
|
+
```
|
|
48
|
+
|
|
28
49
|
## About Primer Design
|
|
29
50
|
|
|
30
51
|
- Design system https://primer.style
|
package/lib/App.d.ts
CHANGED
|
@@ -1,8 +1,32 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { BoxProps } from "@primer/react";
|
|
3
|
+
import { Icon } from "@primer/octicons-react";
|
|
3
4
|
export type CardProps = Omit<BoxProps, 'border'> & {
|
|
4
5
|
rounded?: 'small' | 'medium' | 'large' | 'full' | number;
|
|
5
6
|
border?: boolean;
|
|
6
7
|
shadow?: 'small' | 'medium' | 'large' | 'extraLarge';
|
|
7
8
|
};
|
|
8
|
-
export
|
|
9
|
+
export type CardHeaderProps = {
|
|
10
|
+
title?: string;
|
|
11
|
+
description?: string;
|
|
12
|
+
leadingIcon?: Icon;
|
|
13
|
+
action?: React.ReactNode;
|
|
14
|
+
};
|
|
15
|
+
export type CardImageProps = {
|
|
16
|
+
url?: string;
|
|
17
|
+
image?: string;
|
|
18
|
+
svg?: string;
|
|
19
|
+
height: number;
|
|
20
|
+
};
|
|
21
|
+
export type CardContentProps = {
|
|
22
|
+
children: React.ReactNode;
|
|
23
|
+
};
|
|
24
|
+
export type CardActionsProps = {
|
|
25
|
+
children: React.ReactNode;
|
|
26
|
+
};
|
|
27
|
+
export declare const Card: React.FC<CardProps> & {
|
|
28
|
+
Header: React.FC<CardHeaderProps>;
|
|
29
|
+
Image: React.FC<CardImageProps>;
|
|
30
|
+
Content: React.FC<CardContentProps>;
|
|
31
|
+
Actions: React.FC<CardActionsProps>;
|
|
32
|
+
};
|
|
@@ -1,23 +1,21 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { Box } from "@primer/react";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Box, StyledOcticon, Text } from "@primer/react";
|
|
3
3
|
const roundedVals = {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
small: "3px",
|
|
5
|
+
medium: "6px",
|
|
6
|
+
large: "12px",
|
|
7
|
+
full: "100vh",
|
|
8
8
|
};
|
|
9
9
|
const shadowVals = {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
small: '0 1px 0 rgba(31,35,40,0.04)',
|
|
11
|
+
medium: '0 3px 6px rgba(140,149,159,0.15)',
|
|
12
|
+
large: '0 8px 24px rgba(140,149,159,0.2)',
|
|
13
|
+
extraLarge: '0 12px 28px rgba(140,149,159,0.3)',
|
|
14
14
|
};
|
|
15
15
|
export const Card = (props) => {
|
|
16
16
|
const { sx, rounded, border, shadow, children, ...otherProps } = props;
|
|
17
17
|
return (_jsx(Box, { sx: {
|
|
18
18
|
...(sx ? sx : undefined),
|
|
19
|
-
display: 'flex',
|
|
20
|
-
alignItems: 'center',
|
|
21
19
|
...(rounded ? typeof rounded === "string" ? {
|
|
22
20
|
borderRadius: roundedVals[rounded]
|
|
23
21
|
} : {
|
|
@@ -33,5 +31,23 @@ export const Card = (props) => {
|
|
|
33
31
|
} : {
|
|
34
32
|
boxShadow: shadowVals['small']
|
|
35
33
|
})
|
|
36
|
-
},
|
|
34
|
+
}, ...otherProps, children: children }));
|
|
35
|
+
};
|
|
36
|
+
Card.Header = (props) => {
|
|
37
|
+
const { title, description, leadingIcon, action } = props;
|
|
38
|
+
return _jsxs(Box, { display: "flex", alignItems: "center", sx: { p: 3 }, children: [leadingIcon && _jsx(Box, { sx: { mr: 3 }, children: _jsx(StyledOcticon, { size: "medium", icon: leadingIcon }) }), _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
|
+
};
|
|
40
|
+
Card.Image = ({ url, image, svg, height }) => {
|
|
41
|
+
return (_jsxs(Box, { display: "block", width: "100%", height: `${height}px`, backgroundImage: `url(${url})`, sx: {
|
|
42
|
+
backgroundSize: "cover",
|
|
43
|
+
backgroundRepeat: "no-repeat",
|
|
44
|
+
backgroundPosition: "center",
|
|
45
|
+
objectFit: "cover"
|
|
46
|
+
}, children: [image && _jsx("img", { src: image, style: { maxHeight: `${height}px` } }), svg && _jsx("img", { src: `data:image/svg+xml;utf8,${svg}`, style: { maxHeight: height } })] }));
|
|
47
|
+
};
|
|
48
|
+
Card.Content = ({ children }) => {
|
|
49
|
+
return (_jsx(Box, { display: "block", sx: { p: 3 }, children: children }));
|
|
50
|
+
};
|
|
51
|
+
Card.Actions = ({ children }) => {
|
|
52
|
+
return _jsx(Box, { display: "block", sx: { p: 3 }, children: children });
|
|
37
53
|
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { StoryObj } from '@storybook/react';
|
|
3
|
+
import { CardProps } from '../../../index';
|
|
4
|
+
declare const meta: {
|
|
5
|
+
title: string;
|
|
6
|
+
component: import("react").FC<CardProps> & {
|
|
7
|
+
Header: import("react").FC<import("../Card").CardHeaderProps>;
|
|
8
|
+
Image: import("react").FC<import("../Card").CardImageProps>;
|
|
9
|
+
Content: import("react").FC<import("../Card").CardContentProps>;
|
|
10
|
+
Actions: import("react").FC<import("../Card").CardActionsProps>;
|
|
11
|
+
};
|
|
12
|
+
tags: string[];
|
|
13
|
+
parameters: {
|
|
14
|
+
layout: string;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
export default meta;
|
|
18
|
+
type Story = StoryObj<typeof meta>;
|
|
19
|
+
export declare const CardDay: Story;
|
|
20
|
+
export declare const CardDaySvg: Story;
|
|
21
|
+
export declare const CardNight: Story;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { ThemeProvider, BaseStyles, Box, Button, IconButton, Text, ButtonGroup, } from "@primer/react";
|
|
3
|
+
import { Card } from '../../../index';
|
|
4
|
+
import { ProjectIcon, ThreeBarsIcon } from '@primer/octicons-react';
|
|
5
|
+
const meta = {
|
|
6
|
+
title: 'Components/Card',
|
|
7
|
+
component: Card,
|
|
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 ThemedCard = (props) => {
|
|
17
|
+
return (_jsx(ThemeProvider, { colorMode: props.colorMode, children: _jsx(BaseStyles, { children: _jsx(Box, { p: 3, bg: "canvas.default", children: _jsx(Box, { children: _jsx(Card, { ...props }) }) }) }) }));
|
|
18
|
+
};
|
|
19
|
+
export const CardDay = {
|
|
20
|
+
args: {
|
|
21
|
+
rounded: "medium",
|
|
22
|
+
shadow: "medium",
|
|
23
|
+
border: true,
|
|
24
|
+
sx: { maxWidth: 360 }
|
|
25
|
+
},
|
|
26
|
+
render: (args) => _jsxs(ThemedCard, { ...args, colorMode: "day", children: [_jsx(Card.Header, { leadingIcon: 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
|
+
};
|
|
28
|
+
const SVG = `
|
|
29
|
+
<svg viewBox="0 0 220 100" xmlns="http://www.w3.org/2000/svg">
|
|
30
|
+
<rect width="100" height="100" />
|
|
31
|
+
<rect x="120" width="100" height="100" rx="15" />
|
|
32
|
+
</svg>
|
|
33
|
+
`;
|
|
34
|
+
export const CardDaySvg = {
|
|
35
|
+
args: {
|
|
36
|
+
rounded: "medium",
|
|
37
|
+
shadow: "medium",
|
|
38
|
+
border: true,
|
|
39
|
+
sx: { maxWidth: 360 }
|
|
40
|
+
},
|
|
41
|
+
render: (args) => _jsxs(ThemedCard, { ...args, colorMode: "day", children: [_jsx(Card.Header, { leadingIcon: 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
|
+
};
|
|
43
|
+
export const CardNight = {
|
|
44
|
+
args: {
|
|
45
|
+
rounded: "medium",
|
|
46
|
+
shadow: "medium",
|
|
47
|
+
border: true,
|
|
48
|
+
sx: { maxWidth: 360 }
|
|
49
|
+
},
|
|
50
|
+
render: (args) => _jsxs(ThemedCard, { ...args, colorMode: "night", children: [_jsx(Card.Header, { leadingIcon: 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
|
+
};
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { FC } from "react";
|
|
2
2
|
import { FlashProps } from "@primer/react";
|
|
3
3
|
import { Icon } from "@primer/octicons-react";
|
|
4
|
-
type CloseableFlashProps = FlashProps & {
|
|
4
|
+
export type CloseableFlashProps = FlashProps & {
|
|
5
5
|
leadingIcon?: Icon;
|
|
6
|
-
onClose
|
|
6
|
+
onClose?: () => void;
|
|
7
7
|
};
|
|
8
|
-
export declare const CloseableFlash:
|
|
9
|
-
export {};
|
|
8
|
+
export declare const CloseableFlash: FC<CloseableFlashProps>;
|
|
@@ -3,10 +3,12 @@ import { useState } from "react";
|
|
|
3
3
|
import { Box, Flash, StyledOcticon, Text } from "@primer/react";
|
|
4
4
|
import { XIcon } from "@primer/octicons-react";
|
|
5
5
|
export const CloseableFlash = (props) => {
|
|
6
|
-
const { leadingIcon, variant, ...otherProps } = props;
|
|
6
|
+
const { leadingIcon, variant, onClose, ...otherProps } = props;
|
|
7
7
|
const [isVisible, setIsVisible] = useState(true);
|
|
8
8
|
const handleClose = () => {
|
|
9
|
-
|
|
9
|
+
if (onClose) {
|
|
10
|
+
onClose();
|
|
11
|
+
}
|
|
10
12
|
setIsVisible(false);
|
|
11
13
|
};
|
|
12
14
|
if (!isVisible) {
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { StoryObj } from '@storybook/react';
|
|
3
|
+
import { CloseableFlashProps } from '../../../index';
|
|
4
|
+
declare const meta: {
|
|
5
|
+
title: string;
|
|
6
|
+
component: import("react").FC<CloseableFlashProps>;
|
|
7
|
+
tags: string[];
|
|
8
|
+
parameters: {
|
|
9
|
+
layout: string;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
export default meta;
|
|
13
|
+
type Story = StoryObj<typeof meta>;
|
|
14
|
+
export declare const CloseableFlashDay: Story;
|
|
15
|
+
export declare const CloseableFlashNight: Story;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { ThemeProvider, BaseStyles, Box } from "@primer/react";
|
|
3
|
+
import { CheckIcon } from "@primer/octicons-react";
|
|
4
|
+
import { CloseableFlash } from '../../../index';
|
|
5
|
+
const meta = {
|
|
6
|
+
title: 'Components/CloseableFlash',
|
|
7
|
+
component: CloseableFlash,
|
|
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 ThemedCloseableFlash = (props) => {
|
|
17
|
+
return (_jsx(ThemeProvider, { colorMode: props.colorMode, children: _jsx(BaseStyles, { children: _jsx(Box, { p: 3, bg: "canvas.default", children: _jsx(Box, { children: _jsx(CloseableFlash, { ...props }) }) }) }) }));
|
|
18
|
+
};
|
|
19
|
+
export const CloseableFlashDay = {
|
|
20
|
+
args: {
|
|
21
|
+
variant: "success",
|
|
22
|
+
leadingIcon: CheckIcon,
|
|
23
|
+
onClose: () => window.alert("closed")
|
|
24
|
+
},
|
|
25
|
+
render: (args) => _jsx(ThemedCloseableFlash, { ...args, colorMode: "day", children: "Success Flash" })
|
|
26
|
+
};
|
|
27
|
+
export const CloseableFlashNight = {
|
|
28
|
+
args: {
|
|
29
|
+
variant: "success",
|
|
30
|
+
leadingIcon: CheckIcon,
|
|
31
|
+
onClose: () => window.alert("closed")
|
|
32
|
+
},
|
|
33
|
+
render: (args) => _jsx(ThemedCloseableFlash, { ...args, colorMode: "night", children: "Success Flash" })
|
|
34
|
+
};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
interface CommonProps {
|
|
3
2
|
name?: string;
|
|
4
3
|
id?: string;
|
|
@@ -20,5 +19,5 @@ type ConditionalProps = {
|
|
|
20
19
|
step?: number;
|
|
21
20
|
};
|
|
22
21
|
export type SliderProps = CommonProps & ConditionalProps;
|
|
23
|
-
export declare const Slider: ({ name, id, min, max, value, label, step, markers, displayValue, disabled, orientation, width, onChange, }: SliderProps) => JSX.Element;
|
|
22
|
+
export declare const Slider: ({ name, id, min, max, value, label, step, markers, displayValue, disabled, orientation, width, onChange, }: SliderProps) => import("react/jsx-runtime").JSX.Element;
|
|
24
23
|
export default Slider;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { StoryObj } from '@storybook/react';
|
|
2
|
+
import { SliderProps } from '../../../index';
|
|
3
|
+
declare const meta: {
|
|
4
|
+
title: string;
|
|
5
|
+
component: ({ name, id, min, max, value, label, step, markers, displayValue, disabled, orientation, width, onChange, }: SliderProps) => 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 SliderDay: Story;
|
|
14
|
+
export declare const SliderNight: Story;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { ThemeProvider, BaseStyles, Box, CounterLabel } from "@primer/react";
|
|
4
|
+
import { Slider } from '../../../index';
|
|
5
|
+
const meta = {
|
|
6
|
+
title: 'Components/Slider',
|
|
7
|
+
component: Slider,
|
|
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 ThemedSlider = (props) => {
|
|
17
|
+
const [value, setValue] = useState(50);
|
|
18
|
+
return (_jsx(ThemeProvider, { colorMode: props.colorMode, children: _jsx(BaseStyles, { children: _jsxs(Box, { p: 3, bg: "canvas.default", children: [_jsx(Box, { children: _jsx(Slider, { ...props, value: value, onChange: setValue }) }), _jsx(Box, { children: _jsx(CounterLabel, { sx: { ml: 2 }, children: value }) })] }) }) }));
|
|
19
|
+
};
|
|
20
|
+
export const SliderDay = {
|
|
21
|
+
args: {
|
|
22
|
+
name: "slider-day",
|
|
23
|
+
id: "slider-day",
|
|
24
|
+
min: 0,
|
|
25
|
+
max: 100,
|
|
26
|
+
step: 10,
|
|
27
|
+
value: 50,
|
|
28
|
+
onChange: (value) => {
|
|
29
|
+
console.log('Slider value changed:', value);
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
render: (args) => _jsx(ThemedSlider, { ...args, colorMode: "day" })
|
|
33
|
+
};
|
|
34
|
+
export const SliderNight = {
|
|
35
|
+
args: {
|
|
36
|
+
name: "slider-night",
|
|
37
|
+
id: "slider-night",
|
|
38
|
+
min: 0,
|
|
39
|
+
max: 100,
|
|
40
|
+
step: 10,
|
|
41
|
+
value: 50,
|
|
42
|
+
onChange: (value) => {
|
|
43
|
+
console.log('Slider value changed:', value);
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
render: (args) => _jsx(ThemedSlider, { ...args, colorMode: "night" })
|
|
47
|
+
};
|
|
@@ -11,5 +11,5 @@ export interface ToolbarProps {
|
|
|
11
11
|
border?: boolean;
|
|
12
12
|
children: React.ReactNode | React.ReactNode[];
|
|
13
13
|
}
|
|
14
|
-
export declare const Toolbar: ({ align, height, gap, padding, heading, backgroundColor, borderBottomHeight, borderBottomColor, border, children, }: ToolbarProps) => JSX.Element;
|
|
14
|
+
export declare const Toolbar: ({ align, height, gap, padding, heading, backgroundColor, borderBottomHeight, borderBottomColor, border, children, }: ToolbarProps) => import("react/jsx-runtime").JSX.Element;
|
|
15
15
|
export default Toolbar;
|
|
@@ -0,0 +1,14 @@
|
|
|
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;
|
|
@@ -0,0 +1,36 @@
|
|
|
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
|
+
};
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@datalayer/primer-addons",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.14",
|
|
4
4
|
"license": "BSD-3-Clause",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"dev": "vite",
|
|
7
7
|
"start": "vite",
|
|
8
8
|
"build": "tsc && vite build",
|
|
9
|
+
"watch": "tsc -w",
|
|
9
10
|
"lint": "eslint src --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
|
|
10
11
|
"preview": "vite preview",
|
|
11
12
|
"storybook": "storybook dev -p 6006",
|
|
@@ -16,12 +17,18 @@
|
|
|
16
17
|
"lib",
|
|
17
18
|
"style"
|
|
18
19
|
],
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "https://github.com/datalayer/primer-addons.git"
|
|
23
|
+
},
|
|
24
|
+
"homepage": "https://primer-addons.datalayer.tech/",
|
|
19
25
|
"dependencies": {
|
|
26
|
+
"@primer/brand-primitives": "0.20.0",
|
|
20
27
|
"@primer/octicons-react": "18.2.0",
|
|
21
|
-
"@primer/react": "
|
|
28
|
+
"@primer/react": "36.0.0-rc.8ab77098",
|
|
29
|
+
"@primer/react-brand": "0.20.0",
|
|
22
30
|
"react": "18.2.0",
|
|
23
31
|
"react-dom": "18.2.0",
|
|
24
|
-
"sass": "^1.62.1",
|
|
25
32
|
"styled-components": "5.3.10"
|
|
26
33
|
},
|
|
27
34
|
"devDependencies": {
|
|
@@ -32,8 +39,8 @@
|
|
|
32
39
|
"@storybook/react": "^7.0.9",
|
|
33
40
|
"@storybook/react-vite": "^7.0.9",
|
|
34
41
|
"@storybook/testing-library": "^0.0.14-next.2",
|
|
35
|
-
"@types/react": "18.
|
|
36
|
-
"@types/react-dom": "18.
|
|
42
|
+
"@types/react": "18.2.12",
|
|
43
|
+
"@types/react-dom": "18.2.5",
|
|
37
44
|
"@typescript-eslint/eslint-plugin": "^5.57.1",
|
|
38
45
|
"@typescript-eslint/parser": "^5.57.1",
|
|
39
46
|
"@vitejs/plugin-react": "^4.0.0",
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { FlashProps } from "@primer/react";
|
|
3
|
-
import { Icon } from "@primer/octicons-react";
|
|
4
|
-
type CloseableFlashProps = FlashProps & {
|
|
5
|
-
onClose: () => void;
|
|
6
|
-
leadingIcon: Icon | null;
|
|
7
|
-
};
|
|
8
|
-
export declare const CloseableFlash: React.FC<CloseableFlashProps>;
|
|
9
|
-
export {};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useState } from "react";
|
|
3
|
-
import { Box, Flash, StyledOcticon, Text } from "@primer/react";
|
|
4
|
-
import { XIcon } from "@primer/octicons-react";
|
|
5
|
-
export const CloseableFlash = (props) => {
|
|
6
|
-
const { leadingIcon, variant, ...otherProps } = props;
|
|
7
|
-
const [isVisible, setIsVisible] = useState(true);
|
|
8
|
-
const handleClose = () => {
|
|
9
|
-
props.onClose();
|
|
10
|
-
setIsVisible(false);
|
|
11
|
-
};
|
|
12
|
-
if (!isVisible) {
|
|
13
|
-
return null;
|
|
14
|
-
}
|
|
15
|
-
return (_jsx(Flash, { variant: variant, ...otherProps, children: _jsxs(Box, { display: "flex", justifyContent: "space-between", alignItems: "center", children: [_jsxs(Box, { sx: { flexGrow: 1 }, children: [leadingIcon && _jsx(StyledOcticon, { icon: leadingIcon }), _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 }) })] }) }));
|
|
16
|
-
};
|