@dtdot/lego 2.2.0 → 2.3.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/build/components/Checklist/Checklist.component.d.ts +2 -1
- package/build/components/Checklist/Checklist.component.js +4 -4
- package/build/components/Checklist/_ChecklistItem.component.d.ts +3 -2
- package/build/components/Checklist/_ChecklistItem.component.js +13 -4
- package/build/index.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
+
import { Status } from '../../theme/theme.types';
|
|
2
3
|
export interface ChecklistItemProps {
|
|
3
4
|
id: string;
|
|
4
5
|
label: string;
|
|
5
|
-
|
|
6
|
+
status?: Status;
|
|
6
7
|
}
|
|
7
8
|
export interface ChecklistProps {
|
|
8
9
|
items: ChecklistItemProps[];
|
|
@@ -36,10 +36,10 @@ const Checklist = ({ items, value, onChange, noSplitGap, large }) => {
|
|
|
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
38
|
return (React.createElement(LayoutGroup, { "data-testid": 'checklist' },
|
|
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), large: !!large,
|
|
39
|
+
unCheckedItems.map((item) => (React.createElement(motion.div, { layoutId: item.id, key: item.id, layout: true },
|
|
40
|
+
React.createElement(ChecklistItem, { label: item.label, value: value.includes(item.id), onChange: (checked) => handleChange(item.id, checked), large: !!large, status: item.status })))),
|
|
41
41
|
checkedItems.length && !noSplitGap ? 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), large: !!large,
|
|
42
|
+
checkedItems.map((item) => (React.createElement(motion.div, { layoutId: item.id, key: item.id, layout: true },
|
|
43
|
+
React.createElement(ChecklistItem, { label: item.label, value: value.includes(item.id), onChange: (checked) => handleChange(item.id, checked), large: !!large, status: item.status }))))));
|
|
44
44
|
};
|
|
45
45
|
export default Checklist;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
+
import { Status } from '../../theme/theme.types';
|
|
2
3
|
export interface ChecklistItemProps {
|
|
3
4
|
label: string;
|
|
4
5
|
value: boolean;
|
|
5
6
|
onChange: (value: boolean) => void;
|
|
6
7
|
large: boolean;
|
|
7
|
-
|
|
8
|
+
status?: Status;
|
|
8
9
|
}
|
|
9
|
-
declare const ChecklistItem: ({ label, value, onChange, large,
|
|
10
|
+
declare const ChecklistItem: ({ label, value, onChange, large, status }: ChecklistItemProps) => JSX.Element;
|
|
10
11
|
export default ChecklistItem;
|
|
@@ -2,6 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { motion } from 'framer-motion';
|
|
3
3
|
import styled, { useTheme } from 'styled-components';
|
|
4
4
|
import { Checkmark } from '../common/Checkmark.component';
|
|
5
|
+
import getThemeStatusColour from '../../theme/helpers/getThemeStatusColour';
|
|
5
6
|
const Outerlabel = styled(motion.label) `
|
|
6
7
|
position: relative;
|
|
7
8
|
margin-bottom: 4px;
|
|
@@ -15,8 +16,10 @@ const Outerlabel = styled(motion.label) `
|
|
|
15
16
|
font-weight: ${(props) => props.theme.fonts.default.weight};
|
|
16
17
|
color: ${(props) => (props.checked ? props.theme.colours.defaultBorder : props.theme.colours.defaultFont)};
|
|
17
18
|
|
|
18
|
-
background-color: ${(props) => props
|
|
19
|
-
border-left:
|
|
19
|
+
background-color: ${(props) => props.theme.colours.background};
|
|
20
|
+
border-left: 3px solid transparent;
|
|
21
|
+
|
|
22
|
+
transition: border-color 0.3s ease-in-out;
|
|
20
23
|
|
|
21
24
|
user-select: none;
|
|
22
25
|
cursor: pointer;
|
|
@@ -41,8 +44,12 @@ const Strikethrough = styled.div `
|
|
|
41
44
|
padding-left: 2px;
|
|
42
45
|
background-color: ${(props) => props.theme.colours.defaultBorder};
|
|
43
46
|
`;
|
|
44
|
-
const ChecklistItem = ({ label, value, onChange, large,
|
|
47
|
+
const ChecklistItem = ({ label, value, onChange, large, status }) => {
|
|
45
48
|
const theme = useTheme();
|
|
49
|
+
const statusColour = status ? getThemeStatusColour(status, theme) : null;
|
|
50
|
+
if (status) {
|
|
51
|
+
console.log('ChecklistItem with status:', { label, status, statusColour, borderColor: statusColour?.main });
|
|
52
|
+
}
|
|
46
53
|
const handleChange = (event) => {
|
|
47
54
|
if (event.target.checked) {
|
|
48
55
|
onChange(true);
|
|
@@ -51,7 +58,9 @@ const ChecklistItem = ({ label, value, onChange, large, colour }) => {
|
|
|
51
58
|
onChange(false);
|
|
52
59
|
}
|
|
53
60
|
};
|
|
54
|
-
return (React.createElement(Outerlabel, { checked: value, "$
|
|
61
|
+
return (React.createElement(Outerlabel, { checked: value, "$status": status, style: {
|
|
62
|
+
borderLeftColor: statusColour?.main ?? 'transparent',
|
|
63
|
+
}, whileHover: { backgroundColor: theme.colours.cardBackground }, "data-testid": value ? 'checklist-item-checked' : 'checklist-item', "data-highlight": status ?? undefined },
|
|
55
64
|
React.createElement(Checkmark, { checked: value, large: large }),
|
|
56
65
|
React.createElement(Spacer, null),
|
|
57
66
|
label,
|
package/build/index.d.ts
CHANGED
|
@@ -61,3 +61,4 @@ export { ButtonProps as ButtonProps } from './components/Button/Button.component
|
|
|
61
61
|
export { ToggleProps } from './components/Toggle/Toggle.component';
|
|
62
62
|
export { default as menuHelpers } from './components/Menu/menu.helpers';
|
|
63
63
|
export { default as responsive } from './responsive/responsive';
|
|
64
|
+
export type { Status } from './theme/theme.types';
|