@dtdot/lego 1.5.0 → 1.6.0
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/Card/Card.component.d.ts +1 -0
- package/build/components/Card/Card.component.js +2 -0
- package/build/components/Card/_CardToggleSection.component.d.ts +9 -0
- package/build/components/Card/_CardToggleSection.component.js +24 -0
- package/build/components/Toggle/Toggle.component.d.ts +7 -0
- package/build/components/Toggle/Toggle.component.js +36 -0
- package/build/theme/dark.theme.js +5 -0
- package/build/theme/default.theme.js +5 -0
- package/build/theme/theme.types.d.ts +2 -0
- package/package.json +1 -1
|
@@ -8,6 +8,7 @@ export interface CardProps {
|
|
|
8
8
|
}
|
|
9
9
|
declare const Card: {
|
|
10
10
|
({ children, padded, size, onClick }: CardProps): JSX.Element;
|
|
11
|
+
ToggleSection: ({ heading, enabled, setEnabled, children }: import("./_CardToggleSection.component").CardToggleSectionProps) => JSX.Element;
|
|
11
12
|
Actions: ({ children }: import("./_CardActions.component").CardActionsProps) => React.ReactPortal | null;
|
|
12
13
|
Action: ({ children, onClick }: import("./_CardActions.component").CardActionProps) => JSX.Element;
|
|
13
14
|
Content: ({ children }: import("./_CardContent.component").CardContentProps) => JSX.Element;
|
|
@@ -9,6 +9,7 @@ import CardHeader from './_CardHeader.component';
|
|
|
9
9
|
import CardMedia from './_CardMedia.component';
|
|
10
10
|
import CardSpacer from './_CardSpacer.component';
|
|
11
11
|
import CardSubContent from './_CardSubContent.component';
|
|
12
|
+
import CardToggleSection from './_CardToggleSection.component';
|
|
12
13
|
const CardActionsContainer = styled.div `
|
|
13
14
|
position: absolute;
|
|
14
15
|
top: -32px;
|
|
@@ -97,6 +98,7 @@ const Card = ({ children, padded, size = 'sm', onClick }) => {
|
|
|
97
98
|
React.createElement(CardActionsContainer, { ref: actionsRef }),
|
|
98
99
|
React.createElement(CardInner, null, children))));
|
|
99
100
|
};
|
|
101
|
+
Card.ToggleSection = CardToggleSection;
|
|
100
102
|
Card.Actions = CardActions;
|
|
101
103
|
Card.Action = CardAction;
|
|
102
104
|
Card.Content = CardContent;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface CardToggleSectionProps {
|
|
3
|
+
children: React.ReactNode;
|
|
4
|
+
heading: string;
|
|
5
|
+
enabled: boolean;
|
|
6
|
+
setEnabled: (enabled: boolean) => void;
|
|
7
|
+
}
|
|
8
|
+
declare const CardToggleSection: ({ heading, enabled, setEnabled, children }: CardToggleSectionProps) => JSX.Element;
|
|
9
|
+
export default CardToggleSection;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
import Text from '../Text/Text.component';
|
|
4
|
+
import Toggle from '../Toggle/Toggle.component';
|
|
5
|
+
const ToggleHeaderContainer = styled.div `
|
|
6
|
+
height: 48px;
|
|
7
|
+
width: 100%;
|
|
8
|
+
padding: 8px 16px;
|
|
9
|
+
|
|
10
|
+
display: flex;
|
|
11
|
+
justify-content: space-between;
|
|
12
|
+
align-items: center;
|
|
13
|
+
cursor: pointer;
|
|
14
|
+
|
|
15
|
+
background-color: ${(props) => props.theme.colours.cardBackgroundSecondary};
|
|
16
|
+
`;
|
|
17
|
+
const CardToggleSection = ({ heading, enabled, setEnabled, children }) => {
|
|
18
|
+
return (React.createElement(React.Fragment, null,
|
|
19
|
+
React.createElement(ToggleHeaderContainer, { onClick: () => setEnabled(!enabled) },
|
|
20
|
+
React.createElement(Text, null, heading),
|
|
21
|
+
React.createElement(Toggle, { value: enabled, onChange: setEnabled })),
|
|
22
|
+
enabled && React.createElement("div", null, children)));
|
|
23
|
+
};
|
|
24
|
+
export default CardToggleSection;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { motion } from 'framer-motion';
|
|
3
|
+
import styled from 'styled-components';
|
|
4
|
+
import darkTheme from '../../theme/dark.theme';
|
|
5
|
+
const ToggleOuter = styled(motion.div) `
|
|
6
|
+
width: 42px;
|
|
7
|
+
height: 24px;
|
|
8
|
+
border-radius: 12px;
|
|
9
|
+
|
|
10
|
+
background-color: ${(props) => props.theme.colours.controlBackground};
|
|
11
|
+
cursor: pointer;
|
|
12
|
+
|
|
13
|
+
display: flex;
|
|
14
|
+
align-items: center;
|
|
15
|
+
`;
|
|
16
|
+
const ToggleDot = styled(motion.div) `
|
|
17
|
+
height: 16px;
|
|
18
|
+
width: 16px;
|
|
19
|
+
border-radius: 16px;
|
|
20
|
+
background-color: ${(props) => props.theme.colours.defaultFont};
|
|
21
|
+
|
|
22
|
+
transform: translateX(4px);
|
|
23
|
+
`;
|
|
24
|
+
const toggleOuterVariants = {
|
|
25
|
+
off: { backgroundColor: darkTheme.colours.controlBackground },
|
|
26
|
+
on: { backgroundColor: darkTheme.colours.statusSuccess.dull },
|
|
27
|
+
};
|
|
28
|
+
const toggleDotVariants = {
|
|
29
|
+
off: { transform: 'translateX(4px)' },
|
|
30
|
+
on: { transform: 'translateX(22px)' },
|
|
31
|
+
};
|
|
32
|
+
const Toggle = ({ value, onChange }) => {
|
|
33
|
+
return (React.createElement(ToggleOuter, { animate: value ? 'on' : 'off', variants: toggleOuterVariants, transition: { type: 'spring', duration: 0.3 }, onClick: () => onChange(!value) },
|
|
34
|
+
React.createElement(ToggleDot, { animate: value ? 'on' : 'off', variants: toggleDotVariants, transition: { type: 'spring', duration: 0.3 } })));
|
|
35
|
+
};
|
|
36
|
+
export default Toggle;
|
|
@@ -32,21 +32,26 @@ const darkTheme = {
|
|
|
32
32
|
uploadBackground: '#5e6167',
|
|
33
33
|
uploadIcon: '#e2e2e2',
|
|
34
34
|
cardBackground: '#494b50',
|
|
35
|
+
cardBackgroundSecondary: '#525459',
|
|
35
36
|
statusInfo: {
|
|
36
37
|
main: '#83bfff',
|
|
37
38
|
contrast: '#191919',
|
|
39
|
+
dull: '#0070e8',
|
|
38
40
|
},
|
|
39
41
|
statusSuccess: {
|
|
40
42
|
main: '#8ddaa9',
|
|
41
43
|
contrast: '#191919',
|
|
44
|
+
dull: '#35a35d',
|
|
42
45
|
},
|
|
43
46
|
statusWarn: {
|
|
44
47
|
main: '#f1a374',
|
|
45
48
|
contrast: '#191919',
|
|
49
|
+
dull: '#c35514',
|
|
46
50
|
},
|
|
47
51
|
statusDanger: {
|
|
48
52
|
main: '#e87a7a',
|
|
49
53
|
contrast: '#191919',
|
|
54
|
+
dull: '#b51f1f',
|
|
50
55
|
},
|
|
51
56
|
},
|
|
52
57
|
fonts: {
|
|
@@ -33,21 +33,26 @@ const defaultTheme = {
|
|
|
33
33
|
uploadBackground: colours.grey20,
|
|
34
34
|
uploadIcon: colours.grey10,
|
|
35
35
|
cardBackground: colours.white,
|
|
36
|
+
cardBackgroundSecondary: colours.white,
|
|
36
37
|
statusInfo: {
|
|
37
38
|
main: colours.blue,
|
|
38
39
|
contrast: colours.blue,
|
|
40
|
+
dull: colours.blue,
|
|
39
41
|
},
|
|
40
42
|
statusSuccess: {
|
|
41
43
|
main: colours.green,
|
|
42
44
|
contrast: colours.green,
|
|
45
|
+
dull: colours.green,
|
|
43
46
|
},
|
|
44
47
|
statusWarn: {
|
|
45
48
|
main: colours.yellow,
|
|
46
49
|
contrast: colours.yellow,
|
|
50
|
+
dull: colours.yellow,
|
|
47
51
|
},
|
|
48
52
|
statusDanger: {
|
|
49
53
|
main: colours.red,
|
|
50
54
|
contrast: colours.red,
|
|
55
|
+
dull: colours.red,
|
|
51
56
|
},
|
|
52
57
|
},
|
|
53
58
|
fonts: {
|
|
@@ -8,6 +8,7 @@ export interface IPalette {
|
|
|
8
8
|
export interface IStatus {
|
|
9
9
|
main: string;
|
|
10
10
|
contrast: string;
|
|
11
|
+
dull: string;
|
|
11
12
|
}
|
|
12
13
|
export interface IFont {
|
|
13
14
|
family: string;
|
|
@@ -36,6 +37,7 @@ export interface LegoTheme {
|
|
|
36
37
|
uploadBackground: string;
|
|
37
38
|
uploadIcon: string;
|
|
38
39
|
cardBackground: string;
|
|
40
|
+
cardBackgroundSecondary: string;
|
|
39
41
|
statusInfo: IStatus;
|
|
40
42
|
statusSuccess: IStatus;
|
|
41
43
|
statusWarn: IStatus;
|