@ledgerhq/react-ui 0.1.1 → 0.4.0
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 +54 -13
- package/assets/icons.d.ts +1 -0
- package/assets/icons.js +1 -0
- package/components/Chart/index.js +1 -1
- package/components/Table/Columns.d.ts +2 -2
- package/components/Table/Columns.js +2 -2
- package/components/Table/index.d.ts +3 -2
- package/components/Table/index.js +1 -4
- package/components/Table/stories.helper.js +6 -6
- package/components/Tag/index.d.ts +18 -5
- package/components/Tag/index.js +54 -21
- package/components/animations/GlitchText/index.d.ts +7 -0
- package/components/animations/GlitchText/index.js +35 -0
- package/components/asorted/Divider/index.js +2 -2
- package/components/asorted/Icon/Icon.d.ts +1 -0
- package/components/asorted/Icon/Icon.js +8 -1
- package/components/asorted/Icon/index.d.ts +1 -1
- package/components/asorted/Icon/index.js +1 -1
- package/components/asorted/Text/index.d.ts +9 -31
- package/components/asorted/Text/index.js +11 -17
- package/components/asorted/Text/styles.d.ts +7 -2
- package/components/asorted/Text/styles.js +69 -85
- package/components/asorted/index.d.ts +1 -1
- package/components/asorted/index.js +1 -1
- package/components/cards/Carousel/Slide.js +3 -3
- package/components/cards/Carousel/index.js +8 -8
- package/components/cta/Button/index.d.ts +26 -14
- package/components/cta/Button/index.js +77 -66
- package/components/cta/Link/index.d.ts +12 -4
- package/components/cta/Link/index.js +4 -3
- package/components/cta/Toggle/index.js +1 -1
- package/components/cta/getCtaStyle.d.ts +2 -2
- package/components/cta/index.d.ts +1 -0
- package/components/cta/index.js +1 -0
- package/components/form/BaseInput/index.d.ts +86 -15
- package/components/form/BaseInput/index.js +47 -20
- package/components/form/Checkbox/Checkbox.js +12 -9
- package/components/form/Dropdown/index.js +3 -3
- package/components/form/LegendInput/index.js +3 -3
- package/components/form/NumberInput/index.d.ts +1 -1
- package/components/form/NumberInput/index.js +18 -7
- package/components/form/QrCodeInput/index.js +4 -4
- package/components/form/QuantityInput/index.js +8 -8
- package/components/form/Radio/RadioElement.d.ts +5 -2
- package/components/form/Radio/RadioElement.js +16 -14
- package/components/form/Radio/RadioListElement.d.ts +22 -0
- package/components/form/Radio/RadioListElement.js +63 -0
- package/components/form/Radio/index.d.ts +8 -1
- package/components/form/Radio/index.js +2 -0
- package/components/form/SearchInput/index.js +1 -1
- package/components/form/SelectInput/DropdownIndicator.js +1 -1
- package/components/form/SelectInput/MenuList.js +1 -1
- package/components/form/SelectInput/Option.js +12 -12
- package/components/form/SelectInput/ValueContainer.js +2 -2
- package/components/form/SelectInput/index.d.ts +3 -2
- package/components/form/SelectInput/index.js +5 -5
- package/components/form/SplitInput/index.js +5 -5
- package/components/form/Switch/Switch.js +9 -9
- package/components/helpers.d.ts +2 -2
- package/components/layout/Box/index.d.ts +11 -0
- package/components/layout/Box/index.js +3 -0
- package/components/layout/Drawer/index.d.ts +13 -0
- package/components/layout/{Side/Side.js → Drawer/index.js} +12 -12
- package/components/layout/Flex/index.d.ts +10 -7
- package/components/layout/Flex/index.js +2 -11
- package/components/layout/Grid/index.d.ts +3 -2
- package/components/layout/Grid/index.js +3 -3
- package/components/layout/Popin/index.d.ts +33 -6
- package/components/layout/Popin/index.js +65 -41
- package/components/layout/Side/Provider.d.ts +9 -8
- package/components/layout/Side/Provider.js +1 -3
- package/components/layout/Side/index.js +7 -10
- package/components/layout/index.d.ts +2 -0
- package/components/layout/index.js +2 -0
- package/components/loaders/ProgressLoader/index.js +4 -4
- package/components/message/Alert/index.js +7 -7
- package/components/message/Log/index.js +2 -2
- package/components/message/Notification/Badge.js +2 -2
- package/components/message/Notification/index.d.ts +8 -14
- package/components/message/Notification/index.js +9 -29
- package/components/message/StatusNotification/index.d.ts +11 -0
- package/components/message/StatusNotification/index.js +33 -0
- package/components/message/Tip/index.d.ts +8 -0
- package/components/message/Tip/index.js +43 -0
- package/components/message/Tooltip/index.d.ts +3 -2
- package/components/message/Tooltip/index.js +26 -3
- package/components/message/Tooltip/styles.js +3 -3
- package/components/message/index.d.ts +3 -0
- package/components/message/index.js +3 -0
- package/components/navigation/Aside/index.d.ts +8 -1
- package/components/navigation/Breadcrumb/index.js +5 -5
- package/components/navigation/Header/index.d.ts +3 -3
- package/components/navigation/progress/ProgressBar/Onboarding.js +6 -6
- package/components/navigation/progress/Stepper/index.js +10 -10
- package/components/navigation/sideBar/Item/Item.d.ts +4 -7
- package/components/navigation/sideBar/Item/Item.js +34 -16
- package/components/navigation/sideBar/SideBar/SideBar.d.ts +1 -1
- package/components/navigation/sideBar/SideBar/SideBar.js +14 -6
- package/components/navigation/sideBar/Toggle/Toggle.js +2 -2
- package/components/styled.d.ts +13 -0
- package/components/styled.js +13 -0
- package/components/tabs/Bar/index.js +4 -4
- package/components/tabs/Chip/index.d.ts +13 -0
- package/components/tabs/Chip/index.js +21 -0
- package/components/tabs/Pill/index.js +7 -7
- package/components/tabs/Tabs/index.js +8 -7
- package/components/tabs/index.d.ts +2 -0
- package/components/tabs/index.js +2 -0
- package/package.json +19 -8
- package/styles/InvertTheme.d.ts +1 -8
- package/styles/StyleProvider.d.ts +3 -3
- package/styles/StyleProvider.js +3 -3
- package/styles/global.d.ts +1 -0
- package/styles/global.js +16 -38
- package/styles/index.d.ts +0 -1
- package/styles/index.js +0 -1
- package/styles/theme.d.ts +63 -39
- package/styles/theme.js +34 -8
- package/components/layout/Side/Side.d.ts +0 -13
- package/styles/reset.d.ts +0 -2
- package/styles/reset.js +0 -62
|
@@ -12,54 +12,75 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
12
12
|
import React from "react";
|
|
13
13
|
import ReactDOM from "react-dom";
|
|
14
14
|
import styled from "styled-components";
|
|
15
|
+
import CloseIcon from "@ledgerhq/icons-ui/react/CloseRegular";
|
|
16
|
+
import ArrowLeftIcon from "@ledgerhq/icons-ui/react/ArrowLeftRegular";
|
|
17
|
+
import baseStyled from "../../styled";
|
|
18
|
+
import Flex from "../../layout/Flex";
|
|
15
19
|
import Button from "../../cta/Button";
|
|
16
|
-
import Close from "@ledgerhq/icons-ui/react/CloseRegular";
|
|
17
20
|
import TransitionInOut from "../../transitions/TransitionInOut";
|
|
18
21
|
import TransitionScale from "../../transitions/TransitionScale";
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
const ICON_SIZE = 20;
|
|
23
|
+
const Wrapper = styled(Flex).attrs((p) => ({
|
|
24
|
+
flexDirection: "column",
|
|
25
|
+
alignItems: "stretch",
|
|
26
|
+
justifyContent: "space-between",
|
|
27
|
+
height: p.height || `${p.theme.sizes.drawer.popin.max.height}px`,
|
|
28
|
+
width: p.width || `${p.theme.sizes.drawer.popin.max.width}px`,
|
|
29
|
+
minHeight: `${p.theme.sizes.drawer.popin.min.height}px`,
|
|
30
|
+
minWidth: `${p.theme.sizes.drawer.popin.min.width}px`,
|
|
31
|
+
maxHeight: `${p.theme.sizes.drawer.popin.max.height}px`,
|
|
32
|
+
maxWidth: `${p.theme.sizes.drawer.popin.max.width}px`,
|
|
33
|
+
zIndex: p.theme.zIndexes[8],
|
|
34
|
+
p: p.p !== undefined ? p.p : p.theme.space[10],
|
|
35
|
+
rowGap: 6,
|
|
36
|
+
backgroundColor: p.theme.colors.neutral.c00,
|
|
37
|
+
})) ``;
|
|
38
|
+
const Overlay = styled(Flex).attrs((p) => ({
|
|
39
|
+
justifyContent: "center",
|
|
40
|
+
alignItems: "center",
|
|
41
|
+
width: "100vw",
|
|
42
|
+
height: "100vh",
|
|
43
|
+
zIndex: p.theme.zIndexes[8],
|
|
44
|
+
position: "fixed",
|
|
45
|
+
top: 0,
|
|
46
|
+
left: 0,
|
|
47
|
+
backgroundColor: p.theme.colors.neutral.c100a07,
|
|
48
|
+
})) ``;
|
|
49
|
+
const Header = baseStyled.section `
|
|
50
|
+
display: grid;
|
|
51
|
+
grid-template-columns: [icon] ${ICON_SIZE}px [title] 1fr [icon] ${ICON_SIZE}px;
|
|
52
|
+
column-gap: 12px;
|
|
25
53
|
`;
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
54
|
+
const HeaderTitleContainer = styled(Flex).attrs(() => ({
|
|
55
|
+
justifyContent: "center",
|
|
56
|
+
})) ``;
|
|
57
|
+
const PopinBody = baseStyled(Flex).attrs({
|
|
58
|
+
as: "section",
|
|
59
|
+
flexDirection: "column",
|
|
60
|
+
flex: 1,
|
|
61
|
+
overflow: "auto",
|
|
62
|
+
}) ``;
|
|
63
|
+
const PopinFooter = baseStyled(Flex).attrs({ as: "section" }) ``;
|
|
64
|
+
const IconContainer = styled(Button.Unstyled) `
|
|
33
65
|
display: flex;
|
|
34
|
-
flex-direction: column;
|
|
35
|
-
align-items: stretch;
|
|
36
|
-
justify-content: space-between;
|
|
37
|
-
z-index: ${(p) => p.theme.zIndexes[8]};
|
|
38
|
-
`;
|
|
39
|
-
const Overlay = styled.div `
|
|
40
|
-
position: fixed;
|
|
41
|
-
display: flex;
|
|
42
|
-
justify-content: center;
|
|
43
66
|
align-items: center;
|
|
44
|
-
top: 0;
|
|
45
|
-
left: 0;
|
|
46
|
-
width: 100vw;
|
|
47
|
-
height: 100vh;
|
|
48
|
-
z-index: 999;
|
|
49
|
-
background-color: ${(p) => p.theme.colors.palette.neutral.c100a07};
|
|
50
|
-
`;
|
|
51
|
-
const CloseButton = styled(Button) `
|
|
52
|
-
position: absolute;
|
|
53
|
-
top: ${(p) => p.theme.space[6]}px;
|
|
54
|
-
right: ${(p) => p.theme.space[6]}px;
|
|
55
67
|
`;
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
68
|
+
const PopinHeader = (_a) => {
|
|
69
|
+
var { children, onClose, onBack } = _a, props = __rest(_a, ["children", "onClose", "onBack"]);
|
|
70
|
+
return (React.createElement(Header, Object.assign({}, props),
|
|
71
|
+
React.createElement(Flex, null, onBack ? (React.createElement(IconContainer, { onClick: onBack },
|
|
72
|
+
React.createElement(ArrowLeftIcon, { size: ICON_SIZE, color: "neutral.c100" }))) : null),
|
|
73
|
+
React.createElement(HeaderTitleContainer, null, children),
|
|
74
|
+
React.createElement(Flex, null, onClose ? (React.createElement(IconContainer, { onClick: onClose },
|
|
75
|
+
React.createElement(CloseIcon, { size: ICON_SIZE, color: "neutral.c100" }))) : null)));
|
|
76
|
+
};
|
|
77
|
+
const Popin = (_a) => {
|
|
78
|
+
var { isOpen, children, width, height } = _a, props = __rest(_a, ["isOpen", "children", "width", "height"]);
|
|
79
|
+
return (React.createElement(TransitionInOut, { in: isOpen, appear: true, mountOnEnter: true, unmountOnExit: true },
|
|
80
|
+
React.createElement(Overlay, null,
|
|
81
|
+
React.createElement(TransitionScale, { in: isOpen, appear: true },
|
|
82
|
+
React.createElement(Wrapper, Object.assign({ width: width, height: height }, props), children)))));
|
|
83
|
+
};
|
|
63
84
|
const PopinWrapper = (_a) => {
|
|
64
85
|
var { children } = _a, popinProps = __rest(_a, ["children"]);
|
|
65
86
|
const $root = React.useMemo(() => document.querySelector("#ll-popin-root"), []);
|
|
@@ -67,4 +88,7 @@ const PopinWrapper = (_a) => {
|
|
|
67
88
|
throw new Error("popin root cannot be found");
|
|
68
89
|
return ReactDOM.createPortal(React.createElement(Popin, Object.assign({}, popinProps), children), $root);
|
|
69
90
|
};
|
|
91
|
+
PopinWrapper.Header = PopinHeader;
|
|
92
|
+
PopinWrapper.Body = PopinBody;
|
|
93
|
+
PopinWrapper.Footer = PopinFooter;
|
|
70
94
|
export default PopinWrapper;
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
import type { SideProps } from ".";
|
|
3
|
+
interface State<P extends SideProps = SideProps> {
|
|
4
|
+
Component: React.ComponentType<P> | null | undefined;
|
|
5
|
+
props?: P;
|
|
5
6
|
open: boolean;
|
|
6
7
|
}
|
|
7
|
-
export declare let setSide: (Component?:
|
|
8
|
-
interface ContextValue {
|
|
9
|
-
state: State
|
|
10
|
-
setSide: (Component?: React.ComponentType<
|
|
8
|
+
export declare let setSide: <P extends SideProps = SideProps>(Component?: State<P>["Component"], props?: State<P>["props"]) => void;
|
|
9
|
+
interface ContextValue<P extends SideProps = SideProps> {
|
|
10
|
+
state: State<P>;
|
|
11
|
+
setSide: (Component?: React.ComponentType<P>, props?: P) => void;
|
|
11
12
|
}
|
|
12
|
-
export declare const context: React.Context<ContextValue
|
|
13
|
+
export declare const context: React.Context<ContextValue<SideProps>>;
|
|
13
14
|
export declare const useSide: () => ContextValue;
|
|
14
15
|
declare const SideProvider: ({ children }: {
|
|
15
16
|
children: React.ReactNode;
|
|
@@ -8,7 +8,6 @@ const reducer = (state, update) => {
|
|
|
8
8
|
};
|
|
9
9
|
const initialState = {
|
|
10
10
|
Component: null,
|
|
11
|
-
props: null,
|
|
12
11
|
open: false,
|
|
13
12
|
};
|
|
14
13
|
export const context = React.createContext({
|
|
@@ -16,8 +15,7 @@ export const context = React.createContext({
|
|
|
16
15
|
setSide: () => { },
|
|
17
16
|
});
|
|
18
17
|
export const useSide = () => {
|
|
19
|
-
|
|
20
|
-
return sideContext;
|
|
18
|
+
return useContext(context);
|
|
21
19
|
};
|
|
22
20
|
const SideProvider = ({ children }) => {
|
|
23
21
|
const [state, dispatch] = useReducer(reducer, initialState);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { useRef, useCallback, useEffect, useState } from "react";
|
|
2
2
|
import { TransitionGroup } from "react-transition-group";
|
|
3
|
-
import
|
|
3
|
+
import Drawer from "../Drawer";
|
|
4
4
|
import TransitionSlide from "../../transitions/TransitionSlide";
|
|
5
5
|
import { useSide } from "./Provider";
|
|
6
6
|
export const SideWrapper = (props) => {
|
|
@@ -13,13 +13,10 @@ export const SideWrapper = (props) => {
|
|
|
13
13
|
const nonce = useRef(0);
|
|
14
14
|
const onClose = useCallback(() => setSide(), [setSide]);
|
|
15
15
|
useEffect(() => {
|
|
16
|
-
// @ts-expect-error FIXME
|
|
17
16
|
setQueue((q) => {
|
|
18
|
-
if (!state.open)
|
|
17
|
+
if (!state.open || !state.Component)
|
|
19
18
|
return [];
|
|
20
|
-
|
|
21
|
-
if (state.Component != null)
|
|
22
|
-
return q.concat([Object.assign(Object.assign({}, state), { key: nonce.current++ })]);
|
|
19
|
+
return q.concat([Object.assign(Object.assign({}, state), { key: nonce.current++ })]);
|
|
23
20
|
});
|
|
24
21
|
}, [state]);
|
|
25
22
|
useEffect(() => {
|
|
@@ -39,10 +36,10 @@ export const SideWrapper = (props) => {
|
|
|
39
36
|
const wrappedOnBack = useCallback(() => {
|
|
40
37
|
var _a;
|
|
41
38
|
setDirection("right");
|
|
42
|
-
(_a = state === null || state === void 0 ? void 0 : state.props) === null || _a === void 0 ? void 0 : _a.onBack
|
|
39
|
+
const onBack = (_a = state === null || state === void 0 ? void 0 : state.props) === null || _a === void 0 ? void 0 : _a.onBack;
|
|
40
|
+
onBack && onBack();
|
|
43
41
|
}, [state === null || state === void 0 ? void 0 : state.props]);
|
|
44
|
-
return (React.createElement(
|
|
45
|
-
React.createElement(TransitionGroup, { enter: transitionsEnabled, exit: transitionsEnabled, component: null }, queue.map(({ Component, props, key }) => (React.createElement(TransitionSlide, { key: key, direction: direction },
|
|
46
|
-
React.createElement(Component, Object.assign({}, props))))))));
|
|
42
|
+
return (React.createElement(Drawer, Object.assign({}, props, { isOpen: !!state.open, onClose: onClose, onBack: ((_a = state === null || state === void 0 ? void 0 : state.props) === null || _a === void 0 ? void 0 : _a.onBack) ? wrappedOnBack : undefined, setTransitionsEnabled: setTransitionsEnabled, hideNavigation: false }),
|
|
43
|
+
React.createElement(TransitionGroup, { enter: transitionsEnabled, exit: transitionsEnabled, component: null }, queue.map(({ Component, props, key }) => (React.createElement(TransitionSlide, { key: key, direction: direction }, Component && React.createElement(Component, Object.assign({}, props))))))));
|
|
47
44
|
};
|
|
48
45
|
export default SideWrapper;
|
|
@@ -11,13 +11,13 @@ const StyledCircle = styled.circle.attrs({
|
|
|
11
11
|
transform-origin: 50% 50%;
|
|
12
12
|
`;
|
|
13
13
|
const StyledCircleBackground = styled(StyledCircle).attrs((props) => ({
|
|
14
|
-
stroke: props.theme.colors.
|
|
14
|
+
stroke: props.theme.colors.primary.c20,
|
|
15
15
|
})) ``;
|
|
16
16
|
const StyledCircleFront = styled(StyledCircle).attrs((props) => ({
|
|
17
|
-
stroke: props.theme.colors.
|
|
17
|
+
stroke: props.theme.colors.primary.c60,
|
|
18
18
|
})) ``;
|
|
19
19
|
const StyledCenteredText = styled(Text).attrs({
|
|
20
|
-
color: "
|
|
20
|
+
color: "primary.c80",
|
|
21
21
|
}) `
|
|
22
22
|
position: absolute;
|
|
23
23
|
top: 50%;
|
|
@@ -39,7 +39,7 @@ function ProgressCircleSvg({ radius, stroke, progress, }) {
|
|
|
39
39
|
}
|
|
40
40
|
export default function ProgressLoader({ radius = 32, stroke = 6, progress = 0, }) {
|
|
41
41
|
return (React.createElement(StyledProgressLoaderContainer, null,
|
|
42
|
-
React.createElement(StyledCenteredText, {
|
|
42
|
+
React.createElement(StyledCenteredText, { variant: "body" },
|
|
43
43
|
progress,
|
|
44
44
|
"%"),
|
|
45
45
|
React.createElement(ProgressCircleSvg, { radius: radius, stroke: stroke, progress: progress })));
|
|
@@ -19,19 +19,19 @@ const StyledAlertContainer = styled.div `
|
|
|
19
19
|
switch (p.type) {
|
|
20
20
|
case "warning":
|
|
21
21
|
return css `
|
|
22
|
-
background: ${p.theme.colors.
|
|
23
|
-
color: ${p.theme.colors.
|
|
22
|
+
background: ${p.theme.colors.warning.c30};
|
|
23
|
+
color: ${p.theme.colors.warning.c100};
|
|
24
24
|
`;
|
|
25
25
|
case "error":
|
|
26
26
|
return css `
|
|
27
|
-
background: ${p.theme.colors.
|
|
28
|
-
color: ${p.theme.colors.
|
|
27
|
+
background: ${p.theme.colors.error.c30};
|
|
28
|
+
color: ${p.theme.colors.error.c100};
|
|
29
29
|
`;
|
|
30
30
|
case "info":
|
|
31
31
|
default:
|
|
32
32
|
return css `
|
|
33
|
-
background: ${p.theme.colors.
|
|
34
|
-
color: ${p.theme.colors.
|
|
33
|
+
background: ${p.theme.colors.primary.c20};
|
|
34
|
+
color: ${p.theme.colors.primary.c90};
|
|
35
35
|
`;
|
|
36
36
|
}
|
|
37
37
|
}}
|
|
@@ -44,5 +44,5 @@ const StyledAlertContainer = styled.div `
|
|
|
44
44
|
export default function Alert({ type = "info", title, showIcon = true }) {
|
|
45
45
|
return (React.createElement(StyledAlertContainer, { type: type },
|
|
46
46
|
showIcon && !!icons[type] && React.createElement(StyledIconContainer, null, icons[type]),
|
|
47
|
-
React.createElement(Text, {
|
|
47
|
+
React.createElement(Text, { variant: "body", color: "inherit" }, title)));
|
|
48
48
|
}
|
|
@@ -19,7 +19,7 @@ const Container = styled(FlexBox) `
|
|
|
19
19
|
flex-wrap: wrap;
|
|
20
20
|
align-items: stretch;
|
|
21
21
|
min-height: ${(p) => p.theme.space[12]}px;
|
|
22
|
-
color: ${(p) => p.theme.colors.
|
|
22
|
+
color: ${(p) => p.theme.colors.neutral.c100};
|
|
23
23
|
`;
|
|
24
24
|
const TextContainer = styled(FlexBox).attrs(() => ({
|
|
25
25
|
flex: "1",
|
|
@@ -35,7 +35,7 @@ function Log(_a) {
|
|
|
35
35
|
return (React.createElement(Container, Object.assign({}, props),
|
|
36
36
|
React.createElement(BracketLeft, null),
|
|
37
37
|
React.createElement(TextContainer, { flex: "1", alignItems: "center", justifyContent: "center" },
|
|
38
|
-
React.createElement(Text, {
|
|
38
|
+
React.createElement(Text, { variant: "h3", textTransform: "uppercase", textAlign: "center" }, children)),
|
|
39
39
|
React.createElement(BracketRight, null)));
|
|
40
40
|
}
|
|
41
41
|
export default memo(Log);
|
|
@@ -20,14 +20,14 @@ const ActiveCircle = styled.div `
|
|
|
20
20
|
width: 10px;
|
|
21
21
|
border-radius: 9999px;
|
|
22
22
|
box-sizing: content-box;
|
|
23
|
-
background-color: ${(p) => p.theme.colors.
|
|
23
|
+
background-color: ${(p) => p.theme.colors.error.c100};
|
|
24
24
|
|
|
25
25
|
border: 2px solid
|
|
26
26
|
var(
|
|
27
27
|
--notification-badge-border,
|
|
28
28
|
${(p) => {
|
|
29
29
|
/* The CSS variable is dynamically set by the Notification component */
|
|
30
|
-
return p.theme.colors.
|
|
30
|
+
return p.theme.colors.background.main;
|
|
31
31
|
}}
|
|
32
32
|
);
|
|
33
33
|
`;
|
|
@@ -1,23 +1,17 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { FlexBoxProps } from "../../layout/Flex";
|
|
3
3
|
import Badge from "./Badge";
|
|
4
|
-
import
|
|
5
|
-
|
|
4
|
+
import { LinkProps } from "../../cta/Link";
|
|
5
|
+
interface ContainerProps extends FlexBoxProps {
|
|
6
|
+
hasBackground?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface Props extends ContainerProps {
|
|
6
9
|
title: string;
|
|
7
10
|
badge: React.ReactNode;
|
|
8
11
|
description?: string;
|
|
9
12
|
link?: string;
|
|
10
|
-
onLinkClick?:
|
|
11
|
-
|
|
12
|
-
} & ColorProps & React.ComponentProps<typeof Container>;
|
|
13
|
-
declare const Container: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, import("../../layout/Flex").FlexBoxProps & {
|
|
14
|
-
p: number;
|
|
15
|
-
columnGap: number;
|
|
16
|
-
alignItems: string;
|
|
17
|
-
} & {
|
|
18
|
-
hasBackground?: boolean | undefined;
|
|
19
|
-
theme: Theme;
|
|
20
|
-
}, "p" | "alignItems" | "columnGap">;
|
|
13
|
+
onLinkClick?: LinkProps["onClick"];
|
|
14
|
+
}
|
|
21
15
|
export declare type NotificationType = {
|
|
22
16
|
(p: Props): JSX.Element;
|
|
23
17
|
Badge: typeof Badge;
|
|
@@ -11,11 +11,11 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
11
11
|
};
|
|
12
12
|
import React from "react";
|
|
13
13
|
import styled from "styled-components";
|
|
14
|
-
import { color } from "styled-system";
|
|
15
14
|
import FlexBox from "../../layout/Flex";
|
|
16
15
|
import Text from "../../asorted/Text";
|
|
17
|
-
import Icon from "../../asorted/Icon";
|
|
18
16
|
import Badge from "./Badge";
|
|
17
|
+
import Link from "../../cta/Link";
|
|
18
|
+
import { ExternalLinkMedium } from "@ledgerhq/icons-ui/react";
|
|
19
19
|
const Container = styled(FlexBox).attrs({
|
|
20
20
|
p: 6,
|
|
21
21
|
columnGap: 8,
|
|
@@ -23,41 +23,21 @@ const Container = styled(FlexBox).attrs({
|
|
|
23
23
|
}) `
|
|
24
24
|
--notification-badge-border: ${(p) => {
|
|
25
25
|
/* Set a CSS variable that will be consumed by the Badge component */
|
|
26
|
-
return p.hasBackground
|
|
27
|
-
? p.theme.colors.palette.neutral.c30
|
|
28
|
-
: p.theme.colors.palette.background.main;
|
|
26
|
+
return p.hasBackground ? p.theme.colors.neutral.c30 : p.theme.colors.background.main;
|
|
29
27
|
}};
|
|
30
|
-
background-color: ${(p) => p.hasBackground ? p.theme.colors.
|
|
28
|
+
background-color: ${(p) => (p.hasBackground ? p.theme.colors.neutral.c30 : "transparent")};
|
|
31
29
|
|
|
32
30
|
border-radius: 8px;
|
|
33
|
-
${color}
|
|
34
|
-
`;
|
|
35
|
-
const Link = styled(Text).attrs({
|
|
36
|
-
ff: "Inter|SemiBold",
|
|
37
|
-
fontSize: 4,
|
|
38
|
-
color: "palette.neutral.c100",
|
|
39
|
-
}) `
|
|
40
|
-
display: inline-flex;
|
|
41
|
-
align-items: center;
|
|
42
|
-
column-gap: 6px;
|
|
43
|
-
cursor: pointer;
|
|
44
|
-
|
|
45
|
-
:hover,
|
|
46
|
-
:focus,
|
|
47
|
-
:active {
|
|
48
|
-
text-decoration: underline;
|
|
49
|
-
}
|
|
50
31
|
`;
|
|
51
32
|
function Notification(_a) {
|
|
52
33
|
var { title, description, badge, link, onLinkClick, hasBackground = false } = _a, containerProps = __rest(_a, ["title", "description", "badge", "link", "onLinkClick", "hasBackground"]);
|
|
53
|
-
return (React.createElement(Container, Object.assign({
|
|
34
|
+
return (React.createElement(Container, Object.assign({ hasBackground: hasBackground }, containerProps),
|
|
54
35
|
badge,
|
|
55
36
|
React.createElement(FlexBox, { flexDirection: "column", rowGap: 3, flex: "auto" },
|
|
56
|
-
React.createElement(Text, {
|
|
57
|
-
description && (React.createElement(Text, {
|
|
58
|
-
link && (React.createElement(
|
|
59
|
-
link
|
|
60
|
-
React.createElement(Icon, { name: "ExternalLink", size: 18 }))))));
|
|
37
|
+
React.createElement(Text, { variant: "large", fontWeight: "medium", color: "neutral.c100" }, title),
|
|
38
|
+
description && (React.createElement(Text, { variant: "paragraph", fontWeight: "medium", color: "neutral.c80", whiteSpace: "pre-wrap" }, description)),
|
|
39
|
+
link && (React.createElement(FlexBox, { justifyContent: "flex-start" },
|
|
40
|
+
React.createElement(Link, { onClick: (event) => onLinkClick && onLinkClick(event), Icon: ExternalLinkMedium }, link))))));
|
|
61
41
|
}
|
|
62
42
|
Notification.Badge = Badge;
|
|
63
43
|
export default Notification;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { FlexBoxProps } from "../../layout/Flex";
|
|
3
|
+
interface ContainerProps extends FlexBoxProps {
|
|
4
|
+
hasBorder?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export interface Props extends ContainerProps {
|
|
7
|
+
text: string;
|
|
8
|
+
badge: React.ReactNode;
|
|
9
|
+
}
|
|
10
|
+
declare function StatusNotification({ text, badge, hasBorder, ...containerProps }: Props): JSX.Element;
|
|
11
|
+
export default StatusNotification;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import React from "react";
|
|
13
|
+
import styled from "styled-components";
|
|
14
|
+
import FlexBox from "../../layout/Flex";
|
|
15
|
+
import Log from "../Log/";
|
|
16
|
+
const Container = styled(FlexBox).attrs({
|
|
17
|
+
p: 8,
|
|
18
|
+
rowGap: 9,
|
|
19
|
+
alignItems: "center",
|
|
20
|
+
flexDirection: "column",
|
|
21
|
+
}) `
|
|
22
|
+
border-width: 1px;
|
|
23
|
+
border-style: ${(p) => (p.hasBorder ? "solid" : "none")};
|
|
24
|
+
border-radius: 8px;
|
|
25
|
+
border-color: ${(p) => p.theme.colors.neutral.c40};
|
|
26
|
+
`;
|
|
27
|
+
function StatusNotification(_a) {
|
|
28
|
+
var { text, badge, hasBorder = false } = _a, containerProps = __rest(_a, ["text", "badge", "hasBorder"]);
|
|
29
|
+
return (React.createElement(Container, Object.assign({ hasBorder: hasBorder }, containerProps),
|
|
30
|
+
badge,
|
|
31
|
+
React.createElement(Log, null, text)));
|
|
32
|
+
}
|
|
33
|
+
export default StatusNotification;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import styled, { css } from "styled-components";
|
|
3
|
+
import Text from "../../asorted/Text";
|
|
4
|
+
import { CheckAloneMedium, CloseMedium, CircledAlertMedium } from "@ledgerhq/icons-ui/react";
|
|
5
|
+
import { Flex } from "../../layout";
|
|
6
|
+
const icons = {
|
|
7
|
+
success: React.createElement(CheckAloneMedium, { size: 16 }),
|
|
8
|
+
warning: React.createElement(CircledAlertMedium, { size: 16 }),
|
|
9
|
+
error: React.createElement(CloseMedium, { size: 16 }),
|
|
10
|
+
};
|
|
11
|
+
const StyledIconContainer = styled.div `
|
|
12
|
+
${(p) => {
|
|
13
|
+
switch (p.type) {
|
|
14
|
+
case "warning":
|
|
15
|
+
return css `
|
|
16
|
+
background: ${p.theme.colors.warning.c10};
|
|
17
|
+
color: ${p.theme.colors.warning.c100};
|
|
18
|
+
`;
|
|
19
|
+
case "error":
|
|
20
|
+
return css `
|
|
21
|
+
background: ${p.theme.colors.error.c10};
|
|
22
|
+
color: ${p.theme.colors.error.c100};
|
|
23
|
+
`;
|
|
24
|
+
case "success":
|
|
25
|
+
default:
|
|
26
|
+
return css `
|
|
27
|
+
background: ${p.theme.colors.success.c30};
|
|
28
|
+
color: ${p.theme.colors.success.c100};
|
|
29
|
+
`;
|
|
30
|
+
}
|
|
31
|
+
}}
|
|
32
|
+
|
|
33
|
+
border-radius: ${(p) => `${p.theme.radii[1]}px`};
|
|
34
|
+
margin-right ${(p) => `${p.theme.space[6]}px`};
|
|
35
|
+
padding: 6px;
|
|
36
|
+
display: flex;
|
|
37
|
+
align-items: center;
|
|
38
|
+
`;
|
|
39
|
+
export default function Tip({ type, label }) {
|
|
40
|
+
return (React.createElement(Flex, { alignItems: "center" },
|
|
41
|
+
type && React.createElement(StyledIconContainer, { type: type }, icons[type]),
|
|
42
|
+
React.createElement(Text, { variant: "paragraph", fontWeight: "medium", color: "neutral.c100", flexShrink: 1 }, label)));
|
|
43
|
+
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { TippyProps } from "@tippyjs/react";
|
|
3
3
|
declare type Placement = "top" | "top-start" | "top-end" | "right" | "right-start" | "right-end" | "bottom" | "bottom-start" | "bottom-end" | "left" | "left-start" | "left-end" | "auto" | "auto-start" | "auto-end";
|
|
4
|
-
export
|
|
4
|
+
export interface Props extends TippyProps {
|
|
5
|
+
/** The preferred placement of the tippy. */
|
|
5
6
|
placement?: Placement;
|
|
6
|
-
}
|
|
7
|
+
}
|
|
7
8
|
export default function Tooltip(props: Props): JSX.Element | null;
|
|
8
9
|
export {};
|
|
@@ -9,10 +9,33 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
9
9
|
}
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
|
-
import React from "react";
|
|
12
|
+
import React, { forwardRef } from "react";
|
|
13
|
+
import { isForwardRef } from "react-is";
|
|
13
14
|
import Tippy from "@tippyjs/react";
|
|
14
15
|
import Text from "../../asorted/Text";
|
|
16
|
+
// Tippyjs need the ref to be forwarded to the DOM element wrapping the children.
|
|
17
|
+
// This component has been created to add a wrapping span and use its ref when needed.
|
|
18
|
+
// See: https://github.com/atomiks/tippyjs-react#component-children
|
|
19
|
+
const Wrapper = forwardRef((props, ref) => {
|
|
20
|
+
const childrenCount = React.Children.count(props.children);
|
|
21
|
+
try {
|
|
22
|
+
const child = React.Children.only(props.children);
|
|
23
|
+
const isValidElement = React.isValidElement(child);
|
|
24
|
+
const isForwardingRef = isForwardRef(child);
|
|
25
|
+
const isDomElement = isValidElement && typeof child.type === "string";
|
|
26
|
+
if (isForwardingRef || isDomElement) {
|
|
27
|
+
return React.cloneElement(child, { ref });
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
return React.createElement("span", { ref: ref }, props.children);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
catch (e) {
|
|
34
|
+
return childrenCount < 1 ? null : React.createElement("span", { ref: ref }, props.children);
|
|
35
|
+
}
|
|
36
|
+
});
|
|
15
37
|
export default function Tooltip(props) {
|
|
16
|
-
const { content, placement = "auto" } = props, rest = __rest(props, ["content", "placement"]);
|
|
17
|
-
return (React.createElement(Tippy, Object.assign({}, rest, { placement: placement, content: React.createElement(Text, {
|
|
38
|
+
const { content, placement = "auto", children } = props, rest = __rest(props, ["content", "placement", "children"]);
|
|
39
|
+
return (React.createElement(Tippy, Object.assign({}, rest, { placement: placement, content: React.createElement(Text, { fontWeight: "medium", variant: "paragraph", color: "neutral.c00" }, content) }),
|
|
40
|
+
React.createElement(Wrapper, { children: children })));
|
|
18
41
|
}
|
|
@@ -10,8 +10,8 @@ export default css `
|
|
|
10
10
|
|
|
11
11
|
.tippy-box {
|
|
12
12
|
position: relative;
|
|
13
|
-
background-color: ${(p) => p.theme.colors.
|
|
14
|
-
color: ${(p) => p.theme.colors.
|
|
13
|
+
background-color: ${(p) => p.theme.colors.neutral.c100};
|
|
14
|
+
color: ${(p) => p.theme.colors.neutral.c00};
|
|
15
15
|
border-radius: 4px;
|
|
16
16
|
font-size: 14px;
|
|
17
17
|
line-height: 1.4;
|
|
@@ -72,7 +72,7 @@ export default css `
|
|
|
72
72
|
.tippy-arrow {
|
|
73
73
|
width: 16px;
|
|
74
74
|
height: 16px;
|
|
75
|
-
color: ${(p) => p.theme.colors.
|
|
75
|
+
color: ${(p) => p.theme.colors.neutral.c100};
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
.tippy-arrow:before {
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
export { default as Alert } from "./Alert";
|
|
2
2
|
export { default as Log } from "./Log";
|
|
3
3
|
export { default as Notification } from "./Notification";
|
|
4
|
+
export { default as Badge } from "./Notification/Badge";
|
|
4
5
|
export { default as Tooltip } from "./Tooltip";
|
|
6
|
+
export { default as Tip } from "./Tip";
|
|
7
|
+
export { default as StatusNotification } from "./StatusNotification";
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
export { default as Alert } from "./Alert";
|
|
2
2
|
export { default as Log } from "./Log";
|
|
3
3
|
export { default as Notification } from "./Notification";
|
|
4
|
+
export { default as Badge } from "./Notification/Badge";
|
|
4
5
|
export { default as Tooltip } from "./Tooltip";
|
|
6
|
+
export { default as Tip } from "./Tip";
|
|
7
|
+
export { default as StatusNotification } from "./StatusNotification";
|
|
@@ -6,6 +6,13 @@ export declare type Props = React.PropsWithChildren<{
|
|
|
6
6
|
}> & React.ComponentProps<typeof Wrapper>;
|
|
7
7
|
interface ExtraWrapperProps extends ColorProps, LayoutProps, TypographyProps {
|
|
8
8
|
}
|
|
9
|
-
declare const Wrapper: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, import("
|
|
9
|
+
declare const Wrapper: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, import("styled-system").SpaceProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, string | number | symbol> & import("styled-system").FlexboxProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & import("styled-system").PositionProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & ColorProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>, string | number | symbol> & LayoutProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & import("styled-system").OverflowProps<Required<import("styled-system").Theme<import("styled-system").TLengthStyledSystem>>> & {
|
|
10
|
+
columnGap?: string | number | undefined;
|
|
11
|
+
rowGap?: string | number | undefined;
|
|
12
|
+
color?: string | undefined;
|
|
13
|
+
display?: string | undefined;
|
|
14
|
+
position?: string | undefined;
|
|
15
|
+
maxHeight?: number | undefined;
|
|
16
|
+
} & ExtraWrapperProps, "overflow" | "p" | "color" | "left" | "right" | "bottom" | "top" | "size" | "flex" | "padding" | "rowGap" | "alignContent" | "alignItems" | "alignSelf" | "backgroundColor" | "columnGap" | "display" | "flexBasis" | "flexDirection" | "flexGrow" | "flexShrink" | "flexWrap" | "height" | "justifyContent" | "justifyItems" | "justifySelf" | "marginBottom" | "marginLeft" | "marginRight" | "marginTop" | "maxHeight" | "maxWidth" | "minHeight" | "minWidth" | "opacity" | "order" | "overflowX" | "overflowY" | "paddingBottom" | "paddingLeft" | "paddingRight" | "paddingTop" | "position" | "verticalAlign" | "width" | "zIndex" | "margin" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "marginX" | "my" | "marginY" | "pt" | "pr" | "pb" | "pl" | "px" | "paddingX" | "py" | "paddingY" | "bg">;
|
|
10
17
|
export default function Aside({ header, footer, children, ...props }: Props): JSX.Element;
|
|
11
18
|
export {};
|