react-miui 0.1.0 → 0.2.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 (112) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/assets/back.svg +1 -0
  3. package/dist/components/icons/Back.d.ts +7 -0
  4. package/dist/components/icons/Back.d.ts.map +1 -0
  5. package/dist/components/icons/Back.js +13 -0
  6. package/dist/components/icons/Back.js.map +1 -0
  7. package/dist/components/icons/Icon.d.ts +3 -1
  8. package/dist/components/icons/Icon.d.ts.map +1 -1
  9. package/dist/components/icons/Icon.js +4 -3
  10. package/dist/components/icons/Icon.js.map +1 -1
  11. package/dist/components/layout/header/Header.d.ts +3 -0
  12. package/dist/components/layout/header/Header.d.ts.map +1 -1
  13. package/dist/components/layout/header/Header.js +13 -2
  14. package/dist/components/layout/header/Header.js.map +1 -1
  15. package/dist/components/layout/header/Header.module.scss +47 -3
  16. package/dist/components/layout/header/HeaderIconAction.d.ts +17 -0
  17. package/dist/components/layout/header/HeaderIconAction.d.ts.map +1 -0
  18. package/dist/components/layout/header/HeaderIconAction.js +40 -0
  19. package/dist/components/layout/header/HeaderIconAction.js.map +1 -0
  20. package/dist/components/layout/header/HeaderIconAction.module.scss +22 -0
  21. package/dist/components/ui/action/EqualActions.d.ts +4 -1
  22. package/dist/components/ui/action/EqualActions.d.ts.map +1 -1
  23. package/dist/components/ui/action/EqualActions.js +3 -2
  24. package/dist/components/ui/action/EqualActions.js.map +1 -1
  25. package/dist/demo/Menu.module.scss +2 -0
  26. package/dist/demo/components/layout/header/Header.d.ts +4 -1
  27. package/dist/demo/components/layout/header/Header.d.ts.map +1 -1
  28. package/dist/demo/components/layout/header/Header.js +40 -1
  29. package/dist/demo/components/layout/header/Header.js.map +1 -1
  30. package/dist/demo/components/ui/action/Action.js +2 -2
  31. package/dist/demo/components/ui/action/Action.js.map +1 -1
  32. package/dist/demo/components/ui/icons/Icons.d.ts.map +1 -1
  33. package/dist/demo/components/ui/icons/Icons.js +6 -6
  34. package/dist/demo/components/ui/icons/Icons.js.map +1 -1
  35. package/dist/demo/components/ui/icons/Icons.module.scss +4 -0
  36. package/dist/demo/componentsMap.d.ts.map +1 -1
  37. package/dist/demo/componentsMap.js +39 -23
  38. package/dist/demo/componentsMap.js.map +1 -1
  39. package/dist/global.scss +10 -1
  40. package/dist/pages/react-miui.d.ts +4 -0
  41. package/dist/pages/react-miui.d.ts.map +1 -0
  42. package/dist/pages/react-miui.js +11 -0
  43. package/dist/pages/react-miui.js.map +1 -0
  44. package/dist/types.d.ts +1 -1
  45. package/dist/types.d.ts.map +1 -1
  46. package/docs/assets/js/search.js +1 -1
  47. package/docs/assets/js/search.json +1 -1
  48. package/docs/enums/ICON.html +18 -4
  49. package/docs/index.html +4 -4
  50. package/docs/modules/StickyHeader.html +4 -4
  51. package/docs/modules.html +12 -12
  52. package/docs/pages/Tutorials/Test.html +3 -3
  53. package/esm/components/icons/Back.d.ts +7 -0
  54. package/esm/components/icons/Back.d.ts.map +1 -0
  55. package/esm/components/icons/Back.js +7 -0
  56. package/esm/components/icons/Back.js.map +1 -0
  57. package/esm/components/icons/Icon.d.ts +3 -1
  58. package/esm/components/icons/Icon.d.ts.map +1 -1
  59. package/esm/components/icons/Icon.js +4 -3
  60. package/esm/components/icons/Icon.js.map +1 -1
  61. package/esm/components/layout/header/Header.d.ts +3 -0
  62. package/esm/components/layout/header/Header.d.ts.map +1 -1
  63. package/esm/components/layout/header/Header.js +13 -2
  64. package/esm/components/layout/header/Header.js.map +1 -1
  65. package/esm/components/layout/header/Header.module.scss +47 -3
  66. package/esm/components/layout/header/HeaderIconAction.d.ts +17 -0
  67. package/esm/components/layout/header/HeaderIconAction.d.ts.map +1 -0
  68. package/esm/components/layout/header/HeaderIconAction.js +23 -0
  69. package/esm/components/layout/header/HeaderIconAction.js.map +1 -0
  70. package/esm/components/layout/header/HeaderIconAction.module.scss +22 -0
  71. package/esm/components/ui/action/EqualActions.d.ts +4 -1
  72. package/esm/components/ui/action/EqualActions.d.ts.map +1 -1
  73. package/esm/components/ui/action/EqualActions.js +3 -2
  74. package/esm/components/ui/action/EqualActions.js.map +1 -1
  75. package/esm/demo/Menu.module.scss +2 -0
  76. package/esm/demo/components/layout/header/Header.d.ts +4 -1
  77. package/esm/demo/components/layout/header/Header.d.ts.map +1 -1
  78. package/esm/demo/components/layout/header/Header.js +38 -2
  79. package/esm/demo/components/layout/header/Header.js.map +1 -1
  80. package/esm/demo/components/ui/action/Action.js +2 -2
  81. package/esm/demo/components/ui/action/Action.js.map +1 -1
  82. package/esm/demo/components/ui/icons/Icons.d.ts.map +1 -1
  83. package/esm/demo/components/ui/icons/Icons.js +7 -7
  84. package/esm/demo/components/ui/icons/Icons.js.map +1 -1
  85. package/esm/demo/components/ui/icons/Icons.module.scss +4 -0
  86. package/esm/demo/componentsMap.d.ts.map +1 -1
  87. package/esm/demo/componentsMap.js +40 -24
  88. package/esm/demo/componentsMap.js.map +1 -1
  89. package/esm/global.scss +10 -1
  90. package/esm/pages/react-miui.d.ts +4 -0
  91. package/esm/pages/react-miui.d.ts.map +1 -0
  92. package/esm/pages/react-miui.js +6 -0
  93. package/esm/pages/react-miui.js.map +1 -0
  94. package/esm/types.d.ts +1 -1
  95. package/esm/types.d.ts.map +1 -1
  96. package/package.json +1 -1
  97. package/src/components/icons/Back.tsx +15 -0
  98. package/src/components/icons/Icon.tsx +5 -3
  99. package/src/components/layout/header/Header.module.scss +47 -3
  100. package/src/components/layout/header/Header.tsx +25 -3
  101. package/src/components/layout/header/HeaderIconAction.module.scss +22 -0
  102. package/src/components/layout/header/HeaderIconAction.tsx +49 -0
  103. package/src/components/ui/action/EqualActions.tsx +8 -3
  104. package/src/demo/Menu.module.scss +2 -0
  105. package/src/demo/components/layout/header/Header.tsx +96 -2
  106. package/src/demo/components/ui/action/Action.tsx +4 -4
  107. package/src/demo/components/ui/icons/Icons.module.scss +4 -0
  108. package/src/demo/components/ui/icons/Icons.tsx +12 -11
  109. package/src/demo/componentsMap.ts +45 -24
  110. package/src/global.scss +10 -1
  111. package/src/pages/react-miui.tsx +12 -0
  112. package/src/types.ts +1 -1
@@ -0,0 +1,49 @@
1
+ import React from "react";
2
+ import type { ReactNode } from "react";
3
+
4
+ import type { ICON } from "../../icons/Icon";
5
+ import { Icon } from "../../icons/Icon";
6
+ import styles from "./HeaderIconAction.module.scss";
7
+
8
+ interface LinkProps { // @TODO extract? - same on list item
9
+ href: string;
10
+ }
11
+
12
+ interface Props {
13
+ icon?: ICON | Exclude<ReactNode, string>;
14
+ onClick?: () => void;
15
+ href?: string;
16
+ to?: string;
17
+ Link?: React.ComponentClass<LinkProps> | React.FC<LinkProps>;
18
+ label?: ReactNode;
19
+ // if className ever goes here make sure that `a` gets classnames merged
20
+ }
21
+
22
+ const HeaderIconAction: React.VFC<Props> = (props) => {
23
+ const { icon, label, href, to, Link, ...restProps } = props;
24
+
25
+ let content: ReactNode = icon;
26
+ if (typeof icon === "string") {
27
+ content = <Icon className={styles.icon} name={icon as ICON} />;
28
+ }
29
+
30
+ if (to) {
31
+ if (!Link) {
32
+ throw new TypeError("`to` prop given without `Link` component");
33
+ }
34
+
35
+ return <Link href={to} {...restProps}><a className={styles.a}>{content}</a></Link>;
36
+ }
37
+
38
+ if (href) {
39
+ return <a href={href} className={styles.a} {...restProps}>{content}</a>;
40
+ }
41
+
42
+ return (
43
+ <button className={styles.btn} onClick={props.onClick}>
44
+ {content}
45
+ </button>
46
+ );
47
+ };
48
+
49
+ export { HeaderIconAction };
@@ -2,11 +2,16 @@ import React from "react";
2
2
  import { Action } from "./Action";
3
3
 
4
4
  import styles from "./EqualActions.module.scss";
5
+ import classnames from "classnames";
5
6
 
6
- const EqualActions: React.FC = (props) => {
7
+ interface Props {
8
+ className?: string;
9
+ }
10
+
11
+ const EqualActions: React.FC<Props> = (props) => {
7
12
  React.Children.forEach(props.children, (child) => {
8
13
  if (!child || typeof child !== "object" || !("type" in child) || child.type !== Action) {
9
- throw new TypeError("Every child of Actions must be an Action component");
14
+ throw new TypeError("Every child of EqualActions must be an Action component");
10
15
  }
11
16
  });
12
17
 
@@ -16,7 +21,7 @@ const EqualActions: React.FC = (props) => {
16
21
  } as React.CSSProperties;
17
22
 
18
23
  return (
19
- <div className={styles.actions} style={style}>
24
+ <div className={classnames(styles.actions, props.className)} style={style}>
20
25
  {props.children}
21
26
  </div>
22
27
  );
@@ -35,5 +35,7 @@
35
35
  &:hover {
36
36
  background: var(--active-bg);
37
37
  }
38
+
39
+ --focus-bg-set: var(--focus-color);
38
40
  }
39
41
  }
@@ -1,6 +1,8 @@
1
1
  import React from "react";
2
+ import Link from "next/link";
2
3
 
3
- import { Header } from "../../../../index.js";
4
+ import { Header, ICON, StickyHeader } from "../../../../index.js";
5
+ import { HeaderIconAction } from "../../../../components/layout/header/HeaderIconAction";
4
6
 
5
7
  const HeaderDemo = () => {
6
8
  // eslint-disable-next-line @typescript-eslint/no-magic-numbers,react/no-array-index-key
@@ -14,4 +16,96 @@ const HeaderDemo = () => {
14
16
  );
15
17
  };
16
18
 
17
- export { HeaderDemo };
19
+ const CenteredHeaderDemo = () => {
20
+ return (
21
+ <>
22
+ <Header center={true}>Messages</Header>
23
+ <div>
24
+ Header text is centered
25
+ </div>
26
+ </>
27
+ );
28
+ };
29
+
30
+ const handleClick = () => { alert(1); };
31
+
32
+ // eslint-disable-next-line max-lines-per-function
33
+ const HeaderWithButtonsDemo = () => {
34
+ const demo = (
35
+ <>
36
+ <HeaderIconAction icon={ICON.back} onClick={handleClick} />
37
+ <HeaderIconAction icon={ICON.checkmark} onClick={handleClick} />
38
+ </>
39
+ );
40
+
41
+ return (
42
+ <>
43
+ <Header center={true} before={"A text"}>Messages</Header>
44
+ <div>
45
+ Header text is centered
46
+ </div>
47
+ <Header before={"A text"}>Messages</Header>
48
+ <div>
49
+ Header text is start aligned
50
+ </div>
51
+ <Header before={demo}>Messages</Header>
52
+ <div>
53
+ Some button icons are added on the left to left aligned title
54
+ </div>
55
+ <Header before={demo} center={true}>Messages</Header>
56
+ <div>
57
+ Some button icons are added on the left to centered aligned title
58
+ </div>
59
+ <Header
60
+ before={<HeaderIconAction icon={ICON.back} to={"/react-miui"} Link={Link} />}
61
+ center={true}
62
+ >Messages
63
+ </Header>
64
+ <div>
65
+ Some internal link icons are added on the left to centered aligned title
66
+ </div>
67
+ <Header
68
+ before={<HeaderIconAction icon={ICON.back} href={"https://www.npmjs.com/package/react-miui"} />}
69
+ center={true}
70
+ >Messages
71
+ </Header>
72
+ <div>
73
+ Some external link icons are added on the left to centered aligned title
74
+ </div>
75
+ <Header
76
+ before={<HeaderIconAction icon={ICON.back} href={"https://www.npmjs.com/package/react-miui"} />}
77
+ after={<HeaderIconAction icon={ICON.checkmark} href={"https://www.npmjs.com/package/react-miui"} />}
78
+ center={true}
79
+ >Messages
80
+ </Header>
81
+ <div>
82
+ Some external link icons are added on both sides to centered aligned title
83
+ </div>
84
+ </>
85
+ );
86
+ };
87
+
88
+ const HeaderWithButtonsOnSideDemo = () => {
89
+ const demo = (
90
+ <>
91
+ <HeaderIconAction icon={ICON.back} onClick={handleClick} />
92
+ <HeaderIconAction icon={ICON.checkmark} onClick={handleClick} />
93
+ </>
94
+ );
95
+
96
+ return (
97
+ <StickyHeader position={"left"}>
98
+ <Header
99
+ center={true}
100
+ before={demo}
101
+ after={demo}
102
+ >M
103
+ </Header>
104
+ <StickyHeader.Content>
105
+ Header is on the side
106
+ </StickyHeader.Content>
107
+ </StickyHeader>
108
+ );
109
+ };
110
+
111
+ export { HeaderDemo, CenteredHeaderDemo, HeaderWithButtonsDemo, HeaderWithButtonsOnSideDemo };
@@ -26,7 +26,7 @@ const ActionDemo: React.FC = () => {
26
26
  <Action icon={ICON.checkmark} onClick={handleClick} /> - onClick action
27
27
  </div>
28
28
  <div>
29
- <Action icon={ICON.checkmark} onClick={handleClick} label={"Pineapple"} /> - onClick action
29
+ <Action icon={ICON.checkmark} onClick={handleClick} label={"Pineapple"} /> - onClick action with label
30
30
  </div>
31
31
  </>
32
32
  );
@@ -94,9 +94,9 @@ const ActionLabelsOnBottom = () => {
94
94
  const ActionsDemo = () => {
95
95
  return (
96
96
  <div>
97
- To make every action take the same amount of horizontal space you need to wrap every Action with Actions
98
- wrapper. Some components (like Header) will do that automatically for you. If you need to use Actions
99
- outside of such components - manually wrap them with Actions.
97
+ To make every action take the same amount of horizontal space you need to wrap every Action with
98
+ EqualActions wrapper. Some components (like Header) will do that automatically for you. If you need to use
99
+ Actions outside of such components - manually wrap them with EqualActions.
100
100
 
101
101
  <div>
102
102
  <EqualActions>
@@ -0,0 +1,4 @@
1
+ .row {
2
+ display: flex;
3
+ justify-content: space-between;
4
+ }
@@ -1,23 +1,24 @@
1
1
  import React from "react";
2
- import { Icon, ICON } from "../../../../index.js";
2
+ import { Icon, ICON, Item, List } from "../../../../index.js";
3
+
4
+ import styles from "./Icons.module.scss";
3
5
 
4
6
  const IconsDemo: React.FC = () => {
5
7
  const icons = Object.values(ICON).map((value) => {
6
8
  return (
7
- <li key={value}>
8
- <Icon name={value} />
9
- {value}
10
- </li>
9
+ <Item key={value}>
10
+ <div className={styles.row}>
11
+ {value}
12
+ <Icon name={value} />
13
+ </div>
14
+ </Item>
11
15
  );
12
16
  });
13
17
 
14
18
  return (
15
- <div>
16
- Icons:
17
- <ul>
18
- {icons}
19
- </ul>
20
- </div>
19
+ <List>
20
+ {icons}
21
+ </List>
21
22
  );
22
23
  };
23
24
 
@@ -1,6 +1,11 @@
1
1
  import type { AnyComponent } from "../types";
2
2
  import { CheckboxDemo } from "./components/form/Checkbox";
3
- import { HeaderDemo } from "./components/layout/header/Header";
3
+ import {
4
+ CenteredHeaderDemo,
5
+ HeaderDemo,
6
+ HeaderWithButtonsDemo,
7
+ HeaderWithButtonsOnSideDemo,
8
+ } from "./components/layout/header/Header";
4
9
  import {
5
10
  StickyHeaderBottomDemo,
6
11
  StickyHeaderDemo, StickyHeaderLeftCenterDemo, StickyHeaderLeftDemo, StickyHeaderRightDemo,
@@ -42,29 +47,45 @@ const componentsMap: TheMap = {
42
47
  name: "Header",
43
48
  Component: HeaderDemo,
44
49
  children: {
45
- Sticky: {
46
- name: "Sticky header",
47
- Component: StickyHeaderDemo,
48
- },
49
- StickyBottom: {
50
- name: "On bottom",
51
- Component: StickyHeaderBottomDemo,
50
+ Centered: {
51
+ name: "Centered",
52
+ Component: CenteredHeaderDemo,
52
53
  },
53
- StickyTopBottom: {
54
- name: "On top & bottom",
55
- Component: StickyHeaderTopBottomDemo,
54
+ WithButtons: {
55
+ name: "With buttons",
56
+ Component: HeaderWithButtonsDemo,
57
+ children: {
58
+ OnLeft: {
59
+ name: "On the side",
60
+ Component: HeaderWithButtonsOnSideDemo,
61
+ },
62
+ },
56
63
  },
57
- StickyLeft: {
58
- name: "On left",
59
- Component: StickyHeaderLeftDemo,
60
- },
61
- StickyRight: {
62
- name: "On right",
63
- Component: StickyHeaderRightDemo,
64
- },
65
- StickyLeftCentered: {
66
- name: "On left centered",
67
- Component: StickyHeaderLeftCenterDemo,
64
+ Sticky: {
65
+ name: "Sticky",
66
+ Component: StickyHeaderDemo,
67
+ children: {
68
+ StickyBottom: {
69
+ name: "On bottom",
70
+ Component: StickyHeaderBottomDemo,
71
+ },
72
+ StickyTopBottom: {
73
+ name: "On top & bottom",
74
+ Component: StickyHeaderTopBottomDemo,
75
+ },
76
+ StickyLeft: {
77
+ name: "On left",
78
+ Component: StickyHeaderLeftDemo,
79
+ },
80
+ StickyRight: {
81
+ name: "On right",
82
+ Component: StickyHeaderRightDemo,
83
+ },
84
+ StickyLeftCentered: {
85
+ name: "On left centered",
86
+ Component: StickyHeaderLeftCenterDemo,
87
+ },
88
+ },
68
89
  },
69
90
  },
70
91
  },
@@ -84,8 +105,8 @@ const componentsMap: TheMap = {
84
105
  name: "Actions on left header",
85
106
  Component: ActionsOnLeft,
86
107
  },
87
- Actions: {
88
- name: "Actions (wrapper)",
108
+ EqualActions: {
109
+ name: "EqualActions (wrapper)",
89
110
  Component: ActionsDemo,
90
111
  },
91
112
  },
package/src/global.scss CHANGED
@@ -31,12 +31,21 @@
31
31
  --red1: #ea2700;
32
32
 
33
33
  --grey1: #737373;
34
+
35
+ --focus-color: #dcaf00;
34
36
  }
35
37
 
36
- *:focus { // @TODO take care of focus
38
+ *:focus {
37
39
  outline: none!important;
38
40
  }
39
41
 
42
+ *:focus-visible:focus-visible {
43
+ outline: none!important;
44
+ border-color: var(--focus-color);
45
+ background-color: var(--focus-bg-set);
46
+ }
47
+
48
+
40
49
  body {
41
50
  font-size: 15px;
42
51
  }
@@ -0,0 +1,12 @@
1
+ import React from "react";
2
+
3
+ const ReactMiuiPage = () => {
4
+ // @TODO nicer UI, add back button etc
5
+ return (
6
+ <div>
7
+ Hi. This is an example page to demonstrate application level routing.
8
+ </div>
9
+ );
10
+ };
11
+
12
+ export default ReactMiuiPage;
package/src/types.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type React from "react";
2
2
 
3
- type AnyComponent = React.ComponentClass | React.FC;
3
+ type AnyComponent = React.ComponentClass | React.FC | React.VFC;
4
4
 
5
5
  export type {
6
6
  AnyComponent,