@dtdot/lego 1.4.3 → 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.
@@ -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;
@@ -13,7 +13,7 @@ export interface InlineCardProps extends React.HTMLAttributes<HTMLDivElement> {
13
13
  }
14
14
  declare const InlineCard: {
15
15
  ({ children, size, value, onClick, gestureLeftIcon, gestureLeftVariant, onGestureLeft, }: InlineCardProps): JSX.Element;
16
- Media: ({ children }: import("./_InlineCardMedia.component").InlineCardMediaProps) => JSX.Element;
16
+ Media: ({ children, variant }: import("./_InlineCardMedia.component").InlineCardMediaProps) => JSX.Element;
17
17
  Content: ({ children, center }: import("./_InlineCardContent.component").InlineCardContentProps) => JSX.Element;
18
18
  Meta: ({ children }: import("./_InlineCardMeta.component").InlineCardMetaProps) => JSX.Element;
19
19
  };
@@ -1,6 +1,8 @@
1
1
  import React from 'react';
2
+ export type InlineCardMediaVariant = 'rectangle' | 'square';
2
3
  export interface InlineCardMediaProps {
3
4
  children: React.ReactNode;
5
+ variant?: InlineCardMediaVariant;
4
6
  }
5
- declare const InlineCardMedia: ({ children }: InlineCardMediaProps) => JSX.Element;
7
+ declare const InlineCardMedia: ({ children, variant }: InlineCardMediaProps) => JSX.Element;
6
8
  export default InlineCardMedia;
@@ -1,8 +1,17 @@
1
1
  import React from 'react';
2
2
  import styled from 'styled-components';
3
+ const getMediaWidth = (variant) => {
4
+ switch (variant) {
5
+ case 'square':
6
+ return '64px';
7
+ case 'rectangle':
8
+ default:
9
+ return '128px';
10
+ }
11
+ };
3
12
  const MediaContainer = styled.div `
4
- width: 128px;
5
- min-width: 128px;
13
+ width: ${(props) => getMediaWidth(props.variant)};
14
+ min-width: ${(props) => getMediaWidth(props.variant)};
6
15
  height: 64px;
7
16
 
8
17
  img {
@@ -11,7 +20,7 @@ const MediaContainer = styled.div `
11
20
  object-fit: cover;
12
21
  }
13
22
  `;
14
- const InlineCardMedia = ({ children }) => {
15
- return React.createElement(MediaContainer, null, children);
23
+ const InlineCardMedia = ({ children, variant = 'rectangle' }) => {
24
+ return React.createElement(MediaContainer, { variant: variant }, children);
16
25
  };
17
26
  export default InlineCardMedia;
@@ -0,0 +1,7 @@
1
+ /// <reference types="react" />
2
+ export interface ToggleProps {
3
+ value: boolean;
4
+ onChange: (value: boolean) => void;
5
+ }
6
+ declare const Toggle: ({ value, onChange }: ToggleProps) => JSX.Element;
7
+ export default Toggle;
@@ -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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dtdot/lego",
3
- "version": "1.4.3",
3
+ "version": "1.6.0",
4
4
  "description": "Some reusable components for building my applications",
5
5
  "main": "build/index.js",
6
6
  "scripts": {