@lumx/react 2.2.11 → 2.2.12-alpha.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/package.json CHANGED
@@ -7,8 +7,8 @@
7
7
  },
8
8
  "dependencies": {
9
9
  "@juggle/resize-observer": "^3.2.0",
10
- "@lumx/core": "^2.2.11",
11
- "@lumx/icons": "^2.2.11",
10
+ "@lumx/core": "^2.2.12-alpha.1",
11
+ "@lumx/icons": "^2.2.12-alpha.1",
12
12
  "@popperjs/core": "^2.5.4",
13
13
  "body-scroll-lock": "^3.1.5",
14
14
  "classnames": "^2.2.6",
@@ -120,6 +120,6 @@
120
120
  "build:storybook": "cd storybook && ./build"
121
121
  },
122
122
  "sideEffects": false,
123
- "version": "2.2.11",
124
- "gitHead": "a223105b739e72009fde0ade1919b74b13c3e528"
123
+ "version": "2.2.12-alpha.1",
124
+ "gitHead": "85d4c80e91aabae08a93cd09e001768730bd1012"
125
125
  }
@@ -1,10 +1,10 @@
1
- import React from 'react';
1
+ import React, { Fragment } from 'react';
2
2
 
3
3
  import { mdiEmail } from '@lumx/icons';
4
- import { ColorPalette, FlexBox, Icon, IconSizes, Size } from '@lumx/react';
4
+ import { ColorPalette, ColorVariant, FlexBox, Icon, IconSizes, Size } from '@lumx/react';
5
5
  import { Orientation } from '..';
6
6
 
7
- export default { title: 'LumX components/icon/Icon' };
7
+ export default { title: 'LumX components/icon/Icon', parameters: { hasGreyBackground: true } };
8
8
 
9
9
  const iconSizes: Array<IconSizes | undefined> = [
10
10
  undefined,
@@ -16,42 +16,49 @@ const iconSizes: Array<IconSizes | undefined> = [
16
16
  Size.xl,
17
17
  Size.xxl,
18
18
  ];
19
- const iconColors = [undefined, ...Object.values(ColorPalette)];
20
- const iconShapes = [false, true];
21
19
 
22
- export const AllIcon = ({ theme }: any) => {
20
+ const TemplateSizeVariants = ({ hasShape, theme }: any) => (
21
+ <FlexBox orientation={Orientation.horizontal}>
22
+ {iconSizes.map((size) => (
23
+ <FlexBox fillSpace key={`${size}`}>
24
+ <h2>Size: {size || 'undefined'}</h2>
25
+ <Icon icon={mdiEmail} size={size} hasShape={hasShape} theme={theme} />
26
+ </FlexBox>
27
+ ))}
28
+ </FlexBox>
29
+ );
30
+
31
+ export const AllSize = ({ theme }: any) => TemplateSizeVariants({ theme });
32
+
33
+ export const AllSizeWithShape = ({ theme }: any) => TemplateSizeVariants({ theme, hasShape: true });
34
+
35
+ const TemplateColorVariants = ({ hasShape, theme }: any) => {
36
+ const withUndefined = (a: any) => [undefined].concat(Object.values(a));
23
37
  return (
24
- <>
25
- {iconShapes.map((hasShape) => {
26
- return (
27
- <>
28
- <h1>{`With shape: ${hasShape}`}</h1>
29
- {iconSizes.map((size) => {
30
- return (
31
- <>
32
- <h2>{`Size: ${size}`}</h2>
33
- <FlexBox orientation={Orientation.horizontal}>
34
- {iconColors.map((color) => {
35
- return (
36
- <FlexBox fillSpace key={color}>
37
- {`Color: ${color}`}
38
- <Icon
39
- hasShape={hasShape}
40
- icon={mdiEmail}
41
- color={color}
42
- size={size}
43
- theme={theme}
44
- />
45
- </FlexBox>
46
- );
47
- })}
48
- </FlexBox>
49
- </>
50
- );
51
- })}
52
- </>
53
- );
54
- })}
55
- </>
38
+ <FlexBox orientation={Orientation.horizontal}>
39
+ {withUndefined(ColorPalette).map((color) => (
40
+ <FlexBox fillSpace key={`${color}`}>
41
+ <small key={`${color}`}>Color: {color || 'undefined'}</small>
42
+ <br />
43
+ {withUndefined(Object.values(ColorVariant).reverse()).map((colorVariant) => (
44
+ <Fragment key={`${colorVariant}`}>
45
+ <small>Variant: {colorVariant || 'undefined'}</small>
46
+ <Icon
47
+ icon={mdiEmail}
48
+ color={color}
49
+ colorVariant={colorVariant}
50
+ size="m"
51
+ theme={theme}
52
+ hasShape={hasShape}
53
+ />
54
+ </Fragment>
55
+ ))}
56
+ </FlexBox>
57
+ ))}
58
+ </FlexBox>
56
59
  );
57
60
  };
61
+
62
+ export const AllColors = ({ theme }: any) => TemplateColorVariants({ theme });
63
+
64
+ export const AllColorsWithShape = ({ theme }: any) => TemplateColorVariants({ theme, hasShape: true });
@@ -19,8 +19,8 @@ export interface IconProps extends GenericProps {
19
19
  /** Whether the icon has a shape. */
20
20
  hasShape?: boolean;
21
21
  /**
22
- * Icon (SVG path).draw code (`d` property of the `<path>` SVG element).
23
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/SVG/Tutorial/Paths}
22
+ * Icon (SVG path) draw code (`d` property of the `<path>` SVG element).
23
+ * See https://developer.mozilla.org/en-US/docs/Web/SVG/Tutorial/Paths
24
24
  */
25
25
  icon: string;
26
26
  /** Size variant. */
@@ -58,19 +58,30 @@ export const Icon: Comp<IconProps, HTMLElement> = forwardRef((props, ref) => {
58
58
 
59
59
  let iconColor;
60
60
  let iconColorVariant;
61
+ let iconTheme;
61
62
  if (color) {
62
63
  iconColor = color;
63
- iconColorVariant = colorVariant;
64
- } else if (theme) {
65
- iconColor = theme === Theme.light ? ColorPalette.dark : ColorPalette.light;
64
+ iconTheme = theme;
65
+ }
66
66
 
67
- if (colorVariant) {
68
- iconColorVariant = colorVariant;
67
+ if (hasShape) {
68
+ if (theme === Theme.dark && !iconColor) {
69
+ iconColor = ColorPalette.light;
70
+ iconTheme = theme;
69
71
  } else {
70
- iconColorVariant = Theme.light ? 'L1' : 'N';
72
+ iconColor = iconColor || ColorPalette.dark;
73
+ }
74
+ } else if (!iconColor && theme) {
75
+ iconTheme = theme;
76
+ iconColor = iconColor || theme === Theme.light ? ColorPalette.dark : ColorPalette.light;
77
+ }
78
+
79
+ if (!iconColorVariant) {
80
+ if (hasShape && iconColor === ColorPalette.dark) {
81
+ iconColorVariant = colorVariant || 'L2';
82
+ } else {
83
+ iconColorVariant = colorVariant || (theme === Theme.dark ? 'N' : 'L1');
71
84
  }
72
- } else if (hasShape) {
73
- iconColor = ColorPalette.dark;
74
85
  }
75
86
 
76
87
  let iconSize;
@@ -101,6 +112,7 @@ export const Icon: Comp<IconProps, HTMLElement> = forwardRef((props, ref) => {
101
112
  colorVariant: iconColorVariant,
102
113
  hasShape,
103
114
  prefix: CLASSNAME,
115
+ theme: iconTheme,
104
116
  size: iconSize,
105
117
  }),
106
118
  !hasShape && `${CLASSNAME}--no-shape`,
@@ -26,7 +26,7 @@ exports[`<Icon> Snapshots and structure should render color & color variant 1`]
26
26
 
27
27
  exports[`<Icon> Snapshots and structure should render correctly 1`] = `
28
28
  <i
29
- className="lumx-icon lumx-icon--no-shape lumx-icon--path"
29
+ className="lumx-icon lumx-icon--color-variant-L1 lumx-icon--no-shape lumx-icon--path"
30
30
  >
31
31
  <svg
32
32
  aria-hidden="true"
package/types.d.ts CHANGED
@@ -1171,8 +1171,8 @@ export interface IconProps extends GenericProps {
1171
1171
  /** Whether the icon has a shape. */
1172
1172
  hasShape?: boolean;
1173
1173
  /**
1174
- * Icon (SVG path).draw code (`d` property of the `<path>` SVG element).
1175
- * @see {@link https://developer.mozilla.org/en-US/docs/Web/SVG/Tutorial/Paths}
1174
+ * Icon (SVG path) draw code (`d` property of the `<path>` SVG element).
1175
+ * See https://developer.mozilla.org/en-US/docs/Web/SVG/Tutorial/Paths
1176
1176
  */
1177
1177
  icon: string;
1178
1178
  /** Size variant. */