@dtdot/lego 0.17.22 → 0.18.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 +9 -0
- package/build/components/ActionMenu/ActionMenu.component.js +52 -0
- package/build/components/ActionMenu/ActionMenu.stories.d.ts +6 -0
- package/build/components/ActionMenu/ActionMenu.stories.js +48 -0
- package/build/components/ActionMenu/_ActionMenu.types.d.ts +4 -0
- package/build/components/ActionMenu/_ActionMenu.types.js +1 -0
- package/build/components/ActionMenu/_ActionMenuItem.component.d.ts +7 -0
- package/build/components/ActionMenu/_ActionMenuItem.component.js +18 -0
- package/build/components/ActionMenu/_ActionMenuPanel.component.d.ts +7 -0
- package/build/components/ActionMenu/_ActionMenuPanel.component.js +9 -0
- package/build/components/BadgeSelector/BadgeSelector.component.js +4 -0
- package/build/components/BadgeSelector/BadgeSelector.stories.d.ts +1 -0
- package/build/components/BadgeSelector/BadgeSelector.stories.js +61 -0
- package/build/components/Button/Button.component.d.ts +1 -1
- package/build/components/Button/Button.component.js +4 -3
- package/build/components/Checklist/Checklist.component.d.ts +12 -0
- package/build/components/Checklist/Checklist.component.js +45 -0
- package/build/components/Checklist/Checklist.stories.d.ts +5 -0
- package/build/components/Checklist/Checklist.stories.js +42 -0
- package/build/components/Checklist/_ChecklistItem.component.d.ts +8 -0
- package/build/components/Checklist/_ChecklistItem.component.js +78 -0
- package/build/index.d.ts +2 -0
- package/build/index.js +2 -0
- package/package.json +4 -2
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { ColourVariant } from '../../theme/theme.types';
|
|
3
|
+
import { IActionMenuItem } from './_ActionMenu.types';
|
|
4
|
+
export interface ActionMenuProps {
|
|
5
|
+
items: IActionMenuItem[];
|
|
6
|
+
variant?: ColourVariant;
|
|
7
|
+
}
|
|
8
|
+
declare const ActionMenu: ({ items, variant }: ActionMenuProps) => JSX.Element;
|
|
9
|
+
export default ActionMenu;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { faEllipsisV } from '@fortawesome/free-solid-svg-icons';
|
|
2
|
+
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
3
|
+
import React, { useCallback, useEffect, useState } from 'react';
|
|
4
|
+
import ReactDOM from 'react-dom';
|
|
5
|
+
import styled from 'styled-components';
|
|
6
|
+
import { usePopper } from 'react-popper';
|
|
7
|
+
import Button from '../Button/Button.component';
|
|
8
|
+
import ActionMenuPanel from './_ActionMenuPanel.component';
|
|
9
|
+
const StyledIcon = styled(FontAwesomeIcon) `
|
|
10
|
+
font-size: 18px;
|
|
11
|
+
`;
|
|
12
|
+
const offsetFn = () => [70, 4];
|
|
13
|
+
const ActionMenu = ({ items, variant }) => {
|
|
14
|
+
const [shown, setShown] = useState(false);
|
|
15
|
+
const [referenceElement, setReferenceElement] = useState();
|
|
16
|
+
const [popperElement, setPopperElement] = useState();
|
|
17
|
+
const { styles, attributes } = usePopper(referenceElement, popperElement, {
|
|
18
|
+
modifiers: [
|
|
19
|
+
{
|
|
20
|
+
name: 'offset',
|
|
21
|
+
options: {
|
|
22
|
+
offset: offsetFn,
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
],
|
|
26
|
+
});
|
|
27
|
+
const handleGlobalClick = useCallback((event) => {
|
|
28
|
+
if (!popperElement?.contains(event.target)) {
|
|
29
|
+
setShown(false);
|
|
30
|
+
}
|
|
31
|
+
}, [setShown, popperElement]);
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
document.addEventListener('mouseup', handleGlobalClick);
|
|
34
|
+
return () => {
|
|
35
|
+
document.removeEventListener('mouseup', handleGlobalClick);
|
|
36
|
+
};
|
|
37
|
+
}, [handleGlobalClick, popperElement]);
|
|
38
|
+
const augmentedItems = items.map((item) => ({
|
|
39
|
+
...item,
|
|
40
|
+
onClick: () => {
|
|
41
|
+
setShown(false);
|
|
42
|
+
item.onClick();
|
|
43
|
+
},
|
|
44
|
+
}));
|
|
45
|
+
return (React.createElement(React.Fragment, null,
|
|
46
|
+
React.createElement(Button, { variant: variant, ref: setReferenceElement, onClick: () => setShown(true) },
|
|
47
|
+
React.createElement(StyledIcon, { icon: faEllipsisV })),
|
|
48
|
+
shown &&
|
|
49
|
+
ReactDOM.createPortal(React.createElement("div", { ref: setPopperElement, style: styles.popper, ...attributes.popper },
|
|
50
|
+
React.createElement(ActionMenuPanel, { items: augmentedItems })), document.querySelector('body'))));
|
|
51
|
+
};
|
|
52
|
+
export default ActionMenu;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { Meta } from '@storybook/react/types-6-0';
|
|
3
|
+
export declare const Standard: () => JSX.Element;
|
|
4
|
+
export declare const Variants: () => JSX.Element;
|
|
5
|
+
declare const _default: Meta<import("@storybook/react/types-6-0").Args>;
|
|
6
|
+
export default _default;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ActionMenu } from '../..';
|
|
3
|
+
/* eslint-disable @typescript-eslint/no-empty-function */
|
|
4
|
+
const items = [
|
|
5
|
+
{
|
|
6
|
+
label: 'Angry Lama',
|
|
7
|
+
onClick: () => {
|
|
8
|
+
console.log('Item 1 clicked');
|
|
9
|
+
},
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
label: 'Frightened Frog',
|
|
13
|
+
onClick: () => {
|
|
14
|
+
console.log('Item 2 clicked');
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
label: 'Hungry Bear',
|
|
19
|
+
onClick: () => {
|
|
20
|
+
console.log('Item 3 clicked');
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
label: 'Crazy Koala',
|
|
25
|
+
onClick: () => {
|
|
26
|
+
console.log('Item 4 clicked');
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
label: 'Dizzy Snake',
|
|
31
|
+
onClick: () => {
|
|
32
|
+
console.log('Item 5 clicked');
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
];
|
|
36
|
+
export const Standard = () => React.createElement(ActionMenu, { items: items, variant: 'tertiary' });
|
|
37
|
+
export const Variants = () => (React.createElement(React.Fragment, null,
|
|
38
|
+
React.createElement(ActionMenu, { items: items, variant: 'primary' }),
|
|
39
|
+
React.createElement("br", null),
|
|
40
|
+
React.createElement("br", null),
|
|
41
|
+
React.createElement(ActionMenu, { items: items, variant: 'secondary' }),
|
|
42
|
+
React.createElement("br", null),
|
|
43
|
+
React.createElement("br", null),
|
|
44
|
+
React.createElement(ActionMenu, { items: items, variant: 'tertiary' })));
|
|
45
|
+
export default {
|
|
46
|
+
title: 'Components/ActionMenu',
|
|
47
|
+
component: ActionMenu,
|
|
48
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { motion } from 'framer-motion';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import styled, { useTheme } from 'styled-components';
|
|
4
|
+
const ActionMenuItemOuter = styled(motion.div) `
|
|
5
|
+
padding: 12px 16px;
|
|
6
|
+
cursor: pointer;
|
|
7
|
+
|
|
8
|
+
color: ${(props) => props.theme.colours.defaultFont};
|
|
9
|
+
font-family: ${(props) => props.theme.fonts.default.family};
|
|
10
|
+
font-size: ${(props) => props.theme.fonts.default.size};
|
|
11
|
+
font-weight: ${(props) => props.theme.fonts.default.weight};
|
|
12
|
+
`;
|
|
13
|
+
const ActionMenuItem = ({ label, onClick }) => {
|
|
14
|
+
const theme = useTheme();
|
|
15
|
+
return (React.createElement(React.Fragment, null,
|
|
16
|
+
React.createElement(ActionMenuItemOuter, { style: { backgroundColor: theme.colours.tertiary.main }, whileHover: { backgroundColor: theme.colours.tertiary.hover }, onClick: onClick }, label)));
|
|
17
|
+
};
|
|
18
|
+
export default ActionMenuItem;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { IActionMenuItem } from './_ActionMenu.types';
|
|
3
|
+
export interface ActionMenuPanelProps {
|
|
4
|
+
items: IActionMenuItem[];
|
|
5
|
+
}
|
|
6
|
+
declare const ActionMenuPanel: ({ items }: ActionMenuPanelProps) => JSX.Element;
|
|
7
|
+
export default ActionMenuPanel;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
import ActionMenuItem from './_ActionMenuItem.component';
|
|
4
|
+
const ActionMenuPanelOuter = styled.div `
|
|
5
|
+
background-color: ${(props) => props.theme.colours.tertiary.main};
|
|
6
|
+
min-width: 160px;
|
|
7
|
+
`;
|
|
8
|
+
const ActionMenuPanel = ({ items }) => (React.createElement(ActionMenuPanelOuter, null, items.map((item) => (React.createElement(ActionMenuItem, { key: item.label, label: item.label, onClick: item.onClick })))));
|
|
9
|
+
export default ActionMenuPanel;
|
|
@@ -4,6 +4,7 @@ import getThemeVariantColours from '../../theme/helpers/getThemeVariantColours';
|
|
|
4
4
|
import { BadgeSpan } from '../Badge/Badge.component';
|
|
5
5
|
const InteractiveBadge = styled(BadgeSpan) `
|
|
6
6
|
cursor: pointer;
|
|
7
|
+
margin-bottom: 8px;
|
|
7
8
|
|
|
8
9
|
${(props) => props.inactive &&
|
|
9
10
|
`
|
|
@@ -12,6 +13,9 @@ const InteractiveBadge = styled(BadgeSpan) `
|
|
|
12
13
|
`}
|
|
13
14
|
`;
|
|
14
15
|
const BadgeSelectorOuter = styled.div `
|
|
16
|
+
display: flex;
|
|
17
|
+
flex-wrap: wrap;
|
|
18
|
+
|
|
15
19
|
${InteractiveBadge} {
|
|
16
20
|
margin-right: 8px;
|
|
17
21
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { Meta } from '@storybook/react/types-6-0';
|
|
3
3
|
export declare const Standard: () => JSX.Element;
|
|
4
|
+
export declare const LotsOfBadges: () => JSX.Element;
|
|
4
5
|
declare const _default: Meta<import("@storybook/react/types-6-0").Args>;
|
|
5
6
|
export default _default;
|
|
@@ -27,6 +27,67 @@ export const Standard = () => {
|
|
|
27
27
|
const [value, setValue] = useState(['pending']);
|
|
28
28
|
return React.createElement(BadgeSelector, { options: options, value: value, onChange: setValue });
|
|
29
29
|
};
|
|
30
|
+
const options2 = [
|
|
31
|
+
{
|
|
32
|
+
value: 'one',
|
|
33
|
+
name: 'one',
|
|
34
|
+
variant: 'info',
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
value: 'two',
|
|
38
|
+
name: 'two',
|
|
39
|
+
variant: 'info',
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
value: 'three',
|
|
43
|
+
name: 'three',
|
|
44
|
+
variant: 'info',
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
value: 'four',
|
|
48
|
+
name: 'four',
|
|
49
|
+
variant: 'info',
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
value: 'five',
|
|
53
|
+
name: 'five',
|
|
54
|
+
variant: 'info',
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
value: 'six',
|
|
58
|
+
name: 'six',
|
|
59
|
+
variant: 'info',
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
value: 'seven',
|
|
63
|
+
name: 'seven',
|
|
64
|
+
variant: 'info',
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
value: 'eight',
|
|
68
|
+
name: 'eight',
|
|
69
|
+
variant: 'info',
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
value: 'nine',
|
|
73
|
+
name: 'nine',
|
|
74
|
+
variant: 'info',
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
value: 'ten',
|
|
78
|
+
name: 'ten',
|
|
79
|
+
variant: 'info',
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
value: 'eleven',
|
|
83
|
+
name: 'eleven',
|
|
84
|
+
variant: 'info',
|
|
85
|
+
},
|
|
86
|
+
];
|
|
87
|
+
export const LotsOfBadges = () => {
|
|
88
|
+
const [value, setValue] = useState(['one']);
|
|
89
|
+
return React.createElement(BadgeSelector, { options: options2, value: value, onChange: setValue });
|
|
90
|
+
};
|
|
30
91
|
export default {
|
|
31
92
|
title: 'Components/BadgeSelector',
|
|
32
93
|
component: BadgeSelector,
|
|
@@ -7,5 +7,5 @@ export interface ButtonProps {
|
|
|
7
7
|
type?: 'submit';
|
|
8
8
|
onClick?: () => void;
|
|
9
9
|
}
|
|
10
|
-
declare const Button:
|
|
10
|
+
declare const Button: React.ForwardRefExoticComponent<ButtonProps & React.RefAttributes<unknown>>;
|
|
11
11
|
export default Button;
|
|
@@ -53,8 +53,9 @@ const ButtonSpinner = styled.div `
|
|
|
53
53
|
animation-iteration-count: infinite;
|
|
54
54
|
}
|
|
55
55
|
`;
|
|
56
|
-
const Button = (
|
|
56
|
+
const Button = React.forwardRef(function Button(props, ref) {
|
|
57
|
+
const { children, loading, variant = 'primary', type, onClick } = props;
|
|
57
58
|
const { width, height, alignSelf, marginTop } = useContext(ButtonContext);
|
|
58
|
-
return (React.createElement(StyledButton, { width: width, height: height, alignSelf: alignSelf, marginTop: marginTop, variant: variant, type: type, onClick: onClick }, loading ? React.createElement(ButtonSpinner, { variant: variant }) : children));
|
|
59
|
-
};
|
|
59
|
+
return (React.createElement(StyledButton, { ref: ref, width: width, height: height, alignSelf: alignSelf, marginTop: marginTop, variant: variant, type: type, onClick: onClick }, loading ? React.createElement(ButtonSpinner, { variant: variant }) : children));
|
|
60
|
+
});
|
|
60
61
|
export default Button;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export interface ChecklistItemProps {
|
|
3
|
+
id: string;
|
|
4
|
+
label: string;
|
|
5
|
+
}
|
|
6
|
+
export interface ChecklistProps {
|
|
7
|
+
items: ChecklistItemProps[];
|
|
8
|
+
value: string[];
|
|
9
|
+
onChange: (value: string[]) => void;
|
|
10
|
+
}
|
|
11
|
+
declare const Checklist: ({ items, value, onChange }: ChecklistProps) => JSX.Element;
|
|
12
|
+
export default Checklist;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
import { motion, LayoutGroup } from 'framer-motion';
|
|
4
|
+
import ChecklistItem from './_ChecklistItem.component';
|
|
5
|
+
const ListDivider = styled.div `
|
|
6
|
+
width: 100%;
|
|
7
|
+
height: 0px;
|
|
8
|
+
|
|
9
|
+
padding: 20px 0;
|
|
10
|
+
`;
|
|
11
|
+
const Checklist = ({ items, value, onChange }) => {
|
|
12
|
+
const [checkedOrder, setCheckedOrder] = useState([]);
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
if (value.some((id) => !checkedOrder.includes(id))) {
|
|
15
|
+
const newCheckedOrder = [...checkedOrder];
|
|
16
|
+
value.forEach((valueId) => {
|
|
17
|
+
if (!newCheckedOrder.includes(valueId)) {
|
|
18
|
+
newCheckedOrder.push(valueId);
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
setCheckedOrder(newCheckedOrder);
|
|
22
|
+
}
|
|
23
|
+
}, [value, checkedOrder, setCheckedOrder]);
|
|
24
|
+
const handleChange = (id, checked) => {
|
|
25
|
+
if (checked && !value.includes(id)) {
|
|
26
|
+
onChange([...value, id]);
|
|
27
|
+
setCheckedOrder([id, ...checkedOrder]);
|
|
28
|
+
}
|
|
29
|
+
else if (!checked && value.includes(id)) {
|
|
30
|
+
onChange(value.filter((_id) => _id !== id));
|
|
31
|
+
setCheckedOrder(checkedOrder.filter((_id) => _id !== id));
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
const checkedItems = items
|
|
35
|
+
.filter((item) => value.includes(item.id))
|
|
36
|
+
.sort((a, b) => checkedOrder.indexOf(a.id) - checkedOrder.indexOf(b.id));
|
|
37
|
+
const unCheckedItems = items.filter((item) => !value.includes(item.id));
|
|
38
|
+
return (React.createElement(LayoutGroup, null,
|
|
39
|
+
unCheckedItems.map((item) => (React.createElement(motion.div, { layoutId: item.id, key: item.id },
|
|
40
|
+
React.createElement(ChecklistItem, { label: item.label, value: value.includes(item.id), onChange: (checked) => handleChange(item.id, checked) })))),
|
|
41
|
+
checkedItems.length ? React.createElement(ListDivider, null) : null,
|
|
42
|
+
checkedItems.map((item) => (React.createElement(motion.div, { layoutId: item.id, key: item.id },
|
|
43
|
+
React.createElement(ChecklistItem, { label: item.label, value: value.includes(item.id), onChange: (checked) => handleChange(item.id, checked) }))))));
|
|
44
|
+
};
|
|
45
|
+
export default Checklist;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { Checklist } from '../..';
|
|
3
|
+
const items = [
|
|
4
|
+
{
|
|
5
|
+
id: '1',
|
|
6
|
+
value: 'one',
|
|
7
|
+
label: 'one',
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
id: '2',
|
|
11
|
+
value: 'two',
|
|
12
|
+
label: 'two',
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
id: '3',
|
|
16
|
+
value: 'three',
|
|
17
|
+
label: 'three',
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
id: '4',
|
|
21
|
+
value: 'four',
|
|
22
|
+
label: 'four',
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
id: '5',
|
|
26
|
+
value: 'five',
|
|
27
|
+
label: 'five',
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
id: '6',
|
|
31
|
+
value: 'six',
|
|
32
|
+
label: 'six',
|
|
33
|
+
},
|
|
34
|
+
];
|
|
35
|
+
export const Standard = () => {
|
|
36
|
+
const [value, setValue] = useState(['2', '4']);
|
|
37
|
+
return React.createElement(Checklist, { items: items, value: value, onChange: setValue });
|
|
38
|
+
};
|
|
39
|
+
export default {
|
|
40
|
+
title: 'Components/Checklist',
|
|
41
|
+
component: Checklist,
|
|
42
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export interface ChecklistItemProps {
|
|
3
|
+
label: string;
|
|
4
|
+
value: boolean;
|
|
5
|
+
onChange: (value: boolean) => void;
|
|
6
|
+
}
|
|
7
|
+
declare const ChecklistItem: ({ label, value, onChange }: ChecklistItemProps) => JSX.Element;
|
|
8
|
+
export default ChecklistItem;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { motion } from 'framer-motion';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import styled, { useTheme } from 'styled-components';
|
|
4
|
+
const Outerlabel = styled(motion.label) `
|
|
5
|
+
position: relative;
|
|
6
|
+
margin-bottom: 4px;
|
|
7
|
+
padding: 4px;
|
|
8
|
+
|
|
9
|
+
display: flex;
|
|
10
|
+
align-items: center;
|
|
11
|
+
|
|
12
|
+
font-size: ${(props) => props.theme.fonts.default.size};
|
|
13
|
+
font-family: ${(props) => props.theme.fonts.default.family};
|
|
14
|
+
font-weight: ${(props) => props.theme.fonts.default.weight};
|
|
15
|
+
color: ${(props) => (props.checked ? props.theme.colours.defaultBorder : props.theme.colours.defaultFont)};
|
|
16
|
+
|
|
17
|
+
background-color: ${(props) => props.theme.colours.background};
|
|
18
|
+
|
|
19
|
+
user-select: none;
|
|
20
|
+
cursor: pointer;
|
|
21
|
+
`;
|
|
22
|
+
const HiddenCheckbox = styled.input `
|
|
23
|
+
position: absolute;
|
|
24
|
+
opacity: 0;
|
|
25
|
+
cursor: pointer;
|
|
26
|
+
height: 0;
|
|
27
|
+
width: 0;
|
|
28
|
+
`;
|
|
29
|
+
const Checkmark = styled.div `
|
|
30
|
+
position: relative;
|
|
31
|
+
height: 24px;
|
|
32
|
+
width: 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: 9px;
|
|
42
|
+
top: 5px;
|
|
43
|
+
width: 5px;
|
|
44
|
+
height: 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
|
+
}
|
|
51
|
+
`;
|
|
52
|
+
const Strikethrough = styled.div `
|
|
53
|
+
position: absolute;
|
|
54
|
+
color: transparent;
|
|
55
|
+
height: 1px;
|
|
56
|
+
|
|
57
|
+
margin-left: 30px;
|
|
58
|
+
padding-right: 2px;
|
|
59
|
+
padding-left: 2px;
|
|
60
|
+
background-color: ${(props) => props.theme.colours.defaultBorder};
|
|
61
|
+
`;
|
|
62
|
+
const ChecklistItem = ({ label, value, onChange }) => {
|
|
63
|
+
const theme = useTheme();
|
|
64
|
+
const handleChange = (event) => {
|
|
65
|
+
if (event.target.checked) {
|
|
66
|
+
onChange(true);
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
onChange(false);
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
return (React.createElement(Outerlabel, { checked: value, whileHover: { backgroundColor: theme.colours.cardBackground } },
|
|
73
|
+
React.createElement(Checkmark, { checked: value }),
|
|
74
|
+
label,
|
|
75
|
+
React.createElement(HiddenCheckbox, { type: 'checkbox', checked: value, onChange: handleChange }),
|
|
76
|
+
value && React.createElement(Strikethrough, null, label)));
|
|
77
|
+
};
|
|
78
|
+
export default ChecklistItem;
|
package/build/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { default as BodyStyle } from './global/BodyStyle.component';
|
|
2
|
+
export { default as ActionMenu } from './components/ActionMenu/ActionMenu.component';
|
|
2
3
|
export { default as ActionMessage } from './components/ActionMessage/ActionMessage.component';
|
|
3
4
|
export { default as Alert } from './components/Alert/Alert.component';
|
|
4
5
|
export { default as Badge } from './components/Badge/Badge.component';
|
|
@@ -7,6 +8,7 @@ export { default as Button } from './components/Button/Button.component';
|
|
|
7
8
|
export { default as ButtonGroup } from './components/ButtonGroup/ButtonGroup.component';
|
|
8
9
|
export { default as Card } from './components/Card/Card.component';
|
|
9
10
|
export { default as CardGroup } from './components/Card/CardGroup.component';
|
|
11
|
+
export { default as Checklist } from './components/Checklist/Checklist.component';
|
|
10
12
|
export { default as ControlGroup } from './components/ControlGroup/ControlGroup.component';
|
|
11
13
|
export { default as FancyCheckbox } from './components/FancyCheckbox/FancyCheckbox.component';
|
|
12
14
|
export { default as Form } from './components/Form/Form.component';
|
package/build/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { default as BodyStyle } from './global/BodyStyle.component';
|
|
2
|
+
export { default as ActionMenu } from './components/ActionMenu/ActionMenu.component';
|
|
2
3
|
export { default as ActionMessage } from './components/ActionMessage/ActionMessage.component';
|
|
3
4
|
export { default as Alert } from './components/Alert/Alert.component';
|
|
4
5
|
export { default as Badge } from './components/Badge/Badge.component';
|
|
@@ -7,6 +8,7 @@ export { default as Button } from './components/Button/Button.component';
|
|
|
7
8
|
export { default as ButtonGroup } from './components/ButtonGroup/ButtonGroup.component';
|
|
8
9
|
export { default as Card } from './components/Card/Card.component';
|
|
9
10
|
export { default as CardGroup } from './components/Card/CardGroup.component';
|
|
11
|
+
export { default as Checklist } from './components/Checklist/Checklist.component';
|
|
10
12
|
export { default as ControlGroup } from './components/ControlGroup/ControlGroup.component';
|
|
11
13
|
export { default as FancyCheckbox } from './components/FancyCheckbox/FancyCheckbox.component';
|
|
12
14
|
export { default as Form } from './components/Form/Form.component';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dtdot/lego",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.3",
|
|
4
4
|
"description": "Some reusable components for building my applications",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"react": "^17.0.2",
|
|
46
46
|
"react-dom": "^17.0.2",
|
|
47
47
|
"storybook-addon-styled-component-theme": "^1.3.0",
|
|
48
|
-
"styled-components": "^5.3.
|
|
48
|
+
"styled-components": "^5.3.5",
|
|
49
49
|
"typescript": "^4.5.5"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
@@ -57,9 +57,11 @@
|
|
|
57
57
|
"@fortawesome/fontawesome-svg-core": "^1.2.32",
|
|
58
58
|
"@fortawesome/free-solid-svg-icons": "^5.15.4",
|
|
59
59
|
"@fortawesome/react-fontawesome": "^0.1.13",
|
|
60
|
+
"@popperjs/core": "^2.11.4",
|
|
60
61
|
"framer-motion": "^6.2.8",
|
|
61
62
|
"identicon.js": "^2.3.3",
|
|
62
63
|
"qrcode": "^1.5.0",
|
|
64
|
+
"react-popper": "^2.2.5",
|
|
63
65
|
"react-use-measure": "^2.1.1",
|
|
64
66
|
"spark-md5": "^3.0.2",
|
|
65
67
|
"uuid": "^8.3.2"
|