react-miui 0.28.1 → 0.28.2

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.
Files changed (104) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/dist/components/form/input/Input.d.ts +1 -1
  3. package/dist/components/form/input/Input.d.ts.map +1 -1
  4. package/dist/components/form/input/Input.js +3 -2
  5. package/dist/components/form/input/Input.js.map +1 -1
  6. package/dist/components/utils/Spacer.d.ts +83 -4
  7. package/dist/components/utils/Spacer.d.ts.map +1 -1
  8. package/dist/components/utils/Spacer.js +2 -8
  9. package/dist/components/utils/Spacer.js.map +1 -1
  10. package/docs/classes/Drawer.html +14 -14
  11. package/docs/classes/Pop.html +14 -14
  12. package/docs/classes/ToasterProvider.html +10 -10
  13. package/docs/enums/ICON.html +14 -14
  14. package/docs/functions/Action.html +4 -4
  15. package/docs/functions/Button.html +4 -4
  16. package/docs/functions/Card.html +4 -4
  17. package/docs/functions/Checkbox.html +4 -4
  18. package/docs/functions/Choice.html +4 -4
  19. package/docs/functions/ColorPicker.html +4 -4
  20. package/docs/functions/CoveringLoader.html +4 -4
  21. package/docs/functions/DirectionPad.html +4 -4
  22. package/docs/functions/EqualActions.html +4 -4
  23. package/docs/functions/FullLoader.html +4 -4
  24. package/docs/functions/HandleEsc.html +4 -4
  25. package/docs/functions/Header.html +4 -4
  26. package/docs/functions/HeaderIconAction.html +4 -4
  27. package/docs/functions/Icon-1.html +4 -4
  28. package/docs/functions/If.html +4 -4
  29. package/docs/functions/Input.html +8 -10
  30. package/docs/functions/KeyValue.html +4 -4
  31. package/docs/functions/Label.html +4 -4
  32. package/docs/functions/Line.html +4 -4
  33. package/docs/functions/List-1.html +4 -4
  34. package/docs/functions/Loader.html +4 -4
  35. package/docs/functions/Loading.html +4 -4
  36. package/docs/functions/Message.html +4 -4
  37. package/docs/functions/Modal-1.html +4 -4
  38. package/docs/functions/ModalButtons.html +4 -4
  39. package/docs/functions/PopLoader.html +4 -4
  40. package/docs/functions/PopOption.html +4 -4
  41. package/docs/functions/Progress.html +4 -4
  42. package/docs/functions/SearchContainer.html +4 -4
  43. package/docs/functions/Section.html +4 -4
  44. package/docs/functions/Select.html +4 -4
  45. package/docs/functions/Selector.html +5 -5
  46. package/docs/functions/Spacer.html +35 -12
  47. package/docs/functions/Stats.html +4 -4
  48. package/docs/functions/StickyHeader.html +4 -4
  49. package/docs/functions/Table.html +4 -4
  50. package/docs/functions/TextArea.html +4 -4
  51. package/docs/functions/Toggle.html +4 -4
  52. package/docs/functions/ToolButton.html +4 -4
  53. package/docs/functions/borderPxToRem.html +5 -5
  54. package/docs/functions/createTheme.html +4 -4
  55. package/docs/functions/css.html +4 -4
  56. package/docs/functions/dimensionsPxToRem.html +5 -5
  57. package/docs/functions/fontPxToRem.html +5 -5
  58. package/docs/functions/getCssText.html +4 -4
  59. package/docs/functions/globalCss.html +4 -4
  60. package/docs/functions/keyframes.html +4 -4
  61. package/docs/functions/pxToRem.html +5 -5
  62. package/docs/functions/styled.html +4 -4
  63. package/docs/functions/useToaster.html +5 -5
  64. package/docs/index.html +4 -4
  65. package/docs/interfaces/IconProps.html +7 -7
  66. package/docs/interfaces/InputCustomProps.html +11 -11
  67. package/docs/interfaces/LabelProps.html +8 -8
  68. package/docs/interfaces/StickyHeaderProps.html +9 -9
  69. package/docs/interfaces/ToggleProps.html +10 -10
  70. package/docs/modules/List.html +7 -7
  71. package/docs/modules/Modal.html +6 -6
  72. package/docs/modules.html +4 -4
  73. package/docs/pages/tutorials/Test.html +4 -4
  74. package/docs/types/ActionProps.html +5 -5
  75. package/docs/types/ChoiceProps.html +5 -5
  76. package/docs/types/InputProps.html +5 -5
  77. package/docs/types/OverwriteProps.html +5 -5
  78. package/docs/types/ThemeCSS.html +5 -5
  79. package/docs/variables/List.Header.html +5 -5
  80. package/docs/variables/List.Item.html +5 -5
  81. package/docs/variables/Modal.RemovePadding.html +5 -5
  82. package/docs/variables/config.html +5 -5
  83. package/docs/variables/cssReset.html +5 -5
  84. package/docs/variables/miuiScrollbars.html +5 -5
  85. package/docs/variables/theme.html +5 -5
  86. package/esm/components/form/input/Input.d.ts +1 -1
  87. package/esm/components/form/input/Input.d.ts.map +1 -1
  88. package/esm/components/form/input/Input.js +3 -2
  89. package/esm/components/form/input/Input.js.map +1 -1
  90. package/esm/components/form/input/Input.stories.d.ts +2 -1
  91. package/esm/components/form/input/Input.stories.d.ts.map +1 -1
  92. package/esm/components/form/input/Input.stories.js +16 -2
  93. package/esm/components/form/input/Input.stories.js.map +1 -1
  94. package/esm/components/utils/Spacer.d.ts +83 -4
  95. package/esm/components/utils/Spacer.d.ts.map +1 -1
  96. package/esm/components/utils/Spacer.js +2 -5
  97. package/esm/components/utils/Spacer.js.map +1 -1
  98. package/package.json +1 -1
  99. package/src/components/form/input/Input.stories.tsx +22 -2
  100. package/src/components/form/input/Input.tsx +8 -2
  101. package/src/components/utils/Spacer.tsx +2 -8
  102. package/dist/components/utils/Spacer.module.scss +0 -3
  103. package/esm/components/utils/Spacer.module.scss +0 -3
  104. package/src/components/utils/Spacer.module.scss +0 -3
@@ -1 +1 @@
1
- {"version":3,"file":"Input.stories.d.ts","sourceRoot":"","sources":["../../../../src/components/form/input/Input.stories.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAKvD,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,OAAO,KAAK,CAY5B,CAAC;AAEF,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,KAAK,CAAC,CAAC;AAEpC,QAAA,MAAM,OAAO,EAAE,KAMd,CAAC;AAMF,QAAA,MAAM,KAAK,EAAE,KAeZ,CAAC;AAEF,OAAO,EACH,OAAO,EAAE,KAAK,GACjB,CAAC;AAEF,eAAe,IAAI,CAAC"}
1
+ {"version":3,"file":"Input.stories.d.ts","sourceRoot":"","sources":["../../../../src/components/form/input/Input.stories.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAMvD,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,OAAO,KAAK,CAY5B,CAAC;AAEF,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,KAAK,CAAC,CAAC;AAEpC,QAAA,MAAM,OAAO,EAAE,KAMd,CAAC;AAMF,QAAA,MAAM,KAAK,EAAE,KAeZ,CAAC;AAEF,QAAA,MAAM,QAAQ,EAAE,KAiBf,CAAC;AAEF,OAAO,EACH,OAAO,EAAE,KAAK,EAAE,QAAQ,GAC3B,CAAC;AAEF,eAAe,IAAI,CAAC"}
@@ -1,6 +1,7 @@
1
- import React from "react";
1
+ import React, { useCallback } from "react";
2
2
  import { Icon, ICON } from "../../icons/Icon.js";
3
3
  import { countries } from "../../../demo/components/form/countries.const.js";
4
+ import { Button } from "../../ui/button/Button.js";
4
5
  import { Input } from "./Input.js";
5
6
  const meta = {
6
7
  title: "Components/Form/Input",
@@ -34,6 +35,19 @@ const Mixed = {
34
35
  React.createElement(Input, { prefix: "Read only", value: "Norma J. Gomez", readOnly: true }),
35
36
  React.createElement(Input, { placeholder: "With suggestions, try country name", suggestions: countries, onSuggestionMatch: handleSuggestionMatch }))),
36
37
  };
37
- export { Primary, Mixed, };
38
+ const InputRef = {
39
+ render: () => {
40
+ const ref = React.useRef(null);
41
+ const handleRandomValue = useCallback(() => {
42
+ if (ref.current) {
43
+ ref.current.value = (Math.random() * 100).toFixed(2);
44
+ }
45
+ }, []);
46
+ return (React.createElement(React.Fragment, null,
47
+ React.createElement(Input, { ref: ref, placeholder: "Capacity", prefix: React.createElement(Icon, { name: ICON.battery }), suffix: "kWh" }),
48
+ React.createElement(Button, { onClick: handleRandomValue }, "Set random value")));
49
+ },
50
+ };
51
+ export { Primary, Mixed, InputRef, };
38
52
  export default meta;
39
53
  //# sourceMappingURL=Input.stories.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Input.stories.js","sourceRoot":"","sources":["../../../../src/components/form/input/Input.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,+CAA+C,CAAC;AAE1E,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,MAAM,IAAI,GAAuB;IAC7B,KAAK,EAAE,uBAAuB;IAC9B,SAAS,EAAE,KAAK;IAChB,IAAI,EAAE,CAAC,UAAU,EAAE,MAAM,CAAC;IAC1B,QAAQ,EAAE;QACN,KAAK,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;QAC1B,QAAQ,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;QAC7B,QAAQ,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE;QAC7B,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QAC1B,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QAC1B,QAAQ,EAAE,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;KACzC;CACJ,CAAC;AAIF,MAAM,OAAO,GAAU;IACnB,IAAI,EAAE;QACF,WAAW,EAAE,UAAU;QACvB,MAAM,EAAE,oBAAC,IAAI,IAAC,IAAI,EAAE,IAAI,CAAC,OAAO,GAAI;QACpC,MAAM,EAAE,KAAK;KAChB;CACJ,CAAC;AAEF,MAAM,qBAAqB,GAAG,CAAC,CAAS,EAAE,MAAe,EAAE,EAAE;IACzD,KAAK,CAAC,aAAa,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG,KAAK,GAAG,CAAC,CAAC,CAAC;AACvE,CAA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,EAAE,WAAW,EAAE,KAAK,EAAE,gBAAgB,EAAE,QAAQ,EAAE,IAAI,GAAI;QACvE,oBAAC,KAAK,IACF,WAAW,EAAE,oCAAoC,EACjD,WAAW,EAAE,SAAS,EACtB,iBAAiB,EAAE,qBAAqB,GAC1C,CACH,CACN;CACJ,CAAC;AAEF,MAAM,QAAQ,GAAU;IACpB,MAAM,EAAE,GAAG,EAAE;QACT,MAAM,GAAG,GAAG,KAAK,CAAC,MAAM,CAAmB,IAAI,CAAC,CAAC;QAEjD,MAAM,iBAAiB,GAAG,WAAW,CAAC,GAAG,EAAE;YACvC,IAAI,GAAG,CAAC,OAAO,EAAE,CAAC;gBACd,GAAG,CAAC,OAAO,CAAC,KAAK,GAAG,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;YACzD,CAAC;QACL,CAAC,EAAE,EAAE,CAAC,CAAC;QAEP,OAAO,CACH;YACI,oBAAC,KAAK,IAAC,GAAG,EAAE,GAAG,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,EAAE,oBAAC,IAAI,IAAC,IAAI,EAAE,IAAI,CAAC,OAAO,GAAI,EAAE,MAAM,EAAE,KAAK,GAAI;YACjG,oBAAC,MAAM,IAAC,OAAO,EAAE,iBAAiB,uBAA2B,CAC9D,CACN,CAAC;IACN,CAAC;CACJ,CAAC;AAEF,OAAO,EACH,OAAO,EAAE,KAAK,EAAE,QAAQ,GAC3B,CAAC;AAEF,eAAe,IAAI,CAAC"}
@@ -1,6 +1,85 @@
1
- import React from "react";
2
- interface Props {
3
- }
4
- declare const Spacer: React.FC<Props>;
1
+ declare const Spacer: import("@stitches/react/types/styled-component").StyledComponent<"div", {}, {}, import("@stitches/react/types/css-util").CSS<{}, {
2
+ colors: {
3
+ background: "white";
4
+ mainColor: "#008ad2";
5
+ mainColorAlt: "#006AA9";
6
+ activeBg: "#e7e7e7";
7
+ inactiveBg: "#d3d3de";
8
+ inactiveDarkBg: "#999";
9
+ toggleHandleBg: "#e0e0e0";
10
+ toggleHandleBorder: "#cdcdcd";
11
+ toggleBgDisabled: "#f0f0f0";
12
+ toggleHandleBorderDisabled: "#c29f7d";
13
+ toggleHandleBgDisabled: "#deae84";
14
+ icon: "#636363";
15
+ border: "#d5d5d5";
16
+ buttonBorder: "#bababa";
17
+ headerBorder: "#c8c8c9";
18
+ headerBg: "#efeff0";
19
+ headerText: "#484848";
20
+ text: "#323232";
21
+ sub: "#959595";
22
+ popText: "#666";
23
+ toolbarBorder: "#ababab";
24
+ toolbarBg: "#f8f8f8";
25
+ modalBg: "#f7f7f7";
26
+ modalButtonBg: "#f8f8f8";
27
+ modalButtonBorder: "#c2c2c2";
28
+ inputDisabledBg: "#f3f3f3";
29
+ inputDisabledText: "#959595";
30
+ choiceBg: "#ffffff";
31
+ choiceText: "#999999";
32
+ choiceActiveBg: "#f3f3f3";
33
+ choiceActiveText: "#313131";
34
+ choiceBorder: "#cfcfcf";
35
+ selectorText: "#606060";
36
+ selectorActive: "#008ad2";
37
+ blue1: "#038bf4";
38
+ blue2: "#b7d6f5";
39
+ blue3: "#dbe6ff";
40
+ blue4: "#33b4ff";
41
+ blue5: "#30a2e6";
42
+ orange1: "#ff7200";
43
+ orange1Darker: "#cc5b00";
44
+ purple1: "#7357e8";
45
+ green1: "#3ec234";
46
+ green1Darker: "#38af2f";
47
+ pink1: "#ff388f";
48
+ red1: "#ea2700";
49
+ yellow1: "#ffde9d";
50
+ yellow2: "#e4a429";
51
+ yellow3: "#fff5db";
52
+ pinky1: "#f5c0b7";
53
+ pinky2: "#e07b67";
54
+ pinky3: "#ffe1db";
55
+ grey1: "#737373";
56
+ focusColor: "#dcaf00";
57
+ scrollbarsThumb: "#737373";
58
+ scrollbarsBg: "transparent";
59
+ tableStripedBg: "#fafafa";
60
+ toolButtonText: "#666e80";
61
+ };
62
+ }, import("@stitches/react/types/config").DefaultThemeMap, {
63
+ mx: (value: string | number) => {
64
+ marginLeft: string | number;
65
+ marginRight: string | number;
66
+ };
67
+ my: (value: string | number) => {
68
+ marginTop: string | number;
69
+ marginBottom: string | number;
70
+ };
71
+ px: (value: string | number) => {
72
+ paddingLeft: string | number;
73
+ paddingRight: string | number;
74
+ };
75
+ py: (value: string | number) => {
76
+ paddingTop: string | number;
77
+ paddingBottom: string | number;
78
+ };
79
+ size: (value: string | number) => {
80
+ width: string | number;
81
+ height: string | number;
82
+ };
83
+ }>>;
5
84
  export { Spacer };
6
85
  //# sourceMappingURL=Spacer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Spacer.d.ts","sourceRoot":"","sources":["../../../src/components/utils/Spacer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,UAAU,KAAK;CAAG;AAElB,QAAA,MAAM,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAE3B,CAAC;AAEF,OAAO,EAAE,MAAM,EAAE,CAAC"}
1
+ {"version":3,"file":"Spacer.d.ts","sourceRoot":"","sources":["../../../src/components/utils/Spacer.tsx"],"names":[],"mappings":"AAEA,QAAA,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAA6B,CAAC;AAE1C,OAAO,EAAE,MAAM,EAAE,CAAC"}
@@ -1,7 +1,4 @@
1
- import React from "react";
2
- import styles from "./Spacer.module.scss";
3
- const Spacer = (props) => {
4
- return React.createElement("div", { className: styles.spacer });
5
- };
1
+ import { styled } from "../../theme.js";
2
+ const Spacer = styled("div", { flex: 1 });
6
3
  export { Spacer };
7
4
  //# sourceMappingURL=Spacer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Spacer.js","sourceRoot":"","sources":["../../../src/components/utils/Spacer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,MAAM,MAAM,sBAAsB,CAAC;AAI1C,MAAM,MAAM,GAAoB,CAAC,KAAK,EAAE,EAAE;IACtC,OAAO,6BAAK,SAAS,EAAE,MAAM,CAAC,MAAM,GAAI,CAAC;AAC7C,CAAC,CAAC;AAEF,OAAO,EAAE,MAAM,EAAE,CAAC"}
1
+ {"version":3,"file":"Spacer.js","sourceRoot":"","sources":["../../../src/components/utils/Spacer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC;AAE1C,OAAO,EAAE,MAAM,EAAE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-miui",
3
- "version": "0.28.1",
3
+ "version": "0.28.2",
4
4
  "author": "Jacek Nowacki",
5
5
  "license": "MIT",
6
6
  "exports": {
@@ -1,9 +1,10 @@
1
- import React from "react";
1
+ import React, { useCallback } from "react";
2
2
 
3
3
  import type { StoryObj, Meta } from "@storybook/react";
4
4
 
5
5
  import { Icon, ICON } from "../../icons/Icon";
6
6
  import { countries } from "../../../demo/components/form/countries.const";
7
+ import { Button } from "../../ui/button/Button";
7
8
 
8
9
  import { Input } from "./Input";
9
10
 
@@ -52,8 +53,27 @@ const Mixed: Story = {
52
53
  ),
53
54
  };
54
55
 
56
+ const InputRef: Story = {
57
+ render: () => {
58
+ const ref = React.useRef<HTMLInputElement>(null);
59
+
60
+ const handleRandomValue = useCallback(() => {
61
+ if (ref.current) {
62
+ ref.current.value = (Math.random() * 100).toFixed(2);
63
+ }
64
+ }, []);
65
+
66
+ return (
67
+ <>
68
+ <Input ref={ref} placeholder={"Capacity"} prefix={<Icon name={ICON.battery} />} suffix={"kWh"} />
69
+ <Button onClick={handleRandomValue}>Set random value</Button>
70
+ </>
71
+ );
72
+ },
73
+ };
74
+
55
75
  export {
56
- Primary, Mixed,
76
+ Primary, Mixed, InputRef,
57
77
  };
58
78
 
59
79
  export default meta;
@@ -20,7 +20,7 @@ type Props<T extends string> = Omit<React.InputHTMLAttributes<HTMLInputElement>,
20
20
  /**
21
21
  * Input component.
22
22
  */
23
- const Input = <T extends string>({ // eslint-disable-line max-lines-per-function
23
+ const InputInner = <T extends string>({ // eslint-disable-line max-lines-per-function
24
24
  className, children,
25
25
  prefix, suffix,
26
26
  onFocus, onBlur, onKeyDown, onChange,
@@ -28,7 +28,7 @@ const Input = <T extends string>({ // eslint-disable-line max-lines-per-function
28
28
  onSuggestionMatch,
29
29
  error,
30
30
  ...props
31
- }: Props<T>): ReturnType<React.FC<Props<T>>> => {
31
+ }: Props<T>, ref: React.Ref<HTMLInputElement>) => {
32
32
  const [focused, setFocused] = useState(false);
33
33
  const suggestionsId = useId();
34
34
  const [info] = useState<{ picked?: boolean }>({});
@@ -88,6 +88,7 @@ const Input = <T extends string>({ // eslint-disable-line max-lines-per-function
88
88
  >
89
89
  {prefixElem}
90
90
  <StyledInput
91
+ ref={ref}
91
92
  {...props}
92
93
  {...extraProps}
93
94
  onChange={handleChange}
@@ -102,6 +103,11 @@ const Input = <T extends string>({ // eslint-disable-line max-lines-per-function
102
103
  );
103
104
  };
104
105
 
106
+ // Forward ref wrapper for Input
107
+ const Input = React.forwardRef(InputInner) as <T extends string>(
108
+ props: Props<T> & React.RefAttributes<HTMLInputElement>
109
+ ) => JSX.Element;
110
+
105
111
  export {
106
112
  Input,
107
113
  };
@@ -1,11 +1,5 @@
1
- import React from "react";
1
+ import { styled } from "../../theme";
2
2
 
3
- import styles from "./Spacer.module.scss";
4
-
5
- interface Props {}
6
-
7
- const Spacer: React.FC<Props> = (props) => {
8
- return <div className={styles.spacer} />;
9
- };
3
+ const Spacer = styled("div", { flex: 1 });
10
4
 
11
5
  export { Spacer };
@@ -1,3 +0,0 @@
1
- .spacer {
2
- flex: 1;
3
- }
@@ -1,3 +0,0 @@
1
- .spacer {
2
- flex: 1;
3
- }
@@ -1,3 +0,0 @@
1
- .spacer {
2
- flex: 1;
3
- }