react-miui 0.1.0 → 0.4.1
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 +33 -0
- package/assets/back.svg +1 -0
- package/assets/forward.svg +1 -0
- package/assets/sources/back.fla +0 -0
- package/dist/components/form/Toggle.d.ts +8 -0
- package/dist/components/form/Toggle.d.ts.map +1 -0
- package/dist/{demo/components/form/Checkbox.js → components/form/Toggle.js} +17 -8
- package/dist/components/form/Toggle.js.map +1 -0
- package/dist/components/form/Toggle.module.scss +46 -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/Forward.d.ts +7 -0
- package/dist/components/icons/Forward.d.ts.map +1 -0
- package/dist/components/icons/Forward.js +13 -0
- package/dist/components/icons/Forward.js.map +1 -0
- package/dist/components/icons/Icon.d.ts +4 -1
- package/dist/components/icons/Icon.d.ts.map +1 -1
- package/dist/components/icons/Icon.js +7 -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/layout/list/Header.d.ts +4 -0
- package/dist/components/layout/list/Header.d.ts.map +1 -0
- package/dist/components/layout/list/Header.js +16 -0
- package/dist/components/layout/list/Header.js.map +1 -0
- package/dist/components/layout/list/Header.module.scss +8 -0
- package/dist/components/layout/list/Item.d.ts +8 -1
- package/dist/components/layout/list/Item.d.ts.map +1 -1
- package/dist/components/layout/list/Item.js +21 -5
- package/dist/components/layout/list/Item.js.map +1 -1
- package/dist/components/layout/list/Item.module.scss +10 -2
- package/dist/components/layout/list/Label.d.ts +8 -0
- package/dist/components/layout/list/Label.d.ts.map +1 -0
- package/dist/components/layout/list/Label.js +16 -0
- package/dist/components/layout/list/Label.js.map +1 -0
- package/dist/components/layout/list/Label.module.scss +9 -0
- package/dist/components/layout/list/List.d.ts +5 -1
- package/dist/components/layout/list/List.d.ts.map +1 -1
- package/dist/components/layout/list/List.js +2 -0
- package/dist/components/layout/list/List.js.map +1 -1
- package/dist/components/layout/list/Value.d.ts +4 -0
- package/dist/components/layout/list/Value.d.ts.map +1 -0
- package/dist/components/layout/list/Value.js +13 -0
- package/dist/components/layout/list/Value.js.map +1 -0
- package/dist/components/layout/list/Value.module.scss +7 -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/global.scss +18 -2
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -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 +44 -4
- package/docs/index.html +22 -4
- package/docs/modules/Item.html +155 -0
- package/docs/modules/List.html +144 -0
- package/docs/modules/StickyHeader.html +10 -4
- package/docs/modules.html +78 -14
- package/docs/pages/Tutorials/Test.html +9 -3
- package/esm/components/form/Toggle.d.ts +8 -0
- package/esm/components/form/Toggle.d.ts.map +1 -0
- package/esm/components/form/Toggle.js +15 -0
- package/esm/components/form/Toggle.js.map +1 -0
- package/esm/components/form/Toggle.module.scss +46 -0
- 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/Forward.d.ts +7 -0
- package/esm/components/icons/Forward.d.ts.map +1 -0
- package/esm/components/icons/Forward.js +7 -0
- package/esm/components/icons/Forward.js.map +1 -0
- package/esm/components/icons/Icon.d.ts +4 -1
- package/esm/components/icons/Icon.d.ts.map +1 -1
- package/esm/components/icons/Icon.js +7 -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/layout/list/Header.d.ts +4 -0
- package/esm/components/layout/list/Header.d.ts.map +1 -0
- package/esm/components/layout/list/Header.js +10 -0
- package/esm/components/layout/list/Header.js.map +1 -0
- package/esm/components/layout/list/Header.module.scss +8 -0
- package/esm/components/layout/list/Item.d.ts +8 -1
- package/esm/components/layout/list/Item.d.ts.map +1 -1
- package/esm/components/layout/list/Item.js +21 -5
- package/esm/components/layout/list/Item.js.map +1 -1
- package/esm/components/layout/list/Item.module.scss +10 -2
- package/esm/components/layout/list/Label.d.ts +8 -0
- package/esm/components/layout/list/Label.d.ts.map +1 -0
- package/esm/components/layout/list/Label.js +10 -0
- package/esm/components/layout/list/Label.js.map +1 -0
- package/esm/components/layout/list/Label.module.scss +9 -0
- package/esm/components/layout/list/List.d.ts +5 -1
- package/esm/components/layout/list/List.d.ts.map +1 -1
- package/esm/components/layout/list/List.js +2 -0
- package/esm/components/layout/list/List.js.map +1 -1
- package/esm/components/layout/list/Value.d.ts +4 -0
- package/esm/components/layout/list/Value.d.ts.map +1 -0
- package/esm/components/layout/list/Value.js +7 -0
- package/esm/components/layout/list/Value.js.map +1 -0
- package/esm/components/layout/list/Value.module.scss +7 -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/global.scss +18 -2
- package/esm/index.d.ts +4 -0
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +4 -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 +1 -1
- package/src/components/form/Toggle.module.scss +46 -0
- package/src/components/form/Toggle.tsx +33 -0
- package/src/components/icons/Back.tsx +21 -0
- package/src/components/icons/Forward.tsx +21 -0
- package/src/components/icons/Icon.tsx +10 -5
- 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/layout/list/Header.module.scss +8 -0
- package/src/components/layout/list/Header.tsx +16 -0
- package/src/components/layout/list/Item.module.scss +10 -2
- package/src/components/layout/list/Item.tsx +33 -6
- package/src/components/layout/list/Label.module.scss +9 -0
- package/src/components/layout/list/Label.tsx +21 -0
- package/src/components/layout/list/List.tsx +8 -1
- package/src/components/layout/list/Value.module.scss +7 -0
- package/src/components/layout/list/Value.tsx +11 -0
- package/src/components/ui/action/EqualActions.tsx +8 -3
- package/src/demo/Menu.module.scss +2 -0
- package/src/demo/components/form/Toggle.tsx +49 -0
- package/src/demo/components/layout/header/Header.tsx +104 -2
- package/src/demo/components/layout/list/Header.tsx +24 -0
- package/src/demo/components/layout/list/ItemRatio.tsx +21 -0
- package/src/demo/components/layout/list/Label.tsx +31 -0
- package/src/demo/components/layout/list/List.Item.module.scss +4 -0
- package/src/demo/components/layout/list/Value.module.scss +4 -0
- package/src/demo/components/layout/list/Value.tsx +26 -0
- package/src/demo/components/ui/action/Action.tsx +4 -4
- package/src/demo/components/ui/icons/Icons.tsx +7 -10
- package/src/demo/componentsMap.ts +75 -23
- package/src/global.scss +18 -2
- package/src/index.ts +4 -0
- package/src/pages/react-miui.tsx +12 -0
- package/src/types.ts +1 -1
- package/dist/demo/Demo.d.ts +0 -4
- package/dist/demo/Demo.d.ts.map +0 -1
- package/dist/demo/Demo.js +0 -18
- package/dist/demo/Demo.js.map +0 -1
- package/dist/demo/Demo.module.scss +0 -4
- package/dist/demo/Main.d.ts +0 -4
- package/dist/demo/Main.d.ts.map +0 -1
- package/dist/demo/Main.js +0 -83
- package/dist/demo/Main.js.map +0 -1
- package/dist/demo/Main.module.scss +0 -30
- package/dist/demo/Menu.d.ts +0 -9
- package/dist/demo/Menu.d.ts.map +0 -1
- package/dist/demo/Menu.js +0 -31
- package/dist/demo/Menu.js.map +0 -1
- package/dist/demo/Menu.module.scss +0 -39
- package/dist/demo/components/form/Checkbox.d.ts +0 -4
- package/dist/demo/components/form/Checkbox.d.ts.map +0 -1
- package/dist/demo/components/form/Checkbox.js.map +0 -1
- package/dist/demo/components/layout/header/Header.d.ts +0 -4
- package/dist/demo/components/layout/header/Header.d.ts.map +0 -1
- package/dist/demo/components/layout/header/Header.js +0 -16
- package/dist/demo/components/layout/header/Header.js.map +0 -1
- package/dist/demo/components/layout/header/StickyHeader.d.ts +0 -9
- package/dist/demo/components/layout/header/StickyHeader.d.ts.map +0 -1
- package/dist/demo/components/layout/header/StickyHeader.js +0 -73
- package/dist/demo/components/layout/header/StickyHeader.js.map +0 -1
- package/dist/demo/components/layout/list/List.Item.d.ts +0 -4
- package/dist/demo/components/layout/list/List.Item.d.ts.map +0 -1
- package/dist/demo/components/layout/list/List.Item.js +0 -42
- package/dist/demo/components/layout/list/List.Item.js.map +0 -1
- package/dist/demo/components/layout/list/List.Item.module.scss +0 -3
- package/dist/demo/components/ui/action/Action.d.ts +0 -8
- package/dist/demo/components/ui/action/Action.d.ts.map +0 -1
- package/dist/demo/components/ui/action/Action.js +0 -83
- package/dist/demo/components/ui/action/Action.js.map +0 -1
- package/dist/demo/components/ui/action/ActionDemo.module.scss +0 -3
- package/dist/demo/components/ui/button/ButtonDemo.d.ts +0 -4
- package/dist/demo/components/ui/button/ButtonDemo.d.ts.map +0 -1
- package/dist/demo/components/ui/button/ButtonDemo.js +0 -20
- package/dist/demo/components/ui/button/ButtonDemo.js.map +0 -1
- package/dist/demo/components/ui/directionPad/Pad.d.ts +0 -4
- package/dist/demo/components/ui/directionPad/Pad.d.ts.map +0 -1
- package/dist/demo/components/ui/directionPad/Pad.js +0 -49
- package/dist/demo/components/ui/directionPad/Pad.js.map +0 -1
- package/dist/demo/components/ui/icons/Icons.d.ts +0 -4
- package/dist/demo/components/ui/icons/Icons.d.ts.map +0 -1
- package/dist/demo/components/ui/icons/Icons.js +0 -20
- package/dist/demo/components/ui/icons/Icons.js.map +0 -1
- package/dist/demo/componentsMap.d.ts +0 -13
- package/dist/demo/componentsMap.d.ts.map +0 -1
- package/dist/demo/componentsMap.js +0 -87
- package/dist/demo/componentsMap.js.map +0 -1
- package/dist/demo/utils/makeVariants.d.ts +0 -3
- package/dist/demo/utils/makeVariants.d.ts.map +0 -1
- package/dist/demo/utils/makeVariants.js +0 -14
- package/dist/demo/utils/makeVariants.js.map +0 -1
- package/dist/demo/utils/safeUseHash.d.ts +0 -3
- package/dist/demo/utils/safeUseHash.d.ts.map +0 -1
- package/dist/demo/utils/safeUseHash.js +0 -13
- package/dist/demo/utils/safeUseHash.js.map +0 -1
- package/dist/demo-global.scss +0 -9
- package/dist/pages/_app.d.ts +0 -7
- package/dist/pages/_app.d.ts.map +0 -1
- package/dist/pages/_app.js +0 -15
- package/dist/pages/_app.js.map +0 -1
- package/dist/pages/index.d.ts +0 -4
- package/dist/pages/index.d.ts.map +0 -1
- package/dist/pages/index.js +0 -10
- package/dist/pages/index.js.map +0 -1
- package/esm/demo/Demo.d.ts +0 -4
- package/esm/demo/Demo.d.ts.map +0 -1
- package/esm/demo/Demo.js +0 -12
- package/esm/demo/Demo.js.map +0 -1
- package/esm/demo/Demo.module.scss +0 -4
- package/esm/demo/Main.d.ts +0 -4
- package/esm/demo/Main.d.ts.map +0 -1
- package/esm/demo/Main.js +0 -58
- package/esm/demo/Main.js.map +0 -1
- package/esm/demo/Main.module.scss +0 -30
- package/esm/demo/Menu.d.ts +0 -9
- package/esm/demo/Menu.d.ts.map +0 -1
- package/esm/demo/Menu.js +0 -25
- package/esm/demo/Menu.js.map +0 -1
- package/esm/demo/Menu.module.scss +0 -39
- package/esm/demo/components/form/Checkbox.d.ts +0 -4
- package/esm/demo/components/form/Checkbox.d.ts.map +0 -1
- package/esm/demo/components/form/Checkbox.js +0 -9
- package/esm/demo/components/form/Checkbox.js.map +0 -1
- package/esm/demo/components/layout/header/Header.d.ts +0 -4
- package/esm/demo/components/layout/header/Header.d.ts.map +0 -1
- package/esm/demo/components/layout/header/Header.js +0 -10
- package/esm/demo/components/layout/header/Header.js.map +0 -1
- package/esm/demo/components/layout/header/StickyHeader.d.ts +0 -9
- package/esm/demo/components/layout/header/StickyHeader.d.ts.map +0 -1
- package/esm/demo/components/layout/header/StickyHeader.js +0 -62
- package/esm/demo/components/layout/header/StickyHeader.js.map +0 -1
- package/esm/demo/components/layout/list/List.Item.d.ts +0 -4
- package/esm/demo/components/layout/list/List.Item.d.ts.map +0 -1
- package/esm/demo/components/layout/list/List.Item.js +0 -17
- package/esm/demo/components/layout/list/List.Item.js.map +0 -1
- package/esm/demo/components/layout/list/List.Item.module.scss +0 -3
- package/esm/demo/components/ui/action/Action.d.ts +0 -8
- package/esm/demo/components/ui/action/Action.d.ts.map +0 -1
- package/esm/demo/components/ui/action/Action.js +0 -73
- package/esm/demo/components/ui/action/Action.js.map +0 -1
- package/esm/demo/components/ui/action/ActionDemo.module.scss +0 -3
- package/esm/demo/components/ui/button/ButtonDemo.d.ts +0 -4
- package/esm/demo/components/ui/button/ButtonDemo.d.ts.map +0 -1
- package/esm/demo/components/ui/button/ButtonDemo.js +0 -14
- package/esm/demo/components/ui/button/ButtonDemo.js.map +0 -1
- package/esm/demo/components/ui/directionPad/Pad.d.ts +0 -4
- package/esm/demo/components/ui/directionPad/Pad.d.ts.map +0 -1
- package/esm/demo/components/ui/directionPad/Pad.js +0 -27
- package/esm/demo/components/ui/directionPad/Pad.js.map +0 -1
- package/esm/demo/components/ui/icons/Icons.d.ts +0 -4
- package/esm/demo/components/ui/icons/Icons.d.ts.map +0 -1
- package/esm/demo/components/ui/icons/Icons.js +0 -14
- package/esm/demo/components/ui/icons/Icons.js.map +0 -1
- package/esm/demo/componentsMap.d.ts +0 -13
- package/esm/demo/componentsMap.d.ts.map +0 -1
- package/esm/demo/componentsMap.js +0 -84
- package/esm/demo/componentsMap.js.map +0 -1
- package/esm/demo/utils/makeVariants.d.ts +0 -3
- package/esm/demo/utils/makeVariants.d.ts.map +0 -1
- package/esm/demo/utils/makeVariants.js +0 -11
- package/esm/demo/utils/makeVariants.js.map +0 -1
- package/esm/demo/utils/safeUseHash.d.ts +0 -3
- package/esm/demo/utils/safeUseHash.d.ts.map +0 -1
- package/esm/demo/utils/safeUseHash.js +0 -10
- package/esm/demo/utils/safeUseHash.js.map +0 -1
- package/esm/demo-global.scss +0 -9
- package/esm/pages/_app.d.ts +0 -7
- package/esm/pages/_app.d.ts.map +0 -1
- package/esm/pages/_app.js +0 -10
- package/esm/pages/_app.js.map +0 -1
- package/esm/pages/index.d.ts +0 -4
- package/esm/pages/index.d.ts.map +0 -1
- package/esm/pages/index.js +0 -5
- package/esm/pages/index.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EqualActions.d.ts","sourceRoot":"","sources":["../../../../src/components/ui/action/EqualActions.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"EqualActions.d.ts","sourceRoot":"","sources":["../../../../src/components/ui/action/EqualActions.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,UAAU,KAAK;IACX,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,QAAA,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAiBjC,CAAC;AAEF,OAAO,EAAE,YAAY,EAAE,CAAC"}
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { Action } from "./Action";
|
|
3
3
|
import styles from "./EqualActions.module.scss";
|
|
4
|
+
import classnames from "classnames";
|
|
4
5
|
const EqualActions = (props) => {
|
|
5
6
|
React.Children.forEach(props.children, (child) => {
|
|
6
7
|
if (!child || typeof child !== "object" || !("type" in child) || child.type !== Action) {
|
|
7
|
-
throw new TypeError("Every child of
|
|
8
|
+
throw new TypeError("Every child of EqualActions must be an Action component");
|
|
8
9
|
}
|
|
9
10
|
});
|
|
10
11
|
const style = {
|
|
11
12
|
"--actions-count": React.Children.count(props.children),
|
|
12
13
|
};
|
|
13
|
-
return (React.createElement("div", { className: styles.actions, style: style }, props.children));
|
|
14
|
+
return (React.createElement("div", { className: classnames(styles.actions, props.className), style: style }, props.children));
|
|
14
15
|
};
|
|
15
16
|
export { EqualActions };
|
|
16
17
|
//# sourceMappingURL=EqualActions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EqualActions.js","sourceRoot":"","sources":["../../../../src/components/ui/action/EqualActions.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,OAAO,MAAM,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"EqualActions.js","sourceRoot":"","sources":["../../../../src/components/ui/action/EqualActions.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,OAAO,MAAM,MAAM,4BAA4B,CAAC;AAChD,OAAO,UAAU,MAAM,YAAY,CAAC;AAMpC,MAAM,YAAY,GAAoB,CAAC,KAAK,EAAE,EAAE;IAC5C,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE;QAC7C,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,CAAC,MAAM,IAAI,KAAK,CAAC,IAAI,KAAK,CAAC,IAAI,KAAK,MAAM,EAAE;YACpF,MAAM,IAAI,SAAS,CAAC,yDAAyD,CAAC,CAAC;SAClF;IACL,CAAC,CAAC,CAAC;IAGH,MAAM,KAAK,GAAG;QACV,iBAAiB,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC;KACnC,CAAC;IAEzB,OAAO,CACH,6BAAK,SAAS,EAAE,UAAU,CAAC,MAAM,CAAC,OAAO,EAAE,KAAK,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,KAAK,IACpE,KAAK,CAAC,QAAQ,CACb,CACT,CAAC;AACN,CAAC,CAAC;AAEF,OAAO,EAAE,YAAY,EAAE,CAAC"}
|
package/esm/global.scss
CHANGED
|
@@ -10,6 +10,9 @@
|
|
|
10
10
|
--active-bg: #d3d3d3;
|
|
11
11
|
--inactive-bg: #d3d3d3; // used
|
|
12
12
|
|
|
13
|
+
--toggle-handle-bg: #e0e0e0;
|
|
14
|
+
--toggle-handle-border: #cdcdcd;
|
|
15
|
+
|
|
13
16
|
--icon: #636363;
|
|
14
17
|
--border: #d5d5d5;
|
|
15
18
|
--button-border: #bababa;
|
|
@@ -17,13 +20,16 @@
|
|
|
17
20
|
--header-border: #c8c8c9;
|
|
18
21
|
--header-bg: #efeff0;
|
|
19
22
|
--header-text: #484848;
|
|
23
|
+
--text: #323232;
|
|
24
|
+
--sub: #959595;
|
|
20
25
|
|
|
21
26
|
--toolbar-border: #ababab;
|
|
22
|
-
--
|
|
27
|
+
--toolbar-bg: #f8f8f8;
|
|
23
28
|
|
|
24
29
|
// Shades: https://maketintsandshades.com/#038bf4,ff7200,7357e8,3ec234,3ec234,ff388f,ea2700
|
|
25
30
|
--blue1: #038bf4;
|
|
26
31
|
--orange1: #ff7200;
|
|
32
|
+
--orange1-darker: #cc5b00;
|
|
27
33
|
--purple1: #7357e8;
|
|
28
34
|
--green1: #3ec234;
|
|
29
35
|
--green1-darker: #38af2f;
|
|
@@ -31,12 +37,22 @@
|
|
|
31
37
|
--red1: #ea2700;
|
|
32
38
|
|
|
33
39
|
--grey1: #737373;
|
|
40
|
+
|
|
41
|
+
--focus-color: #dcaf00;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
*:focus {
|
|
45
|
+
outline: none!important;
|
|
34
46
|
}
|
|
35
47
|
|
|
36
|
-
*:focus {
|
|
48
|
+
*:focus-visible:focus-visible {
|
|
37
49
|
outline: none!important;
|
|
50
|
+
border-color: var(--focus-color);
|
|
51
|
+
background-color: var(--focus-bg-set);
|
|
38
52
|
}
|
|
39
53
|
|
|
54
|
+
|
|
40
55
|
body {
|
|
41
56
|
font-size: 15px;
|
|
57
|
+
color: var(--text);
|
|
42
58
|
}
|
package/esm/index.d.ts
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
export * from "./components/form/Checkbox.js";
|
|
2
|
+
export * from "./components/form/Toggle.js";
|
|
2
3
|
export * from "./components/icons/Icon.js";
|
|
3
4
|
export * from "./components/layout/header/Header.js";
|
|
5
|
+
export * from "./components/layout/header/HeaderIconAction.js";
|
|
4
6
|
export * from "./components/layout/header/StickyHeader.js";
|
|
5
7
|
export * from "./components/layout/list/List.js";
|
|
6
8
|
export * from "./components/layout/list/Item.js";
|
|
9
|
+
export * from "./components/ui/action/Action.js";
|
|
10
|
+
export * from "./components/ui/action/EqualActions.js";
|
|
7
11
|
export * from "./components/ui/button/Button.js";
|
|
8
12
|
export * from "./components/ui/directionPad/Pad.js";
|
|
9
13
|
//# sourceMappingURL=index.d.ts.map
|
package/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,+BAA+B,CAAC;AAC9C,cAAc,6BAA6B,CAAC;AAE5C,cAAc,4BAA4B,CAAC;AAE3C,cAAc,sCAAsC,CAAC;AACrD,cAAc,gDAAgD,CAAC;AAC/D,cAAc,4CAA4C,CAAC;AAC3D,cAAc,kCAAkC,CAAC;AACjD,cAAc,kCAAkC,CAAC;AAEjD,cAAc,kCAAkC,CAAC;AACjD,cAAc,wCAAwC,CAAC;AACvD,cAAc,kCAAkC,CAAC;AACjD,cAAc,qCAAqC,CAAC"}
|
package/esm/index.js
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
export * from "./components/form/Checkbox.js";
|
|
2
|
+
export * from "./components/form/Toggle.js";
|
|
2
3
|
export * from "./components/icons/Icon.js";
|
|
3
4
|
export * from "./components/layout/header/Header.js";
|
|
5
|
+
export * from "./components/layout/header/HeaderIconAction.js";
|
|
4
6
|
export * from "./components/layout/header/StickyHeader.js";
|
|
5
7
|
export * from "./components/layout/list/List.js";
|
|
6
8
|
export * from "./components/layout/list/Item.js";
|
|
9
|
+
export * from "./components/ui/action/Action.js";
|
|
10
|
+
export * from "./components/ui/action/EqualActions.js";
|
|
7
11
|
export * from "./components/ui/button/Button.js";
|
|
8
12
|
export * from "./components/ui/directionPad/Pad.js";
|
|
9
13
|
//# 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;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,+BAA+B,CAAC;AAC9C,cAAc,6BAA6B,CAAC;AAE5C,cAAc,4BAA4B,CAAC;AAE3C,cAAc,sCAAsC,CAAC;AACrD,cAAc,gDAAgD,CAAC;AAC/D,cAAc,4CAA4C,CAAC;AAC3D,cAAc,kCAAkC,CAAC;AACjD,cAAc,kCAAkC,CAAC;AAEjD,cAAc,kCAAkC,CAAC;AACjD,cAAc,wCAAwC,CAAC;AACvD,cAAc,kCAAkC,CAAC;AACjD,cAAc,qCAAqC,CAAC"}
|
package/esm/types.d.ts
CHANGED
package/esm/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,aAAK,YAAY,GAAG,KAAK,CAAC,cAAc,GAAG,KAAK,CAAC,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,aAAK,YAAY,GAAG,KAAK,CAAC,cAAc,GAAG,KAAK,CAAC,EAAE,GAAG,KAAK,CAAC,GAAG,CAAC;AAEhE,YAAY,EACR,YAAY,GACf,CAAC"}
|
package/package.json
CHANGED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
.container {
|
|
2
|
+
--ratio-dimensions: 2.5;
|
|
3
|
+
|
|
4
|
+
display: inline-flex;
|
|
5
|
+
align-items: center;
|
|
6
|
+
border: 1px solid #ccc;
|
|
7
|
+
border-radius: 100px;
|
|
8
|
+
position: relative;
|
|
9
|
+
line-height: 0;
|
|
10
|
+
width: calc(110px / var(--ratio-dimensions));
|
|
11
|
+
height: calc(62px / var(--ratio-dimensions));
|
|
12
|
+
padding-left: calc(8px / var(--ratio-dimensions));
|
|
13
|
+
box-sizing: border-box;
|
|
14
|
+
|
|
15
|
+
input {
|
|
16
|
+
position: absolute;
|
|
17
|
+
width: 0;
|
|
18
|
+
height: 0;
|
|
19
|
+
overflow: hidden;
|
|
20
|
+
visibility: hidden;
|
|
21
|
+
|
|
22
|
+
&:not(:checked) + .toggle {
|
|
23
|
+
transform: translateX(0);
|
|
24
|
+
background: var(--toggle-handle-bg);
|
|
25
|
+
border-color: var(--toggle-handle-border);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
&[data-undetermined=true] + .toggle {
|
|
29
|
+
transform: translateX(calc(24px / var(--ratio-dimensions)));
|
|
30
|
+
background: var(--toggle-handle-border);
|
|
31
|
+
border-color: var(--toggle-handle-border);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.toggle {
|
|
37
|
+
box-sizing: border-box;
|
|
38
|
+
border-radius: 100px;
|
|
39
|
+
display: inline-block;
|
|
40
|
+
width: calc(44px / var(--ratio-dimensions));
|
|
41
|
+
height: calc(44px / var(--ratio-dimensions));
|
|
42
|
+
border: calc(1px / var(--ratio-border)) solid var(--orange1-darker);
|
|
43
|
+
background: var(--orange1);
|
|
44
|
+
transition: transform 200ms, background-color 200ms, border-color 200ms;
|
|
45
|
+
transform: translateX(calc(48px / var(--ratio-dimensions)));
|
|
46
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { ChangeEvent } from "react";
|
|
2
|
+
import React, { useCallback } from "react";
|
|
3
|
+
|
|
4
|
+
import styles from "./Toggle.module.scss";
|
|
5
|
+
|
|
6
|
+
interface Props {
|
|
7
|
+
onChange: (newState: boolean) => void;
|
|
8
|
+
state: boolean | null;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const Toggle: React.VFC<Props> = (props) => {
|
|
12
|
+
const handleChange = useCallback((e: ChangeEvent<HTMLInputElement>) => {
|
|
13
|
+
if (props.state == null) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
props.onChange(e.target.checked);
|
|
17
|
+
}, [props.onChange, props.state]);
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<label className={styles.container}>
|
|
21
|
+
<input
|
|
22
|
+
type={"checkbox"}
|
|
23
|
+
checked={Boolean(props.state)}
|
|
24
|
+
data-undetermined={props.state == null}
|
|
25
|
+
readOnly={props.state == null}
|
|
26
|
+
onChange={handleChange}
|
|
27
|
+
/>
|
|
28
|
+
<div className={styles.toggle} />
|
|
29
|
+
</label>
|
|
30
|
+
);
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export { Toggle };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
interface Props {
|
|
4
|
+
className?: string;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
const Back: React.VFC<Props> = (props) => {
|
|
8
|
+
return (
|
|
9
|
+
<svg
|
|
10
|
+
width={"9"}
|
|
11
|
+
height={"16"}
|
|
12
|
+
viewBox={"0 0 9 16"}
|
|
13
|
+
xmlns={"http://www.w3.org/2000/svg"}
|
|
14
|
+
className={props.className}
|
|
15
|
+
>
|
|
16
|
+
<path fill={"currentColor"} d={"M8.05.1L0 7.95l8.05 7.85v.05q.15.15.4.15t.4-.15q.15-.2.15-.4 0-.25-.15-.4V15H8.8L1.65 7.95l7.2-7Q9 .75 9 .55q0-.25-.2-.4Q8.65 0 8.4 0q-.2 0-.35.1"} />
|
|
17
|
+
</svg>
|
|
18
|
+
);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export { Back };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
interface Props {
|
|
4
|
+
className?: string;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
const Forward: React.VFC<Props> = (props) => {
|
|
8
|
+
return (
|
|
9
|
+
<svg
|
|
10
|
+
width={"9"}
|
|
11
|
+
height={"16"}
|
|
12
|
+
viewBox={"0 0 9 16"}
|
|
13
|
+
xmlns={"http://www.w3.org/2000/svg"}
|
|
14
|
+
className={props.className}
|
|
15
|
+
>
|
|
16
|
+
<path fill={"currentColor"} d={"M.95.15Q.8 0 .55 0t-.4.15Q0 .3 0 .55t.15.4L7.35 8l-7.2 7.05Q0 15.2 0 15.4q0 .25.2.4.15.2.4.2.2 0 .35-.15L9 8 1 .2Q1 .15.95.15"} />
|
|
17
|
+
</svg>
|
|
18
|
+
);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export { Forward };
|
|
@@ -1,20 +1,25 @@
|
|
|
1
|
-
import type { AnyComponent } from "../../types";
|
|
2
|
-
|
|
3
1
|
import React from "react";
|
|
2
|
+
|
|
3
|
+
import type { AnyComponent } from "../../types";
|
|
4
4
|
import { Checkmark } from "./Checkmark";
|
|
5
|
+
import { Back } from "./Back";
|
|
6
|
+
import { Forward } from "./Forward";
|
|
5
7
|
|
|
6
8
|
enum ICON {
|
|
7
9
|
checkmark = "checkmark",
|
|
10
|
+
back = "back",
|
|
11
|
+
forward = "forward",
|
|
8
12
|
}
|
|
9
13
|
|
|
10
14
|
interface Props {
|
|
11
15
|
name: ICON;
|
|
16
|
+
className?: string;
|
|
12
17
|
}
|
|
13
18
|
|
|
14
19
|
const iconsMap = new Map<ICON, AnyComponent>([
|
|
15
|
-
[
|
|
16
|
-
|
|
17
|
-
],
|
|
20
|
+
[ICON.checkmark, Checkmark],
|
|
21
|
+
[ICON.back, Back],
|
|
22
|
+
[ICON.forward, Forward],
|
|
18
23
|
]);
|
|
19
24
|
|
|
20
25
|
const Icon: React.FC<Props> = ({ name: iconName, ...props }) => {
|
|
@@ -16,13 +16,18 @@
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
.header--top, .header--bottom {
|
|
19
|
-
padding:
|
|
19
|
+
padding: 0 16.666px;
|
|
20
20
|
min-height: 44px;
|
|
21
21
|
}
|
|
22
22
|
.header--left, .header--right {
|
|
23
|
-
padding: 16.666px
|
|
23
|
+
padding: 16.666px 0;
|
|
24
24
|
min-width: 44px;
|
|
25
25
|
flex-direction: column;
|
|
26
|
+
|
|
27
|
+
> .contents {
|
|
28
|
+
flex-direction: column;
|
|
29
|
+
align-items: center;
|
|
30
|
+
}
|
|
26
31
|
}
|
|
27
32
|
|
|
28
33
|
.header--top {
|
|
@@ -40,6 +45,45 @@
|
|
|
40
45
|
order: 2;
|
|
41
46
|
}
|
|
42
47
|
|
|
43
|
-
.
|
|
48
|
+
.contents {
|
|
49
|
+
flex: 1;
|
|
50
|
+
display: flex;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.header--center > .contents {
|
|
44
54
|
justify-content: center;
|
|
45
55
|
}
|
|
56
|
+
|
|
57
|
+
.header--top, .header--bottom {
|
|
58
|
+
.before {
|
|
59
|
+
margin-right: calc(50px / var(--ratio-dimensions));
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.after {
|
|
63
|
+
margin-left: calc(50px / var(--ratio-dimensions));
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.actions {
|
|
67
|
+
margin: calc(56px / var(--ratio-dimensions)) 0;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.header--left, .header--right {
|
|
72
|
+
.before {
|
|
73
|
+
margin-bottom: calc(50px / var(--ratio-dimensions));
|
|
74
|
+
flex-direction: column;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.after {
|
|
78
|
+
margin-top: calc(50px / var(--ratio-dimensions));
|
|
79
|
+
flex-direction: column;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.actions {
|
|
83
|
+
margin: 0 calc(56px / var(--ratio-dimensions));
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.before, .after {
|
|
88
|
+
display: flex;
|
|
89
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import classnames from "classnames";
|
|
3
|
+
import type { ReactNode } from "react";
|
|
3
4
|
|
|
4
5
|
import styles from "./Header.module.scss";
|
|
5
6
|
import { Action } from "../../ui/action/Action";
|
|
@@ -8,10 +9,17 @@ import { EqualActions } from "../../ui/action/EqualActions";
|
|
|
8
9
|
interface Props {
|
|
9
10
|
center?: boolean;
|
|
10
11
|
variant?: "toolbar";
|
|
11
|
-
|
|
12
|
+
/**
|
|
13
|
+
* This indicates just how the borders are drawn and how content is aligned, not the actual position on the screen.
|
|
14
|
+
* To set up position on the screen you need to properly style parent element.
|
|
15
|
+
*/
|
|
16
|
+
position?: "top" | "left" | "right" | "bottom"; // @TODO disallow left/right if not inside StickyHeader?
|
|
12
17
|
className?: string;
|
|
18
|
+
before?: ReactNode;
|
|
19
|
+
after?: ReactNode;
|
|
13
20
|
}
|
|
14
21
|
|
|
22
|
+
// eslint-disable-next-line max-statements
|
|
15
23
|
const Header: React.FC<Props> = (props) => {
|
|
16
24
|
const { center, children, variant, position = "top" } = props;
|
|
17
25
|
|
|
@@ -30,12 +38,26 @@ const Header: React.FC<Props> = (props) => {
|
|
|
30
38
|
|
|
31
39
|
let contents = children;
|
|
32
40
|
if (justActions) {
|
|
33
|
-
contents = <EqualActions>{contents}</EqualActions>;
|
|
41
|
+
contents = <EqualActions className={styles.actions}>{contents}</EqualActions>;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
let before: ReactNode;
|
|
45
|
+
if (props.before != null) {
|
|
46
|
+
before = <div className={styles.before}>{props.before}</div>;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
let after: ReactNode;
|
|
50
|
+
if (props.after != null) {
|
|
51
|
+
after = <div className={styles.after}>{props.after}</div>;
|
|
34
52
|
}
|
|
35
53
|
|
|
36
54
|
return (
|
|
37
55
|
<div className={cls}>
|
|
38
|
-
{
|
|
56
|
+
{before}
|
|
57
|
+
<div className={styles.contents}>
|
|
58
|
+
{contents}
|
|
59
|
+
</div>
|
|
60
|
+
{after}
|
|
39
61
|
</div>
|
|
40
62
|
);
|
|
41
63
|
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
.btn, .a {
|
|
2
|
+
padding: 7px;
|
|
3
|
+
background: none;
|
|
4
|
+
border-radius: 666px;
|
|
5
|
+
display: inline-block;
|
|
6
|
+
border: calc(2px / var(--ratio-border)) solid transparent;
|
|
7
|
+
color: var(--header-text);
|
|
8
|
+
|
|
9
|
+
&:hover {
|
|
10
|
+
background: #00000022;
|
|
11
|
+
}
|
|
12
|
+
&:active {
|
|
13
|
+
background: #00000011;
|
|
14
|
+
color: currentColor;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.icon {
|
|
19
|
+
width: 16px;
|
|
20
|
+
height: 16px;
|
|
21
|
+
display: block;
|
|
22
|
+
}
|
|
@@ -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 };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import classnames from "classnames";
|
|
3
|
+
|
|
4
|
+
import styles from "./Item.module.scss";
|
|
5
|
+
import headerStyles from "./Header.module.scss";
|
|
6
|
+
|
|
7
|
+
const Header: React.FC = (props) => {
|
|
8
|
+
// @TODO way to use h1, h2, h3 instead of div
|
|
9
|
+
return (
|
|
10
|
+
<li className={classnames(styles.item, headerStyles.header)}>
|
|
11
|
+
<div>{props.children}</div>
|
|
12
|
+
</li>
|
|
13
|
+
);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export { Header };
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
list-style-type: none;
|
|
3
3
|
margin: 0;
|
|
4
4
|
padding: 0;
|
|
5
|
-
font-size:
|
|
5
|
+
font-size: calc(34px / var(--ratio-font));
|
|
6
6
|
|
|
7
7
|
&:not(:first-child) > * {
|
|
8
8
|
border-top: 0.37px solid var(--header-border);
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
> * {
|
|
12
12
|
display: block;
|
|
13
|
-
padding:
|
|
13
|
+
padding: 0;
|
|
14
14
|
text-decoration: none;
|
|
15
15
|
}
|
|
16
16
|
}
|
|
@@ -20,4 +20,12 @@
|
|
|
20
20
|
background: none;
|
|
21
21
|
width: 100%;
|
|
22
22
|
text-align: left;
|
|
23
|
+
font-family: inherit;
|
|
24
|
+
font-size: inherit;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.content {
|
|
28
|
+
display: flex;
|
|
29
|
+
min-height: calc(174px / var(--ratio-dimensions));
|
|
30
|
+
align-items: center;
|
|
23
31
|
}
|
|
@@ -2,6 +2,8 @@ import React from "react";
|
|
|
2
2
|
import classnames from "classnames";
|
|
3
3
|
|
|
4
4
|
import styles from "./Item.module.scss";
|
|
5
|
+
import { Value } from "./Value";
|
|
6
|
+
import { Label } from "./Label";
|
|
5
7
|
|
|
6
8
|
interface LinkProps {
|
|
7
9
|
href: string;
|
|
@@ -13,38 +15,63 @@ interface Props {
|
|
|
13
15
|
onClick?: () => void;
|
|
14
16
|
className?: string;
|
|
15
17
|
Link?: React.ComponentClass<LinkProps> | React.FC<LinkProps>;
|
|
18
|
+
ratio?: string; // @TODO number/number/number/.. type?
|
|
16
19
|
}
|
|
17
20
|
|
|
18
|
-
|
|
19
|
-
|
|
21
|
+
interface SubComponents {
|
|
22
|
+
Label: typeof Label;
|
|
23
|
+
Value: typeof Value;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// eslint-disable-next-line max-statements
|
|
27
|
+
const Item: React.FC<Props> & SubComponents = (props) => {
|
|
28
|
+
const { className, children, href, to, onClick, Link, ratio, ...restProps } = props;
|
|
20
29
|
const cls = classnames(styles.item, className);
|
|
21
30
|
|
|
22
31
|
const liProps = {
|
|
23
32
|
className: cls,
|
|
24
33
|
};
|
|
25
34
|
|
|
35
|
+
const r = ratio ? ratio.split("/") : [];
|
|
36
|
+
|
|
37
|
+
const ren = React.Children.map(props.children, (child, index) => {
|
|
38
|
+
let flex = undefined;
|
|
39
|
+
if (!r.length && child && typeof child === "object" && "type" in child && child.type === Value) {
|
|
40
|
+
return child;
|
|
41
|
+
}
|
|
42
|
+
if (index in r) {
|
|
43
|
+
flex = r[index];
|
|
44
|
+
}
|
|
45
|
+
return <div style={{ flex }}>{child}</div>;
|
|
46
|
+
});
|
|
47
|
+
|
|
26
48
|
if (to) {
|
|
27
49
|
if (!Link) {
|
|
28
50
|
throw new TypeError("`to` prop given without `Link` component");
|
|
29
51
|
}
|
|
30
52
|
|
|
31
|
-
return <li {...liProps}><Link href={to} {...restProps}>{
|
|
53
|
+
return <li {...liProps}><Link href={to} {...restProps}><a className={styles.content}>{ren}</a></Link></li>;
|
|
32
54
|
}
|
|
33
55
|
if (href) {
|
|
34
56
|
const aProps: typeof restProps & { onClick?: Props["onClick"]} = { ...restProps };
|
|
35
57
|
if (onClick) {
|
|
36
58
|
aProps.onClick = onClick;
|
|
37
59
|
}
|
|
38
|
-
return <li {...liProps}><a href={href} {...aProps}>{
|
|
60
|
+
return <li {...liProps}><a href={href} {...aProps} className={styles.content}>{ren}</a></li>;
|
|
39
61
|
}
|
|
40
62
|
if (onClick) {
|
|
41
63
|
return (
|
|
42
64
|
<li {...liProps}>
|
|
43
|
-
<button className={styles.button} onClick={props.onClick}
|
|
65
|
+
<button className={classnames(styles.button, styles.content)} onClick={props.onClick}{...restProps}>
|
|
66
|
+
{ren}
|
|
67
|
+
</button>
|
|
44
68
|
</li>
|
|
45
69
|
);
|
|
46
70
|
}
|
|
47
|
-
return <li {...liProps}><div {...restProps}>{
|
|
71
|
+
return <li {...liProps}><div {...restProps} className={styles.content}>{ren}</div></li>;
|
|
48
72
|
};
|
|
49
73
|
|
|
74
|
+
Item.Label = Label;
|
|
75
|
+
Item.Value = Value;
|
|
76
|
+
|
|
50
77
|
export { Item };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { ReactNode } from "react";
|
|
3
|
+
|
|
4
|
+
import styles from "./Label.module.scss";
|
|
5
|
+
|
|
6
|
+
interface Props {
|
|
7
|
+
sub?: ReactNode;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const Label: React.FC<Props> = (props) => {
|
|
11
|
+
const sub = props.sub ? <div className={styles.sub}>{props.sub}</div> : null;
|
|
12
|
+
|
|
13
|
+
return (
|
|
14
|
+
<div className={styles.root}>
|
|
15
|
+
<div>{props.children}</div>
|
|
16
|
+
{sub}
|
|
17
|
+
</div>
|
|
18
|
+
);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export { Label };
|