@dtdot/lego 0.14.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/build/colours/colours.d.ts +16 -0
- package/build/colours/colours.js +15 -0
- package/build/components/ActionMessage/ActionMessage.component.d.ts +9 -0
- package/build/components/ActionMessage/ActionMessage.component.js +27 -0
- package/build/components/ActionMessage/ActionMessage.stories.d.ts +6 -0
- package/build/components/ActionMessage/ActionMessage.stories.js +20 -0
- package/build/components/Alert/Alert.component.d.ts +16 -0
- package/build/components/Alert/Alert.component.js +54 -0
- package/build/components/Alert/Alert.stories.d.ts +8 -0
- package/build/components/Alert/Alert.stories.js +21 -0
- package/build/components/Badge/Badge.component.d.ts +9 -0
- package/build/components/Badge/Badge.component.js +20 -0
- package/build/components/Badge/Badge.stories.d.ts +5 -0
- package/build/components/Badge/Badge.stories.js +18 -0
- package/build/components/Button/Button.component.d.ts +11 -0
- package/build/components/Button/Button.component.js +60 -0
- package/build/components/Button/Button.context.d.ts +8 -0
- package/build/components/Button/Button.context.js +7 -0
- package/build/components/Button/Button.stories.d.ts +7 -0
- package/build/components/Button/Button.stories.js +27 -0
- package/build/components/ButtonGroup/ButtonGroup.component.d.ts +6 -0
- package/build/components/ButtonGroup/ButtonGroup.component.js +17 -0
- package/build/components/ButtonGroup/ButtonGroup.stories.d.ts +7 -0
- package/build/components/ButtonGroup/ButtonGroup.stories.js +17 -0
- package/build/components/Card/Card.component.d.ts +19 -0
- package/build/components/Card/Card.component.js +101 -0
- package/build/components/Card/Card.context.d.ts +9 -0
- package/build/components/Card/Card.context.js +7 -0
- package/build/components/Card/Card.stories.d.ts +9 -0
- package/build/components/Card/Card.stories.js +64 -0
- package/build/components/Card/CardGroup.component.d.ts +9 -0
- package/build/components/Card/CardGroup.component.js +31 -0
- package/build/components/Card/_CardActions.component.d.ts +10 -0
- package/build/components/Card/_CardActions.component.js +48 -0
- package/build/components/Card/_CardContent.component.d.ts +6 -0
- package/build/components/Card/_CardContent.component.js +24 -0
- package/build/components/Card/_CardHeader.component.d.ts +9 -0
- package/build/components/Card/_CardHeader.component.js +48 -0
- package/build/components/Card/_CardMedia.component.d.ts +6 -0
- package/build/components/Card/_CardMedia.component.js +48 -0
- package/build/components/Card/_CardSpacer.component.d.ts +3 -0
- package/build/components/Card/_CardSpacer.component.js +4 -0
- package/build/components/Card/_CardSubContent.component.d.ts +6 -0
- package/build/components/Card/_CardSubContent.component.js +24 -0
- package/build/components/ControlGroup/ControlGroup.component.d.ts +11 -0
- package/build/components/ControlGroup/ControlGroup.component.js +75 -0
- package/build/components/ControlGroup/ControlGroup.stories.d.ts +7 -0
- package/build/components/ControlGroup/ControlGroup.stories.js +24 -0
- package/build/components/ControlGroup/_ControlGroupSpacer.component.d.ts +3 -0
- package/build/components/ControlGroup/_ControlGroupSpacer.component.js +4 -0
- package/build/components/FancyCheckbox/FancyCheckbox.component.d.ts +14 -0
- package/build/components/FancyCheckbox/FancyCheckbox.component.js +53 -0
- package/build/components/FancyCheckbox/FancyCheckbox.stories.d.ts +5 -0
- package/build/components/FancyCheckbox/FancyCheckbox.stories.js +29 -0
- package/build/components/Form/Form.component.d.ts +9 -0
- package/build/components/Form/Form.component.js +24 -0
- package/build/components/Form/Form.stories.d.ts +5 -0
- package/build/components/Form/Form.stories.js +21 -0
- package/build/components/Form/FormState.context.d.ts +7 -0
- package/build/components/Form/FormState.context.js +6 -0
- package/build/components/Form/useFormNode.hook.d.ts +5 -0
- package/build/components/Form/useFormNode.hook.js +16 -0
- package/build/components/Heading/Heading.component.d.ts +6 -0
- package/build/components/Heading/Heading.component.js +13 -0
- package/build/components/Heading/Heading.stories.d.ts +5 -0
- package/build/components/Heading/Heading.stories.js +7 -0
- package/build/components/ImageUpload/ImageUpload.component.d.ts +11 -0
- package/build/components/ImageUpload/ImageUpload.component.js +92 -0
- package/build/components/ImageUpload/ImageUpload.stories.d.ts +8 -0
- package/build/components/ImageUpload/ImageUpload.stories.js +49 -0
- package/build/components/InlineCard/InlineCard.component.d.ts +10 -0
- package/build/components/InlineCard/InlineCard.component.js +20 -0
- package/build/components/InlineCard/InlineCard.stories.d.ts +5 -0
- package/build/components/InlineCard/InlineCard.stories.js +17 -0
- package/build/components/InlineCard/InlineCardGroup.component.d.ts +6 -0
- package/build/components/InlineCard/InlineCardGroup.component.js +17 -0
- package/build/components/InlineCard/_InlineCardContent.component.d.ts +6 -0
- package/build/components/InlineCard/_InlineCardContent.component.js +15 -0
- package/build/components/InlineCard/_InlineCardMedia.component.d.ts +6 -0
- package/build/components/InlineCard/_InlineCardMedia.component.js +17 -0
- package/build/components/Input/Input.component.d.ts +11 -0
- package/build/components/Input/Input.component.js +57 -0
- package/build/components/Input/Input.stories.d.ts +6 -0
- package/build/components/Input/Input.stories.js +12 -0
- package/build/components/LiveInput/LiveInput.component.d.ts +10 -0
- package/build/components/LiveInput/LiveInput.component.js +22 -0
- package/build/components/LiveInput/LiveInput.stories.d.ts +6 -0
- package/build/components/LiveInput/LiveInput.stories.js +12 -0
- package/build/components/Loader/Loader.component.d.ts +3 -0
- package/build/components/Loader/Loader.component.js +48 -0
- package/build/components/Loader/Loader.stories.d.ts +5 -0
- package/build/components/Loader/Loader.stories.js +9 -0
- package/build/components/Menu/Menu.component.d.ts +13 -0
- package/build/components/Menu/Menu.component.js +26 -0
- package/build/components/Menu/Menu.stories.d.ts +7 -0
- package/build/components/Menu/Menu.stories.js +98 -0
- package/build/components/Menu/_MenuContent.component.d.ts +10 -0
- package/build/components/Menu/_MenuContent.component.js +31 -0
- package/build/components/Menu/_MenuContent.context.d.ts +7 -0
- package/build/components/Menu/_MenuContent.context.js +6 -0
- package/build/components/Menu/_MenuHeading.component.d.ts +6 -0
- package/build/components/Menu/_MenuHeading.component.js +27 -0
- package/build/components/Menu/_MenuItem.component.d.ts +10 -0
- package/build/components/Menu/_MenuItem.component.js +50 -0
- package/build/components/Menu/_MenuPage.component.d.ts +6 -0
- package/build/components/Menu/_MenuPage.component.js +39 -0
- package/build/components/Menu/_MenuPanel.component.d.ts +6 -0
- package/build/components/Menu/_MenuPanel.component.js +62 -0
- package/build/components/Menu/menu.helpers.d.ts +4 -0
- package/build/components/Menu/menu.helpers.js +10 -0
- package/build/components/Modal/Modal.component.d.ts +14 -0
- package/build/components/Modal/Modal.component.js +100 -0
- package/build/components/Modal/Modal.stories.d.ts +6 -0
- package/build/components/Modal/Modal.stories.js +55 -0
- package/build/components/Modal/_Modal.context.d.ts +6 -0
- package/build/components/Modal/_Modal.context.js +6 -0
- package/build/components/Modal/_ModalBody.component.d.ts +2 -0
- package/build/components/Modal/_ModalBody.component.js +5 -0
- package/build/components/Modal/_ModalHeader.component.d.ts +7 -0
- package/build/components/Modal/_ModalHeader.component.js +54 -0
- package/build/components/Notification/Notification.component.d.ts +6 -0
- package/build/components/Notification/Notification.component.js +15 -0
- package/build/components/Notification/Notification.stories.d.ts +8 -0
- package/build/components/Notification/Notification.stories.js +28 -0
- package/build/components/Notifications/Notifications.component.d.ts +15 -0
- package/build/components/Notifications/Notifications.component.js +37 -0
- package/build/components/Notifications/Notifications.stories.d.ts +7 -0
- package/build/components/Notifications/Notifications.stories.js +99 -0
- package/build/components/ProfileImage/ProfileImage.component.d.ts +7 -0
- package/build/components/ProfileImage/ProfileImage.component.js +53 -0
- package/build/components/ProfileImage/ProfileImage.stories.d.ts +6 -0
- package/build/components/ProfileImage/ProfileImage.stories.js +8 -0
- package/build/components/QrCode/QrCode.component.d.ts +6 -0
- package/build/components/QrCode/QrCode.component.js +71 -0
- package/build/components/QrCode/QrCode.stories.d.ts +5 -0
- package/build/components/QrCode/QrCode.stories.js +8 -0
- package/build/components/Spacer/Spacer.component.d.ts +7 -0
- package/build/components/Spacer/Spacer.component.js +25 -0
- package/build/components/SquareButton/SquareButton.component.d.ts +9 -0
- package/build/components/SquareButton/SquareButton.component.js +31 -0
- package/build/components/SquareButton/SquareButton.stories.d.ts +5 -0
- package/build/components/SquareButton/SquareButton.stories.js +14 -0
- package/build/components/SubHeading/SubHeading.component.d.ts +2 -0
- package/build/components/SubHeading/SubHeading.component.js +11 -0
- package/build/components/SubHeading/SubHeading.stories.d.ts +5 -0
- package/build/components/SubHeading/SubHeading.stories.js +7 -0
- package/build/components/Table/Table.component.d.ts +16 -0
- package/build/components/Table/Table.component.js +24 -0
- package/build/components/Table/Table.stories.d.ts +7 -0
- package/build/components/Table/Table.stories.js +39 -0
- package/build/components/Table/_Table.context.d.ts +7 -0
- package/build/components/Table/_Table.context.js +5 -0
- package/build/components/Table/_TableRow.component.d.ts +6 -0
- package/build/components/Table/_TableRow.component.js +17 -0
- package/build/components/Text/Text.component.d.ts +8 -0
- package/build/components/Text/Text.component.js +26 -0
- package/build/components/Text/Text.stories.d.ts +6 -0
- package/build/components/Text/Text.stories.js +11 -0
- package/build/constants/zIndex.constants.d.ts +6 -0
- package/build/constants/zIndex.constants.js +5 -0
- package/build/contexts/File.context.d.ts +7 -0
- package/build/contexts/File.context.js +8 -0
- package/build/examples/Modal.stories.d.ts +5 -0
- package/build/examples/Modal.stories.js +37 -0
- package/build/global/BodyStyle.component.d.ts +2 -0
- package/build/global/BodyStyle.component.js +16 -0
- package/build/hooks/useForm.d.ts +7 -0
- package/build/hooks/useForm.js +20 -0
- package/build/index.d.ts +47 -0
- package/build/index.js +43 -0
- package/build/layouts/Action/Action.layout.d.ts +17 -0
- package/build/layouts/Action/Action.layout.js +45 -0
- package/build/layouts/Action/Action.stories.d.ts +6 -0
- package/build/layouts/Action/Action.stories.js +14 -0
- package/build/layouts/Centered/Centered.layout.d.ts +2 -0
- package/build/layouts/Centered/Centered.layout.js +6 -0
- package/build/layouts/Centered/Centered.stories.d.ts +5 -0
- package/build/layouts/Centered/Centered.stories.js +8 -0
- package/build/layouts/Column/Column.layout.d.ts +6 -0
- package/build/layouts/Column/Column.layout.js +5 -0
- package/build/layouts/Column/Column.stories.d.ts +5 -0
- package/build/layouts/Column/Column.stories.js +8 -0
- package/build/layouts/Content/Content.layout.d.ts +10 -0
- package/build/layouts/Content/Content.layout.js +11 -0
- package/build/layouts/Content/Content.stories.d.ts +9 -0
- package/build/layouts/Content/Content.stories.js +37 -0
- package/build/layouts/Content/_ContentContent.component.d.ts +8 -0
- package/build/layouts/Content/_ContentContent.component.js +29 -0
- package/build/layouts/Content/_ContentHeader.component.d.ts +7 -0
- package/build/layouts/Content/_ContentHeader.component.js +17 -0
- package/build/layouts/Emphasis/Emphasis.layout.d.ts +6 -0
- package/build/layouts/Emphasis/Emphasis.layout.js +39 -0
- package/build/layouts/Focus/Focus.layout.d.ts +6 -0
- package/build/layouts/Focus/Focus.layout.js +28 -0
- package/build/layouts/Focus/Focus.stories.d.ts +5 -0
- package/build/layouts/Focus/Focus.stories.js +16 -0
- package/build/layouts/Padded/Padded.layout.d.ts +9 -0
- package/build/layouts/Padded/Padded.layout.js +11 -0
- package/build/layouts/Padded/Padded.stories.d.ts +6 -0
- package/build/layouts/Padded/Padded.stories.js +10 -0
- package/build/responsive/responsive.d.ts +13 -0
- package/build/responsive/responsive.js +63 -0
- package/build/screens/Login/Login.screen.d.ts +13 -0
- package/build/screens/Login/Login.screen.js +60 -0
- package/build/screens/Register/Register.screen.d.ts +12 -0
- package/build/screens/Register/Register.screen.js +32 -0
- package/build/screens/Verification/Verification.screen.d.ts +12 -0
- package/build/screens/Verification/Verification.screen.js +39 -0
- package/build/theme/dark.theme.d.ts +3 -0
- package/build/theme/dark.theme.js +73 -0
- package/build/theme/default.theme.d.ts +3 -0
- package/build/theme/default.theme.js +74 -0
- package/build/theme/helpers/getThemeControlColours.d.ts +10 -0
- package/build/theme/helpers/getThemeControlColours.js +10 -0
- package/build/theme/helpers/getThemeStatusColour.d.ts +4 -0
- package/build/theme/helpers/getThemeStatusColour.js +14 -0
- package/build/theme/helpers/getThemeVariantColours.d.ts +8 -0
- package/build/theme/helpers/getThemeVariantColours.js +23 -0
- package/build/theme/theme.types.d.ts +2 -0
- package/build/theme/theme.types.js +1 -0
- package/build/theme/themes.d.ts +5 -0
- package/build/theme/themes.js +7 -0
- package/package.json +65 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import React, { useContext } from 'react';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
import { faTimes } from '@fortawesome/free-solid-svg-icons';
|
|
4
|
+
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
5
|
+
import ModalContext from './_Modal.context';
|
|
6
|
+
const HeaderContainer = styled.div `
|
|
7
|
+
display: flex;
|
|
8
|
+
justify-content: space-between;
|
|
9
|
+
`;
|
|
10
|
+
const TextContainer = styled.div `
|
|
11
|
+
padding: 16px;
|
|
12
|
+
`;
|
|
13
|
+
const HeaderText = styled.div `
|
|
14
|
+
color: ${(props) => props.theme.colours.defaultFont};
|
|
15
|
+
font-family: ${(props) => props.theme.fonts.subHeading.family};
|
|
16
|
+
font-size: ${(props) => props.theme.fonts.subHeading.size};
|
|
17
|
+
font-weight: ${(props) => props.theme.fonts.subHeading.weight};
|
|
18
|
+
`;
|
|
19
|
+
const SubHeaderText = styled.div `
|
|
20
|
+
margin-top: 4px;
|
|
21
|
+
|
|
22
|
+
color: ${(props) => props.theme.colours.defaultFont};
|
|
23
|
+
font-family: ${(props) => props.theme.fonts.default.family};
|
|
24
|
+
font-size: ${(props) => props.theme.fonts.default.size};
|
|
25
|
+
font-weight: ${(props) => props.theme.fonts.default.weight};
|
|
26
|
+
`;
|
|
27
|
+
const IconContainer = styled.div `
|
|
28
|
+
padding: 12px;
|
|
29
|
+
padding-right: 16px;
|
|
30
|
+
`;
|
|
31
|
+
const IconClickableArea = styled.div `
|
|
32
|
+
font-size: 24px;
|
|
33
|
+
font-weight: 400;
|
|
34
|
+
|
|
35
|
+
padding: 4px;
|
|
36
|
+
cursor: pointer;
|
|
37
|
+
|
|
38
|
+
color: ${(props) => props.theme.colours.secondaryFont};
|
|
39
|
+
|
|
40
|
+
&:hover {
|
|
41
|
+
color: ${(props) => props.theme.colours.secondaryFontHover};
|
|
42
|
+
}
|
|
43
|
+
`;
|
|
44
|
+
const ModalHeader = ({ header, subHeader }) => {
|
|
45
|
+
const { onClose } = useContext(ModalContext);
|
|
46
|
+
return (React.createElement(HeaderContainer, null,
|
|
47
|
+
React.createElement(TextContainer, null,
|
|
48
|
+
React.createElement(HeaderText, null, header),
|
|
49
|
+
SubHeaderText && React.createElement(SubHeaderText, null, subHeader)),
|
|
50
|
+
React.createElement(IconContainer, null,
|
|
51
|
+
React.createElement(IconClickableArea, { onClick: onClose },
|
|
52
|
+
React.createElement(FontAwesomeIcon, { icon: faTimes })))));
|
|
53
|
+
};
|
|
54
|
+
export default ModalHeader;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
import responsive from '../../responsive/responsive';
|
|
4
|
+
import Alert, { AlertContainer } from '../Alert/Alert.component';
|
|
5
|
+
const NotificationContainer = styled.div `
|
|
6
|
+
${AlertContainer} {
|
|
7
|
+
${responsive.useStylesFor('tablet').andLarger(`
|
|
8
|
+
max-width: 320px;
|
|
9
|
+
width: 320px;
|
|
10
|
+
`)}
|
|
11
|
+
}
|
|
12
|
+
`;
|
|
13
|
+
const Notification = (props) => (React.createElement(NotificationContainer, null,
|
|
14
|
+
React.createElement(Alert, Object.assign({}, props))));
|
|
15
|
+
export default Notification;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { Meta } from '@storybook/react/types-6-0';
|
|
3
|
+
export declare const Standard: () => JSX.Element;
|
|
4
|
+
export declare const Variants: () => JSX.Element;
|
|
5
|
+
export declare const WithCount: () => JSX.Element;
|
|
6
|
+
export declare const WithAction: () => JSX.Element;
|
|
7
|
+
declare const _default: Meta<import("@storybook/react/types-6-0").Args>;
|
|
8
|
+
export default _default;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Notification } from '../..';
|
|
3
|
+
/* eslint-disable no-alert */
|
|
4
|
+
export const Standard = () => (React.createElement(React.Fragment, null,
|
|
5
|
+
React.createElement(Notification, { variant: 'info', message: 'This is a base notification' }),
|
|
6
|
+
React.createElement("br", null),
|
|
7
|
+
React.createElement(Notification, { variant: 'info', message: 'This is a base notification with quite a bit of content. It may wrap around to the next line...' })));
|
|
8
|
+
export const Variants = () => (React.createElement(React.Fragment, null,
|
|
9
|
+
React.createElement(Notification, { variant: 'info', message: 'This is an info notification' }),
|
|
10
|
+
React.createElement("br", null),
|
|
11
|
+
React.createElement(Notification, { variant: 'success', message: 'This is a success notification' }),
|
|
12
|
+
React.createElement("br", null),
|
|
13
|
+
React.createElement(Notification, { variant: 'warn', message: 'This is a warn notification' }),
|
|
14
|
+
React.createElement("br", null),
|
|
15
|
+
React.createElement(Notification, { variant: 'danger', message: 'This is a danger notification' })));
|
|
16
|
+
export const WithCount = () => (React.createElement(React.Fragment, null,
|
|
17
|
+
React.createElement(Notification, { variant: 'info', count: 5, message: 'This is a notification with a count' }),
|
|
18
|
+
React.createElement("br", null),
|
|
19
|
+
React.createElement(Notification, { variant: 'success', count: 5, message: 'This is a notification with a count' }),
|
|
20
|
+
React.createElement("br", null),
|
|
21
|
+
React.createElement(Notification, { variant: 'warn', count: 5, message: 'This is a notification with a count' }),
|
|
22
|
+
React.createElement("br", null),
|
|
23
|
+
React.createElement(Notification, { variant: 'danger', count: 5, message: 'This is a notification with a count' })));
|
|
24
|
+
export const WithAction = () => (React.createElement(Notification, { variant: 'info', message: 'This is a notification with an action', action: 'Undo', onAction: () => alert('Undoing...') }));
|
|
25
|
+
export default {
|
|
26
|
+
title: 'Components/Notification',
|
|
27
|
+
component: Notification,
|
|
28
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare type NotificationVariant = 'info' | 'success' | 'warn' | 'danger';
|
|
3
|
+
export interface INotification {
|
|
4
|
+
id: string;
|
|
5
|
+
variant: NotificationVariant;
|
|
6
|
+
message: string;
|
|
7
|
+
count?: number;
|
|
8
|
+
action?: string;
|
|
9
|
+
onAction?: () => void;
|
|
10
|
+
}
|
|
11
|
+
interface NotificationsProps {
|
|
12
|
+
notifications: INotification[];
|
|
13
|
+
}
|
|
14
|
+
declare const Notifications: ({ notifications }: NotificationsProps) => JSX.Element;
|
|
15
|
+
export default Notifications;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import styled from 'styled-components';
|
|
4
|
+
import { animated, useTransition } from 'react-spring';
|
|
5
|
+
import { Notification, Spacer } from '../..';
|
|
6
|
+
import responsive from '../../responsive/responsive';
|
|
7
|
+
import zIndexConstants from '../../constants/zIndex.constants';
|
|
8
|
+
const NotificationContainer = styled.div `
|
|
9
|
+
position: fixed;
|
|
10
|
+
bottom: 20px;
|
|
11
|
+
left: 270px;
|
|
12
|
+
|
|
13
|
+
z-index: ${zIndexConstants.notifications};
|
|
14
|
+
|
|
15
|
+
${responsive.useStylesFor('mobile').andSmaller(`
|
|
16
|
+
bottom: 80px;
|
|
17
|
+
left: 20px;
|
|
18
|
+
|
|
19
|
+
width: calc(100% - 40px);
|
|
20
|
+
`)}
|
|
21
|
+
`;
|
|
22
|
+
const Notifications = ({ notifications }) => {
|
|
23
|
+
const transitions = useTransition(notifications, (item) => item.id, {
|
|
24
|
+
from: { transform: 'translateX(-300px)', opacity: 0 },
|
|
25
|
+
enter: { transform: 'translateX(0px)', opacity: 1 },
|
|
26
|
+
leave: { transform: 'translateX(300px)', opacity: 0 },
|
|
27
|
+
config: {
|
|
28
|
+
tension: 280,
|
|
29
|
+
mass: 0.2,
|
|
30
|
+
friction: 10,
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
return (React.createElement(NotificationContainer, null, transitions.map(({ item, props, key }) => (React.createElement(animated.div, { key: key, style: props },
|
|
34
|
+
React.createElement(Spacer, { size: '1x' }),
|
|
35
|
+
React.createElement(Notification, { variant: item.variant, message: item.message, action: item.action, onAction: item.onAction, count: item.count }))))));
|
|
36
|
+
};
|
|
37
|
+
export default Notifications;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { Meta } from '@storybook/react/types-6-0';
|
|
3
|
+
export declare const Standard: () => JSX.Element;
|
|
4
|
+
export declare const Interactive: () => JSX.Element;
|
|
5
|
+
export declare const OverModal: () => JSX.Element;
|
|
6
|
+
declare const _default: Meta<import("@storybook/react/types-6-0").Args>;
|
|
7
|
+
export default _default;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { Button, FocusLayout, Menu, Modal, Notifications, PaddedLayout, Text } from '../..';
|
|
3
|
+
/* eslint-disable no-alert, no-console */
|
|
4
|
+
export const Standard = () => {
|
|
5
|
+
const notifications = [
|
|
6
|
+
{
|
|
7
|
+
id: '123',
|
|
8
|
+
message: 'User saved!',
|
|
9
|
+
variant: 'success',
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
id: '456',
|
|
13
|
+
message: 'Error validating form',
|
|
14
|
+
variant: 'danger',
|
|
15
|
+
},
|
|
16
|
+
];
|
|
17
|
+
return (React.createElement(React.Fragment, null,
|
|
18
|
+
React.createElement(Notifications, { notifications: notifications }),
|
|
19
|
+
React.createElement(Menu, null,
|
|
20
|
+
React.createElement(Menu.Heading, null, "Something Tasty")),
|
|
21
|
+
React.createElement(Menu.Page, null,
|
|
22
|
+
React.createElement(FocusLayout, null,
|
|
23
|
+
React.createElement(Text, null, "Content...")))));
|
|
24
|
+
};
|
|
25
|
+
export const Interactive = () => {
|
|
26
|
+
const [notifications, setNotifications] = useState([]);
|
|
27
|
+
const successNotification = {
|
|
28
|
+
id: '123',
|
|
29
|
+
message: 'User saved!',
|
|
30
|
+
variant: 'success',
|
|
31
|
+
count: 1,
|
|
32
|
+
};
|
|
33
|
+
const errorNotification = {
|
|
34
|
+
id: '456',
|
|
35
|
+
message: 'Error validating form',
|
|
36
|
+
variant: 'danger',
|
|
37
|
+
count: 1,
|
|
38
|
+
};
|
|
39
|
+
const addNotification = (notification) => {
|
|
40
|
+
const exists = notifications.find((n) => n.id === notification.id);
|
|
41
|
+
if (exists) {
|
|
42
|
+
const newNotifications = notifications.map((n) => n.id === notification.id
|
|
43
|
+
? {
|
|
44
|
+
...n,
|
|
45
|
+
count: (n.count || 1) + 1,
|
|
46
|
+
}
|
|
47
|
+
: n);
|
|
48
|
+
setNotifications(newNotifications);
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
setNotifications([...notifications, notification]);
|
|
52
|
+
};
|
|
53
|
+
return (React.createElement(React.Fragment, null,
|
|
54
|
+
React.createElement(Notifications, { notifications: notifications }),
|
|
55
|
+
React.createElement(Menu, null,
|
|
56
|
+
React.createElement(Menu.Heading, null, "Something Tasty")),
|
|
57
|
+
React.createElement(Menu.Page, null,
|
|
58
|
+
React.createElement(FocusLayout, null,
|
|
59
|
+
React.createElement(Button, { onClick: () => addNotification(successNotification) }, "Save user"),
|
|
60
|
+
React.createElement("br", null),
|
|
61
|
+
React.createElement("br", null),
|
|
62
|
+
React.createElement(Button, { onClick: () => addNotification(errorNotification) }, "Validate Form"),
|
|
63
|
+
React.createElement("br", null),
|
|
64
|
+
React.createElement("br", null),
|
|
65
|
+
React.createElement(Button, { variant: 'secondary', onClick: () => setNotifications(notifications.slice(1)) }, "Clear")))));
|
|
66
|
+
};
|
|
67
|
+
export const OverModal = () => {
|
|
68
|
+
const notifications = [
|
|
69
|
+
{
|
|
70
|
+
id: '123',
|
|
71
|
+
message: 'User saved!',
|
|
72
|
+
variant: 'success',
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
id: '456',
|
|
76
|
+
message: 'Error validating form',
|
|
77
|
+
variant: 'danger',
|
|
78
|
+
},
|
|
79
|
+
];
|
|
80
|
+
return (React.createElement(React.Fragment, null,
|
|
81
|
+
React.createElement(Notifications, { notifications: notifications }),
|
|
82
|
+
React.createElement(Menu, null,
|
|
83
|
+
React.createElement(Menu.Heading, null, "Something Tasty")),
|
|
84
|
+
React.createElement(Menu.Page, null,
|
|
85
|
+
React.createElement(Modal, { onClose: () => {
|
|
86
|
+
console.log('close..');
|
|
87
|
+
} },
|
|
88
|
+
React.createElement(Modal.Header, { header: 'A test modal' }),
|
|
89
|
+
React.createElement(Modal.Body, null,
|
|
90
|
+
React.createElement(PaddedLayout, null,
|
|
91
|
+
React.createElement(Text, null, "Some text...")))))));
|
|
92
|
+
};
|
|
93
|
+
export default {
|
|
94
|
+
title: 'Components/Notifications',
|
|
95
|
+
component: Notifications,
|
|
96
|
+
parameters: {
|
|
97
|
+
layout: 'fullscreen',
|
|
98
|
+
},
|
|
99
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
import IdenticonObj from 'identicon.js';
|
|
4
|
+
import colours from '../../colours/colours';
|
|
5
|
+
import SparkMD5 from 'spark-md5';
|
|
6
|
+
const ImageContainer = styled.div `
|
|
7
|
+
height: 36px;
|
|
8
|
+
width: 36px;
|
|
9
|
+
border-radius: 4px;
|
|
10
|
+
|
|
11
|
+
border: thin solid ${(props) => props.theme.colours.defaultBorder};
|
|
12
|
+
`;
|
|
13
|
+
const Image = styled.img `
|
|
14
|
+
height: 34px;
|
|
15
|
+
width: 34px;
|
|
16
|
+
border-radius: 4px;
|
|
17
|
+
object-fit: cover;
|
|
18
|
+
`;
|
|
19
|
+
const hexToRgb = (hex) => {
|
|
20
|
+
const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
|
|
21
|
+
return result
|
|
22
|
+
? {
|
|
23
|
+
r: parseInt(result[1], 16),
|
|
24
|
+
g: parseInt(result[2], 16),
|
|
25
|
+
b: parseInt(result[3], 16),
|
|
26
|
+
}
|
|
27
|
+
: null;
|
|
28
|
+
};
|
|
29
|
+
const Identicon = ({ value }) => {
|
|
30
|
+
const hexColours = [colours.red, colours.green, colours.blue, colours.yellow];
|
|
31
|
+
const convertedColours = hexColours.map((hex) => {
|
|
32
|
+
const rgb = hexToRgb(hex);
|
|
33
|
+
return [rgb === null || rgb === void 0 ? void 0 : rgb.r, rgb === null || rgb === void 0 ? void 0 : rgb.g, rgb === null || rgb === void 0 ? void 0 : rgb.b, 255];
|
|
34
|
+
});
|
|
35
|
+
const hash = SparkMD5.hash(value || 'unknown user');
|
|
36
|
+
const colourIndex = Math.floor(Math.random() * 4);
|
|
37
|
+
const data = new IdenticonObj(hash, {
|
|
38
|
+
foreground: convertedColours[colourIndex] || [0, 0, 0, 255],
|
|
39
|
+
background: [255, 255, 255, 255],
|
|
40
|
+
margin: 0,
|
|
41
|
+
size: 34,
|
|
42
|
+
}).toString();
|
|
43
|
+
return React.createElement(Image, { src: `data:image/png;base64,${data}` });
|
|
44
|
+
};
|
|
45
|
+
const ProfileImage = ({ name, image }) => {
|
|
46
|
+
if (image) {
|
|
47
|
+
return (React.createElement(ImageContainer, null,
|
|
48
|
+
React.createElement(Image, { src: image })));
|
|
49
|
+
}
|
|
50
|
+
return (React.createElement(ImageContainer, null,
|
|
51
|
+
React.createElement(Identicon, { value: name })));
|
|
52
|
+
};
|
|
53
|
+
export default ProfileImage;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { Meta } from '@storybook/react/types-6-0';
|
|
3
|
+
export declare const Standard: () => JSX.Element;
|
|
4
|
+
export declare const Generated: () => JSX.Element;
|
|
5
|
+
declare const _default: Meta<import("@storybook/react/types-6-0").Args>;
|
|
6
|
+
export default _default;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ProfileImage } from '../..';
|
|
3
|
+
export const Standard = () => (React.createElement(ProfileImage, { name: 'Hungry Bear', image: 'https://i.guim.co.uk/img/media/86c3481516dce247943ac2978b4f48d16a3ac265/0_170_5120_3074/master/5120.jpg?width=1200&height=1200&quality=85&auto=format&fit=crop&s=637dc5731d52754675ef36344a6af3c8' }));
|
|
4
|
+
export const Generated = () => React.createElement(ProfileImage, { name: 'Hungry Bear' });
|
|
5
|
+
export default {
|
|
6
|
+
title: 'Components/ProfileImage',
|
|
7
|
+
component: ProfileImage,
|
|
8
|
+
};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
2
|
+
import QRCode from 'qrcode';
|
|
3
|
+
import styled from 'styled-components';
|
|
4
|
+
import Text from '../Text/Text.component';
|
|
5
|
+
const StyledCanvas = styled.canvas `
|
|
6
|
+
cursor: pointer;
|
|
7
|
+
`;
|
|
8
|
+
const Container = styled.div `
|
|
9
|
+
position: relative;
|
|
10
|
+
height: 132px;
|
|
11
|
+
width: 132px;
|
|
12
|
+
`;
|
|
13
|
+
const ToastContainer = styled.div `
|
|
14
|
+
position: absolute;
|
|
15
|
+
bottom: -12px;
|
|
16
|
+
|
|
17
|
+
width: 100%;
|
|
18
|
+
|
|
19
|
+
display: flex;
|
|
20
|
+
justify-content: center;
|
|
21
|
+
|
|
22
|
+
pointer-events: none;
|
|
23
|
+
touch-action: none;
|
|
24
|
+
`;
|
|
25
|
+
const Toast = styled.div `
|
|
26
|
+
background-color: ${(props) => props.theme.colours.secondary.main};
|
|
27
|
+
padding: 2px 8px;
|
|
28
|
+
border-radius: 4px;
|
|
29
|
+
`;
|
|
30
|
+
const StyledText = styled(Text) `
|
|
31
|
+
color: ${(props) => props.theme.colours.secondary.contrastText};
|
|
32
|
+
`;
|
|
33
|
+
const CopyInput = styled.input `
|
|
34
|
+
opacity: 0;
|
|
35
|
+
position: absolute;
|
|
36
|
+
left: -9999px;
|
|
37
|
+
top: -9999px;
|
|
38
|
+
`;
|
|
39
|
+
const QrCode = ({ value }) => {
|
|
40
|
+
const ref = useRef(null);
|
|
41
|
+
const inputRef = useRef(null);
|
|
42
|
+
const hintTimeoutRef = useRef();
|
|
43
|
+
const [copiedHint, setCopiedHint] = useState(false);
|
|
44
|
+
const showHint = async () => {
|
|
45
|
+
if (hintTimeoutRef.current) {
|
|
46
|
+
window.clearTimeout(hintTimeoutRef.current);
|
|
47
|
+
}
|
|
48
|
+
if (inputRef === null || inputRef === void 0 ? void 0 : inputRef.current) {
|
|
49
|
+
inputRef.current.select();
|
|
50
|
+
document.execCommand('copy');
|
|
51
|
+
}
|
|
52
|
+
setCopiedHint(true);
|
|
53
|
+
hintTimeoutRef.current = setTimeout(() => {
|
|
54
|
+
setCopiedHint(false);
|
|
55
|
+
}, 2000);
|
|
56
|
+
};
|
|
57
|
+
useEffect(() => {
|
|
58
|
+
if (ref.current) {
|
|
59
|
+
QRCode.toCanvas(ref.current, value, {
|
|
60
|
+
width: 132,
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
}, [value]);
|
|
64
|
+
return (React.createElement(Container, { onClick: () => showHint() },
|
|
65
|
+
copiedHint && (React.createElement(ToastContainer, null,
|
|
66
|
+
React.createElement(Toast, null,
|
|
67
|
+
React.createElement(StyledText, null, "Copied!")))),
|
|
68
|
+
React.createElement(CopyInput, { readOnly: true, ref: inputRef, value: value }),
|
|
69
|
+
React.createElement(StyledCanvas, { ref: ref })));
|
|
70
|
+
};
|
|
71
|
+
export default QrCode;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { QrCode } from '../..';
|
|
3
|
+
export const Standard = () => (React.createElement(React.Fragment, null,
|
|
4
|
+
React.createElement(QrCode, { value: 'http://www.google.com' })));
|
|
5
|
+
export default {
|
|
6
|
+
title: 'Components/QrCode',
|
|
7
|
+
component: QrCode,
|
|
8
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
const getSpacing = (size) => {
|
|
4
|
+
switch (size) {
|
|
5
|
+
case '0.5x':
|
|
6
|
+
return '4px';
|
|
7
|
+
case '1x':
|
|
8
|
+
return '8px';
|
|
9
|
+
case '2x':
|
|
10
|
+
return '16px';
|
|
11
|
+
case '4x':
|
|
12
|
+
return '32px';
|
|
13
|
+
case '6x':
|
|
14
|
+
return '48px';
|
|
15
|
+
default:
|
|
16
|
+
return 0;
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
const SpacerInternal = styled.div `
|
|
20
|
+
width: 0;
|
|
21
|
+
visibility: hidden;
|
|
22
|
+
height: ${(props) => getSpacing(props.size)};
|
|
23
|
+
`;
|
|
24
|
+
const Spacer = ({ size }) => React.createElement(SpacerInternal, { size: size });
|
|
25
|
+
export default Spacer;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ColourVariant } from '../../theme/theme.types';
|
|
3
|
+
export interface SquareButtonProps {
|
|
4
|
+
children: React.ReactChild;
|
|
5
|
+
variant?: ColourVariant;
|
|
6
|
+
onClick?: () => void;
|
|
7
|
+
}
|
|
8
|
+
declare const SquareButton: ({ children, variant, onClick }: SquareButtonProps) => JSX.Element;
|
|
9
|
+
export default SquareButton;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
import getThemeVariantColours from '../../theme/helpers/getThemeVariantColours';
|
|
4
|
+
const StyledButton = styled.button `
|
|
5
|
+
height: 128px;
|
|
6
|
+
width: 128px;
|
|
7
|
+
|
|
8
|
+
outline: none;
|
|
9
|
+
box-shadow: none;
|
|
10
|
+
border: none;
|
|
11
|
+
|
|
12
|
+
cursor: pointer;
|
|
13
|
+
|
|
14
|
+
padding: 0 24px;
|
|
15
|
+
|
|
16
|
+
font-size: ${(props) => props.theme.fonts.default.size};
|
|
17
|
+
font: ${(props) => props.theme.fonts.default.family};
|
|
18
|
+
|
|
19
|
+
color: ${(props) => getThemeVariantColours(props.variant, props.theme).contrastText};
|
|
20
|
+
background-color: ${(props) => getThemeVariantColours(props.variant, props.theme).main};
|
|
21
|
+
|
|
22
|
+
border-radius: 2px;
|
|
23
|
+
|
|
24
|
+
&:hover {
|
|
25
|
+
background-color: ${(props) => getThemeVariantColours(props.variant, props.theme).hover};
|
|
26
|
+
}
|
|
27
|
+
`;
|
|
28
|
+
const SquareButton = ({ children, variant = 'primary', onClick }) => {
|
|
29
|
+
return (React.createElement(StyledButton, { variant: variant, onClick: onClick }, children));
|
|
30
|
+
};
|
|
31
|
+
export default SquareButton;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { SquareButton } from '../..';
|
|
3
|
+
export const Standard = () => (React.createElement(React.Fragment, null,
|
|
4
|
+
React.createElement(SquareButton, null, "Primary"),
|
|
5
|
+
React.createElement("br", null),
|
|
6
|
+
React.createElement("br", null),
|
|
7
|
+
React.createElement(SquareButton, { variant: 'secondary' }, "A Secondary Button"),
|
|
8
|
+
React.createElement("br", null),
|
|
9
|
+
React.createElement("br", null),
|
|
10
|
+
React.createElement(SquareButton, { variant: 'tertiary' }, "A Tertiary Square Button")));
|
|
11
|
+
export default {
|
|
12
|
+
title: 'Components/SquareButton',
|
|
13
|
+
component: SquareButton,
|
|
14
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
const SubHeading = styled.h2 `
|
|
3
|
+
font-family: ${(props) => props.theme.fonts.subHeading.family};
|
|
4
|
+
font-size: ${(props) => props.theme.fonts.subHeading.size};
|
|
5
|
+
font-weight: ${(props) => props.theme.fonts.subHeading.weight};
|
|
6
|
+
|
|
7
|
+
color: ${(props) => props.theme.colours.defaultFont};
|
|
8
|
+
|
|
9
|
+
margin: 0;
|
|
10
|
+
`;
|
|
11
|
+
export default SubHeading;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { TableVariant } from './_Table.context';
|
|
3
|
+
export declare type TableCellVariant = 'tight';
|
|
4
|
+
export interface TableProps {
|
|
5
|
+
children: React.ReactNode;
|
|
6
|
+
variant?: TableVariant;
|
|
7
|
+
}
|
|
8
|
+
export interface TableCellProps {
|
|
9
|
+
variant?: TableCellVariant;
|
|
10
|
+
}
|
|
11
|
+
declare const Table: {
|
|
12
|
+
({ children, variant }: TableProps): JSX.Element;
|
|
13
|
+
Row: ({ children }: import("./_TableRow.component").TableRowProps) => JSX.Element;
|
|
14
|
+
Cell: import("styled-components").StyledComponent<"td", import("styled-components").DefaultTheme, TableCellProps, never>;
|
|
15
|
+
};
|
|
16
|
+
export default Table;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
import TableContext from './_Table.context';
|
|
4
|
+
import TableRow from './_TableRow.component';
|
|
5
|
+
const StyledTable = styled.table `
|
|
6
|
+
width: 100%;
|
|
7
|
+
`;
|
|
8
|
+
const TableCell = styled.td `
|
|
9
|
+
font-family: ${(props) => props.theme.fonts.default.family};
|
|
10
|
+
font-size: ${(props) => props.theme.fonts.default.size};
|
|
11
|
+
font-weight: ${(props) => props.theme.fonts.default.weight};
|
|
12
|
+
|
|
13
|
+
color: ${(props) => props.theme.colours.defaultFont};
|
|
14
|
+
|
|
15
|
+
padding: ${(props) => (props.variant === 'tight' ? '0' : '0 16px')};
|
|
16
|
+
height: 36px;
|
|
17
|
+
`;
|
|
18
|
+
const Table = ({ children, variant = 'regular' }) => {
|
|
19
|
+
return (React.createElement(TableContext.Provider, { value: { variant } },
|
|
20
|
+
React.createElement(StyledTable, null, children)));
|
|
21
|
+
};
|
|
22
|
+
Table.Row = TableRow;
|
|
23
|
+
Table.Cell = TableCell;
|
|
24
|
+
export default Table;
|