@datalayer/primer-addons 0.0.10 → 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
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" />
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { FlashProps } from "@primer/react";
|
|
3
|
+
import { Icon } from "@primer/octicons-react";
|
|
3
4
|
type CloseableFlashProps = FlashProps & {
|
|
4
5
|
onClose: () => void;
|
|
6
|
+
leadingIcon: Icon | null;
|
|
5
7
|
};
|
|
6
8
|
export declare const CloseableFlash: React.FC<CloseableFlashProps>;
|
|
7
9
|
export {};
|
|
@@ -1,8 +1,9 @@
|
|
|
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 = () => {
|
|
8
9
|
props.onClose();
|
|
@@ -11,5 +12,5 @@ export const CloseableFlash = (props) => {
|
|
|
11
12
|
if (!isVisible) {
|
|
12
13
|
return null;
|
|
13
14
|
}
|
|
14
|
-
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 }) })] }) }));
|
|
15
16
|
};
|