@datalayer/primer-addons 0.0.9 → 0.0.11
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 +4 -4
- package/lib/components/card/Card.d.ts +8 -0
- package/lib/components/card/Card.js +37 -0
- package/lib/components/closeableflash/CloseableFlash.d.ts +5 -1
- package/lib/components/closeableflash/CloseableFlash.js +4 -2
- package/lib/components/slider/Slider.d.ts +1 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -14,12 +14,12 @@ This project has been [shared in a discussion](https://github.com/primer/react/d
|
|
|
14
14
|
|
|
15
15
|
## Current Addons
|
|
16
16
|
|
|
17
|
-
- [x] Slider
|
|
18
|
-
- [x] Toolbar
|
|
19
|
-
- [ ] ClosableFlash
|
|
20
|
-
- [ ] Skeleton
|
|
21
17
|
- [ ] Card
|
|
18
|
+
- [ ] ClosableFlash
|
|
22
19
|
- [ ] MasonryBox
|
|
20
|
+
- [ ] Skeleton
|
|
21
|
+
- [x] Slider
|
|
22
|
+
- [x] Toolbar
|
|
23
23
|
|
|
24
24
|
<div align="center" style="text-align: center">
|
|
25
25
|
<img alt="Primer React Addons" src="https://datalayer-examples.s3.amazonaws.com/primer-addons-example.png" />
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { BoxProps } from "@primer/react";
|
|
3
|
+
export type CardProps = Omit<BoxProps, 'border'> & {
|
|
4
|
+
rounded?: 'small' | 'medium' | 'large' | 'full' | number;
|
|
5
|
+
border?: boolean;
|
|
6
|
+
shadow?: 'small' | 'medium' | 'large' | 'extraLarge';
|
|
7
|
+
};
|
|
8
|
+
export declare const Card: React.FC<CardProps>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Box } from "@primer/react";
|
|
3
|
+
const roundedVals = {
|
|
4
|
+
"small": "3px",
|
|
5
|
+
"medium": "6px",
|
|
6
|
+
"large": "12px",
|
|
7
|
+
"full": "100vh",
|
|
8
|
+
};
|
|
9
|
+
const shadowVals = {
|
|
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
|
+
};
|
|
15
|
+
export const Card = (props) => {
|
|
16
|
+
const { sx, rounded, border, shadow, children, ...otherProps } = props;
|
|
17
|
+
return (_jsx(Box, { sx: {
|
|
18
|
+
...(sx ? sx : undefined),
|
|
19
|
+
display: 'flex',
|
|
20
|
+
alignItems: 'center',
|
|
21
|
+
...(rounded ? typeof rounded === "string" ? {
|
|
22
|
+
borderRadius: roundedVals[rounded]
|
|
23
|
+
} : {
|
|
24
|
+
borderRadius: props.rounded
|
|
25
|
+
} : undefined),
|
|
26
|
+
...(border ? {
|
|
27
|
+
borderWidth: 1,
|
|
28
|
+
borderStyle: 'solid',
|
|
29
|
+
borderColor: 'border.default'
|
|
30
|
+
} : undefined),
|
|
31
|
+
...(shadow ? {
|
|
32
|
+
boxShadow: shadowVals[shadow]
|
|
33
|
+
} : {
|
|
34
|
+
boxShadow: shadowVals['small']
|
|
35
|
+
})
|
|
36
|
+
}, className: "color-shadow-medium", ...otherProps, children: children }));
|
|
37
|
+
};
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { FlashProps } from "@primer/react";
|
|
3
|
-
|
|
3
|
+
import { Icon } from "@primer/octicons-react";
|
|
4
|
+
type CloseableFlashProps = FlashProps & {
|
|
5
|
+
onClose: () => void;
|
|
6
|
+
leadingIcon: Icon | null;
|
|
7
|
+
};
|
|
4
8
|
export declare const CloseableFlash: React.FC<CloseableFlashProps>;
|
|
5
9
|
export {};
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useState } from "react";
|
|
3
|
-
import { Box, Flash } from "@primer/react";
|
|
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
7
|
const [isVisible, setIsVisible] = useState(true);
|
|
7
8
|
const handleClose = () => {
|
|
9
|
+
props.onClose();
|
|
8
10
|
setIsVisible(false);
|
|
9
11
|
};
|
|
10
12
|
if (!isVisible) {
|
|
11
13
|
return null;
|
|
12
14
|
}
|
|
13
|
-
return (_jsx(Flash, { ...
|
|
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 }) })] }) }));
|
|
14
16
|
};
|
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED