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.
- package/CHANGELOG.md +11 -0
- package/assets/back.svg +1 -0
- package/dist/components/icons/Back.d.ts +7 -0
- package/dist/components/icons/Back.d.ts.map +1 -0
- package/dist/components/icons/Back.js +13 -0
- package/dist/components/icons/Back.js.map +1 -0
- package/dist/components/icons/Icon.d.ts +3 -1
- package/dist/components/icons/Icon.d.ts.map +1 -1
- package/dist/components/icons/Icon.js +4 -3
- package/dist/components/icons/Icon.js.map +1 -1
- package/dist/components/layout/header/Header.d.ts +3 -0
- package/dist/components/layout/header/Header.d.ts.map +1 -1
- package/dist/components/layout/header/Header.js +13 -2
- package/dist/components/layout/header/Header.js.map +1 -1
- package/dist/components/layout/header/Header.module.scss +47 -3
- package/dist/components/layout/header/HeaderIconAction.d.ts +17 -0
- package/dist/components/layout/header/HeaderIconAction.d.ts.map +1 -0
- package/dist/components/layout/header/HeaderIconAction.js +40 -0
- package/dist/components/layout/header/HeaderIconAction.js.map +1 -0
- package/dist/components/layout/header/HeaderIconAction.module.scss +22 -0
- package/dist/components/ui/action/EqualActions.d.ts +4 -1
- package/dist/components/ui/action/EqualActions.d.ts.map +1 -1
- package/dist/components/ui/action/EqualActions.js +3 -2
- package/dist/components/ui/action/EqualActions.js.map +1 -1
- package/dist/demo/Menu.module.scss +2 -0
- package/dist/demo/components/layout/header/Header.d.ts +4 -1
- package/dist/demo/components/layout/header/Header.d.ts.map +1 -1
- package/dist/demo/components/layout/header/Header.js +40 -1
- package/dist/demo/components/layout/header/Header.js.map +1 -1
- package/dist/demo/components/ui/action/Action.js +2 -2
- package/dist/demo/components/ui/action/Action.js.map +1 -1
- package/dist/demo/components/ui/icons/Icons.d.ts.map +1 -1
- package/dist/demo/components/ui/icons/Icons.js +6 -6
- package/dist/demo/components/ui/icons/Icons.js.map +1 -1
- package/dist/demo/components/ui/icons/Icons.module.scss +4 -0
- package/dist/demo/componentsMap.d.ts.map +1 -1
- package/dist/demo/componentsMap.js +39 -23
- package/dist/demo/componentsMap.js.map +1 -1
- package/dist/global.scss +10 -1
- package/dist/pages/react-miui.d.ts +4 -0
- package/dist/pages/react-miui.d.ts.map +1 -0
- package/dist/pages/react-miui.js +11 -0
- package/dist/pages/react-miui.js.map +1 -0
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/docs/assets/js/search.js +1 -1
- package/docs/assets/js/search.json +1 -1
- package/docs/enums/ICON.html +18 -4
- package/docs/index.html +4 -4
- package/docs/modules/StickyHeader.html +4 -4
- package/docs/modules.html +12 -12
- package/docs/pages/Tutorials/Test.html +3 -3
- package/esm/components/icons/Back.d.ts +7 -0
- package/esm/components/icons/Back.d.ts.map +1 -0
- package/esm/components/icons/Back.js +7 -0
- package/esm/components/icons/Back.js.map +1 -0
- package/esm/components/icons/Icon.d.ts +3 -1
- package/esm/components/icons/Icon.d.ts.map +1 -1
- package/esm/components/icons/Icon.js +4 -3
- package/esm/components/icons/Icon.js.map +1 -1
- package/esm/components/layout/header/Header.d.ts +3 -0
- package/esm/components/layout/header/Header.d.ts.map +1 -1
- package/esm/components/layout/header/Header.js +13 -2
- package/esm/components/layout/header/Header.js.map +1 -1
- package/esm/components/layout/header/Header.module.scss +47 -3
- package/esm/components/layout/header/HeaderIconAction.d.ts +17 -0
- package/esm/components/layout/header/HeaderIconAction.d.ts.map +1 -0
- package/esm/components/layout/header/HeaderIconAction.js +23 -0
- package/esm/components/layout/header/HeaderIconAction.js.map +1 -0
- package/esm/components/layout/header/HeaderIconAction.module.scss +22 -0
- package/esm/components/ui/action/EqualActions.d.ts +4 -1
- package/esm/components/ui/action/EqualActions.d.ts.map +1 -1
- package/esm/components/ui/action/EqualActions.js +3 -2
- package/esm/components/ui/action/EqualActions.js.map +1 -1
- package/esm/demo/Menu.module.scss +2 -0
- package/esm/demo/components/layout/header/Header.d.ts +4 -1
- package/esm/demo/components/layout/header/Header.d.ts.map +1 -1
- package/esm/demo/components/layout/header/Header.js +38 -2
- package/esm/demo/components/layout/header/Header.js.map +1 -1
- package/esm/demo/components/ui/action/Action.js +2 -2
- package/esm/demo/components/ui/action/Action.js.map +1 -1
- package/esm/demo/components/ui/icons/Icons.d.ts.map +1 -1
- package/esm/demo/components/ui/icons/Icons.js +7 -7
- package/esm/demo/components/ui/icons/Icons.js.map +1 -1
- package/esm/demo/components/ui/icons/Icons.module.scss +4 -0
- package/esm/demo/componentsMap.d.ts.map +1 -1
- package/esm/demo/componentsMap.js +40 -24
- package/esm/demo/componentsMap.js.map +1 -1
- package/esm/global.scss +10 -1
- package/esm/pages/react-miui.d.ts +4 -0
- package/esm/pages/react-miui.d.ts.map +1 -0
- package/esm/pages/react-miui.js +6 -0
- package/esm/pages/react-miui.js.map +1 -0
- package/esm/types.d.ts +1 -1
- package/esm/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/icons/Back.tsx +15 -0
- package/src/components/icons/Icon.tsx +5 -3
- package/src/components/layout/header/Header.module.scss +47 -3
- package/src/components/layout/header/Header.tsx +25 -3
- package/src/components/layout/header/HeaderIconAction.module.scss +22 -0
- package/src/components/layout/header/HeaderIconAction.tsx +49 -0
- package/src/components/ui/action/EqualActions.tsx +8 -3
- package/src/demo/Menu.module.scss +2 -0
- package/src/demo/components/layout/header/Header.tsx +96 -2
- package/src/demo/components/ui/action/Action.tsx +4 -4
- package/src/demo/components/ui/icons/Icons.module.scss +4 -0
- package/src/demo/components/ui/icons/Icons.tsx +12 -11
- package/src/demo/componentsMap.ts +45 -24
- package/src/global.scss +10 -1
- package/src/pages/react-miui.tsx +12 -0
- 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
|
-
|
|
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
|
|
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
|
);
|
|
@@ -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
|
-
|
|
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
|
|
98
|
-
wrapper. Some components (like Header) will do that automatically for you. If you need to use
|
|
99
|
-
outside of such components - manually wrap them with
|
|
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>
|
|
@@ -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
|
-
<
|
|
8
|
-
<
|
|
9
|
-
|
|
10
|
-
|
|
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
|
-
<
|
|
16
|
-
|
|
17
|
-
|
|
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 {
|
|
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
|
-
|
|
46
|
-
name: "
|
|
47
|
-
Component:
|
|
48
|
-
},
|
|
49
|
-
StickyBottom: {
|
|
50
|
-
name: "On bottom",
|
|
51
|
-
Component: StickyHeaderBottomDemo,
|
|
50
|
+
Centered: {
|
|
51
|
+
name: "Centered",
|
|
52
|
+
Component: CenteredHeaderDemo,
|
|
52
53
|
},
|
|
53
|
-
|
|
54
|
-
name: "
|
|
55
|
-
Component:
|
|
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
|
-
|
|
58
|
-
name: "
|
|
59
|
-
Component:
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
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
|
-
|
|
88
|
-
name: "
|
|
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 {
|
|
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
|
}
|