@dtdot/lego 1.8.3 → 2.0.0-10
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/components/ActionMenu/ActionMenu.component.d.ts +12 -4
- package/build/components/ActionMenu/ActionMenu.component.js +9 -16
- package/build/components/ActionMenu/ActionMenu.context.d.ts +6 -0
- package/build/components/ActionMenu/ActionMenu.context.js +6 -0
- package/build/components/ActionMenu/_ActionMenuCheckbox.component.d.ts +9 -0
- package/build/components/ActionMenu/_ActionMenuCheckbox.component.js +30 -0
- package/build/components/ActionMenu/_ActionMenuItem.component.d.ts +5 -4
- package/build/components/ActionMenu/_ActionMenuItem.component.js +14 -4
- package/build/components/ActionMenu/_ActionMenuPanel.component.d.ts +3 -4
- package/build/components/ActionMenu/_ActionMenuPanel.component.js +1 -2
- package/build/components/Button/Button.component.d.ts +5 -1
- package/build/components/Button/Button.component.js +68 -10
- package/build/components/Checklist/_ChecklistItem.component.js +4 -22
- package/build/components/Form/Form.component.d.ts +4 -1
- package/build/components/Form/Form.component.js +2 -0
- package/build/components/Form/_NestedFormArray.d.ts +8 -0
- package/build/components/Form/_NestedFormArray.js +25 -0
- package/build/components/Heading/Heading.component.d.ts +1 -0
- package/build/components/Heading/Heading.component.js +2 -0
- package/build/components/Heading/_DividerHeading.component.d.ts +2 -0
- package/build/components/Heading/_DividerHeading.component.js +15 -0
- package/build/components/Loader/Loader.component.d.ts +4 -1
- package/build/components/Loader/Loader.component.js +17 -5
- package/build/components/MinimalMenu/MinimalMenu.component.d.ts +1 -0
- package/build/components/MinimalMenu/MinimalMenu.component.js +2 -0
- package/build/components/MinimalMenu/_MinimalMenuHeader.component.d.ts +15 -0
- package/build/components/MinimalMenu/_MinimalMenuHeader.component.js +31 -0
- package/build/components/Spacer/Spacer.component.d.ts +1 -1
- package/build/components/Spacer/Spacer.component.js +2 -0
- package/build/components/Table/Table.component.d.ts +3 -1
- package/build/components/Table/Table.component.js +14 -0
- package/build/components/Table/_TableAction.d.ts +6 -2
- package/build/components/Table/_TableAction.js +6 -3
- package/build/components/Table/_TableActionMenu.js +1 -1
- package/build/components/common/Checkmark.component.d.ts +6 -0
- package/build/components/common/Checkmark.component.js +23 -0
- package/build/theme/dark.theme.js +16 -6
- package/build/theme/default.theme.js +6 -0
- package/build/theme/helpers/getThemeVariantColours.d.ts +1 -5
- package/build/theme/helpers/getThemeVariantColours.js +3 -15
- package/build/theme/theme.types.d.ts +2 -0
- package/package.json +5 -10
- package/LICENSE +0 -21
- package/README.md +0 -51
|
@@ -1,10 +1,18 @@
|
|
|
1
|
-
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { IconProp } from '@fortawesome/fontawesome-svg-core';
|
|
2
3
|
import { ColourVariant } from '../../theme/theme.types';
|
|
3
|
-
import {
|
|
4
|
+
import { ButtonSize } from '../Button/Button.component';
|
|
4
5
|
export interface ActionMenuProps {
|
|
5
|
-
'
|
|
6
|
+
'children': React.ReactNode;
|
|
6
7
|
'variant'?: ColourVariant;
|
|
8
|
+
'size'?: ButtonSize;
|
|
9
|
+
'icon'?: IconProp;
|
|
10
|
+
'text'?: string;
|
|
7
11
|
'data-cy'?: string;
|
|
8
12
|
}
|
|
9
|
-
declare const ActionMenu:
|
|
13
|
+
declare const ActionMenu: {
|
|
14
|
+
({ children, variant, size, icon, text, "data-cy": dataCy }: ActionMenuProps): JSX.Element;
|
|
15
|
+
Item: ({ children, onClick, "data-cy": dataCy }: import("./_ActionMenuItem.component").ActionMenuItemProps) => JSX.Element;
|
|
16
|
+
Checkbox: ({ children, checked, onClick, "data-cy": dataCy }: import("./_ActionMenuCheckbox.component").ActionMenuCheckboxProps) => JSX.Element;
|
|
17
|
+
};
|
|
10
18
|
export default ActionMenu;
|
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
2
1
|
import React, { useCallback, useEffect, useState } from 'react';
|
|
3
2
|
import ReactDOM from 'react-dom';
|
|
4
3
|
import { usePopper } from 'react-popper';
|
|
5
4
|
import { faEllipsisV } from '@fortawesome/free-solid-svg-icons';
|
|
6
|
-
import styled from 'styled-components';
|
|
7
5
|
import Button from '../Button/Button.component';
|
|
6
|
+
import ActionMenuContext from './ActionMenu.context';
|
|
7
|
+
import ActionMenuCheckbox from './_ActionMenuCheckbox.component';
|
|
8
|
+
import ActionMenuItem from './_ActionMenuItem.component';
|
|
8
9
|
import ActionMenuPanel from './_ActionMenuPanel.component';
|
|
9
|
-
const StyledIcon = styled(FontAwesomeIcon) `
|
|
10
|
-
font-size: 18px;
|
|
11
|
-
`;
|
|
12
10
|
const offsetFn = () => [70, 4];
|
|
13
|
-
const ActionMenu = ({
|
|
11
|
+
const ActionMenu = ({ children, variant, size, icon, text, 'data-cy': dataCy }) => {
|
|
14
12
|
const [shown, setShown] = useState(false);
|
|
15
13
|
const [referenceElement, setReferenceElement] = useState();
|
|
16
14
|
const [popperElement, setPopperElement] = useState();
|
|
@@ -35,18 +33,13 @@ const ActionMenu = ({ items, variant, 'data-cy': dataCy }) => {
|
|
|
35
33
|
document.removeEventListener('mouseup', handleGlobalClick);
|
|
36
34
|
};
|
|
37
35
|
}, [handleGlobalClick, popperElement]);
|
|
38
|
-
const augmentedItems = items.map((item) => ({
|
|
39
|
-
...item,
|
|
40
|
-
onClick: () => {
|
|
41
|
-
setShown(false);
|
|
42
|
-
item.onClick();
|
|
43
|
-
},
|
|
44
|
-
}));
|
|
45
36
|
return (React.createElement(React.Fragment, null,
|
|
46
|
-
React.createElement(Button, { variant: variant, "data-cy": dataCy || 'action-menu-button', ref: setReferenceElement, onClick: () => setShown(true) },
|
|
47
|
-
React.createElement(StyledIcon, { icon: faEllipsisV })),
|
|
37
|
+
React.createElement(Button, { variant: variant, size: size, icon: icon || faEllipsisV, "data-cy": dataCy || 'action-menu-button', ref: setReferenceElement, onClick: () => setShown(true) }, text),
|
|
48
38
|
shown &&
|
|
49
39
|
ReactDOM.createPortal(React.createElement("div", { ref: setPopperElement, style: styles.popper, ...attributes.popper },
|
|
50
|
-
React.createElement(
|
|
40
|
+
React.createElement(ActionMenuContext.Provider, { value: { closeActionMenu: () => setShown(false) } },
|
|
41
|
+
React.createElement(ActionMenuPanel, null, children))), document.querySelector('body'))));
|
|
51
42
|
};
|
|
43
|
+
ActionMenu.Item = ActionMenuItem;
|
|
44
|
+
ActionMenu.Checkbox = ActionMenuCheckbox;
|
|
52
45
|
export default ActionMenu;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface ActionMenuCheckboxProps {
|
|
3
|
+
'children': React.ReactNode;
|
|
4
|
+
'checked': boolean;
|
|
5
|
+
'onClick': () => void;
|
|
6
|
+
'data-cy'?: string;
|
|
7
|
+
}
|
|
8
|
+
declare const ActionMenuCheckbox: ({ children, checked, onClick, "data-cy": dataCy }: ActionMenuCheckboxProps) => JSX.Element;
|
|
9
|
+
export default ActionMenuCheckbox;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { motion } from 'framer-motion';
|
|
3
|
+
import styled, { useTheme } from 'styled-components';
|
|
4
|
+
import { Checkmark } from '../common/Checkmark.component';
|
|
5
|
+
const ActionMenuCheckboxOuter = styled(motion.div) `
|
|
6
|
+
display: flex;
|
|
7
|
+
align-items: center;
|
|
8
|
+
justify-content: space-between;
|
|
9
|
+
height: 42px;
|
|
10
|
+
|
|
11
|
+
padding: 0px 16px;
|
|
12
|
+
cursor: pointer;
|
|
13
|
+
|
|
14
|
+
color: ${(props) => props.theme.colours.defaultFont};
|
|
15
|
+
font-family: ${(props) => props.theme.fonts.default.family};
|
|
16
|
+
font-size: ${(props) => props.theme.fonts.default.size};
|
|
17
|
+
font-weight: ${(props) => props.theme.fonts.default.weight};
|
|
18
|
+
`;
|
|
19
|
+
const Spacer = styled.div `
|
|
20
|
+
width: 16px;
|
|
21
|
+
`;
|
|
22
|
+
const ActionMenuCheckbox = ({ children, checked, onClick, 'data-cy': dataCy }) => {
|
|
23
|
+
const theme = useTheme();
|
|
24
|
+
return (React.createElement(React.Fragment, null,
|
|
25
|
+
React.createElement(ActionMenuCheckboxOuter, { style: { backgroundColor: theme.colours.tertiary.main }, whileHover: { backgroundColor: theme.colours.tertiary.hover }, onClick: onClick, "data-cy": dataCy || 'action-menu-checkbox' },
|
|
26
|
+
children,
|
|
27
|
+
React.createElement(Spacer, null),
|
|
28
|
+
React.createElement(Checkmark, { checked: checked, large: false }))));
|
|
29
|
+
};
|
|
30
|
+
export default ActionMenuCheckbox;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import React from 'react';
|
|
2
2
|
export interface ActionMenuItemProps {
|
|
3
|
-
|
|
4
|
-
onClick: () => void;
|
|
3
|
+
'children': React.ReactNode;
|
|
4
|
+
'onClick': () => void;
|
|
5
|
+
'data-cy'?: string;
|
|
5
6
|
}
|
|
6
|
-
declare const ActionMenuItem: ({
|
|
7
|
+
declare const ActionMenuItem: ({ children, onClick, "data-cy": dataCy }: ActionMenuItemProps) => JSX.Element;
|
|
7
8
|
export default ActionMenuItem;
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useContext } from 'react';
|
|
2
2
|
import { motion } from 'framer-motion';
|
|
3
3
|
import styled, { useTheme } from 'styled-components';
|
|
4
|
+
import ActionMenuContext from './ActionMenu.context';
|
|
4
5
|
const ActionMenuItemOuter = styled(motion.div) `
|
|
5
|
-
|
|
6
|
+
display: flex;
|
|
7
|
+
align-items: center;
|
|
8
|
+
height: 42px;
|
|
9
|
+
|
|
10
|
+
padding: 0px 16px;
|
|
6
11
|
cursor: pointer;
|
|
7
12
|
|
|
8
13
|
color: ${(props) => props.theme.colours.defaultFont};
|
|
@@ -10,9 +15,14 @@ const ActionMenuItemOuter = styled(motion.div) `
|
|
|
10
15
|
font-size: ${(props) => props.theme.fonts.default.size};
|
|
11
16
|
font-weight: ${(props) => props.theme.fonts.default.weight};
|
|
12
17
|
`;
|
|
13
|
-
const ActionMenuItem = ({
|
|
18
|
+
const ActionMenuItem = ({ children, onClick, 'data-cy': dataCy }) => {
|
|
14
19
|
const theme = useTheme();
|
|
20
|
+
const { closeActionMenu } = useContext(ActionMenuContext);
|
|
21
|
+
const handleClick = () => {
|
|
22
|
+
onClick();
|
|
23
|
+
closeActionMenu();
|
|
24
|
+
};
|
|
15
25
|
return (React.createElement(React.Fragment, null,
|
|
16
|
-
React.createElement(ActionMenuItemOuter, { style: { backgroundColor: theme.colours.tertiary.main }, whileHover: { backgroundColor: theme.colours.tertiary.hover }, onClick:
|
|
26
|
+
React.createElement(ActionMenuItemOuter, { style: { backgroundColor: theme.colours.tertiary.main }, whileHover: { backgroundColor: theme.colours.tertiary.hover }, onClick: handleClick, "data-cy": dataCy || 'action-menu-item' }, children)));
|
|
17
27
|
};
|
|
18
28
|
export default ActionMenuItem;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
import { IActionMenuItem } from './_ActionMenu.types';
|
|
1
|
+
import React from 'react';
|
|
3
2
|
export interface ActionMenuPanelProps {
|
|
4
|
-
|
|
3
|
+
children: React.ReactNode;
|
|
5
4
|
}
|
|
6
|
-
declare const ActionMenuPanel: ({
|
|
5
|
+
declare const ActionMenuPanel: ({ children }: ActionMenuPanelProps) => JSX.Element;
|
|
7
6
|
export default ActionMenuPanel;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import styled from 'styled-components';
|
|
3
|
-
import ActionMenuItem from './_ActionMenuItem.component';
|
|
4
3
|
const ActionMenuPanelOuter = styled.div `
|
|
5
4
|
background-color: ${(props) => props.theme.colours.tertiary.main};
|
|
6
5
|
min-width: 160px;
|
|
7
6
|
`;
|
|
8
|
-
const ActionMenuPanel = ({
|
|
7
|
+
const ActionMenuPanel = ({ children }) => (React.createElement(ActionMenuPanelOuter, { "data-cy": 'action-menu-popover' }, children));
|
|
9
8
|
export default ActionMenuPanel;
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { IconProp } from '@fortawesome/fontawesome-svg-core';
|
|
2
3
|
import { ColourVariant } from '../../theme/theme.types';
|
|
4
|
+
export type ButtonSize = 'sm' | 'md';
|
|
3
5
|
export interface ButtonProps {
|
|
4
|
-
'children'
|
|
6
|
+
'children'?: React.ReactNode;
|
|
5
7
|
'loading'?: boolean;
|
|
6
8
|
'variant'?: ColourVariant;
|
|
9
|
+
'size'?: ButtonSize;
|
|
7
10
|
'type'?: 'submit' | 'button';
|
|
11
|
+
'icon'?: IconProp;
|
|
8
12
|
'onClick'?: () => void;
|
|
9
13
|
'data-cy'?: string;
|
|
10
14
|
}
|
|
@@ -1,15 +1,52 @@
|
|
|
1
|
+
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
1
2
|
import React, { useContext } from 'react';
|
|
2
3
|
import styled, { keyframes } from 'styled-components';
|
|
3
4
|
import getThemeVariantColours from '../../theme/helpers/getThemeVariantColours';
|
|
4
5
|
import ButtonContext from './Button.context';
|
|
6
|
+
const getButtonHeightPx = (size) => {
|
|
7
|
+
switch (size) {
|
|
8
|
+
case 'sm':
|
|
9
|
+
return '32px';
|
|
10
|
+
case 'md':
|
|
11
|
+
return '48px';
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
const getButtonPaddingPx = (size) => {
|
|
15
|
+
switch (size) {
|
|
16
|
+
case 'sm':
|
|
17
|
+
return '0 12px';
|
|
18
|
+
case 'md':
|
|
19
|
+
return '0 24px';
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
const getIconContainerSizePx = (size) => {
|
|
23
|
+
switch (size) {
|
|
24
|
+
case 'sm':
|
|
25
|
+
return { width: '32px', height: '32px' };
|
|
26
|
+
case 'md':
|
|
27
|
+
return { width: '48px', height: '48px' };
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
const IconOuter = styled.span `
|
|
31
|
+
display: inline-flex;
|
|
32
|
+
align-items: center;
|
|
33
|
+
justify-content: center;
|
|
34
|
+
|
|
35
|
+
color: ${(props) => getThemeVariantColours(props.variant, props.theme).contrastText};
|
|
36
|
+
background-color: ${(props) => props.iconOnly
|
|
37
|
+
? getThemeVariantColours(props.variant, props.theme).main
|
|
38
|
+
: getThemeVariantColours(props.variant, props.theme).darker};
|
|
39
|
+
|
|
40
|
+
height: ${(props) => props.height || getIconContainerSizePx(props.size).height};
|
|
41
|
+
width: ${(props) => getIconContainerSizePx(props.size).width};
|
|
42
|
+
`;
|
|
5
43
|
const StyledButton = styled.button `
|
|
6
44
|
outline: none;
|
|
7
45
|
box-shadow: none;
|
|
8
46
|
border: none;
|
|
9
47
|
|
|
10
48
|
cursor: pointer;
|
|
11
|
-
|
|
12
|
-
padding: 0 24px;
|
|
49
|
+
padding: 0;
|
|
13
50
|
|
|
14
51
|
font-size: ${(props) => props.theme.fonts.default.size};
|
|
15
52
|
font-family: ${(props) => props.theme.fonts.default.family};
|
|
@@ -20,30 +57,47 @@ const StyledButton = styled.button `
|
|
|
20
57
|
border-radius: 2px;
|
|
21
58
|
|
|
22
59
|
// Props defined by the context
|
|
23
|
-
height: ${(props) => props.height ||
|
|
60
|
+
height: ${(props) => props.height || getButtonHeightPx(props.size)};
|
|
24
61
|
width: ${(props) => props.width};
|
|
25
62
|
align-self: ${(props) => props.alignSelf};
|
|
26
63
|
margin-top: ${(props) => props.marginTop};
|
|
27
64
|
|
|
28
65
|
&:hover {
|
|
29
66
|
background-color: ${(props) => getThemeVariantColours(props.variant, props.theme).hover};
|
|
67
|
+
|
|
68
|
+
${IconOuter} {
|
|
69
|
+
background-color: ${(props) => props.iconOnly
|
|
70
|
+
? getThemeVariantColours(props.variant, props.theme).hover
|
|
71
|
+
: getThemeVariantColours(props.variant, props.theme).darkerHover};
|
|
72
|
+
}
|
|
30
73
|
}
|
|
31
74
|
`;
|
|
75
|
+
const ButtonInner = styled.div `
|
|
76
|
+
display: flex;
|
|
77
|
+
align-items: center;
|
|
78
|
+
justify-content: center;
|
|
79
|
+
`;
|
|
80
|
+
const ButtonTextContainer = styled.span `
|
|
81
|
+
padding: ${(props) => getButtonPaddingPx(props.size)};
|
|
82
|
+
`;
|
|
32
83
|
const spinAnimation = keyframes `
|
|
33
84
|
0% { transform: rotate(0deg); }
|
|
34
85
|
100% { transform: rotate(360deg); }
|
|
35
86
|
`;
|
|
87
|
+
const SpinnerContainer = styled.span `
|
|
88
|
+
padding: 0 24px;
|
|
89
|
+
`;
|
|
36
90
|
const ButtonSpinner = styled.div `
|
|
37
91
|
display: inline-block;
|
|
38
|
-
width:
|
|
39
|
-
height:
|
|
92
|
+
width: ${(props) => getButtonHeightPx(props.size)};
|
|
93
|
+
height: ${(props) => getButtonHeightPx(props.size)};
|
|
40
94
|
|
|
41
95
|
&:after {
|
|
42
96
|
content: ' ';
|
|
43
97
|
display: block;
|
|
44
|
-
width: 24px;
|
|
45
|
-
height: 24px;
|
|
46
|
-
margin: 10px;
|
|
98
|
+
width: ${(props) => (props.size === 'md' ? '24px' : '16px')};
|
|
99
|
+
height: ${(props) => (props.size === 'md' ? '24px' : '16px')};
|
|
100
|
+
margin: ${(props) => (props.size === 'md' ? '10px' : '6px')};
|
|
47
101
|
border-radius: 50%;
|
|
48
102
|
border: 2px solid ${(props) => getThemeVariantColours(props.variant, props.theme).contrastText};
|
|
49
103
|
border-color: ${(props) => getThemeVariantColours(props.variant, props.theme).contrastText} transparent
|
|
@@ -54,8 +108,12 @@ const ButtonSpinner = styled.div `
|
|
|
54
108
|
}
|
|
55
109
|
`;
|
|
56
110
|
const Button = React.forwardRef(function Button(props, ref) {
|
|
57
|
-
const { children, loading, variant = 'primary', type = 'button', onClick, 'data-cy': dataCy } = props;
|
|
111
|
+
const { children, loading, variant = 'primary', size = 'md', type = 'button', icon, onClick, 'data-cy': dataCy, } = props;
|
|
58
112
|
const { width, height, alignSelf, marginTop } = useContext(ButtonContext);
|
|
59
|
-
return (React.createElement(StyledButton, { ref: ref, width: width, height: height, alignSelf: alignSelf, marginTop: marginTop, variant: variant, type: type, onClick: onClick, "data-cy": dataCy || 'button' }, loading ? React.createElement(
|
|
113
|
+
return (React.createElement(StyledButton, { ref: ref, width: width, height: height, alignSelf: alignSelf, marginTop: marginTop, variant: variant, size: size, type: type, onClick: onClick, "data-cy": dataCy || 'button', iconOnly: !children }, loading ? (React.createElement(SpinnerContainer, null,
|
|
114
|
+
React.createElement(ButtonSpinner, { "data-cy": 'button-loading-spinner', variant: variant, size: size, iconOnly: !children }))) : (React.createElement(ButtonInner, null,
|
|
115
|
+
children && React.createElement(ButtonTextContainer, { size: size }, children),
|
|
116
|
+
icon && (React.createElement(IconOuter, { variant: variant, size: size, height: height, iconOnly: !children },
|
|
117
|
+
React.createElement(FontAwesomeIcon, { icon: icon })))))));
|
|
60
118
|
});
|
|
61
119
|
export default Button;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { motion } from 'framer-motion';
|
|
3
3
|
import styled, { useTheme } from 'styled-components';
|
|
4
|
+
import { Checkmark } from '../common/Checkmark.component';
|
|
4
5
|
const Outerlabel = styled(motion.label) `
|
|
5
6
|
position: relative;
|
|
6
7
|
margin-bottom: 4px;
|
|
@@ -26,28 +27,8 @@ const HiddenCheckbox = styled.input `
|
|
|
26
27
|
height: 0;
|
|
27
28
|
width: 0;
|
|
28
29
|
`;
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
height: ${(props) => (props.large ? '36px' : '24px')};
|
|
32
|
-
width: ${(props) => (props.large ? '36px' : '24px')};
|
|
33
|
-
margin-right: 8px;
|
|
34
|
-
background-color: ${(props) => props.theme.colours.cardBackground};
|
|
35
|
-
|
|
36
|
-
&:after {
|
|
37
|
-
content: '';
|
|
38
|
-
position: absolute;
|
|
39
|
-
display: ${(props) => (props.checked ? 'block' : 'none')};
|
|
40
|
-
|
|
41
|
-
left: ${(props) => (props.large ? '14px' : '9px')};
|
|
42
|
-
top: ${(props) => (props.large ? '7px' : '5px')};
|
|
43
|
-
width: ${(props) => (props.large ? '7px' : '5px')};
|
|
44
|
-
height: ${(props) => (props.large ? '16px' : '10px')};
|
|
45
|
-
border: solid ${(props) => props.theme.colours.defaultFont};
|
|
46
|
-
border-width: 0 3px 3px 0;
|
|
47
|
-
-webkit-transform: rotate(45deg);
|
|
48
|
-
-ms-transform: rotate(45deg);
|
|
49
|
-
transform: rotate(45deg);
|
|
50
|
-
}
|
|
30
|
+
const Spacer = styled.div `
|
|
31
|
+
width: 8px;
|
|
51
32
|
`;
|
|
52
33
|
const Strikethrough = styled.div `
|
|
53
34
|
position: absolute;
|
|
@@ -71,6 +52,7 @@ const ChecklistItem = ({ label, value, onChange, large }) => {
|
|
|
71
52
|
};
|
|
72
53
|
return (React.createElement(Outerlabel, { checked: value, whileHover: { backgroundColor: theme.colours.cardBackground }, "data-cy": value ? 'checklist-item-checked' : 'checklist-item' },
|
|
73
54
|
React.createElement(Checkmark, { checked: value, large: large }),
|
|
55
|
+
React.createElement(Spacer, null),
|
|
74
56
|
label,
|
|
75
57
|
React.createElement(HiddenCheckbox, { type: 'checkbox', checked: value, onChange: handleChange }),
|
|
76
58
|
value && React.createElement(Strikethrough, { large: large }, label)));
|
|
@@ -6,5 +6,8 @@ interface FormProps {
|
|
|
6
6
|
onSubmit?: () => void;
|
|
7
7
|
children: React.ReactNode;
|
|
8
8
|
}
|
|
9
|
-
declare const Form:
|
|
9
|
+
declare const Form: {
|
|
10
|
+
({ value, errors, onChange, onSubmit, children }: FormProps): JSX.Element;
|
|
11
|
+
NestedFormArray: ({ name, index, children }: import("./_NestedFormArray").NestedFormArrayProps) => JSX.Element;
|
|
12
|
+
};
|
|
10
13
|
export default Form;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import FormStateContext from './FormState.context';
|
|
4
|
+
import NestedFormArray from './_NestedFormArray';
|
|
4
5
|
const Form = ({ value, errors = {}, onChange, onSubmit, children }) => {
|
|
5
6
|
const onChangeFn = (key, fieldValue) => {
|
|
6
7
|
onChange({
|
|
@@ -22,4 +23,5 @@ const Form = ({ value, errors = {}, onChange, onSubmit, children }) => {
|
|
|
22
23
|
return (React.createElement(FormStateContext.Provider, { value: contextValue },
|
|
23
24
|
React.createElement("form", { onSubmit: onSubmitFn }, children)));
|
|
24
25
|
};
|
|
26
|
+
Form.NestedFormArray = NestedFormArray;
|
|
25
27
|
export default Form;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface NestedFormArrayProps {
|
|
3
|
+
name: string;
|
|
4
|
+
index: number;
|
|
5
|
+
children: React.ReactNode;
|
|
6
|
+
}
|
|
7
|
+
declare const NestedFormArray: ({ name, index, children }: NestedFormArrayProps) => JSX.Element;
|
|
8
|
+
export default NestedFormArray;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import FormStateContext from './FormState.context';
|
|
3
|
+
import useFormNode from './useFormNode.hook';
|
|
4
|
+
const NestedFormArray = ({ name, index, children }) => {
|
|
5
|
+
const { value, error, onChange } = useFormNode(name);
|
|
6
|
+
const safeValue = Array.from(Array(Math.max(index + 1, value?.length || 0))).map((_, i) => value?.[i] || {});
|
|
7
|
+
const safeError = Array.from(Array(Math.max(index + 1, value?.length || 0))).map((_, i) => error?.[i] || {});
|
|
8
|
+
const nestedValue = safeValue[index];
|
|
9
|
+
const nestedErrors = safeError[index];
|
|
10
|
+
console.log('safe', safeValue);
|
|
11
|
+
const onChangeFn = (key, fieldValue) => {
|
|
12
|
+
const newValue = [
|
|
13
|
+
...safeValue.map((item, i) => (i === index ? { ...item, [key]: fieldValue } : item)),
|
|
14
|
+
];
|
|
15
|
+
console.log(newValue);
|
|
16
|
+
onChange && onChange(newValue);
|
|
17
|
+
};
|
|
18
|
+
const contextValue = {
|
|
19
|
+
value: nestedValue,
|
|
20
|
+
errors: nestedErrors,
|
|
21
|
+
onChange: onChangeFn,
|
|
22
|
+
};
|
|
23
|
+
return React.createElement(FormStateContext.Provider, { value: contextValue }, children);
|
|
24
|
+
};
|
|
25
|
+
export default NestedFormArray;
|
|
@@ -6,5 +6,6 @@ declare const Heading: {
|
|
|
6
6
|
({ children }: HeadingProps): JSX.Element;
|
|
7
7
|
SubHeading: import("styled-components").StyledComponent<"h3", import("styled-components").DefaultTheme, {}, never>;
|
|
8
8
|
FormHeading: import("styled-components").StyledComponent<"h3", import("styled-components").DefaultTheme, {}, never>;
|
|
9
|
+
DividerHeading: import("styled-components").StyledComponent<"h3", import("styled-components").DefaultTheme, {}, never>;
|
|
9
10
|
};
|
|
10
11
|
export default Heading;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import styled from 'styled-components';
|
|
3
|
+
import DividerHeading from './_DividerHeading.component';
|
|
3
4
|
import FormHeading from './_FormHeading.component';
|
|
4
5
|
import SubHeading from './_SubHeading.component';
|
|
5
6
|
const HeadingContainer = styled.h2 `
|
|
@@ -14,4 +15,5 @@ const HeadingContainer = styled.h2 `
|
|
|
14
15
|
const Heading = ({ children }) => React.createElement(HeadingContainer, null, children);
|
|
15
16
|
Heading.SubHeading = SubHeading;
|
|
16
17
|
Heading.FormHeading = FormHeading;
|
|
18
|
+
Heading.DividerHeading = DividerHeading;
|
|
17
19
|
export default Heading;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
const DividerHeading = styled.h3 `
|
|
3
|
+
font-family: ${(props) => props.theme.fonts.default.family};
|
|
4
|
+
font-size: ${(props) => props.theme.fonts.default.size};
|
|
5
|
+
font-weight: ${(props) => props.theme.fonts.default.weight};
|
|
6
|
+
|
|
7
|
+
color: ${(props) => props.theme.colours.defaultFont};
|
|
8
|
+
|
|
9
|
+
width: 100%;
|
|
10
|
+
padding: 8px;
|
|
11
|
+
|
|
12
|
+
background-color: ${(props) => props.theme.colours.cardBackground};
|
|
13
|
+
box-shadow: ${(props) => props.theme.shadows.small};
|
|
14
|
+
`;
|
|
15
|
+
export default DividerHeading;
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { motion } from 'framer-motion';
|
|
3
|
+
import styled from 'styled-components';
|
|
3
4
|
import colours from '../../colours/colours';
|
|
5
|
+
const PageLoaderContainer = styled.div `
|
|
6
|
+
display: flex;
|
|
7
|
+
height: 300px;
|
|
8
|
+
justify-content: center;
|
|
9
|
+
align-items: center;
|
|
10
|
+
`;
|
|
4
11
|
const loadingContainer = {
|
|
5
12
|
width: '40px',
|
|
6
13
|
height: '26px',
|
|
@@ -40,10 +47,15 @@ const loadingCircleTransition = {
|
|
|
40
47
|
repeatType: 'reverse',
|
|
41
48
|
ease: 'easeInOut',
|
|
42
49
|
}; // Framer motion isn't accepting 'repeatType' but animation breaks without it
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
50
|
+
const BaseLoader = () => (React.createElement(motion.div, { style: loadingContainer, variants: loadingContainerVariants, initial: 'start', animate: 'end', "data-cy": 'loader' },
|
|
51
|
+
React.createElement(motion.span, { style: loadingCircle, variants: loadingCircleVariants, transition: loadingCircleTransition }),
|
|
52
|
+
React.createElement(motion.span, { style: loadingCircle, variants: loadingCircleVariants, transition: loadingCircleTransition }),
|
|
53
|
+
React.createElement(motion.span, { style: loadingCircle, variants: loadingCircleVariants, transition: loadingCircleTransition })));
|
|
54
|
+
const Loader = ({ variant = 'default' }) => {
|
|
55
|
+
if (variant === 'page-loader') {
|
|
56
|
+
return (React.createElement(PageLoaderContainer, null,
|
|
57
|
+
React.createElement(BaseLoader, null)));
|
|
58
|
+
}
|
|
59
|
+
return React.createElement(BaseLoader, null);
|
|
48
60
|
};
|
|
49
61
|
export default Loader;
|
|
@@ -4,6 +4,7 @@ export interface MinimalMenuProps {
|
|
|
4
4
|
}
|
|
5
5
|
declare const MinimalMenu: {
|
|
6
6
|
({ children }: MinimalMenuProps): JSX.Element;
|
|
7
|
+
Header: ({ hiddenMenu, text, rightContent }: import("./_MinimalMenuHeader.component").MinimalMenuHeaderProps) => JSX.Element;
|
|
7
8
|
Item: ({ icon, active, onClick, "data-cy": dataCy }: import("./_MinimalMenuItem.component").MinimalMenuItemProps) => JSX.Element;
|
|
8
9
|
Page: ({ children, hiddenMenu }: import("./_MinimalMenuPage.component").MinimalMenuPageProps) => JSX.Element;
|
|
9
10
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { useIsScreenSize } from '../../responsive/responsive';
|
|
3
|
+
import MinimalMenuHeader from './_MinimalMenuHeader.component';
|
|
3
4
|
import MinimalMenuItem from './_MinimalMenuItem.component';
|
|
4
5
|
import MinimalMenuPage from './_MinimalMenuPage.component';
|
|
5
6
|
import DesktopMinimalMenuContainer from './desktop/_DesktopMinimalMenuContainer.component';
|
|
@@ -11,6 +12,7 @@ const MinimalMenu = ({ children }) => {
|
|
|
11
12
|
}
|
|
12
13
|
return React.createElement(DesktopMinimalMenuContainer, null, children);
|
|
13
14
|
};
|
|
15
|
+
MinimalMenu.Header = MinimalMenuHeader;
|
|
14
16
|
MinimalMenu.Item = MinimalMenuItem;
|
|
15
17
|
MinimalMenu.Page = MinimalMenuPage;
|
|
16
18
|
export default MinimalMenu;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface MinimalMenuHeaderProps {
|
|
3
|
+
/** Set the page to be in hidden menu mode.
|
|
4
|
+
* This is useful for rendering your app and preventing re-renders between a un-authenticated no-menu mode and the regular authenticated mode
|
|
5
|
+
**/
|
|
6
|
+
hiddenMenu?: boolean;
|
|
7
|
+
text?: string;
|
|
8
|
+
rightContent?: React.ReactNode;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* A header that is designed to be nested within the page content.
|
|
12
|
+
* You can use a header per page or simply use a single header for your entire application.
|
|
13
|
+
*/
|
|
14
|
+
declare const MinimalMenuHeader: ({ hiddenMenu, text, rightContent }: MinimalMenuHeaderProps) => JSX.Element;
|
|
15
|
+
export default MinimalMenuHeader;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
const MinimalMenuHeaderContainer = styled.div ``;
|
|
4
|
+
const Header = styled.div `
|
|
5
|
+
height: 48px;
|
|
6
|
+
background-color: ${(props) => props.theme.colours.cardBackground};
|
|
7
|
+
|
|
8
|
+
display: flex;
|
|
9
|
+
align-items: center;
|
|
10
|
+
justify-content: space-between;
|
|
11
|
+
`;
|
|
12
|
+
const HeaderItem = styled.div `
|
|
13
|
+
padding: 0 16px;
|
|
14
|
+
`;
|
|
15
|
+
const TitleText = styled.div `
|
|
16
|
+
font-family: ${(props) => props.theme.fonts.subHeading.family};
|
|
17
|
+
font-size: ${(props) => props.theme.fonts.subHeading.size};
|
|
18
|
+
font-weight: ${(props) => props.theme.fonts.subHeading.weight};
|
|
19
|
+
color: ${(props) => props.theme.colours.defaultFont};
|
|
20
|
+
`;
|
|
21
|
+
/**
|
|
22
|
+
* A header that is designed to be nested within the page content.
|
|
23
|
+
* You can use a header per page or simply use a single header for your entire application.
|
|
24
|
+
*/
|
|
25
|
+
const MinimalMenuHeader = ({ hiddenMenu, text, rightContent }) => {
|
|
26
|
+
return (React.createElement(MinimalMenuHeaderContainer, { hiddenMenu: !!hiddenMenu },
|
|
27
|
+
React.createElement(Header, null,
|
|
28
|
+
React.createElement(HeaderItem, null, text && React.createElement(TitleText, null, text)),
|
|
29
|
+
React.createElement(HeaderItem, null, rightContent))));
|
|
30
|
+
};
|
|
31
|
+
export default MinimalMenuHeader;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { TableVariant } from './_Table.context';
|
|
3
|
+
import { TableActionProps } from './_TableAction';
|
|
3
4
|
export type TableCellVariant = 'tight';
|
|
4
5
|
export interface TableProps {
|
|
5
6
|
children: React.ReactNode;
|
|
@@ -13,7 +14,8 @@ declare const Table: {
|
|
|
13
14
|
Row: ({ children, "data-cy": dataCy }: import("./_TableRow.component").TableRowProps) => JSX.Element;
|
|
14
15
|
Cell: import("styled-components").StyledComponent<"td", import("styled-components").DefaultTheme, TableCellProps, never>;
|
|
15
16
|
ActionContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
16
|
-
Action: ({ text, onClick, "data-cy": dataCy }:
|
|
17
|
+
Action: ({ text, variant, icon, onClick, "data-cy": dataCy }: TableActionProps) => JSX.Element;
|
|
17
18
|
ActionMenu: ({ items, "data-cy": dataCy }: import("./_TableActionMenu").TableActionMenuProps) => JSX.Element;
|
|
19
|
+
HiddenAction: (props: TableActionProps) => JSX.Element;
|
|
18
20
|
};
|
|
19
21
|
export default Table;
|
|
@@ -9,6 +9,10 @@ import TableRow from './_TableRow.component';
|
|
|
9
9
|
const StyledTable = styled.table `
|
|
10
10
|
width: 100%;
|
|
11
11
|
`;
|
|
12
|
+
const TableHiddenActionSpan = styled.span `
|
|
13
|
+
visibility: none;
|
|
14
|
+
opacity: 0;
|
|
15
|
+
`;
|
|
12
16
|
const TableCell = styled.td `
|
|
13
17
|
font-family: ${(props) => props.theme.fonts.default.family};
|
|
14
18
|
font-size: ${(props) => props.theme.fonts.default.size};
|
|
@@ -18,7 +22,16 @@ const TableCell = styled.td `
|
|
|
18
22
|
|
|
19
23
|
padding: ${(props) => (props.variant === 'tight' ? '0' : '0 16px')};
|
|
20
24
|
height: 36px;
|
|
25
|
+
|
|
26
|
+
&:hover {
|
|
27
|
+
${TableHiddenActionSpan} {
|
|
28
|
+
visibility: visible;
|
|
29
|
+
opacity: 1;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
21
32
|
`;
|
|
33
|
+
const TableHiddenAction = (props) => (React.createElement(TableHiddenActionSpan, null,
|
|
34
|
+
React.createElement(TableAction, { ...props })));
|
|
22
35
|
const Table = ({ children, variant = 'regular' }) => {
|
|
23
36
|
return (React.createElement(TableContext.Provider, { value: { variant } },
|
|
24
37
|
React.createElement(ButtonContext.Provider, { value: { height: '24px' } },
|
|
@@ -30,4 +43,5 @@ Table.Cell = TableCell;
|
|
|
30
43
|
Table.ActionContainer = TableActionContainer;
|
|
31
44
|
Table.Action = TableAction;
|
|
32
45
|
Table.ActionMenu = TableActionMenu;
|
|
46
|
+
Table.HiddenAction = TableHiddenAction;
|
|
33
47
|
export default Table;
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
+
import { IconProp } from '@fortawesome/fontawesome-svg-core';
|
|
3
|
+
import { ColourVariant } from '../../theme/theme.types';
|
|
2
4
|
export interface TableActionProps {
|
|
3
|
-
'text'
|
|
5
|
+
'text'?: string;
|
|
6
|
+
'variant'?: ColourVariant;
|
|
7
|
+
'icon'?: IconProp;
|
|
4
8
|
'onClick': () => void;
|
|
5
9
|
'data-cy'?: string;
|
|
6
10
|
}
|
|
7
|
-
declare const TableAction: ({ text, onClick, "data-cy": dataCy }: TableActionProps) => JSX.Element;
|
|
11
|
+
declare const TableAction: ({ text, variant, icon, onClick, "data-cy": dataCy }: TableActionProps) => JSX.Element;
|
|
8
12
|
export default TableAction;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useContext } from 'react';
|
|
2
2
|
import Button from '../Button/Button.component';
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
import ButtonContext from '../Button/Button.context';
|
|
4
|
+
const TableAction = ({ text, variant, icon, onClick, 'data-cy': dataCy }) => {
|
|
5
|
+
const buttonContextVal = useContext(ButtonContext);
|
|
6
|
+
return (React.createElement(ButtonContext.Provider, { value: { ...buttonContextVal, ...(!text && icon && { width: '32px' }) } },
|
|
7
|
+
React.createElement(Button, { variant: variant || 'tertiary', icon: icon, onClick: onClick, "data-cy": dataCy || 'button-table-action' }, text)));
|
|
5
8
|
};
|
|
6
9
|
export default TableAction;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import ActionMenu from '../ActionMenu/ActionMenu.component';
|
|
3
3
|
const TableActionMenu = ({ items, 'data-cy': dataCy }) => {
|
|
4
|
-
return React.createElement(ActionMenu, { variant: 'tertiary',
|
|
4
|
+
return (React.createElement(ActionMenu, { variant: 'tertiary', "data-cy": dataCy }, items.map((item) => (React.createElement(ActionMenu.Item, { key: item.label, onClick: item.onClick }, item.label)))));
|
|
5
5
|
};
|
|
6
6
|
export default TableActionMenu;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
export const Checkmark = styled.div `
|
|
3
|
+
position: relative;
|
|
4
|
+
height: ${(props) => (props.large ? '36px' : '24px')};
|
|
5
|
+
width: ${(props) => (props.large ? '36px' : '24px')};
|
|
6
|
+
background-color: ${(props) => props.theme.colours.controlBackground};
|
|
7
|
+
|
|
8
|
+
&:after {
|
|
9
|
+
content: '';
|
|
10
|
+
position: absolute;
|
|
11
|
+
display: ${(props) => (props.checked ? 'block' : 'none')};
|
|
12
|
+
|
|
13
|
+
left: ${(props) => (props.large ? '14px' : '9px')};
|
|
14
|
+
top: ${(props) => (props.large ? '7px' : '5px')};
|
|
15
|
+
width: ${(props) => (props.large ? '7px' : '5px')};
|
|
16
|
+
height: ${(props) => (props.large ? '16px' : '10px')};
|
|
17
|
+
border: solid ${(props) => props.theme.colours.defaultFont};
|
|
18
|
+
border-width: 0 3px 3px 0;
|
|
19
|
+
-webkit-transform: rotate(45deg);
|
|
20
|
+
-ms-transform: rotate(45deg);
|
|
21
|
+
transform: rotate(45deg);
|
|
22
|
+
}
|
|
23
|
+
`;
|
|
@@ -1,21 +1,31 @@
|
|
|
1
|
+
import tinycolour from 'tinycolor2';
|
|
2
|
+
const primaryBase = '#94b8e3';
|
|
3
|
+
const secondaryBase = '#424448';
|
|
4
|
+
const tertiaryBase = '#5c5f67';
|
|
1
5
|
const darkTheme = {
|
|
2
6
|
name: 'dark',
|
|
3
7
|
colours: {
|
|
4
8
|
background: '#424448',
|
|
5
9
|
overlayBackground: '#a4caf9',
|
|
6
10
|
primary: {
|
|
7
|
-
main:
|
|
8
|
-
hover:
|
|
11
|
+
main: primaryBase,
|
|
12
|
+
hover: tinycolour(primaryBase).lighten(2).toString(),
|
|
13
|
+
darker: tinycolour(primaryBase).darken(10).toString(),
|
|
14
|
+
darkerHover: tinycolour(primaryBase).darken(10).lighten(2).toString(),
|
|
9
15
|
contrastText: '#191919',
|
|
10
16
|
},
|
|
11
17
|
secondary: {
|
|
12
|
-
main:
|
|
13
|
-
hover:
|
|
18
|
+
main: secondaryBase,
|
|
19
|
+
hover: tinycolour(secondaryBase).lighten(5).toString(),
|
|
20
|
+
darker: secondaryBase,
|
|
21
|
+
darkerHover: tinycolour(secondaryBase).lighten(5).toString(),
|
|
14
22
|
contrastText: '#e2e2e2',
|
|
15
23
|
},
|
|
16
24
|
tertiary: {
|
|
17
|
-
main:
|
|
18
|
-
hover:
|
|
25
|
+
main: tertiaryBase,
|
|
26
|
+
hover: tinycolour(tertiaryBase).lighten(5).toString(),
|
|
27
|
+
darker: tinycolour(tertiaryBase).darken(5).toString(),
|
|
28
|
+
darkerHover: tinycolour(tertiaryBase).darken(5).lighten(5).toString(),
|
|
19
29
|
contrastText: '#e2e2e2',
|
|
20
30
|
},
|
|
21
31
|
defaultFont: '#e2e2e2',
|
|
@@ -7,16 +7,22 @@ const defaultTheme = {
|
|
|
7
7
|
primary: {
|
|
8
8
|
main: colours.grey70,
|
|
9
9
|
hover: 'red',
|
|
10
|
+
darker: colours.grey70,
|
|
11
|
+
darkerHover: colours.grey70,
|
|
10
12
|
contrastText: colours.grey10,
|
|
11
13
|
},
|
|
12
14
|
secondary: {
|
|
13
15
|
main: colours.yellow,
|
|
14
16
|
hover: 'red',
|
|
17
|
+
darker: colours.yellow,
|
|
18
|
+
darkerHover: colours.yellow,
|
|
15
19
|
contrastText: colours.grey90,
|
|
16
20
|
},
|
|
17
21
|
tertiary: {
|
|
18
22
|
main: colours.yellow,
|
|
19
23
|
hover: 'red',
|
|
24
|
+
darker: colours.yellow,
|
|
25
|
+
darkerHover: colours.yellow,
|
|
20
26
|
contrastText: colours.grey90,
|
|
21
27
|
},
|
|
22
28
|
defaultFont: colours.grey90,
|
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
import { DefaultTheme } from 'styled-components';
|
|
2
2
|
import { ColourVariant } from '../theme.types';
|
|
3
|
-
declare const _default: (variant: ColourVariant, theme: DefaultTheme) =>
|
|
4
|
-
main: string;
|
|
5
|
-
hover: string;
|
|
6
|
-
contrastText: string;
|
|
7
|
-
};
|
|
3
|
+
declare const _default: (variant: ColourVariant, theme: DefaultTheme) => import("../theme.types").IPalette;
|
|
8
4
|
export default _default;
|
|
@@ -1,23 +1,11 @@
|
|
|
1
1
|
export default (variant, theme) => {
|
|
2
2
|
switch (variant) {
|
|
3
3
|
case 'tertiary':
|
|
4
|
-
return
|
|
5
|
-
main: theme.colours.tertiary.main,
|
|
6
|
-
hover: theme.colours.tertiary.hover,
|
|
7
|
-
contrastText: theme.colours.tertiary.contrastText,
|
|
8
|
-
};
|
|
4
|
+
return theme.colours.tertiary;
|
|
9
5
|
case 'secondary':
|
|
10
|
-
return
|
|
11
|
-
main: theme.colours.secondary.main,
|
|
12
|
-
hover: theme.colours.secondary.hover,
|
|
13
|
-
contrastText: theme.colours.secondary.contrastText,
|
|
14
|
-
};
|
|
6
|
+
return theme.colours.secondary;
|
|
15
7
|
case 'primary':
|
|
16
8
|
default:
|
|
17
|
-
return
|
|
18
|
-
main: theme.colours.primary.main,
|
|
19
|
-
hover: theme.colours.primary.hover,
|
|
20
|
-
contrastText: theme.colours.primary.contrastText,
|
|
21
|
-
};
|
|
9
|
+
return theme.colours.primary;
|
|
22
10
|
}
|
|
23
11
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dtdot/lego",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-10",
|
|
4
4
|
"description": "Some reusable components for building my applications",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -15,15 +15,8 @@
|
|
|
15
15
|
"author": "Simon Pratt <19920260+simonpratt@users.noreply.github.com>",
|
|
16
16
|
"license": "ISC",
|
|
17
17
|
"files": [
|
|
18
|
-
"build"
|
|
19
|
-
"README.md",
|
|
20
|
-
"LICENSE"
|
|
18
|
+
"build"
|
|
21
19
|
],
|
|
22
|
-
"repository": {
|
|
23
|
-
"type": "git",
|
|
24
|
-
"url": "git+https://github.com/simonpratt/lego.git"
|
|
25
|
-
},
|
|
26
|
-
"homepage": "https://dtdot-lego.pages.dev/",
|
|
27
20
|
"devDependencies": {
|
|
28
21
|
"@babel/cli": "^7.20.7",
|
|
29
22
|
"@babel/core": "^7.20.7",
|
|
@@ -45,6 +38,7 @@
|
|
|
45
38
|
"@types/react-dom": "^18.0.9",
|
|
46
39
|
"@types/spark-md5": "^3.0.2",
|
|
47
40
|
"@types/styled-components": "^5.1.26",
|
|
41
|
+
"@types/tinycolor2": "^1.4.3",
|
|
48
42
|
"@types/uuid": "^9.0.0",
|
|
49
43
|
"@typescript-eslint/eslint-plugin": "^5.47.0",
|
|
50
44
|
"@typescript-eslint/parser": "^5.47.0",
|
|
@@ -63,7 +57,7 @@
|
|
|
63
57
|
"peerDependencies": {
|
|
64
58
|
"react": "16 - 18",
|
|
65
59
|
"react-dom": "16 - 18",
|
|
66
|
-
"styled-components": "
|
|
60
|
+
"styled-components": "5.x"
|
|
67
61
|
},
|
|
68
62
|
"dependencies": {
|
|
69
63
|
"@fortawesome/fontawesome-svg-core": "^6.2.1",
|
|
@@ -76,6 +70,7 @@
|
|
|
76
70
|
"react-popper": "^2.3.0",
|
|
77
71
|
"react-use-measure": "^2.1.1",
|
|
78
72
|
"spark-md5": "^3.0.2",
|
|
73
|
+
"tinycolor2": "^1.6.0",
|
|
79
74
|
"uuid": "^9.0.0"
|
|
80
75
|
}
|
|
81
76
|
}
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2023 Simon Pratt
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
package/README.md
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
# Usage
|
|
2
|
-
|
|
3
|
-
### Preview
|
|
4
|
-
|
|
5
|
-
Storybook preview is available at https://dtdot-lego.pages.dev
|
|
6
|
-
|
|
7
|
-
### Installation
|
|
8
|
-
|
|
9
|
-
- Install peer dependencies
|
|
10
|
-
`npm i -S styled-components@^5.2.1` (and `npm i -D @types/styled-components` if using typescript)
|
|
11
|
-
- Install package
|
|
12
|
-
`npm i -S @dtdot/lego`
|
|
13
|
-
|
|
14
|
-
### Theme Context
|
|
15
|
-
|
|
16
|
-
Lego requires a `styled-components` theme context to function, this instructs lego whether to render in dark or default themes. It's recommended to place this near the root of your application.
|
|
17
|
-
|
|
18
|
-
```jsx
|
|
19
|
-
import { ThemeProvider } from 'styled-components';
|
|
20
|
-
import { Themes } from '@dtdot/lego';
|
|
21
|
-
|
|
22
|
-
export default function MyApp() {
|
|
23
|
-
return (
|
|
24
|
-
<ThemeProvider theme={Themes.default}>
|
|
25
|
-
<AppImplementation />
|
|
26
|
-
</ThemeProvider>
|
|
27
|
-
);
|
|
28
|
-
}
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
### Components
|
|
32
|
-
|
|
33
|
-
After the above steps have been completed you're ready to start building. Here's a small example of importing and using a component, but see [Documentation](#documentation) for more complete examples.
|
|
34
|
-
|
|
35
|
-
```jsx
|
|
36
|
-
import { Alert } from '@dtdot/lego';
|
|
37
|
-
|
|
38
|
-
export default function Example() {
|
|
39
|
-
return <Alert variant='success' message="Great! I'm rendering my first lego component..." />;
|
|
40
|
-
}
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
### Documentation
|
|
44
|
-
|
|
45
|
-
Lego uses storybook for documentation. This documentation is hosted at https://dtdot-lego.pages.dev
|
|
46
|
-
|
|
47
|
-
# Contributing
|
|
48
|
-
|
|
49
|
-
## Storybook
|
|
50
|
-
|
|
51
|
-
Storybook is used both for testing as you develop and as living documentation. After cloning the repository you can run `npm start` at the root directory to host the documentation locally on port `6006`. Changes to the source will hot reload the documentation as you develop.
|