@dtdot/lego 2.0.0-8 → 2.0.1
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/LICENSE +21 -0
- package/README.md +51 -0
- package/build/components/ActionMenu/ActionMenu.component.d.ts +4 -4
- package/build/components/ActionMenu/ActionMenu.component.js +3 -3
- package/build/components/ActionMenu/_ActionMenuCheckbox.component.d.ts +2 -2
- package/build/components/ActionMenu/_ActionMenuCheckbox.component.js +2 -2
- package/build/components/ActionMenu/_ActionMenuItem.component.d.ts +2 -2
- package/build/components/ActionMenu/_ActionMenuItem.component.js +2 -2
- package/build/components/ActionMenu/_ActionMenuPanel.component.js +1 -1
- package/build/components/ActionMessage/ActionMessage.component.js +1 -1
- package/build/components/Alert/Alert.component.js +3 -3
- package/build/components/Badge/Badge.component.js +1 -1
- package/build/components/BadgeSelector/BadgeSelector.component.js +1 -1
- package/build/components/Button/Button.component.d.ts +1 -1
- package/build/components/Button/Button.component.js +15 -11
- package/build/components/Button/Button.context.d.ts +1 -0
- package/build/components/Button/Button.context.js +1 -0
- package/build/components/Card/Card.component.d.ts +7 -6
- package/build/components/Card/Card.component.js +2 -2
- package/build/components/Card/_CardHeader.component.js +4 -2
- package/build/components/Card/_CardToggleSection.component.d.ts +6 -5
- package/build/components/Card/_CardToggleSection.component.js +2 -2
- package/build/components/Checklist/Checklist.component.js +1 -1
- package/build/components/Checklist/_ChecklistItem.component.js +1 -1
- package/build/components/ControlLine/ControlLine.component.d.ts +7 -0
- package/build/components/ControlLine/ControlLine.component.js +33 -0
- package/build/components/FancyCheckbox/FancyCheckbox.component.js +1 -1
- package/build/components/FloatingActionButton/FloatingActionButton.component.d.ts +13 -0
- package/build/components/FloatingActionButton/FloatingActionButton.component.js +21 -0
- package/build/components/FloatingActionButton/_FloatingActionButton.context.d.ts +15 -0
- package/build/components/FloatingActionButton/_FloatingActionButton.context.js +6 -0
- package/build/components/FloatingActionButton/_FloatingActionButton.internal.d.ts +10 -0
- package/build/components/FloatingActionButton/_FloatingActionButton.internal.js +45 -0
- package/build/components/FloatingActionButton/_FloatingActionButton.provider.d.ts +6 -0
- package/build/components/FloatingActionButton/_FloatingActionButton.provider.js +15 -0
- package/build/components/Form/_NestedFormArray.js +2 -4
- package/build/components/ImageUpload/ImageUpload.component.d.ts +2 -2
- package/build/components/ImageUpload/ImageUpload.component.js +10 -10
- package/build/components/InlineCard/InlineCard.component.d.ts +8 -7
- package/build/components/InlineCard/InlineCard.component.js +2 -2
- package/build/components/InlineCard/_InlineCardContent.component.js +2 -0
- package/build/components/InlineCard/_InlineCardMeta.component.js +1 -0
- package/build/components/Input/Input.component.d.ts +5 -1
- package/build/components/Input/Input.component.js +38 -8
- package/build/components/LiveInput/LiveInput.component.d.ts +2 -2
- package/build/components/LiveInput/LiveInput.component.js +2 -2
- package/build/components/LiveList/LiveList.component.js +2 -2
- package/build/components/LiveList/_LiveListRow.js +3 -3
- package/build/components/Loader/Loader.component.d.ts +7 -2
- package/build/components/Loader/Loader.component.js +28 -8
- package/build/components/Menu/_MenuHeading.component.js +2 -2
- package/build/components/Menu/_MenuItem.component.js +1 -1
- package/build/components/Menu/_MenuPanel.component.js +1 -1
- package/build/components/MinimalMenu/MinimalMenu.component.d.ts +2 -2
- package/build/components/MinimalMenu/MinimalMenu.context.d.ts +7 -0
- package/build/components/MinimalMenu/MinimalMenu.context.js +6 -0
- package/build/components/MinimalMenu/_MinimalMenuHeader.component.d.ts +2 -1
- package/build/components/MinimalMenu/_MinimalMenuHeader.component.js +3 -3
- package/build/components/MinimalMenu/_MinimalMenuItem.component.d.ts +3 -2
- package/build/components/MinimalMenu/_MinimalMenuItem.component.js +3 -3
- package/build/components/MinimalMenu/_MinimalMenuPage.component.js +10 -3
- package/build/components/MinimalMenu/desktop/_DesktopMinimalMenuItem.component.d.ts +2 -2
- package/build/components/MinimalMenu/desktop/_DesktopMinimalMenuItem.component.js +2 -2
- package/build/components/MinimalMenu/mobile/_MobileMenu.constants.js +1 -1
- package/build/components/MinimalMenu/mobile/_MobileMinimalMenuContainer.component.js +4 -24
- package/build/components/MinimalMenu/mobile/_MobileMinimalMenuItem.component.d.ts +3 -2
- package/build/components/MinimalMenu/mobile/_MobileMinimalMenuItem.component.js +22 -24
- package/build/components/Modal/Modal.component.d.ts +6 -5
- package/build/components/Modal/Modal.component.js +2 -2
- package/build/components/Modal/_ModalHeader.component.js +2 -2
- package/build/components/Notification/Notification.component.js +1 -1
- package/build/components/ProfileImage/ProfileImage.component.js +2 -2
- package/build/components/QrCode/QrCode.component.js +2 -2
- package/build/components/Select/Select.component.d.ts +3 -5
- package/build/components/Select/Select.component.js +13 -30
- package/build/components/SquareButton/SquareButton.component.d.ts +2 -2
- package/build/components/SquareButton/SquareButton.component.js +2 -2
- package/build/components/Table/Table.component.d.ts +3 -3
- package/build/components/Table/Table.component.js +1 -0
- package/build/components/Table/_TableAction.d.ts +2 -2
- package/build/components/Table/_TableAction.js +2 -2
- package/build/components/Table/_TableActionMenu.d.ts +2 -2
- package/build/components/Table/_TableActionMenu.js +2 -2
- package/build/components/Table/_TableRow.component.d.ts +3 -2
- package/build/components/Table/_TableRow.component.js +10 -4
- package/build/components/Text/Text.component.d.ts +5 -3
- package/build/components/Text/Text.component.js +21 -3
- package/build/components/TextArea/TextArea.component.d.ts +1 -1
- package/build/components/TextArea/TextArea.component.js +5 -5
- package/build/components/Toggle/Toggle.component.js +1 -1
- package/build/components/common/Options.component.d.ts +19 -0
- package/build/components/common/Options.component.js +50 -0
- package/build/constants/zIndex.constants.d.ts +1 -0
- package/build/constants/zIndex.constants.js +1 -0
- package/build/index.d.ts +2 -0
- package/build/index.js +2 -0
- package/build/screens/Login/Login.screen.js +4 -4
- package/build/screens/Register/Register.screen.js +3 -3
- package/build/screens/Verification/Verification.screen.js +2 -2
- package/build/shared/ControlStyles.js +1 -1
- package/build/theme/dark.theme.js +4 -2
- package/package.json +14 -14
- package/build/components/MinimalMenu/mobile/_MobileMenuBump.component.d.ts +0 -3
- package/build/components/MinimalMenu/mobile/_MobileMenuBump.component.js +0 -4
- package/build/components/MinimalMenu/mobile/_MobileMenuBump.context.d.ts +0 -6
- package/build/components/MinimalMenu/mobile/_MobileMenuBump.context.js +0 -6
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
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
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
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.
|
|
@@ -8,11 +8,11 @@ export interface ActionMenuProps {
|
|
|
8
8
|
'size'?: ButtonSize;
|
|
9
9
|
'icon'?: IconProp;
|
|
10
10
|
'text'?: string;
|
|
11
|
-
'data-
|
|
11
|
+
'data-testid'?: string;
|
|
12
12
|
}
|
|
13
13
|
declare const ActionMenu: {
|
|
14
|
-
({ children, variant, size, icon, text, "data-
|
|
15
|
-
Item: ({ children, onClick, "data-
|
|
16
|
-
Checkbox: ({ children, checked, onClick, "data-
|
|
14
|
+
({ children, variant, size, icon, text, "data-testid": dataTestId }: ActionMenuProps): JSX.Element;
|
|
15
|
+
Item: ({ children, onClick, "data-testid": dataTestId }: import("./_ActionMenuItem.component").ActionMenuItemProps) => JSX.Element;
|
|
16
|
+
Checkbox: ({ children, checked, onClick, "data-testid": dataTestId }: import("./_ActionMenuCheckbox.component").ActionMenuCheckboxProps) => JSX.Element;
|
|
17
17
|
};
|
|
18
18
|
export default ActionMenu;
|
|
@@ -8,7 +8,7 @@ import ActionMenuCheckbox from './_ActionMenuCheckbox.component';
|
|
|
8
8
|
import ActionMenuItem from './_ActionMenuItem.component';
|
|
9
9
|
import ActionMenuPanel from './_ActionMenuPanel.component';
|
|
10
10
|
const offsetFn = () => [70, 4];
|
|
11
|
-
const ActionMenu = ({ children, variant, size, icon, text, 'data-
|
|
11
|
+
const ActionMenu = ({ children, variant, size, icon, text, 'data-testid': dataTestId }) => {
|
|
12
12
|
const [shown, setShown] = useState(false);
|
|
13
13
|
const [referenceElement, setReferenceElement] = useState();
|
|
14
14
|
const [popperElement, setPopperElement] = useState();
|
|
@@ -34,9 +34,9 @@ const ActionMenu = ({ children, variant, size, icon, text, 'data-cy': dataCy })
|
|
|
34
34
|
};
|
|
35
35
|
}, [handleGlobalClick, popperElement]);
|
|
36
36
|
return (React.createElement(React.Fragment, null,
|
|
37
|
-
React.createElement(Button, { variant: variant, size: size, icon: icon || faEllipsisV, "data-
|
|
37
|
+
React.createElement(Button, { variant: variant, size: size, icon: icon || faEllipsisV, "data-testid": dataTestId || 'action-menu-button', ref: setReferenceElement, onClick: () => setShown(true) }, text),
|
|
38
38
|
shown &&
|
|
39
|
-
ReactDOM.createPortal(React.createElement("div", { ref: setPopperElement, style: styles.popper, ...attributes.popper },
|
|
39
|
+
ReactDOM.createPortal(React.createElement("div", { ref: setPopperElement, style: { ...styles.popper, zIndex: 999 }, ...attributes.popper },
|
|
40
40
|
React.createElement(ActionMenuContext.Provider, { value: { closeActionMenu: () => setShown(false) } },
|
|
41
41
|
React.createElement(ActionMenuPanel, null, children))), document.querySelector('body'))));
|
|
42
42
|
};
|
|
@@ -3,7 +3,7 @@ export interface ActionMenuCheckboxProps {
|
|
|
3
3
|
'children': React.ReactNode;
|
|
4
4
|
'checked': boolean;
|
|
5
5
|
'onClick': () => void;
|
|
6
|
-
'data-
|
|
6
|
+
'data-testid'?: string;
|
|
7
7
|
}
|
|
8
|
-
declare const ActionMenuCheckbox: ({ children, checked, onClick, "data-
|
|
8
|
+
declare const ActionMenuCheckbox: ({ children, checked, onClick, "data-testid": dataTestId }: ActionMenuCheckboxProps) => JSX.Element;
|
|
9
9
|
export default ActionMenuCheckbox;
|
|
@@ -19,10 +19,10 @@ const ActionMenuCheckboxOuter = styled(motion.div) `
|
|
|
19
19
|
const Spacer = styled.div `
|
|
20
20
|
width: 16px;
|
|
21
21
|
`;
|
|
22
|
-
const ActionMenuCheckbox = ({ children, checked, onClick, 'data-
|
|
22
|
+
const ActionMenuCheckbox = ({ children, checked, onClick, 'data-testid': dataTestId }) => {
|
|
23
23
|
const theme = useTheme();
|
|
24
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-
|
|
25
|
+
React.createElement(ActionMenuCheckboxOuter, { style: { backgroundColor: theme.colours.tertiary.main }, whileHover: { backgroundColor: theme.colours.tertiary.hover }, onClick: onClick, "data-testid": dataTestId || 'action-menu-checkbox' },
|
|
26
26
|
children,
|
|
27
27
|
React.createElement(Spacer, null),
|
|
28
28
|
React.createElement(Checkmark, { checked: checked, large: false }))));
|
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
export interface ActionMenuItemProps {
|
|
3
3
|
'children': React.ReactNode;
|
|
4
4
|
'onClick': () => void;
|
|
5
|
-
'data-
|
|
5
|
+
'data-testid'?: string;
|
|
6
6
|
}
|
|
7
|
-
declare const ActionMenuItem: ({ children, onClick, "data-
|
|
7
|
+
declare const ActionMenuItem: ({ children, onClick, "data-testid": dataTestId }: ActionMenuItemProps) => JSX.Element;
|
|
8
8
|
export default ActionMenuItem;
|
|
@@ -15,7 +15,7 @@ const ActionMenuItemOuter = styled(motion.div) `
|
|
|
15
15
|
font-size: ${(props) => props.theme.fonts.default.size};
|
|
16
16
|
font-weight: ${(props) => props.theme.fonts.default.weight};
|
|
17
17
|
`;
|
|
18
|
-
const ActionMenuItem = ({ children, onClick, 'data-
|
|
18
|
+
const ActionMenuItem = ({ children, onClick, 'data-testid': dataTestId }) => {
|
|
19
19
|
const theme = useTheme();
|
|
20
20
|
const { closeActionMenu } = useContext(ActionMenuContext);
|
|
21
21
|
const handleClick = () => {
|
|
@@ -23,6 +23,6 @@ const ActionMenuItem = ({ children, onClick, 'data-cy': dataCy }) => {
|
|
|
23
23
|
closeActionMenu();
|
|
24
24
|
};
|
|
25
25
|
return (React.createElement(React.Fragment, null,
|
|
26
|
-
React.createElement(ActionMenuItemOuter, { style: { backgroundColor: theme.colours.tertiary.main }, whileHover: { backgroundColor: theme.colours.tertiary.hover }, onClick: handleClick, "data-
|
|
26
|
+
React.createElement(ActionMenuItemOuter, { style: { backgroundColor: theme.colours.tertiary.main }, whileHover: { backgroundColor: theme.colours.tertiary.hover }, onClick: handleClick, "data-testid": dataTestId || 'action-menu-item' }, children)));
|
|
27
27
|
};
|
|
28
28
|
export default ActionMenuItem;
|
|
@@ -4,5 +4,5 @@ const ActionMenuPanelOuter = styled.div `
|
|
|
4
4
|
background-color: ${(props) => props.theme.colours.tertiary.main};
|
|
5
5
|
min-width: 160px;
|
|
6
6
|
`;
|
|
7
|
-
const ActionMenuPanel = ({ children }) => (React.createElement(ActionMenuPanelOuter, { "data-
|
|
7
|
+
const ActionMenuPanel = ({ children }) => (React.createElement(ActionMenuPanelOuter, { "data-testid": 'action-menu-popover' }, children));
|
|
8
8
|
export default ActionMenuPanel;
|
|
@@ -14,7 +14,7 @@ const ActionMessageContainer = styled.div `
|
|
|
14
14
|
}
|
|
15
15
|
`;
|
|
16
16
|
const ActionMessage = ({ header, info, action, onAction }) => {
|
|
17
|
-
return (React.createElement(ActionMessageContainer, { "data-
|
|
17
|
+
return (React.createElement(ActionMessageContainer, { "data-testid": 'action-message' },
|
|
18
18
|
React.createElement("div", null,
|
|
19
19
|
React.createElement(Heading.SubHeading, null, header)),
|
|
20
20
|
info && (React.createElement(React.Fragment, null,
|
|
@@ -46,9 +46,9 @@ const CountContainer = styled.div `
|
|
|
46
46
|
const Alert = ({ variant, message, count, action, onAction }) => {
|
|
47
47
|
const theme = useTheme();
|
|
48
48
|
const colour = getThemeStatusColour(variant, theme).main;
|
|
49
|
-
return (React.createElement(AlertContainer, { colour: colour, "data-
|
|
50
|
-
React.createElement(MessageContainer, { "data-
|
|
51
|
-
action && (React.createElement(ActionContainer, { onClick: onAction, "data-
|
|
49
|
+
return (React.createElement(AlertContainer, { colour: colour, "data-testid": 'alert' },
|
|
50
|
+
React.createElement(MessageContainer, { "data-testid": 'alert-message' }, message),
|
|
51
|
+
action && (React.createElement(ActionContainer, { onClick: onAction, "data-testid": 'alert-action' }, action)),
|
|
52
52
|
count && count > 1 && React.createElement(CountContainer, { colour: colour }, count)));
|
|
53
53
|
};
|
|
54
54
|
export default Alert;
|
|
@@ -30,7 +30,7 @@ const ActionSpan = styled.span `
|
|
|
30
30
|
font-size: ${(props) => props.theme.fonts.default.size};
|
|
31
31
|
`;
|
|
32
32
|
const Badge = ({ children, variant, actionIcon, onAction }) => {
|
|
33
|
-
return (React.createElement(BadgeSpan, { variant: variant, useHover: !!actionIcon, "data-
|
|
33
|
+
return (React.createElement(BadgeSpan, { variant: variant, useHover: !!actionIcon, "data-testid": 'badge' },
|
|
34
34
|
children,
|
|
35
35
|
actionIcon && (React.createElement(ActionSpan, { onClick: onAction },
|
|
36
36
|
React.createElement(FontAwesomeIcon, { icon: actionIcon })))));
|
|
@@ -24,6 +24,6 @@ const BadgeSelector = ({ options, value, onChange }) => {
|
|
|
24
24
|
const handleClick = (_value) => {
|
|
25
25
|
onChange([_value]);
|
|
26
26
|
};
|
|
27
|
-
return (React.createElement(BadgeSelectorOuter, { "data-
|
|
27
|
+
return (React.createElement(BadgeSelectorOuter, { "data-testid": 'badge-selector' }, options.map((option) => (React.createElement(InteractiveBadge, { useHover: false, key: option.value, variant: option.variant, inactive: !value.includes(option.value), onClick: () => handleClick(option.value), "data-testid": value.includes(option.value) ? 'badge-selected' : 'badge' }, option.name)))));
|
|
28
28
|
};
|
|
29
29
|
export default BadgeSelector;
|
|
@@ -10,7 +10,7 @@ export interface ButtonProps {
|
|
|
10
10
|
'type'?: 'submit' | 'button';
|
|
11
11
|
'icon'?: IconProp;
|
|
12
12
|
'onClick'?: () => void;
|
|
13
|
-
'data-
|
|
13
|
+
'data-testid'?: string;
|
|
14
14
|
}
|
|
15
15
|
declare const Button: React.ForwardRefExoticComponent<ButtonProps & React.RefAttributes<unknown>>;
|
|
16
16
|
export default Button;
|
|
@@ -33,9 +33,11 @@ const IconOuter = styled.span `
|
|
|
33
33
|
justify-content: center;
|
|
34
34
|
|
|
35
35
|
color: ${(props) => getThemeVariantColours(props.variant, props.theme).contrastText};
|
|
36
|
-
background-color: ${(props) => props.
|
|
37
|
-
?
|
|
38
|
-
:
|
|
36
|
+
background-color: ${(props) => props.noBackground
|
|
37
|
+
? 'transparent'
|
|
38
|
+
: props.iconOnly
|
|
39
|
+
? getThemeVariantColours(props.variant, props.theme).main
|
|
40
|
+
: getThemeVariantColours(props.variant, props.theme).darker};
|
|
39
41
|
|
|
40
42
|
height: ${(props) => props.height || getIconContainerSizePx(props.size).height};
|
|
41
43
|
width: ${(props) => getIconContainerSizePx(props.size).width};
|
|
@@ -47,12 +49,13 @@ const StyledButton = styled.button `
|
|
|
47
49
|
|
|
48
50
|
cursor: pointer;
|
|
49
51
|
padding: 0;
|
|
52
|
+
margin: 0;
|
|
50
53
|
|
|
51
54
|
font-size: ${(props) => props.theme.fonts.default.size};
|
|
52
55
|
font-family: ${(props) => props.theme.fonts.default.family};
|
|
53
56
|
|
|
54
|
-
color: ${(props) => getThemeVariantColours(props.variant, props.theme).contrastText};
|
|
55
|
-
background-color: ${(props) => getThemeVariantColours(props.variant, props.theme).main};
|
|
57
|
+
color: ${(props) => getThemeVariantColours(props.noBackground ? 'secondary' : props.variant, props.theme).contrastText};
|
|
58
|
+
background-color: ${(props) => props.noBackground ? 'transparent' : getThemeVariantColours(props.variant, props.theme).main};
|
|
56
59
|
|
|
57
60
|
border-radius: 2px;
|
|
58
61
|
|
|
@@ -63,7 +66,7 @@ const StyledButton = styled.button `
|
|
|
63
66
|
margin-top: ${(props) => props.marginTop};
|
|
64
67
|
|
|
65
68
|
&:hover {
|
|
66
|
-
background-color: ${(props) => getThemeVariantColours(props.variant, props.theme).hover};
|
|
69
|
+
background-color: ${(props) => props.noBackground ? 'transparent' : getThemeVariantColours(props.variant, props.theme).hover};
|
|
67
70
|
|
|
68
71
|
${IconOuter} {
|
|
69
72
|
background-color: ${(props) => props.iconOnly
|
|
@@ -75,6 +78,7 @@ const StyledButton = styled.button `
|
|
|
75
78
|
const ButtonInner = styled.div `
|
|
76
79
|
display: flex;
|
|
77
80
|
align-items: center;
|
|
81
|
+
justify-content: center;
|
|
78
82
|
`;
|
|
79
83
|
const ButtonTextContainer = styled.span `
|
|
80
84
|
padding: ${(props) => getButtonPaddingPx(props.size)};
|
|
@@ -107,12 +111,12 @@ const ButtonSpinner = styled.div `
|
|
|
107
111
|
}
|
|
108
112
|
`;
|
|
109
113
|
const Button = React.forwardRef(function Button(props, ref) {
|
|
110
|
-
const { children, loading, variant = 'primary', size = 'md', type = 'button', icon, onClick, 'data-
|
|
111
|
-
const { width, height, alignSelf, marginTop } = useContext(ButtonContext);
|
|
112
|
-
return (React.createElement(StyledButton, { ref: ref, width: width, height: height, alignSelf: alignSelf, marginTop: marginTop, variant: variant, size: size, type: type, onClick: onClick, "data-
|
|
113
|
-
React.createElement(ButtonSpinner, { "data-
|
|
114
|
+
const { children, loading, variant = 'primary', size = 'md', type = 'button', icon, onClick, 'data-testid': dataTestId, } = props;
|
|
115
|
+
const { width, height, alignSelf, marginTop, noBackground } = useContext(ButtonContext);
|
|
116
|
+
return (React.createElement(StyledButton, { ref: ref, width: width, height: height, alignSelf: alignSelf, marginTop: marginTop, noBackground: noBackground, variant: variant, size: size, type: type, onClick: onClick, "data-testid": dataTestId || 'button', iconOnly: !children }, loading ? (React.createElement(SpinnerContainer, null,
|
|
117
|
+
React.createElement(ButtonSpinner, { "data-testid": 'button-loading-spinner', variant: variant, size: size, iconOnly: !children }))) : (React.createElement(ButtonInner, null,
|
|
114
118
|
children && React.createElement(ButtonTextContainer, { size: size }, children),
|
|
115
|
-
icon && (React.createElement(IconOuter, { variant: variant, size: size, height: height, iconOnly: !children },
|
|
119
|
+
icon && (React.createElement(IconOuter, { noBackground: noBackground, variant: variant, size: size, height: height, iconOnly: !children },
|
|
116
120
|
React.createElement(FontAwesomeIcon, { icon: icon })))))));
|
|
117
121
|
});
|
|
118
122
|
export default Button;
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { CardSize } from './Card.context';
|
|
3
3
|
export interface CardProps {
|
|
4
|
-
children: React.ReactNode;
|
|
5
|
-
size?: CardSize;
|
|
6
|
-
padded?: boolean;
|
|
7
|
-
onClick?: () => void;
|
|
4
|
+
'children': React.ReactNode;
|
|
5
|
+
'size'?: CardSize;
|
|
6
|
+
'padded'?: boolean;
|
|
7
|
+
'onClick'?: () => void;
|
|
8
|
+
'data-testid'?: string;
|
|
8
9
|
}
|
|
9
10
|
declare const Card: {
|
|
10
|
-
({ children, padded, size, onClick }: CardProps): JSX.Element;
|
|
11
|
-
ToggleSection: ({ heading, enabled, setEnabled, children }: import("./_CardToggleSection.component").CardToggleSectionProps) => JSX.Element;
|
|
11
|
+
({ children, padded, size, onClick, "data-testid": dataTestId }: CardProps): JSX.Element;
|
|
12
|
+
ToggleSection: ({ heading, enabled, setEnabled, children, "data-testid": dataTestId, }: import("./_CardToggleSection.component").CardToggleSectionProps) => JSX.Element;
|
|
12
13
|
Actions: ({ children }: import("./_CardActions.component").CardActionsProps) => React.ReactPortal | null;
|
|
13
14
|
Action: ({ children, onClick }: import("./_CardActions.component").CardActionProps) => JSX.Element;
|
|
14
15
|
Content: ({ children }: import("./_CardContent.component").CardContentProps) => JSX.Element;
|
|
@@ -69,7 +69,7 @@ const CardOuter = styled(motion.div) `
|
|
|
69
69
|
cursor: ${(props) => (props.usePointer ? 'pointer' : 'default')};
|
|
70
70
|
padding: ${(props) => (props.padded ? '16px' : 0)};
|
|
71
71
|
`;
|
|
72
|
-
const Card = ({ children, padded, size = 'sm', onClick }) => {
|
|
72
|
+
const Card = ({ children, padded, size = 'sm', onClick, 'data-testid': dataTestId }) => {
|
|
73
73
|
const actionsRef = useRef(null);
|
|
74
74
|
const [htmlActionsRef, setHtmlActionsRef] = useState();
|
|
75
75
|
const [showActions, setShowActions] = useState(false);
|
|
@@ -94,7 +94,7 @@ const Card = ({ children, padded, size = 'sm', onClick }) => {
|
|
|
94
94
|
scale: 1.005,
|
|
95
95
|
boxShadow: theme.shadows.xlarge,
|
|
96
96
|
}
|
|
97
|
-
: {}, size: size, padded: padded, onClick: handleClick, usePointer: !!onClick, "data-
|
|
97
|
+
: {}, size: size, padded: padded, onClick: handleClick, usePointer: !!onClick, "data-testid": dataTestId || 'card' },
|
|
98
98
|
React.createElement(CardActionsContainer, { ref: actionsRef }),
|
|
99
99
|
React.createElement(CardInner, null, children))));
|
|
100
100
|
};
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import styled from 'styled-components';
|
|
3
3
|
import { Text } from '../..';
|
|
4
|
+
import ButtonContext from '../Button/Button.context';
|
|
4
5
|
const HeaderRow = styled.div `
|
|
5
6
|
display: flex;
|
|
6
7
|
justify-content: space-between;
|
|
7
8
|
padding: 8px 16px;
|
|
8
9
|
margin-bottom: 8px;
|
|
9
10
|
|
|
10
|
-
|
|
11
|
+
background-color: ${(props) => props.theme.colours.cardBackgroundSecondary};
|
|
11
12
|
`;
|
|
12
13
|
const LeftContainer = styled.div `
|
|
13
14
|
display: flex;
|
|
@@ -43,6 +44,7 @@ const CardHeader = ({ image, heading, subHeading, meta }) => {
|
|
|
43
44
|
React.createElement(Text, null, heading)),
|
|
44
45
|
React.createElement("div", null,
|
|
45
46
|
React.createElement(Text, { variant: 'secondary' }, subHeading)))),
|
|
46
|
-
meta && React.createElement(MetaContainer, null,
|
|
47
|
+
meta && (React.createElement(MetaContainer, null,
|
|
48
|
+
React.createElement(ButtonContext.Provider, { value: { height: '24px', width: '24px', noBackground: true } }, meta)))));
|
|
47
49
|
};
|
|
48
50
|
export default CardHeader;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
export interface CardToggleSectionProps {
|
|
3
|
-
children: React.ReactNode;
|
|
4
|
-
heading: string;
|
|
5
|
-
enabled: boolean;
|
|
6
|
-
setEnabled: (enabled: boolean) => void;
|
|
3
|
+
'children': React.ReactNode;
|
|
4
|
+
'heading': string;
|
|
5
|
+
'enabled': boolean;
|
|
6
|
+
'setEnabled': (enabled: boolean) => void;
|
|
7
|
+
'data-testid'?: string;
|
|
7
8
|
}
|
|
8
|
-
declare const CardToggleSection: ({ heading, enabled, setEnabled, children }: CardToggleSectionProps) => JSX.Element;
|
|
9
|
+
declare const CardToggleSection: ({ heading, enabled, setEnabled, children, "data-testid": dataTestId, }: CardToggleSectionProps) => JSX.Element;
|
|
9
10
|
export default CardToggleSection;
|
|
@@ -14,9 +14,9 @@ const ToggleHeaderContainer = styled.div `
|
|
|
14
14
|
|
|
15
15
|
background-color: ${(props) => props.theme.colours.cardBackgroundSecondary};
|
|
16
16
|
`;
|
|
17
|
-
const CardToggleSection = ({ heading, enabled, setEnabled, children }) => {
|
|
17
|
+
const CardToggleSection = ({ heading, enabled, setEnabled, children, 'data-testid': dataTestId, }) => {
|
|
18
18
|
return (React.createElement(React.Fragment, null,
|
|
19
|
-
React.createElement(ToggleHeaderContainer, { onClick: () => setEnabled(!enabled) },
|
|
19
|
+
React.createElement(ToggleHeaderContainer, { onClick: () => setEnabled(!enabled), "data-testid": dataTestId || 'card-toggle-header' },
|
|
20
20
|
React.createElement(Text, null, heading),
|
|
21
21
|
React.createElement(Toggle, { value: enabled, onChange: setEnabled })),
|
|
22
22
|
enabled && React.createElement("div", null, children)));
|
|
@@ -35,7 +35,7 @@ const Checklist = ({ items, value, onChange, noSplitGap, large }) => {
|
|
|
35
35
|
.filter((item) => value.includes(item.id))
|
|
36
36
|
.sort((a, b) => checkedOrder.indexOf(a.id) - checkedOrder.indexOf(b.id));
|
|
37
37
|
const unCheckedItems = items.filter((item) => !value.includes(item.id));
|
|
38
|
-
return (React.createElement(LayoutGroup, { "data-
|
|
38
|
+
return (React.createElement(LayoutGroup, { "data-testid": 'checklist' },
|
|
39
39
|
unCheckedItems.map((item) => (React.createElement(motion.div, { layoutId: item.id, key: item.id },
|
|
40
40
|
React.createElement(ChecklistItem, { label: item.label, value: value.includes(item.id), onChange: (checked) => handleChange(item.id, checked), large: !!large })))),
|
|
41
41
|
checkedItems.length && !noSplitGap ? React.createElement(ListDivider, null) : null,
|
|
@@ -50,7 +50,7 @@ const ChecklistItem = ({ label, value, onChange, large }) => {
|
|
|
50
50
|
onChange(false);
|
|
51
51
|
}
|
|
52
52
|
};
|
|
53
|
-
return (React.createElement(Outerlabel, { checked: value, whileHover: { backgroundColor: theme.colours.cardBackground }, "data-
|
|
53
|
+
return (React.createElement(Outerlabel, { checked: value, whileHover: { backgroundColor: theme.colours.cardBackground }, "data-testid": value ? 'checklist-item-checked' : 'checklist-item' },
|
|
54
54
|
React.createElement(Checkmark, { checked: value, large: large }),
|
|
55
55
|
React.createElement(Spacer, null),
|
|
56
56
|
label,
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
const ActionContainer = styled.div `
|
|
4
|
+
display: flex;
|
|
5
|
+
width: 100%;
|
|
6
|
+
|
|
7
|
+
> :first-child {
|
|
8
|
+
flex-grow: 1;
|
|
9
|
+
margin-right: 3px;
|
|
10
|
+
}
|
|
11
|
+
`;
|
|
12
|
+
const SpacedContainer = styled.div `
|
|
13
|
+
display: flex;
|
|
14
|
+
|
|
15
|
+
> * {
|
|
16
|
+
flex-grow: 1;
|
|
17
|
+
margin-right: 3px;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
> *:last-child {
|
|
21
|
+
margin-right: 0;
|
|
22
|
+
}
|
|
23
|
+
`;
|
|
24
|
+
const ControlLine = ({ children, variant = 'action' }) => {
|
|
25
|
+
if (variant === 'action') {
|
|
26
|
+
return React.createElement(ActionContainer, null, children);
|
|
27
|
+
}
|
|
28
|
+
if (variant === 'spaced') {
|
|
29
|
+
return React.createElement(SpacedContainer, null, children);
|
|
30
|
+
}
|
|
31
|
+
return null;
|
|
32
|
+
};
|
|
33
|
+
export default ControlLine;
|
|
@@ -48,6 +48,6 @@ const FancyCheckbox = ({ name, label, options, value, onChange }) => {
|
|
|
48
48
|
const selectedValue = value || contextValue;
|
|
49
49
|
return (React.createElement("div", null,
|
|
50
50
|
label && React.createElement(FancyCheckboxLabel, { htmlFor: name }, label),
|
|
51
|
-
React.createElement(ButtonGroup, { "data-
|
|
51
|
+
React.createElement(ButtonGroup, { "data-testid": 'checkbox-group' }, options.map((option) => (React.createElement(StyledButton, { selected: option.value === selectedValue, key: option.value, onClick: () => handleChange(option.value), "data-testid": option.value === selectedValue ? 'checkbox-selected' : 'checkbox' }, option.label))))));
|
|
52
52
|
};
|
|
53
53
|
export default FancyCheckbox;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { IconDefinition } from '@fortawesome/fontawesome-svg-core';
|
|
3
|
+
import { ColourVariant } from '../../theme/theme.types';
|
|
4
|
+
interface FloatingActionButtonProps {
|
|
5
|
+
icon: IconDefinition;
|
|
6
|
+
onClick: () => void;
|
|
7
|
+
variant?: ColourVariant;
|
|
8
|
+
}
|
|
9
|
+
declare const FloatingActionButton: {
|
|
10
|
+
({ icon, onClick, variant }: FloatingActionButtonProps): JSX.Element | null;
|
|
11
|
+
Provider: ({ children }: import("./_FloatingActionButton.provider").FloatingActionButtonProviderProps) => JSX.Element;
|
|
12
|
+
};
|
|
13
|
+
export default FloatingActionButton;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React, { useContext, useEffect, useMemo } from 'react';
|
|
2
|
+
import FloatingActionButtonContext from './_FloatingActionButton.context';
|
|
3
|
+
import FloatingActionButtonProvider from './_FloatingActionButton.provider';
|
|
4
|
+
import { v4 } from 'uuid';
|
|
5
|
+
import FloatingActionButtonInternal from './_FloatingActionButton.internal';
|
|
6
|
+
const FloatingActionButton = ({ icon, onClick, variant = 'primary' }) => {
|
|
7
|
+
const { contextExists, setButton } = useContext(FloatingActionButtonContext);
|
|
8
|
+
const id = useMemo(() => v4(), []);
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
setButton({ id, icon, onClick, variant });
|
|
11
|
+
return () => {
|
|
12
|
+
setButton(undefined);
|
|
13
|
+
};
|
|
14
|
+
}, [icon, onClick, variant, setButton]);
|
|
15
|
+
if (!contextExists) {
|
|
16
|
+
return React.createElement(FloatingActionButtonInternal, { icon: icon, onClick: onClick, variant: variant });
|
|
17
|
+
}
|
|
18
|
+
return null;
|
|
19
|
+
};
|
|
20
|
+
FloatingActionButton.Provider = FloatingActionButtonProvider;
|
|
21
|
+
export default FloatingActionButton;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { IconDefinition } from '@fortawesome/fontawesome-svg-core';
|
|
3
|
+
import { ColourVariant } from '../../theme/theme.types';
|
|
4
|
+
export interface FabProps {
|
|
5
|
+
id: string;
|
|
6
|
+
icon: IconDefinition | null;
|
|
7
|
+
onClick: () => void;
|
|
8
|
+
variant?: ColourVariant;
|
|
9
|
+
}
|
|
10
|
+
interface FloatingActionButtonContextProps {
|
|
11
|
+
contextExists: boolean;
|
|
12
|
+
setButton: (props: FabProps | undefined) => void;
|
|
13
|
+
}
|
|
14
|
+
declare const FloatingActionButtonContext: import("react").Context<FloatingActionButtonContextProps>;
|
|
15
|
+
export default FloatingActionButtonContext;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { IconDefinition } from '@fortawesome/fontawesome-svg-core';
|
|
3
|
+
import { ColourVariant } from '../../theme/theme.types';
|
|
4
|
+
interface FloatingActionButtonInternalProps {
|
|
5
|
+
icon: IconDefinition;
|
|
6
|
+
onClick: () => void;
|
|
7
|
+
variant?: ColourVariant;
|
|
8
|
+
}
|
|
9
|
+
declare const FloatingActionButtonInternal: ({ icon, onClick, variant }: FloatingActionButtonInternalProps) => JSX.Element;
|
|
10
|
+
export default FloatingActionButtonInternal;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import React, { useContext } from 'react';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
import { motion } from 'framer-motion';
|
|
4
|
+
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
5
|
+
import getThemeVariantColours from '../../theme/helpers/getThemeVariantColours';
|
|
6
|
+
import MinimalMenuContext from '../MinimalMenu/MinimalMenu.context';
|
|
7
|
+
import zIndexConstants from '../../constants/zIndex.constants';
|
|
8
|
+
import FloatingActionButtonContext from './_FloatingActionButton.context';
|
|
9
|
+
const FloatingButton = styled(motion.button) `
|
|
10
|
+
position: fixed;
|
|
11
|
+
bottom: ${(props) => (props.offsetBottom ? '76px' : '20px')};
|
|
12
|
+
right: 20px;
|
|
13
|
+
width: 56px;
|
|
14
|
+
height: 56px;
|
|
15
|
+
border-radius: 50%;
|
|
16
|
+
background-color: ${(props) => getThemeVariantColours(props.variant, props.theme).main};
|
|
17
|
+
color: ${(props) => getThemeVariantColours(props.variant, props.theme).contrastText};
|
|
18
|
+
border: none;
|
|
19
|
+
outline: none;
|
|
20
|
+
cursor: pointer;
|
|
21
|
+
display: flex;
|
|
22
|
+
justify-content: center;
|
|
23
|
+
align-items: center;
|
|
24
|
+
font-size: 24px;
|
|
25
|
+
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
|
|
26
|
+
z-index: ${zIndexConstants.floatingActionButton};
|
|
27
|
+
|
|
28
|
+
&:hover {
|
|
29
|
+
background-color: ${(props) => getThemeVariantColours(props.variant, props.theme).darker};
|
|
30
|
+
}
|
|
31
|
+
`;
|
|
32
|
+
const FloatingActionButtonInternal = ({ icon, onClick, variant = 'primary' }) => {
|
|
33
|
+
const { menuExists, isMobile } = useContext(MinimalMenuContext);
|
|
34
|
+
const { contextExists } = useContext(FloatingActionButtonContext);
|
|
35
|
+
const variants = {
|
|
36
|
+
hidden: { opacity: 0, scale: 0 },
|
|
37
|
+
visible: { opacity: 1, scale: 1, transition: { duration: 0.3, delay: 0.2 } },
|
|
38
|
+
exit: { opacity: 0, scale: 0, transition: { duration: 0.3 } },
|
|
39
|
+
hover: { scale: 1.1 },
|
|
40
|
+
tap: { scale: 0.95 },
|
|
41
|
+
};
|
|
42
|
+
return (React.createElement(FloatingButton, { key: 'floating-button', initial: contextExists ? 'hidden' : 'visible', animate: 'visible', exit: 'exit', whileHover: 'hover', whileTap: 'tap', offsetBottom: menuExists && isMobile, variants: variants, onClick: onClick, variant: variant },
|
|
43
|
+
React.createElement(FontAwesomeIcon, { icon: icon })));
|
|
44
|
+
};
|
|
45
|
+
export default FloatingActionButtonInternal;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface FloatingActionButtonProviderProps {
|
|
3
|
+
children: React.ReactNode;
|
|
4
|
+
}
|
|
5
|
+
declare const FloatingActionButtonProvider: ({ children }: FloatingActionButtonProviderProps) => JSX.Element;
|
|
6
|
+
export default FloatingActionButtonProvider;
|