@dtdot/lego 1.8.1 → 2.0.0-3
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 +63 -10
- package/build/components/Checklist/_ChecklistItem.component.js +4 -22
- 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 +3 -1
|
@@ -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,50 @@
|
|
|
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) => getThemeVariantColours(props.variant, props.theme).darker};
|
|
37
|
+
|
|
38
|
+
height: ${(props) => getIconContainerSizePx(props.size).height};
|
|
39
|
+
width: ${(props) => getIconContainerSizePx(props.size).width};
|
|
40
|
+
`;
|
|
5
41
|
const StyledButton = styled.button `
|
|
6
42
|
outline: none;
|
|
7
43
|
box-shadow: none;
|
|
8
44
|
border: none;
|
|
9
45
|
|
|
10
46
|
cursor: pointer;
|
|
11
|
-
|
|
12
|
-
padding: 0 24px;
|
|
47
|
+
padding: 0;
|
|
13
48
|
|
|
14
49
|
font-size: ${(props) => props.theme.fonts.default.size};
|
|
15
50
|
font-family: ${(props) => props.theme.fonts.default.family};
|
|
@@ -20,30 +55,44 @@ const StyledButton = styled.button `
|
|
|
20
55
|
border-radius: 2px;
|
|
21
56
|
|
|
22
57
|
// Props defined by the context
|
|
23
|
-
height: ${(props) => props.height ||
|
|
58
|
+
height: ${(props) => props.height || getButtonHeightPx(props.size)};
|
|
24
59
|
width: ${(props) => props.width};
|
|
25
60
|
align-self: ${(props) => props.alignSelf};
|
|
26
61
|
margin-top: ${(props) => props.marginTop};
|
|
27
62
|
|
|
28
63
|
&:hover {
|
|
29
64
|
background-color: ${(props) => getThemeVariantColours(props.variant, props.theme).hover};
|
|
65
|
+
|
|
66
|
+
${IconOuter} {
|
|
67
|
+
background-color: ${(props) => getThemeVariantColours(props.variant, props.theme).darkerHover};
|
|
68
|
+
}
|
|
30
69
|
}
|
|
31
70
|
`;
|
|
71
|
+
const ButtonInner = styled.div `
|
|
72
|
+
display: flex;
|
|
73
|
+
align-items: center;
|
|
74
|
+
`;
|
|
75
|
+
const ButtonTextContainer = styled.span `
|
|
76
|
+
padding: ${(props) => getButtonPaddingPx(props.size)};
|
|
77
|
+
`;
|
|
32
78
|
const spinAnimation = keyframes `
|
|
33
79
|
0% { transform: rotate(0deg); }
|
|
34
80
|
100% { transform: rotate(360deg); }
|
|
35
81
|
`;
|
|
82
|
+
const SpinnerContainer = styled.span `
|
|
83
|
+
padding: 0 24px;
|
|
84
|
+
`;
|
|
36
85
|
const ButtonSpinner = styled.div `
|
|
37
86
|
display: inline-block;
|
|
38
|
-
width:
|
|
39
|
-
height:
|
|
87
|
+
width: ${(props) => getButtonHeightPx(props.size)};
|
|
88
|
+
height: ${(props) => getButtonHeightPx(props.size)};
|
|
40
89
|
|
|
41
90
|
&:after {
|
|
42
91
|
content: ' ';
|
|
43
92
|
display: block;
|
|
44
|
-
width: 24px;
|
|
45
|
-
height: 24px;
|
|
46
|
-
margin: 10px;
|
|
93
|
+
width: ${(props) => (props.size === 'md' ? '24px' : '16px')};
|
|
94
|
+
height: ${(props) => (props.size === 'md' ? '24px' : '16px')};
|
|
95
|
+
margin: ${(props) => (props.size === 'md' ? '10px' : '6px')};
|
|
47
96
|
border-radius: 50%;
|
|
48
97
|
border: 2px solid ${(props) => getThemeVariantColours(props.variant, props.theme).contrastText};
|
|
49
98
|
border-color: ${(props) => getThemeVariantColours(props.variant, props.theme).contrastText} transparent
|
|
@@ -54,8 +103,12 @@ const ButtonSpinner = styled.div `
|
|
|
54
103
|
}
|
|
55
104
|
`;
|
|
56
105
|
const Button = React.forwardRef(function Button(props, ref) {
|
|
57
|
-
const { children, loading, variant = 'primary', type = 'button', onClick, 'data-cy': dataCy } = props;
|
|
106
|
+
const { children, loading, variant = 'primary', size = 'md', type = 'button', icon, onClick, 'data-cy': dataCy, } = props;
|
|
58
107
|
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(
|
|
108
|
+
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' }, loading ? (React.createElement(SpinnerContainer, null,
|
|
109
|
+
React.createElement(ButtonSpinner, { "data-cy": 'button-loading-spinner', variant: variant, size: size }))) : (React.createElement(ButtonInner, null,
|
|
110
|
+
children && React.createElement(ButtonTextContainer, { size: size }, children),
|
|
111
|
+
icon && (React.createElement(IconOuter, { variant: variant, size: size },
|
|
112
|
+
React.createElement(FontAwesomeIcon, { icon: icon })))))));
|
|
60
113
|
});
|
|
61
114
|
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)));
|
|
@@ -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-3",
|
|
4
4
|
"description": "Some reusable components for building my applications",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
"@types/react-dom": "^18.0.9",
|
|
39
39
|
"@types/spark-md5": "^3.0.2",
|
|
40
40
|
"@types/styled-components": "^5.1.26",
|
|
41
|
+
"@types/tinycolor2": "^1.4.3",
|
|
41
42
|
"@types/uuid": "^9.0.0",
|
|
42
43
|
"@typescript-eslint/eslint-plugin": "^5.47.0",
|
|
43
44
|
"@typescript-eslint/parser": "^5.47.0",
|
|
@@ -69,6 +70,7 @@
|
|
|
69
70
|
"react-popper": "^2.3.0",
|
|
70
71
|
"react-use-measure": "^2.1.1",
|
|
71
72
|
"spark-md5": "^3.0.2",
|
|
73
|
+
"tinycolor2": "^1.6.0",
|
|
72
74
|
"uuid": "^9.0.0"
|
|
73
75
|
}
|
|
74
76
|
}
|