react-miui 0.4.3 → 0.6.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 +22 -0
- package/assets/sources/battery.fla +0 -0
- package/assets/sources/search.fla +0 -0
- package/dist/components/form/Input.d.ts +9 -0
- package/dist/components/form/Input.d.ts.map +1 -0
- package/dist/components/form/Input.js +62 -0
- package/dist/components/form/Input.js.map +1 -0
- package/dist/components/form/Input.module.scss +39 -0
- package/dist/components/form/Label.d.ts +8 -0
- package/dist/components/form/Label.d.ts.map +1 -0
- package/dist/components/form/Label.js +22 -0
- package/dist/components/form/Label.js.map +1 -0
- package/dist/components/form/Label.module.scss +15 -0
- package/dist/components/form/Toggle.d.ts +1 -1
- package/dist/components/form/Toggle.d.ts.map +1 -1
- package/dist/components/form/Toggle.js.map +1 -1
- package/dist/components/icons/Back.d.ts +1 -1
- package/dist/components/icons/Back.d.ts.map +1 -1
- package/dist/components/icons/Back.js.map +1 -1
- package/dist/components/icons/Battery.d.ts +7 -0
- package/dist/components/icons/Battery.d.ts.map +1 -0
- package/dist/components/icons/Battery.js +14 -0
- package/dist/components/icons/Battery.js.map +1 -0
- package/dist/components/icons/Forward.d.ts +1 -1
- package/dist/components/icons/Forward.d.ts.map +1 -1
- package/dist/components/icons/Forward.js.map +1 -1
- 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 +6 -0
- package/dist/components/icons/Icon.js.map +1 -1
- package/dist/components/icons/Search.d.ts +7 -0
- package/dist/components/icons/Search.d.ts.map +1 -0
- package/dist/components/icons/Search.js +13 -0
- package/dist/components/icons/Search.js.map +1 -0
- package/dist/components/layout/card/Card.d.ts +8 -0
- package/dist/components/layout/card/Card.d.ts.map +1 -0
- package/dist/components/layout/card/Card.js +19 -0
- package/dist/components/layout/card/Card.js.map +1 -0
- package/dist/components/layout/card/Card.module.scss +15 -0
- package/dist/components/layout/header/HeaderIconAction.d.ts +1 -1
- package/dist/components/layout/header/HeaderIconAction.d.ts.map +1 -1
- package/dist/components/layout/header/HeaderIconAction.js.map +1 -1
- package/dist/components/layout/section/SearchContainer.d.ts +4 -0
- package/dist/components/layout/section/SearchContainer.d.ts.map +1 -0
- package/dist/components/layout/section/SearchContainer.js +13 -0
- package/dist/components/layout/section/SearchContainer.js.map +1 -0
- package/dist/components/layout/section/SearchContainer.module.scss +3 -0
- package/dist/components/layout/section/Section.d.ts +12 -0
- package/dist/components/layout/section/Section.d.ts.map +1 -0
- package/dist/components/layout/section/Section.js +22 -0
- package/dist/components/layout/section/Section.js.map +1 -0
- package/dist/components/layout/section/Section.module.scss +24 -0
- package/dist/components/layout/section/SectionContainer.d.ts +4 -0
- package/dist/components/layout/section/SectionContainer.d.ts.map +1 -0
- package/dist/components/layout/section/SectionContainer.js +13 -0
- package/dist/components/layout/section/SectionContainer.js.map +1 -0
- package/dist/components/layout/section/SectionContainer.module.scss +4 -0
- package/dist/components/ui/action/Action.d.ts +1 -1
- package/dist/components/ui/action/Action.d.ts.map +1 -1
- package/dist/components/ui/action/Action.js.map +1 -1
- package/dist/components/ui/button/Button.d.ts +1 -2
- package/dist/components/ui/button/Button.d.ts.map +1 -1
- package/dist/components/ui/button/Button.js +15 -3
- package/dist/components/ui/button/Button.js.map +1 -1
- package/dist/global.scss +3 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- 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 +49 -6
- package/docs/index.html +22 -4
- package/docs/modules/Item.html +6 -3
- package/docs/modules/List.html +6 -3
- package/docs/modules/Section.html +147 -0
- package/docs/modules/StickyHeader.html +7 -4
- package/docs/modules.html +94 -20
- package/docs/pages/Tutorials/Test.html +6 -3
- package/esm/components/form/Input.d.ts +9 -0
- package/esm/components/form/Input.d.ts.map +1 -0
- package/esm/components/form/Input.js +25 -0
- package/esm/components/form/Input.js.map +1 -0
- package/esm/components/form/Input.module.scss +39 -0
- package/esm/components/form/Label.d.ts +8 -0
- package/esm/components/form/Label.d.ts.map +1 -0
- package/esm/components/form/Label.js +16 -0
- package/esm/components/form/Label.js.map +1 -0
- package/esm/components/form/Label.module.scss +15 -0
- package/esm/components/form/Toggle.d.ts +1 -1
- package/esm/components/form/Toggle.d.ts.map +1 -1
- package/esm/components/form/Toggle.js.map +1 -1
- package/esm/components/icons/Back.d.ts +1 -1
- package/esm/components/icons/Back.d.ts.map +1 -1
- package/esm/components/icons/Back.js.map +1 -1
- package/esm/components/icons/Battery.d.ts +7 -0
- package/esm/components/icons/Battery.d.ts.map +1 -0
- package/esm/components/icons/Battery.js +8 -0
- package/esm/components/icons/Battery.js.map +1 -0
- package/esm/components/icons/Forward.d.ts +1 -1
- package/esm/components/icons/Forward.d.ts.map +1 -1
- package/esm/components/icons/Forward.js.map +1 -1
- 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 +6 -0
- package/esm/components/icons/Icon.js.map +1 -1
- package/esm/components/icons/Search.d.ts +7 -0
- package/esm/components/icons/Search.d.ts.map +1 -0
- package/esm/components/icons/Search.js +7 -0
- package/esm/components/icons/Search.js.map +1 -0
- package/esm/components/layout/card/Card.d.ts +8 -0
- package/esm/components/layout/card/Card.d.ts.map +1 -0
- package/esm/components/layout/card/Card.js +13 -0
- package/esm/components/layout/card/Card.js.map +1 -0
- package/esm/components/layout/card/Card.module.scss +15 -0
- package/esm/components/layout/header/HeaderIconAction.d.ts +1 -1
- package/esm/components/layout/header/HeaderIconAction.d.ts.map +1 -1
- package/esm/components/layout/header/HeaderIconAction.js.map +1 -1
- package/esm/components/layout/section/SearchContainer.d.ts +4 -0
- package/esm/components/layout/section/SearchContainer.d.ts.map +1 -0
- package/esm/components/layout/section/SearchContainer.js +7 -0
- package/esm/components/layout/section/SearchContainer.js.map +1 -0
- package/esm/components/layout/section/SearchContainer.module.scss +3 -0
- package/esm/components/layout/section/Section.d.ts +12 -0
- package/esm/components/layout/section/Section.d.ts.map +1 -0
- package/esm/components/layout/section/Section.js +16 -0
- package/esm/components/layout/section/Section.js.map +1 -0
- package/esm/components/layout/section/Section.module.scss +24 -0
- package/esm/components/layout/section/SectionContainer.d.ts +4 -0
- package/esm/components/layout/section/SectionContainer.d.ts.map +1 -0
- package/esm/components/layout/section/SectionContainer.js +7 -0
- package/esm/components/layout/section/SectionContainer.js.map +1 -0
- package/esm/components/layout/section/SectionContainer.module.scss +4 -0
- package/esm/components/ui/action/Action.d.ts +1 -1
- package/esm/components/ui/action/Action.d.ts.map +1 -1
- package/esm/components/ui/action/Action.js.map +1 -1
- package/esm/components/ui/button/Button.d.ts +1 -2
- package/esm/components/ui/button/Button.d.ts.map +1 -1
- package/esm/components/ui/button/Button.js +3 -3
- package/esm/components/ui/button/Button.js.map +1 -1
- package/esm/global.scss +3 -0
- package/esm/index.d.ts +5 -0
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +5 -0
- package/esm/index.js.map +1 -1
- package/esm/types.d.ts +1 -1
- package/esm/types.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/components/form/Input.module.scss +39 -0
- package/src/components/form/Input.tsx +48 -0
- package/src/components/form/Label.module.scss +15 -0
- package/src/components/form/Label.tsx +29 -0
- package/src/components/form/Toggle.tsx +1 -1
- package/src/components/icons/Back.tsx +1 -1
- package/src/components/icons/Battery.tsx +34 -0
- package/src/components/icons/Forward.tsx +1 -1
- package/src/components/icons/Icon.tsx +6 -0
- package/src/components/icons/Search.tsx +29 -0
- package/src/components/layout/card/Card.module.scss +15 -0
- package/src/components/layout/card/Card.tsx +26 -0
- package/src/components/layout/header/HeaderIconAction.tsx +1 -1
- package/src/components/layout/section/SearchContainer.module.scss +3 -0
- package/src/components/layout/section/SearchContainer.tsx +11 -0
- package/src/components/layout/section/Section.module.scss +24 -0
- package/src/components/layout/section/Section.tsx +34 -0
- package/src/components/layout/section/SectionContainer.module.scss +4 -0
- package/src/components/layout/section/SectionContainer.tsx +11 -0
- package/src/components/ui/action/Action.tsx +1 -1
- package/src/components/ui/button/Button.tsx +8 -4
- package/src/demo/Main.module.scss +2 -0
- package/src/demo/components/form/Form.tsx +31 -0
- package/src/demo/components/form/Input.tsx +13 -0
- package/src/demo/components/form/Label.tsx +14 -0
- package/src/demo/components/form/Search.tsx +36 -0
- package/src/demo/components/form/Toggle.tsx +1 -1
- package/src/demo/components/layout/card/Card.tsx +21 -0
- package/src/demo/components/layout/section/Section.tsx +34 -0
- package/src/demo/components/ui/button/ButtonDemo.tsx +9 -5
- package/src/demo/componentsMap.ts +43 -11
- package/src/global.scss +3 -0
- package/src/index.ts +5 -0
- package/src/types.ts +1 -1
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import React, { useCallback, useState } from "react";
|
|
2
|
+
import classnames from "classnames";
|
|
3
|
+
|
|
4
|
+
import styles from "./Input.module.scss";
|
|
5
|
+
|
|
6
|
+
interface Props {
|
|
7
|
+
children?: never;
|
|
8
|
+
prefix?: React.ReactNode;
|
|
9
|
+
suffix?: React.ReactNode;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const Input: React.FC<Omit<React.InputHTMLAttributes<HTMLInputElement>, "prefix"> & Props> = ({
|
|
13
|
+
className, children,
|
|
14
|
+
prefix, suffix,
|
|
15
|
+
onFocus, onBlur,
|
|
16
|
+
...props
|
|
17
|
+
}) => {
|
|
18
|
+
const [focused, setFocused] = useState(false);
|
|
19
|
+
|
|
20
|
+
const handleFocus = useCallback((e: React.FocusEvent<HTMLInputElement>) => {
|
|
21
|
+
setFocused(true);
|
|
22
|
+
onFocus?.(e);
|
|
23
|
+
}, [onFocus]);
|
|
24
|
+
|
|
25
|
+
const handleBlur = useCallback((e: React.FocusEvent<HTMLInputElement>) => {
|
|
26
|
+
setFocused(false);
|
|
27
|
+
onBlur?.(e);
|
|
28
|
+
}, [onBlur]);
|
|
29
|
+
|
|
30
|
+
const wrapperCls = classnames(styles.wrapper, {
|
|
31
|
+
[styles.wrapperFocused]: focused,
|
|
32
|
+
}, className);
|
|
33
|
+
|
|
34
|
+
const prefixElem = prefix ? <div className={styles.prefix}>{prefix}</div> : null;
|
|
35
|
+
const suffixElem = suffix ? <div className={styles.suffix}>{suffix}</div> : null;
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<div className={wrapperCls}>
|
|
39
|
+
{prefixElem}
|
|
40
|
+
<input {...props} onFocus={handleFocus} onBlur={handleBlur} className={styles.input} />
|
|
41
|
+
{suffixElem}
|
|
42
|
+
</div>
|
|
43
|
+
);
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export {
|
|
47
|
+
Input,
|
|
48
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
.label + .label {
|
|
2
|
+
margin-top: 23px;
|
|
3
|
+
display: block;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.text {
|
|
7
|
+
font-size: calc(28px / var(--ratio-font));
|
|
8
|
+
margin-bottom: calc(24px / var(--ratio-dimensions));
|
|
9
|
+
color: var(--sub);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.textBig {
|
|
13
|
+
font-size: calc(34px / var(--ratio-font));
|
|
14
|
+
|
|
15
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
import styles from "./Label.module.scss";
|
|
4
|
+
import { makeVariants } from "../../utils/makeVariants";
|
|
5
|
+
import classnames from "classnames";
|
|
6
|
+
|
|
7
|
+
interface Props {
|
|
8
|
+
label?: React.ReactNode;
|
|
9
|
+
variant?: "big";
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const Label: React.FC<Props> = (props) => {
|
|
13
|
+
const v = makeVariants(props.variant);
|
|
14
|
+
|
|
15
|
+
const labelCls = classnames(styles.text, {
|
|
16
|
+
[styles.textBig]: v.includes("big"),
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
const label = props.label ? <div className={labelCls}>{props.label}</div> : null;
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<label className={styles.label}>
|
|
23
|
+
{label}
|
|
24
|
+
{props.children}
|
|
25
|
+
</label>
|
|
26
|
+
);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export { Label };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
interface Props {
|
|
4
|
+
className?: string;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
const Battery: React.FC<Props> = (props) => {
|
|
8
|
+
return (
|
|
9
|
+
<svg
|
|
10
|
+
width={"13"}
|
|
11
|
+
height={"17"}
|
|
12
|
+
xmlns={"http://www.w3.org/2000/svg"}
|
|
13
|
+
className={props.className}
|
|
14
|
+
>
|
|
15
|
+
<path
|
|
16
|
+
fill={"none"}
|
|
17
|
+
stroke={"#000"}
|
|
18
|
+
strokeLinecap={"round"}
|
|
19
|
+
strokeLinejoin={"round"}
|
|
20
|
+
d={"M12.5 2.55q0-.6-.5-.55H9.25q-.65 0-.6-.7v-.2Q8.7.5 8.2.5H4.75q-.4 0-.4.4v.4q.05.75-.75.7H1.1q-.6-.05-.6.55V16q0 .5.6.5h11q.4 0 .4-.45V2.55"}
|
|
21
|
+
/>
|
|
22
|
+
<path
|
|
23
|
+
fill={"none"}
|
|
24
|
+
stroke={"#000"}
|
|
25
|
+
strokeLinecap={"round"}
|
|
26
|
+
strokeLinejoin={"round"}
|
|
27
|
+
d={"M8.9 8.6h-2V5.8l-3 4 1.95.05v2.75l3.05-4"}
|
|
28
|
+
/>
|
|
29
|
+
</svg>
|
|
30
|
+
|
|
31
|
+
);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export { Battery };
|
|
@@ -4,11 +4,15 @@ import type { AnyComponent } from "../../types";
|
|
|
4
4
|
import { Checkmark } from "./Checkmark.js";
|
|
5
5
|
import { Back } from "./Back.js";
|
|
6
6
|
import { Forward } from "./Forward.js";
|
|
7
|
+
import { Search } from "./Search.js";
|
|
8
|
+
import { Battery } from "./Battery.js";
|
|
7
9
|
|
|
8
10
|
enum ICON {
|
|
9
11
|
checkmark = "checkmark",
|
|
10
12
|
back = "back",
|
|
11
13
|
forward = "forward",
|
|
14
|
+
search = "search",
|
|
15
|
+
battery = "battery",
|
|
12
16
|
}
|
|
13
17
|
|
|
14
18
|
interface Props {
|
|
@@ -20,6 +24,8 @@ const iconsMap = new Map<ICON, AnyComponent>([
|
|
|
20
24
|
[ICON.checkmark, Checkmark],
|
|
21
25
|
[ICON.back, Back],
|
|
22
26
|
[ICON.forward, Forward],
|
|
27
|
+
[ICON.search, Search],
|
|
28
|
+
[ICON.battery, Battery],
|
|
23
29
|
]);
|
|
24
30
|
|
|
25
31
|
const Icon: React.FC<Props> = ({ name: iconName, ...props }) => {
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
interface Props {
|
|
4
|
+
className?: string;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
const Search: React.FC<Props> = (props) => {
|
|
8
|
+
return (
|
|
9
|
+
<svg
|
|
10
|
+
baseProfile={"basic"}
|
|
11
|
+
width={"16"}
|
|
12
|
+
height={"16"}
|
|
13
|
+
xmlns={"http://www.w3.org/2000/svg"}
|
|
14
|
+
className={props.className}
|
|
15
|
+
>
|
|
16
|
+
<path
|
|
17
|
+
fill={"none"}
|
|
18
|
+
stroke={"currentColor"}
|
|
19
|
+
strokeWidth={"2"}
|
|
20
|
+
strokeLinecap={"round"}
|
|
21
|
+
strokeLinejoin={"round"}
|
|
22
|
+
d={"M11.95 6.6q0 2.1-1.5 3.6m0-7.2q1.5 1.55 1.5 3.6M6.9 1.5q2.05 0 3.55 1.5m-7.2 0q1.5-1.5 3.65-1.5M1.75 6.6q0-2.05 1.5-3.6m0 7.2q-1.5-1.5-1.5-3.6m5.15 5.1q-2.15 0-3.65-1.5m6.95.2q-1.4 1.3-3.3 1.3m3.3-1.3l4.1 4.1m-3.85-4.3q-.1.1-.25.2"}
|
|
23
|
+
/>
|
|
24
|
+
</svg>
|
|
25
|
+
|
|
26
|
+
);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export { Search };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import classnames from "classnames";
|
|
3
|
+
|
|
4
|
+
import { makeVariants } from "../../../utils/makeVariants.js";
|
|
5
|
+
import styles from "./Card.module.scss";
|
|
6
|
+
|
|
7
|
+
type Variants = "margin";
|
|
8
|
+
|
|
9
|
+
interface Props {
|
|
10
|
+
variant?: Variants;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const Card: React.FC<Props> = (props) => {
|
|
14
|
+
const v = makeVariants(props.variant);
|
|
15
|
+
const cls = classnames(styles.card, {
|
|
16
|
+
[styles.margin]: v.includes("margin"),
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
// @TODO auto wrap some children in Section
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<div className={cls}>{props.children}</div>
|
|
23
|
+
);
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export { Card };
|
|
@@ -19,7 +19,7 @@ interface Props {
|
|
|
19
19
|
// if className ever goes here make sure that `a` gets classnames merged
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
const HeaderIconAction: React.
|
|
22
|
+
const HeaderIconAction: React.FC<Props> = (props) => {
|
|
23
23
|
const { icon, label, href, to, Link, ...restProps } = props;
|
|
24
24
|
|
|
25
25
|
let content: ReactNode = icon;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
.section {
|
|
2
|
+
background: var(--background);
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.section + .section {
|
|
6
|
+
margin-top: 23px;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.vertical {
|
|
10
|
+
margin-top: 23px;
|
|
11
|
+
margin-bottom: 23px;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.horizontal {
|
|
15
|
+
margin-left: 23px;
|
|
16
|
+
margin-right: 23px;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.section > .section.vertical {
|
|
20
|
+
padding-top: 23px;
|
|
21
|
+
padding-bottom: 23px;
|
|
22
|
+
margin-top: 0;
|
|
23
|
+
margin-bottom: 0;
|
|
24
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import classnames from "classnames";
|
|
3
|
+
|
|
4
|
+
import { SectionContainer } from "./SectionContainer.js";
|
|
5
|
+
import { makeVariants } from "../../../utils/makeVariants.js";
|
|
6
|
+
import styles from "./Section.module.scss";
|
|
7
|
+
|
|
8
|
+
interface SubComponents {
|
|
9
|
+
Container: typeof SectionContainer;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
type Variant = "horizontal" | "vertical";
|
|
13
|
+
|
|
14
|
+
interface Props {
|
|
15
|
+
variant?: Variant | Variant[];
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const Section: React.FC<Props> & SubComponents = (props) => {
|
|
19
|
+
const v = makeVariants(props.variant);
|
|
20
|
+
|
|
21
|
+
const cls = classnames(styles.section, {
|
|
22
|
+
[styles.vertical]: v.includes("vertical"),
|
|
23
|
+
[styles.horizontal]: v.includes("horizontal"),
|
|
24
|
+
});
|
|
25
|
+
return (
|
|
26
|
+
<section className={cls}>
|
|
27
|
+
{props.children}
|
|
28
|
+
</section>
|
|
29
|
+
);
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
Section.Container = SectionContainer;
|
|
33
|
+
|
|
34
|
+
export { Section };
|
|
@@ -19,7 +19,7 @@ interface Props {
|
|
|
19
19
|
// if className ever goes here make sure that `a` gets classnames merged
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
const Action: React.
|
|
22
|
+
const Action: React.FC<Props> = (props) => {
|
|
23
23
|
const { icon, label, href, to, Link, ...restProps } = props;
|
|
24
24
|
|
|
25
25
|
let iconElem: ReactNode = icon;
|
|
@@ -5,20 +5,24 @@ import styles from "./Button.module.scss";
|
|
|
5
5
|
import { makeVariants } from "../../../utils/makeVariants.js";
|
|
6
6
|
|
|
7
7
|
interface Props {
|
|
8
|
-
disabled?: boolean;
|
|
9
8
|
variant?: "inline" | "outline";
|
|
10
9
|
}
|
|
11
10
|
|
|
12
|
-
const Button: React.FC<Props> = (props) => {
|
|
11
|
+
const Button: React.FC<React.ButtonHTMLAttributes<HTMLButtonElement> & Props> = ({ className, children, ...props }) => {
|
|
13
12
|
const variants = makeVariants(props.variant);
|
|
14
13
|
|
|
15
14
|
const cls = classnames(styles.btn, {
|
|
16
15
|
[styles["btn--inline"]]: variants.includes("inline"),
|
|
17
16
|
[styles["btn--outline"]]: variants.includes("outline"),
|
|
18
|
-
});
|
|
17
|
+
}, className);
|
|
19
18
|
|
|
20
19
|
return (
|
|
21
|
-
<button
|
|
20
|
+
<button
|
|
21
|
+
{...props}
|
|
22
|
+
className={cls}
|
|
23
|
+
disabled={props.disabled}
|
|
24
|
+
>{children}
|
|
25
|
+
</button>
|
|
22
26
|
);
|
|
23
27
|
};
|
|
24
28
|
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Section } from "../../../components/layout/section/Section";
|
|
3
|
+
import { SectionContainer } from "../../../components/layout/section/SectionContainer";
|
|
4
|
+
import { Input } from "../../../components/form/Input";
|
|
5
|
+
import { Label } from "../../../components/form/Label";
|
|
6
|
+
import { Button } from "../../../components/ui/button/Button";
|
|
7
|
+
|
|
8
|
+
// @TODO add checkbox
|
|
9
|
+
// @TODO add toggle
|
|
10
|
+
// @TODO some kind of `form` wrapper which also takes cares of margins?
|
|
11
|
+
const FormDemo = () => {
|
|
12
|
+
return (
|
|
13
|
+
<SectionContainer>
|
|
14
|
+
<Section>
|
|
15
|
+
<Section variant={["vertical", "horizontal"]}>
|
|
16
|
+
<Label label={"First name"}>
|
|
17
|
+
<Input placeholder={""} />
|
|
18
|
+
</Label>
|
|
19
|
+
<Label label={"E-mail"}>
|
|
20
|
+
<Input placeholder={"Don't forget the @"} suffix={".com"} />
|
|
21
|
+
</Label>
|
|
22
|
+
<Label>
|
|
23
|
+
<Button>Submit</Button>
|
|
24
|
+
</Label>
|
|
25
|
+
</Section>
|
|
26
|
+
</Section>
|
|
27
|
+
</SectionContainer>
|
|
28
|
+
);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export { FormDemo };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Input } from "../../../components/form/Input";
|
|
3
|
+
import { ICON, Icon } from "../../../components/icons/Icon";
|
|
4
|
+
|
|
5
|
+
const InputDemo: React.FC = () => {
|
|
6
|
+
return (
|
|
7
|
+
<>
|
|
8
|
+
<Input placeholder={"Capacity"} prefix={<Icon name={ICON.battery} />} suffix={"kWh"} />
|
|
9
|
+
</>
|
|
10
|
+
);
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export { InputDemo };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Label } from "../../../components/form/Label";
|
|
3
|
+
import { Input } from "../../../components/form/Input";
|
|
4
|
+
import { ICON, Icon } from "../../../components/icons/Icon";
|
|
5
|
+
|
|
6
|
+
const LabelDemo = () => {
|
|
7
|
+
return (
|
|
8
|
+
<Label label={"Capacity"}>
|
|
9
|
+
<Input placeholder={"ie: 500"} prefix={<Icon name={ICON.battery} />} suffix={"kWh"} />
|
|
10
|
+
</Label>
|
|
11
|
+
);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export { LabelDemo };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { SearchContainer } from "../../../components/layout/section/SearchContainer";
|
|
3
|
+
import { Input } from "../../../components/form/Input";
|
|
4
|
+
import { ICON, Icon } from "../../../components/icons/Icon";
|
|
5
|
+
import { Section } from "../../../components/layout/section/Section";
|
|
6
|
+
import { SectionContainer } from "../../../components/layout/section/SectionContainer";
|
|
7
|
+
import { List } from "../../../components/layout/list/List";
|
|
8
|
+
import { Item } from "../../../components/layout/list/Item";
|
|
9
|
+
|
|
10
|
+
const SearchDemo = () => {
|
|
11
|
+
return (
|
|
12
|
+
<SectionContainer>
|
|
13
|
+
<SearchContainer>
|
|
14
|
+
<Input placeholder={"Search..."} prefix={<Icon name={ICON.search} />} />
|
|
15
|
+
</SearchContainer>
|
|
16
|
+
<Section>
|
|
17
|
+
<List>
|
|
18
|
+
<List.Header>Messages</List.Header>
|
|
19
|
+
<Item>Lorem</Item>
|
|
20
|
+
<Item>Ipsum</Item>
|
|
21
|
+
<Item>Dolor</Item>
|
|
22
|
+
</List>
|
|
23
|
+
</Section>
|
|
24
|
+
<Section>
|
|
25
|
+
<List>
|
|
26
|
+
<List.Header>Contacts</List.Header>
|
|
27
|
+
<Item>Lorem</Item>
|
|
28
|
+
<Item>Ipsum</Item>
|
|
29
|
+
<Item>Dolor</Item>
|
|
30
|
+
</List>
|
|
31
|
+
</Section>
|
|
32
|
+
</SectionContainer>
|
|
33
|
+
);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export { SearchDemo };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Card } from "../../../../components/layout/card/Card";
|
|
3
|
+
import { Section } from "../../../../components/layout/section/Section";
|
|
4
|
+
|
|
5
|
+
const CardDemo = () => {
|
|
6
|
+
return (
|
|
7
|
+
<Section.Container>
|
|
8
|
+
<Card>
|
|
9
|
+
<Section variant={["vertical", "horizontal"]}>Content</Section>
|
|
10
|
+
</Card>
|
|
11
|
+
<Card>
|
|
12
|
+
<Section variant={["vertical", "horizontal"]}>Content</Section>
|
|
13
|
+
</Card>
|
|
14
|
+
<Card variant={"margin"}>
|
|
15
|
+
<Section variant={["vertical", "horizontal"]}>Content</Section>
|
|
16
|
+
</Card>
|
|
17
|
+
</Section.Container>
|
|
18
|
+
);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export { CardDemo };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Section } from "../../../../components/layout/section/Section.js";
|
|
3
|
+
import { List } from "../../../../components/layout/list/List";
|
|
4
|
+
import { Item } from "../../../../components/layout/list/Item";
|
|
5
|
+
|
|
6
|
+
const SectionDemo = () => {
|
|
7
|
+
return (
|
|
8
|
+
<Section.Container>
|
|
9
|
+
<Section>
|
|
10
|
+
<List>
|
|
11
|
+
<List.Header>Section name</List.Header>
|
|
12
|
+
<Item>Item</Item>
|
|
13
|
+
<Item>Item</Item>
|
|
14
|
+
</List>
|
|
15
|
+
</Section>
|
|
16
|
+
<Section>
|
|
17
|
+
<List>
|
|
18
|
+
<List.Header>Section name</List.Header>
|
|
19
|
+
<Item>Item</Item>
|
|
20
|
+
<Item>Item</Item>
|
|
21
|
+
</List>
|
|
22
|
+
</Section>
|
|
23
|
+
<Section>
|
|
24
|
+
<List>
|
|
25
|
+
<List.Header>Section name</List.Header>
|
|
26
|
+
<Item>Item</Item>
|
|
27
|
+
<Item>Item</Item>
|
|
28
|
+
</List>
|
|
29
|
+
</Section>
|
|
30
|
+
</Section.Container>
|
|
31
|
+
);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export { SectionDemo };
|
|
@@ -1,16 +1,20 @@
|
|
|
1
|
-
import React from "react";
|
|
1
|
+
import React, { useCallback } from "react";
|
|
2
2
|
import { Button } from "../../../../index.js";
|
|
3
3
|
|
|
4
4
|
const ButtonDemo = () => {
|
|
5
|
+
const handleClick = useCallback(() => {
|
|
6
|
+
alert("Clicked");
|
|
7
|
+
}, []);
|
|
8
|
+
|
|
5
9
|
return (
|
|
6
10
|
<div>
|
|
7
|
-
<Button>Basic button</Button>
|
|
11
|
+
<Button onClick={handleClick}>Basic button</Button>
|
|
8
12
|
<br />
|
|
9
|
-
<Button disabled={true}>Disabled button</Button>
|
|
13
|
+
<Button disabled={true} onClick={handleClick}>Disabled button</Button>
|
|
10
14
|
<br />
|
|
11
|
-
<Button variant={"inline"}>Inline button</Button>
|
|
15
|
+
<Button variant={"inline"} onClick={handleClick}>Inline button</Button>
|
|
12
16
|
<br />
|
|
13
|
-
<Button variant={"outline"}>Outline button</Button>
|
|
17
|
+
<Button variant={"outline"} onClick={handleClick}>Outline button</Button>
|
|
14
18
|
</div>
|
|
15
19
|
);
|
|
16
20
|
};
|