react-miui 0.7.0 → 0.8.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.
Files changed (146) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/components/layout/list/Header.d.ts +5 -1
  3. package/dist/components/layout/list/Header.d.ts.map +1 -1
  4. package/dist/components/layout/list/Header.js +6 -1
  5. package/dist/components/layout/list/Header.js.map +1 -1
  6. package/dist/components/layout/list/Item.d.ts +3 -0
  7. package/dist/components/layout/list/Item.d.ts.map +1 -1
  8. package/dist/components/layout/list/Item.js +20 -6
  9. package/dist/components/layout/list/Item.js.map +1 -1
  10. package/dist/components/layout/list/Item.module.scss +16 -1
  11. package/dist/components/layout/list/List.d.ts +6 -1
  12. package/dist/components/layout/list/List.d.ts.map +1 -1
  13. package/dist/components/layout/list/List.js +15 -1
  14. package/dist/components/layout/list/List.js.map +1 -1
  15. package/dist/components/layout/list/List.module.scss +4 -0
  16. package/dist/components/ui/button/Button.d.ts.map +1 -1
  17. package/dist/components/ui/button/Button.js +2 -2
  18. package/dist/components/ui/button/Button.js.map +1 -1
  19. package/dist/components/ui/modal/Modal.d.ts +18 -0
  20. package/dist/components/ui/modal/Modal.d.ts.map +1 -0
  21. package/dist/components/ui/modal/Modal.js +108 -0
  22. package/dist/components/ui/modal/Modal.js.map +1 -0
  23. package/dist/components/ui/modal/Modal.module.scss +92 -0
  24. package/dist/components/ui/modal/ModalButton.d.ts +8 -0
  25. package/dist/components/ui/modal/ModalButton.d.ts.map +1 -0
  26. package/dist/components/ui/modal/ModalButton.js +31 -0
  27. package/dist/components/ui/modal/ModalButton.js.map +1 -0
  28. package/dist/components/ui/modal/ModalButtons.d.ts +10 -0
  29. package/dist/components/ui/modal/ModalButtons.d.ts.map +1 -0
  30. package/dist/components/ui/modal/ModalButtons.js +15 -0
  31. package/dist/components/ui/modal/ModalButtons.js.map +1 -0
  32. package/dist/components/ui/modal/ModalButtons.module.scss +32 -0
  33. package/dist/components/ui/modal/ModalNoMargin.d.ts +6 -0
  34. package/dist/components/ui/modal/ModalNoMargin.d.ts.map +1 -0
  35. package/dist/components/ui/modal/ModalNoMargin.js +22 -0
  36. package/dist/components/ui/modal/ModalNoMargin.js.map +1 -0
  37. package/dist/components/ui/toaster/Notification.d.ts +9 -0
  38. package/dist/components/ui/toaster/Notification.d.ts.map +1 -0
  39. package/dist/components/ui/toaster/Notification.js +39 -0
  40. package/dist/components/ui/toaster/Notification.js.map +1 -0
  41. package/dist/components/ui/toaster/Toaster.d.ts +18 -0
  42. package/dist/components/ui/toaster/Toaster.d.ts.map +1 -0
  43. package/dist/components/ui/toaster/Toaster.js +79 -0
  44. package/dist/components/ui/toaster/Toaster.js.map +1 -0
  45. package/dist/components/ui/toaster/Toaster.module.scss +32 -0
  46. package/dist/components/ui/toaster/types.d.ts +7 -0
  47. package/dist/components/ui/toaster/types.d.ts.map +1 -0
  48. package/dist/components/ui/toaster/types.js +3 -0
  49. package/dist/components/ui/toaster/types.js.map +1 -0
  50. package/dist/global.scss +3 -0
  51. package/dist/index.d.ts +3 -0
  52. package/dist/index.d.ts.map +1 -1
  53. package/dist/index.js +3 -0
  54. package/dist/index.js.map +1 -1
  55. package/docs/assets/js/search.js +1 -1
  56. package/docs/assets/js/search.json +1 -1
  57. package/docs/classes/ToasterProvider.html +1090 -0
  58. package/docs/enums/ICON.html +27 -8
  59. package/docs/index.html +29 -4
  60. package/docs/modules/Item.html +16 -3
  61. package/docs/modules/List.html +17 -4
  62. package/docs/modules/Modal.html +160 -0
  63. package/docs/modules/ModalButtons.html +160 -0
  64. package/docs/modules/Section.html +16 -3
  65. package/docs/modules/StickyHeader.html +17 -4
  66. package/docs/modules.html +104 -23
  67. package/docs/pages/Tutorials/Test.html +16 -3
  68. package/esm/components/layout/list/Header.d.ts +5 -1
  69. package/esm/components/layout/list/Header.d.ts.map +1 -1
  70. package/esm/components/layout/list/Header.js +6 -1
  71. package/esm/components/layout/list/Header.js.map +1 -1
  72. package/esm/components/layout/list/Item.d.ts +3 -0
  73. package/esm/components/layout/list/Item.d.ts.map +1 -1
  74. package/esm/components/layout/list/Item.js +20 -6
  75. package/esm/components/layout/list/Item.js.map +1 -1
  76. package/esm/components/layout/list/Item.module.scss +16 -1
  77. package/esm/components/layout/list/List.d.ts +6 -1
  78. package/esm/components/layout/list/List.d.ts.map +1 -1
  79. package/esm/components/layout/list/List.js +15 -1
  80. package/esm/components/layout/list/List.js.map +1 -1
  81. package/esm/components/layout/list/List.module.scss +4 -0
  82. package/esm/components/ui/button/Button.d.ts.map +1 -1
  83. package/esm/components/ui/button/Button.js +2 -2
  84. package/esm/components/ui/button/Button.js.map +1 -1
  85. package/esm/components/ui/modal/Modal.d.ts +18 -0
  86. package/esm/components/ui/modal/Modal.d.ts.map +1 -0
  87. package/esm/components/ui/modal/Modal.js +83 -0
  88. package/esm/components/ui/modal/Modal.js.map +1 -0
  89. package/esm/components/ui/modal/Modal.module.scss +92 -0
  90. package/esm/components/ui/modal/ModalButton.d.ts +8 -0
  91. package/esm/components/ui/modal/ModalButton.d.ts.map +1 -0
  92. package/esm/components/ui/modal/ModalButton.js +13 -0
  93. package/esm/components/ui/modal/ModalButton.js.map +1 -0
  94. package/esm/components/ui/modal/ModalButtons.d.ts +10 -0
  95. package/esm/components/ui/modal/ModalButtons.d.ts.map +1 -0
  96. package/esm/components/ui/modal/ModalButtons.js +9 -0
  97. package/esm/components/ui/modal/ModalButtons.js.map +1 -0
  98. package/esm/components/ui/modal/ModalButtons.module.scss +32 -0
  99. package/esm/components/ui/modal/ModalNoMargin.d.ts +6 -0
  100. package/esm/components/ui/modal/ModalNoMargin.d.ts.map +1 -0
  101. package/esm/components/ui/modal/ModalNoMargin.js +16 -0
  102. package/esm/components/ui/modal/ModalNoMargin.js.map +1 -0
  103. package/esm/components/ui/toaster/Notification.d.ts +9 -0
  104. package/esm/components/ui/toaster/Notification.d.ts.map +1 -0
  105. package/esm/components/ui/toaster/Notification.js +14 -0
  106. package/esm/components/ui/toaster/Notification.js.map +1 -0
  107. package/esm/components/ui/toaster/Toaster.d.ts +18 -0
  108. package/esm/components/ui/toaster/Toaster.d.ts.map +1 -0
  109. package/esm/components/ui/toaster/Toaster.js +74 -0
  110. package/esm/components/ui/toaster/Toaster.js.map +1 -0
  111. package/esm/components/ui/toaster/Toaster.module.scss +32 -0
  112. package/esm/components/ui/toaster/types.d.ts +7 -0
  113. package/esm/components/ui/toaster/types.d.ts.map +1 -0
  114. package/esm/components/ui/toaster/types.js +2 -0
  115. package/esm/components/ui/toaster/types.js.map +1 -0
  116. package/esm/global.scss +3 -0
  117. package/esm/index.d.ts +3 -0
  118. package/esm/index.d.ts.map +1 -1
  119. package/esm/index.js +3 -0
  120. package/esm/index.js.map +1 -1
  121. package/package.json +2 -2
  122. package/src/components/layout/list/Header.tsx +15 -2
  123. package/src/components/layout/list/Item.module.scss +16 -1
  124. package/src/components/layout/list/Item.tsx +28 -7
  125. package/src/components/layout/list/List.module.scss +4 -0
  126. package/src/components/layout/list/List.tsx +29 -2
  127. package/src/components/ui/button/Button.tsx +4 -2
  128. package/src/components/ui/modal/Modal.module.scss +92 -0
  129. package/src/components/ui/modal/Modal.tsx +136 -0
  130. package/src/components/ui/modal/ModalButton.tsx +25 -0
  131. package/src/components/ui/modal/ModalButtons.module.scss +32 -0
  132. package/src/components/ui/modal/ModalButtons.tsx +17 -0
  133. package/src/components/ui/modal/ModalNoMargin.tsx +22 -0
  134. package/src/components/ui/toaster/Notification.tsx +31 -0
  135. package/src/components/ui/toaster/Toaster.module.scss +32 -0
  136. package/src/components/ui/toaster/Toaster.tsx +101 -0
  137. package/src/components/ui/toaster/types.ts +9 -0
  138. package/src/demo/Demo.tsx +7 -4
  139. package/src/demo/Menu.module.scss +1 -0
  140. package/src/demo/components/layout/list/Inset.tsx +24 -0
  141. package/src/demo/components/layout/list/Selection.tsx +17 -0
  142. package/src/demo/components/ui/modal/Modal.tsx +110 -0
  143. package/src/demo/components/ui/toaster/Toaster.tsx +28 -0
  144. package/src/demo/componentsMap.ts +31 -0
  145. package/src/global.scss +3 -0
  146. package/src/index.ts +3 -0
@@ -0,0 +1,74 @@
1
+ import React, { createContext, useContext } from "react";
2
+ import { Notification } from "./Notification";
3
+ const ToasterContext = createContext(() => {
4
+ throw new Error("Toaster Provider missing in the tree");
5
+ });
6
+ const prefix = `${Date.now()}_`;
7
+ let counter = 0;
8
+ const DEFAULT_TIMEOUT = 5000;
9
+ class ToasterProvider extends React.Component {
10
+ constructor(props, context) {
11
+ super(props, context);
12
+ this._add = (text) => {
13
+ this._removeAllToasts();
14
+ const id = prefix + String(counter++);
15
+ const hide = false;
16
+ this.setState(prev => ({
17
+ ...prev,
18
+ list: [...prev.list, {
19
+ id,
20
+ text,
21
+ hide,
22
+ }],
23
+ }));
24
+ setTimeout(() => {
25
+ this.setState(prev => ({
26
+ ...prev,
27
+ list: prev.list.map(p => {
28
+ if (p.id !== id) {
29
+ return p;
30
+ }
31
+ return {
32
+ ...p,
33
+ hide: true,
34
+ };
35
+ }),
36
+ }));
37
+ }, DEFAULT_TIMEOUT);
38
+ };
39
+ this._handleRemove = (id) => {
40
+ this.setState(prev => ({
41
+ ...prev,
42
+ list: prev.list.filter(p => p.id !== id),
43
+ }));
44
+ };
45
+ this._removeAllToasts = () => {
46
+ this.setState(prev => ({
47
+ ...prev,
48
+ list: prev.list.map(p => {
49
+ if (p.hide) {
50
+ return p;
51
+ }
52
+ return {
53
+ ...p,
54
+ hide: true,
55
+ };
56
+ }),
57
+ }));
58
+ };
59
+ this.state = {
60
+ list: [],
61
+ };
62
+ }
63
+ render() {
64
+ const notifications = this.state.list.map((t) => {
65
+ return React.createElement(Notification, { onRemove: this._handleRemove, key: t.id, toast: t });
66
+ });
67
+ return (React.createElement(ToasterContext.Provider, { value: this._add },
68
+ notifications,
69
+ this.props.children));
70
+ }
71
+ }
72
+ const useToaster = () => useContext(ToasterContext);
73
+ export { ToasterProvider, useToaster };
74
+ //# sourceMappingURL=Toaster.js.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CACH,oBAAC,cAAc,CAAC,QAAQ,IAAC,KAAK,EAAE,IAAI,CAAC,IAAI;YACpC,aAAa;YACb,IAAI,CAAC,KAAK,CAAC,QAAQ,CACE,CAC7B,CAAC;IACN,CAAC;CACJ;AAED,MAAM,UAAU,GAAG,GAAG,EAAE,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC;AAEpD,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,CAAC"}
@@ -0,0 +1,32 @@
1
+ @keyframes show {
2
+ from {
3
+ transform: translateY(calc(100% + calc(190px / var(--ratio-dimensions))))
4
+ }
5
+ }
6
+
7
+ .toast {
8
+ position: fixed;
9
+ bottom: 0;
10
+ left: 40px;
11
+ right: 40px;
12
+ display: flex;
13
+ justify-content: center;
14
+ z-index: 1;
15
+
16
+ span {
17
+ background: rgba(56, 50, 46, 0.85);
18
+ color: #F9F6F2;
19
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.37);
20
+ border-radius: 12px; // around 22 @TODO use calc here
21
+ display: inline-block;
22
+ padding: 1em 1em;
23
+ animation: show 500ms 1;
24
+ animation-fill-mode: forwards;
25
+ margin-bottom: calc(190px / var(--ratio-dimensions));
26
+ }
27
+ }
28
+
29
+ .hide {
30
+ transition: opacity 300ms;
31
+ opacity: 0;
32
+ }
@@ -0,0 +1,7 @@
1
+ interface Toast {
2
+ id: string;
3
+ text: string;
4
+ hide: boolean;
5
+ }
6
+ export type { Toast, };
7
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/components/ui/toaster/types.ts"],"names":[],"mappings":"AAAA,UAAU,KAAK;IACX,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,OAAO,CAAC;CACjB;AAED,YAAY,EACR,KAAK,GACR,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/components/ui/toaster/types.ts"],"names":[],"mappings":""}
package/esm/global.scss CHANGED
@@ -28,6 +28,9 @@
28
28
 
29
29
  --toolbar-border: #ababab;
30
30
  --toolbar-bg: #f8f8f8;
31
+ --modal-bg: #f7f7f7;
32
+ --modal-button-bg: #f8f8f8;
33
+ --modal-button-border: #c2c2c2;
31
34
 
32
35
  // Shades: https://maketintsandshades.com/#038bf4,ff7200,7357e8,3ec234,3ec234,ff388f,ea2700
33
36
  --blue1: #038bf4;
package/esm/index.d.ts CHANGED
@@ -16,4 +16,7 @@ export * from "./components/ui/action/Action.js";
16
16
  export * from "./components/ui/action/EqualActions.js";
17
17
  export * from "./components/ui/button/Button.js";
18
18
  export * from "./components/ui/directionPad/Pad.js";
19
+ export * from "./components/ui/modal/Modal.js";
20
+ export * from "./components/ui/modal/ModalButtons.js";
21
+ export * from "./components/ui/toaster/Toaster.js";
19
22
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,+BAA+B,CAAC;AAC9C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,6BAA6B,CAAC;AAE5C,cAAc,4BAA4B,CAAC;AAE3C,cAAc,kCAAkC,CAAC;AACjD,cAAc,sCAAsC,CAAC;AACrD,cAAc,gDAAgD,CAAC;AAC/D,cAAc,4CAA4C,CAAC;AAC3D,cAAc,kCAAkC,CAAC;AACjD,cAAc,kCAAkC,CAAC;AACjD,cAAc,gDAAgD,CAAC;AAC/D,cAAc,wCAAwC,CAAC;AAEvD,cAAc,kCAAkC,CAAC;AACjD,cAAc,wCAAwC,CAAC;AACvD,cAAc,kCAAkC,CAAC;AACjD,cAAc,qCAAqC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,+BAA+B,CAAC;AAC9C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,6BAA6B,CAAC;AAE5C,cAAc,4BAA4B,CAAC;AAE3C,cAAc,kCAAkC,CAAC;AACjD,cAAc,sCAAsC,CAAC;AACrD,cAAc,gDAAgD,CAAC;AAC/D,cAAc,4CAA4C,CAAC;AAC3D,cAAc,kCAAkC,CAAC;AACjD,cAAc,kCAAkC,CAAC;AACjD,cAAc,gDAAgD,CAAC;AAC/D,cAAc,wCAAwC,CAAC;AAEvD,cAAc,kCAAkC,CAAC;AACjD,cAAc,wCAAwC,CAAC;AACvD,cAAc,kCAAkC,CAAC;AACjD,cAAc,qCAAqC,CAAC;AACpD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,uCAAuC,CAAC;AACtD,cAAc,oCAAoC,CAAC"}
package/esm/index.js CHANGED
@@ -16,4 +16,7 @@ export * from "./components/ui/action/Action.js";
16
16
  export * from "./components/ui/action/EqualActions.js";
17
17
  export * from "./components/ui/button/Button.js";
18
18
  export * from "./components/ui/directionPad/Pad.js";
19
+ export * from "./components/ui/modal/Modal.js";
20
+ export * from "./components/ui/modal/ModalButtons.js";
21
+ export * from "./components/ui/toaster/Toaster.js";
19
22
  //# sourceMappingURL=index.js.map
package/esm/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,+BAA+B,CAAC;AAC9C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,6BAA6B,CAAC;AAE5C,cAAc,4BAA4B,CAAC;AAE3C,cAAc,kCAAkC,CAAC;AACjD,cAAc,sCAAsC,CAAC;AACrD,cAAc,gDAAgD,CAAC;AAC/D,cAAc,4CAA4C,CAAC;AAC3D,cAAc,kCAAkC,CAAC;AACjD,cAAc,kCAAkC,CAAC;AACjD,cAAc,gDAAgD,CAAC;AAC/D,cAAc,wCAAwC,CAAC;AAEvD,cAAc,kCAAkC,CAAC;AACjD,cAAc,wCAAwC,CAAC;AACvD,cAAc,kCAAkC,CAAC;AACjD,cAAc,qCAAqC,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,+BAA+B,CAAC;AAC9C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,6BAA6B,CAAC;AAE5C,cAAc,4BAA4B,CAAC;AAE3C,cAAc,kCAAkC,CAAC;AACjD,cAAc,sCAAsC,CAAC;AACrD,cAAc,gDAAgD,CAAC;AAC/D,cAAc,4CAA4C,CAAC;AAC3D,cAAc,kCAAkC,CAAC;AACjD,cAAc,kCAAkC,CAAC;AACjD,cAAc,gDAAgD,CAAC;AAC/D,cAAc,wCAAwC,CAAC;AAEvD,cAAc,kCAAkC,CAAC;AACjD,cAAc,wCAAwC,CAAC;AACvD,cAAc,kCAAkC,CAAC;AACjD,cAAc,qCAAqC,CAAC;AACpD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,uCAAuC,CAAC;AACtD,cAAc,oCAAoC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-miui",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "author": "Jacek Nowacki",
5
5
  "license": "MIT",
6
6
  "scripts": {
@@ -13,7 +13,7 @@
13
13
  "lint": "eslint src --ext .ts,.tsx,.js,.jsx,.mjs",
14
14
  "lint:fix": "yarn lint --fix",
15
15
  "prepack": "yarn compile",
16
- "prepublishOnly": "yarn audit && yarn lint && yarn test && yarn docs",
16
+ "prepublishOnly": "yarn lint && yarn test && yarn docs",
17
17
  "start:dev": "next dev",
18
18
  "deploy:dev": "next build && next export && netlify deploy --dir out"
19
19
  },
@@ -3,11 +3,24 @@ import classnames from "classnames";
3
3
 
4
4
  import styles from "./Item.module.scss";
5
5
  import headerStyles from "./Header.module.scss";
6
+ import { makeVariants } from "../../../utils/makeVariants";
7
+
8
+ type Variant = "inset";
9
+
10
+ interface Props {
11
+ variant?: Variant | Variant[];
12
+ }
13
+
14
+ const Header: React.FC<Props> = (props) => {
15
+ const v = makeVariants(props.variant);
16
+
17
+ const cls = classnames(styles.item, headerStyles.header, {
18
+ [styles.inset]: v.includes("inset"),
19
+ });
6
20
 
7
- const Header: React.FC = (props) => {
8
21
  // @TODO way to use h1, h2, h3 instead of div
9
22
  return (
10
- <li className={classnames(styles.item, headerStyles.header)}>
23
+ <li className={cls}>
11
24
  <div>{props.children}</div>
12
25
  </li>
13
26
  );
@@ -4,7 +4,7 @@
4
4
  padding: 0;
5
5
  font-size: calc(34px / var(--ratio-font));
6
6
 
7
- &:not(:first-child) > * {
7
+ &:not(:first-child) {
8
8
  border-top: 0.37px solid var(--header-border);
9
9
  }
10
10
 
@@ -29,3 +29,18 @@
29
29
  min-height: calc(174px / var(--ratio-dimensions));
30
30
  align-items: center;
31
31
  }
32
+
33
+ .inset {
34
+ padding-left: calc(37px / var(--ratio-dimensions));
35
+ padding-right: calc(37px / var(--ratio-dimensions));
36
+ }
37
+
38
+ .icon {
39
+ width: 7px;
40
+ margin-right: 10px;
41
+ display: inline-block;
42
+ }
43
+
44
+ .selected {
45
+ color: var(--main-color);
46
+ }
@@ -4,11 +4,15 @@ import classnames from "classnames";
4
4
  import styles from "./Item.module.scss";
5
5
  import { Value } from "./Value.js";
6
6
  import { Label } from "./Label.js";
7
+ import { makeVariants } from "../../../utils/makeVariants";
8
+ import { ICON, Icon } from "../../icons/Icon";
7
9
 
8
10
  interface LinkProps {
9
11
  href: string;
10
12
  }
11
13
 
14
+ type Variant = "inset";
15
+
12
16
  interface Props {
13
17
  href?: string;
14
18
  to?: string;
@@ -16,6 +20,8 @@ interface Props {
16
20
  className?: string;
17
21
  Link?: React.ComponentClass<LinkProps> | React.FC<LinkProps>;
18
22
  ratio?: string; // @TODO number/number/number/.. type?
23
+ variant?: Variant | Variant[];
24
+ selected?: boolean | undefined;
19
25
  }
20
26
 
21
27
  interface SubComponents {
@@ -23,11 +29,26 @@ interface SubComponents {
23
29
  Value: typeof Value;
24
30
  }
25
31
 
26
- // eslint-disable-next-line max-statements
32
+ const icon = <Icon className={styles.icon} name={ICON.forward} />;
33
+ const noIcon = <span className={styles.icon} />;
34
+
35
+ // eslint-disable-next-line max-statements,max-lines-per-function
27
36
  const Item: React.FC<Props> & SubComponents = (props) => {
28
- const { className, children, href, to, onClick, Link, ratio, ...restProps } = props;
37
+ const { className, children, href, to, onClick, Link, ratio, variant, selected, ...restProps } = props;
38
+ const v = makeVariants(variant);
29
39
  const cls = classnames(styles.item, className);
30
40
 
41
+ const innerCls = classnames(styles.content, {
42
+ [styles.inset]: v.includes("inset"),
43
+ [styles.selected]: selected,
44
+ });
45
+
46
+ const pre = typeof selected === "boolean"
47
+ ? (
48
+ selected ? icon : noIcon
49
+ )
50
+ : null;
51
+
31
52
  const liProps = {
32
53
  className: cls,
33
54
  };
@@ -42,7 +63,7 @@ const Item: React.FC<Props> & SubComponents = (props) => {
42
63
  if (index in r) {
43
64
  flex = r[index];
44
65
  }
45
- return <div style={{ flex }}>{child}</div>;
66
+ return <div style={{ flex }}>{pre}{child}</div>;
46
67
  });
47
68
 
48
69
  if (to) {
@@ -50,25 +71,25 @@ const Item: React.FC<Props> & SubComponents = (props) => {
50
71
  throw new TypeError("`to` prop given without `Link` component");
51
72
  }
52
73
 
53
- return <li {...liProps}><Link href={to} {...restProps}><a className={styles.content}>{ren}</a></Link></li>;
74
+ return <li {...liProps}><Link href={to} {...restProps}><a className={innerCls}>{ren}</a></Link></li>;
54
75
  }
55
76
  if (href) {
56
77
  const aProps: typeof restProps & { onClick?: Props["onClick"]} = { ...restProps };
57
78
  if (onClick) {
58
79
  aProps.onClick = onClick;
59
80
  }
60
- return <li {...liProps}><a href={href} {...aProps} className={styles.content}>{ren}</a></li>;
81
+ return <li {...liProps}><a href={href} {...aProps} className={innerCls}>{ren}</a></li>;
61
82
  }
62
83
  if (onClick) {
63
84
  return (
64
85
  <li {...liProps}>
65
- <button className={classnames(styles.button, styles.content)} onClick={props.onClick}{...restProps}>
86
+ <button className={classnames(styles.button, innerCls)} onClick={props.onClick} {...restProps}>
66
87
  {ren}
67
88
  </button>
68
89
  </li>
69
90
  );
70
91
  }
71
- return <li {...liProps}><div {...restProps} className={styles.content}>{ren}</div></li>;
92
+ return <li {...liProps}><div {...restProps} className={innerCls}>{ren}</div></li>;
72
93
  };
73
94
 
74
95
  Item.Label = Label;
@@ -2,3 +2,7 @@
2
2
  margin: 0 23px;
3
3
  padding: 0;
4
4
  }
5
+
6
+ .inset {
7
+ margin: 0;
8
+ }
@@ -1,15 +1,42 @@
1
1
  import React from "react";
2
+ import classnames from "classnames";
2
3
 
3
4
  import { Header } from "./Header.js";
5
+ import { makeVariants } from "../../../utils/makeVariants";
6
+ import { Item } from "./Item";
4
7
  import styles from "./List.module.scss";
5
8
 
9
+ type Variant = "inset";
10
+
11
+ interface Props {
12
+ className?: string;
13
+ variant?: Variant | Variant[];
14
+ }
15
+
6
16
  interface SubComponents {
7
17
  Header: typeof Header;
8
18
  }
9
19
 
10
- const List: React.FC & SubComponents = (props) => {
20
+ const List: React.FC<Props> & SubComponents = (props) => {
21
+ const v = makeVariants(props.variant);
22
+
23
+ const chld = React.Children.map(props.children, (child) => {
24
+ if (child && typeof child === "object" && "type" in child && (child.type === Item || child.type === Header)) {
25
+ return React.cloneElement(child, {
26
+ // @TODO this will override but should merge?
27
+ variant: props.variant,
28
+ });
29
+ }
30
+ return child;
31
+ });
32
+
11
33
  return (
12
- <ul className={styles.list}>{props.children}</ul>
34
+ <ul
35
+ className={classnames(styles.list, {
36
+ [styles.inset]: v.includes("inset"),
37
+ })}
38
+ >{chld}
39
+ </ul>
13
40
  );
14
41
  };
15
42
 
@@ -8,8 +8,10 @@ interface Props {
8
8
  variant?: "inline" | "outline";
9
9
  }
10
10
 
11
- const Button: React.FC<React.ButtonHTMLAttributes<HTMLButtonElement> & Props> = ({ className, children, ...props }) => {
12
- const variants = makeVariants(props.variant);
11
+ const Button: React.FC<React.ButtonHTMLAttributes<HTMLButtonElement> & Props> = ({
12
+ className, children, variant, ...props
13
+ }) => {
14
+ const variants = makeVariants(variant);
13
15
 
14
16
  const cls = classnames(styles.btn, {
15
17
  [styles["btn--inline"]]: variants.includes("inline"),
@@ -0,0 +1,92 @@
1
+ @keyframes overlay {
2
+ from {
3
+ background: #00000000;
4
+ }
5
+
6
+ to {
7
+ background: #0000004c;
8
+ }
9
+ }
10
+
11
+ .overlay {
12
+ position: fixed;
13
+ z-index: 4;
14
+ top: 0;
15
+ bottom: 0;
16
+ left: 0;
17
+ right: 0;
18
+ display: flex;
19
+ align-items: center;
20
+ justify-content: center;
21
+ animation: overlay 300ms;
22
+ animation-fill-mode: forwards;
23
+ }
24
+
25
+ .overlayOnBottom {
26
+ align-items: flex-end;
27
+ padding-bottom: calc(24px / var(--ratio-dimensions));
28
+ }
29
+
30
+ @keyframes container {
31
+ from {
32
+ transform: translateY(30px);
33
+ opacity: 0;
34
+ }
35
+
36
+ to {
37
+ transform: translateY(0);
38
+ opacity: 1;
39
+ }
40
+ }
41
+
42
+ .container {
43
+ background: var(--modal-bg);
44
+ border-radius: calc(12px / var(--ratio-dimensions));
45
+ max-width: 333px;
46
+ width: calc(100% - 30px);
47
+ padding: 20px;
48
+ position: relative;
49
+ box-sizing: border-box;
50
+ animation: container 300ms;
51
+ animation-fill-mode: forwards;
52
+ }
53
+
54
+ .full {
55
+ width: calc(100vw - 30px);
56
+ max-width: 1000px;
57
+ }
58
+
59
+ .isClosing {
60
+ // keep this after .overlay .container to prevent overwriting
61
+ animation-direction: reverse;
62
+ }
63
+
64
+ .close {
65
+ position: absolute;
66
+ top: 20px;
67
+ right: 20px;
68
+ background: none;
69
+ border: none;
70
+ padding: 0;
71
+ margin: 0;
72
+
73
+ + .title {
74
+ margin-right: 40px;
75
+ margin-top: -4px;
76
+ }
77
+ }
78
+
79
+ .title {
80
+ font-size: calc(40px / var(--ratio-font));
81
+ text-align: center;
82
+ color: black;
83
+ margin: calc(90px / var(--ratio-dimensions)) 0;
84
+ }
85
+
86
+ .negateMargin {
87
+ margin: 0 -20px -20px;
88
+ }
89
+
90
+ .removeMargin {
91
+ margin: 0;
92
+ }
@@ -0,0 +1,136 @@
1
+ import React, { useCallback, useEffect, useRef, useState } from "react";
2
+ import classnames from "classnames";
3
+
4
+ import styles from "./Modal.module.scss";
5
+ import { makeVariants } from "../../../utils/makeVariants";
6
+ import { ModalNegateMargin } from "./ModalNoMargin";
7
+
8
+ type Variant = "bottom" | "full";
9
+
10
+ interface Props {
11
+ onOverlayClick?: (() => void) | "close" | null;
12
+ closeOnEsc?: boolean;
13
+ onClose: () => void;
14
+ isOpen: boolean;
15
+ title?: React.ReactNode;
16
+ className?: string;
17
+ variant?: Variant | Variant[];
18
+ }
19
+
20
+ interface SubComponents {
21
+ NegateMargin: typeof ModalNegateMargin;
22
+ }
23
+
24
+ // eslint-disable-next-line max-lines-per-function,max-statements
25
+ const Modal: React.FC<Props> & SubComponents = ({
26
+ children,
27
+ onClose,
28
+ isOpen,
29
+ title,
30
+ className,
31
+ onOverlayClick = "close",
32
+ closeOnEsc = true,
33
+ variant,
34
+ }) => {
35
+ const [isClosing, setIsClosing] = useState(false);
36
+ const [isRendered, setIsRendered] = useState(false);
37
+ const overlayRef = useRef<HTMLDivElement>(null);
38
+ const containerRef = useRef<HTMLDivElement>(null);
39
+
40
+ const v = makeVariants(variant);
41
+
42
+ useEffect(() => {
43
+ if (!isOpen || !closeOnEsc) {
44
+ return;
45
+ }
46
+
47
+ const onKeyDown = (e: KeyboardEvent) => {
48
+ if (e.key === "Escape") {
49
+ onClose();
50
+ }
51
+ };
52
+ document.addEventListener("keydown", onKeyDown);
53
+ return () => {
54
+ document.removeEventListener("keydown", onKeyDown);
55
+ };
56
+ }, [isOpen, closeOnEsc]);
57
+
58
+ useEffect(() => {
59
+ if (!isOpen) {
60
+ setIsClosing(true);
61
+ return;
62
+ }
63
+ setIsRendered(true);
64
+ setIsClosing(false);
65
+ }, [isOpen]);
66
+
67
+ useEffect(() => {
68
+ if (!isClosing) {
69
+ return;
70
+ }
71
+
72
+ if (!overlayRef.current || !containerRef.current) {
73
+ return;
74
+ }
75
+
76
+ overlayRef.current.style.animation = "none";
77
+ containerRef.current.style.animation = "none";
78
+ // eslint-disable-next-line @typescript-eslint/no-unused-expressions
79
+ overlayRef.current.offsetHeight; // force sync document reflow
80
+ overlayRef.current.style.removeProperty("animation");
81
+ containerRef.current.style.removeProperty("animation");
82
+ }, [isClosing]);
83
+
84
+ const titleElem = title && <div className={styles.title}>{title}</div>;
85
+
86
+ const handleOverlayClick = useCallback((e: React.MouseEvent) => {
87
+ if (e.target !== e.currentTarget) {
88
+ return;
89
+ }
90
+ if (onOverlayClick === "close") {
91
+ onClose();
92
+ }
93
+ if (typeof onOverlayClick === "function") {
94
+ onOverlayClick();
95
+ }
96
+ }, [onOverlayClick, onClose]);
97
+
98
+ const handleAnimationEnd = useCallback(() => {
99
+ if (isOpen) {
100
+ return;
101
+ }
102
+
103
+ setIsRendered(false);
104
+ }, [isOpen]);
105
+
106
+ if (!isRendered) {
107
+ return null;
108
+ }
109
+
110
+ const overlayCls = classnames(styles.overlay, {
111
+ [styles.isClosing]: isClosing,
112
+ [styles.overlayOnBottom]: v.includes("bottom"),
113
+ });
114
+
115
+ const containerCls = classnames(styles.container, className, {
116
+ [styles.isClosing]: isClosing,
117
+ [styles.full]: v.includes("full"),
118
+ });
119
+
120
+ return (
121
+ <div
122
+ className={overlayCls}
123
+ onClick={handleOverlayClick}
124
+ ref={overlayRef}
125
+ onAnimationEnd={handleAnimationEnd}
126
+ >
127
+ <div className={containerCls} ref={containerRef}>
128
+ {titleElem}
129
+ {children}
130
+ </div>
131
+ </div>
132
+ );
133
+ };
134
+ Modal.NegateMargin = ModalNegateMargin;
135
+
136
+ export { Modal };
@@ -0,0 +1,25 @@
1
+ import React from "react";
2
+
3
+ import styles from "./ModalButtons.module.scss";
4
+ import { makeVariants } from "../../../utils/makeVariants";
5
+ import classnames from "classnames";
6
+
7
+ type Variant = "main";
8
+
9
+ interface Props {
10
+ variant?: Variant | Variant[];
11
+ }
12
+
13
+ const ModalButton: React.FC<React.ButtonHTMLAttributes<HTMLButtonElement> & Props> = ({
14
+ className, children, variant, ...props
15
+ }) => {
16
+ const v = makeVariants(variant);
17
+
18
+ const cls = classnames(styles.button, {
19
+ [styles.buttonMain]: v.includes("main"),
20
+ }, className);
21
+
22
+ return <button {...props} className={cls}>{children}</button>;
23
+ };
24
+
25
+ export { ModalButton };