react-miui 0.20.1 → 0.21.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 +10 -0
- package/dist/components/form/input/Input.css.d.ts +16 -16
- package/dist/components/form/input/Input.css.d.ts.map +1 -1
- package/dist/components/form/input/Input.css.js.map +1 -1
- package/dist/components/form/input/Input.styled.d.ts +68 -36
- package/dist/components/form/input/Input.styled.d.ts.map +1 -1
- package/dist/components/form/textarea/TextArea.styled.d.ts +17 -9
- package/dist/components/form/textarea/TextArea.styled.d.ts.map +1 -1
- package/dist/components/icons/Icon.js +1 -2
- package/dist/components/icons/Icon.js.map +1 -1
- package/dist/components/layout/list/Header.d.ts +174 -7
- package/dist/components/layout/list/Header.d.ts.map +1 -1
- package/dist/components/layout/list/Header.js +36 -11
- package/dist/components/layout/list/Header.js.map +1 -1
- package/dist/components/layout/list/Header.stories.d.ts +8 -0
- package/dist/components/layout/list/Header.stories.d.ts.map +1 -0
- package/dist/components/layout/list/Header.stories.js +33 -0
- package/dist/components/layout/list/Header.stories.js.map +1 -0
- package/dist/components/layout/list/Item.d.ts +88 -7
- package/dist/components/layout/list/Item.d.ts.map +1 -1
- package/dist/components/layout/list/Item.js +66 -33
- package/dist/components/layout/list/Item.js.map +1 -1
- package/dist/components/layout/list/Item.stories.d.ts +10 -0
- package/dist/components/layout/list/Item.stories.d.ts.map +1 -0
- package/dist/components/layout/list/Item.stories.js +65 -0
- package/dist/components/layout/list/Item.stories.js.map +1 -0
- package/dist/components/layout/list/Label.d.ts +83 -5
- package/dist/components/layout/list/Label.d.ts.map +1 -1
- package/dist/components/layout/list/Label.js +24 -6
- package/dist/components/layout/list/Label.js.map +1 -1
- package/dist/components/layout/list/Label.stories.d.ts +8 -0
- package/dist/components/layout/list/Label.stories.d.ts.map +1 -0
- package/dist/components/layout/list/Label.stories.js +35 -0
- package/dist/components/layout/list/Label.stories.js.map +1 -0
- package/dist/components/layout/list/List.d.ts +86 -7
- package/dist/components/layout/list/List.d.ts.map +1 -1
- package/dist/components/layout/list/List.js +15 -9
- package/dist/components/layout/list/List.js.map +1 -1
- package/dist/components/layout/list/List.stories.d.ts +9 -0
- package/dist/components/layout/list/List.stories.d.ts.map +1 -0
- package/dist/components/layout/list/List.stories.js +53 -0
- package/dist/components/layout/list/List.stories.js.map +1 -0
- package/dist/components/layout/list/Value.d.ts +81 -1
- package/dist/components/layout/list/Value.d.ts.map +1 -1
- package/dist/components/layout/list/Value.js +9 -2
- package/dist/components/layout/list/Value.js.map +1 -1
- package/dist/components/layout/list/Value.stories.d.ts +8 -0
- package/dist/components/layout/list/Value.stories.d.ts.map +1 -0
- package/dist/components/layout/list/Value.stories.js +29 -0
- package/dist/components/layout/list/Value.stories.js.map +1 -0
- package/dist/components/layout/section/Section.d.ts +83 -8
- package/dist/components/layout/section/Section.d.ts.map +1 -1
- package/dist/components/layout/section/Section.js +17 -15
- package/dist/components/layout/section/Section.js.map +1 -1
- package/dist/components/layout/section/Section.stories.d.ts +8 -0
- package/dist/components/layout/section/Section.stories.d.ts.map +1 -0
- package/dist/components/layout/section/Section.stories.js +37 -0
- package/dist/components/layout/section/Section.stories.js.map +1 -0
- package/dist/components/layout/section/SectionContainer.d.ts +80 -5
- package/dist/components/layout/section/SectionContainer.d.ts.map +1 -1
- package/dist/components/layout/section/SectionContainer.js +9 -8
- package/dist/components/layout/section/SectionContainer.js.map +1 -1
- package/dist/components/ui/message/Message.d.ts +17 -9
- package/dist/components/ui/message/Message.d.ts.map +1 -1
- package/dist/components/ui/message/Message.styled.d.ts +17 -9
- package/dist/components/ui/message/Message.styled.d.ts.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/dist/theme.d.ts +125 -69
- package/dist/theme.d.ts.map +1 -1
- package/dist/theme.js +2 -0
- package/dist/theme.js.map +1 -1
- package/docs/assets/search.js +1 -1
- package/docs/classes/Drawer.html +14 -16
- package/docs/classes/Pop.html +14 -16
- package/docs/classes/ToasterProvider.html +10 -12
- package/docs/enums/ICON.html +14 -16
- package/docs/functions/Action.html +5 -8
- package/docs/functions/Button.html +5 -8
- package/docs/functions/Card.html +5 -8
- package/docs/functions/Checkbox.html +5 -8
- package/docs/functions/Choice.html +6 -9
- package/docs/functions/CoveringLoader.html +5 -8
- package/docs/functions/DirectionPad.html +5 -8
- package/docs/functions/EqualActions.html +5 -8
- package/docs/functions/FullLoader.html +5 -8
- package/docs/functions/HandleEsc.html +5 -8
- package/docs/functions/Header.html +5 -8
- package/docs/functions/HeaderIconAction.html +5 -8
- package/docs/functions/Icon-1.html +5 -8
- package/docs/functions/If.html +5 -8
- package/docs/functions/Input.html +6 -9
- package/docs/functions/KeyValue.html +5 -8
- package/docs/functions/Label.html +5 -8
- package/docs/functions/List-1.html +17 -10
- package/docs/functions/Loader.html +5 -8
- package/docs/functions/Loading.html +5 -8
- package/docs/functions/Message.html +5 -8
- package/docs/functions/Modal-1.html +5 -8
- package/docs/functions/ModalButtons-1.html +5 -8
- package/docs/functions/PopLoader.html +5 -8
- package/docs/functions/PopOption.html +5 -8
- package/docs/functions/SearchContainer.html +5 -8
- package/docs/functions/Section.html +146 -0
- package/docs/functions/Select.html +5 -8
- package/docs/functions/Selector.html +6 -9
- package/docs/functions/Spacer.html +5 -8
- package/docs/functions/Stats.html +5 -8
- package/docs/functions/StickyHeader-1.html +5 -8
- package/docs/functions/StickyHeader.Content.html +5 -7
- package/docs/functions/Table.html +5 -8
- package/docs/functions/TextArea.html +5 -8
- package/docs/functions/Toggle.html +5 -8
- package/docs/functions/getCssText.html +5 -8
- package/docs/functions/styled.html +5 -8
- package/docs/functions/useToaster.html +6 -9
- package/docs/index.html +5 -8
- package/docs/modules/List.html +10 -9
- package/docs/modules/Modal.html +6 -8
- package/docs/modules/ModalButtons.html +6 -8
- package/docs/modules/StickyHeader.html +6 -8
- package/docs/modules.html +7 -13
- package/docs/pages/tutorials/Test.html +5 -8
- package/docs/types/ThemeCSS.html +6 -9
- package/docs/variables/List.Header.html +8 -9
- package/docs/variables/List.Item.html +54 -0
- package/docs/variables/Modal.NegateMargin.html +5 -7
- package/docs/variables/ModalButtons.Button.html +5 -7
- package/docs/variables/cssReset.html +6 -9
- package/docs/variables/miuiScrollbars.html +6 -9
- package/esm/components/form/input/Input.css.d.ts +16 -16
- package/esm/components/form/input/Input.css.d.ts.map +1 -1
- package/esm/components/form/input/Input.css.js.map +1 -1
- package/esm/components/form/input/Input.styled.d.ts +68 -36
- package/esm/components/form/input/Input.styled.d.ts.map +1 -1
- package/esm/components/form/textarea/TextArea.styled.d.ts +17 -9
- package/esm/components/form/textarea/TextArea.styled.d.ts.map +1 -1
- package/esm/components/layout/list/Header.d.ts +174 -7
- package/esm/components/layout/list/Header.d.ts.map +1 -1
- package/esm/components/layout/list/Header.js +24 -11
- package/esm/components/layout/list/Header.js.map +1 -1
- package/esm/components/layout/list/Header.stories.d.ts +8 -0
- package/esm/components/layout/list/Header.stories.d.ts.map +1 -0
- package/esm/components/layout/list/Header.stories.js +27 -0
- package/esm/components/layout/list/Header.stories.js.map +1 -0
- package/esm/components/layout/list/Item.d.ts +88 -7
- package/esm/components/layout/list/Item.d.ts.map +1 -1
- package/esm/components/layout/list/Item.js +64 -33
- package/esm/components/layout/list/Item.js.map +1 -1
- package/esm/components/layout/list/Item.stories.d.ts +10 -0
- package/esm/components/layout/list/Item.stories.d.ts.map +1 -0
- package/esm/components/layout/list/Item.stories.js +57 -0
- package/esm/components/layout/list/Item.stories.js.map +1 -0
- package/esm/components/layout/list/Label.d.ts +83 -5
- package/esm/components/layout/list/Label.d.ts.map +1 -1
- package/esm/components/layout/list/Label.js +12 -6
- package/esm/components/layout/list/Label.js.map +1 -1
- package/esm/components/layout/list/Label.stories.d.ts +8 -0
- package/esm/components/layout/list/Label.stories.d.ts.map +1 -0
- package/esm/components/layout/list/Label.stories.js +29 -0
- package/esm/components/layout/list/Label.stories.js.map +1 -0
- package/esm/components/layout/list/List.d.ts +86 -7
- package/esm/components/layout/list/List.d.ts.map +1 -1
- package/esm/components/layout/list/List.js +15 -9
- package/esm/components/layout/list/List.js.map +1 -1
- package/esm/components/layout/list/List.stories.d.ts +9 -0
- package/esm/components/layout/list/List.stories.d.ts.map +1 -0
- package/esm/components/layout/list/List.stories.js +46 -0
- package/esm/components/layout/list/List.stories.js.map +1 -0
- package/esm/components/layout/list/Value.d.ts +81 -1
- package/esm/components/layout/list/Value.d.ts.map +1 -1
- package/esm/components/layout/list/Value.js +9 -1
- package/esm/components/layout/list/Value.js.map +1 -1
- package/esm/components/layout/list/Value.stories.d.ts +8 -0
- package/esm/components/layout/list/Value.stories.d.ts.map +1 -0
- package/esm/components/layout/list/Value.stories.js +23 -0
- package/esm/components/layout/list/Value.stories.js.map +1 -0
- package/esm/components/layout/section/Section.d.ts +83 -8
- package/esm/components/layout/section/Section.d.ts.map +1 -1
- package/esm/components/layout/section/Section.js +17 -12
- package/esm/components/layout/section/Section.js.map +1 -1
- package/esm/components/layout/section/Section.stories.d.ts +8 -0
- package/esm/components/layout/section/Section.stories.d.ts.map +1 -0
- package/esm/components/layout/section/Section.stories.js +31 -0
- package/esm/components/layout/section/Section.stories.js.map +1 -0
- package/esm/components/layout/section/SectionContainer.d.ts +80 -5
- package/esm/components/layout/section/SectionContainer.d.ts.map +1 -1
- package/esm/components/layout/section/SectionContainer.js +9 -5
- package/esm/components/layout/section/SectionContainer.js.map +1 -1
- package/esm/components/ui/message/Message.d.ts +17 -9
- package/esm/components/ui/message/Message.d.ts.map +1 -1
- package/esm/components/ui/message/Message.styled.d.ts +17 -9
- package/esm/components/ui/message/Message.styled.d.ts.map +1 -1
- package/esm/index.d.ts +0 -1
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +0 -1
- package/esm/index.js.map +1 -1
- package/esm/theme.d.ts +125 -69
- package/esm/theme.d.ts.map +1 -1
- package/esm/theme.js +2 -0
- package/esm/theme.js.map +1 -1
- package/package.json +7 -6
- package/src/components/form/input/Input.css.ts +5 -3
- package/src/components/layout/list/Header.stories.tsx +40 -0
- package/src/components/layout/list/Header.tsx +43 -26
- package/src/components/layout/list/Item.stories.tsx +69 -0
- package/src/components/layout/list/Item.tsx +118 -46
- package/src/components/layout/list/Label.stories.tsx +45 -0
- package/src/components/layout/list/Label.tsx +21 -12
- package/src/components/layout/list/List.stories.tsx +84 -0
- package/src/components/layout/list/List.tsx +34 -23
- package/src/components/layout/list/Value.stories.tsx +37 -0
- package/src/components/layout/list/Value.tsx +15 -1
- package/src/components/layout/section/Section.stories.tsx +54 -0
- package/src/components/layout/section/Section.tsx +27 -27
- package/src/components/layout/section/SectionContainer.tsx +10 -13
- package/src/demo/components/form/Choice.tsx +3 -3
- package/src/demo/components/form/Form.tsx +1 -1
- package/src/demo/components/form/Search.tsx +3 -1
- package/src/demo/components/form/Toggle.tsx +3 -1
- package/src/demo/components/layout/card/Card.tsx +3 -3
- package/src/demo/components/ui/icons/Icons.tsx +3 -1
- package/src/demo/components/ui/keyValue/KeyValue.tsx +1 -1
- package/src/demo/components/ui/modal/Modal.tsx +4 -2
- package/src/demo/components/ui/pop/Pop.tsx +1 -1
- package/src/demo/componentsMap.ts +0 -52
- package/src/index.ts +0 -1
- package/src/pages/_app.tsx +2 -0
- package/src/theme.ts +5 -3
- package/dist/components/layout/list/Header.module.scss +0 -8
- package/dist/components/layout/list/Item.module.scss +0 -46
- package/dist/components/layout/list/Label.module.scss +0 -9
- package/dist/components/layout/list/List.module.scss +0 -8
- package/dist/components/layout/list/Value.styled.d.ts +0 -74
- package/dist/components/layout/list/Value.styled.d.ts.map +0 -1
- package/dist/components/layout/list/Value.styled.js +0 -13
- package/dist/components/layout/list/Value.styled.js.map +0 -1
- package/dist/components/layout/section/Section.module.scss +0 -24
- package/dist/components/layout/section/SectionContainer.module.scss +0 -4
- package/docs/functions/Item-1.html +0 -110
- package/docs/functions/Section-1.html +0 -110
- package/docs/modules/Item.html +0 -64
- package/docs/modules/Section.html +0 -61
- package/docs/variables/Item.Label.html +0 -56
- package/docs/variables/Item.Value.html +0 -56
- package/docs/variables/Section.Container.html +0 -55
- package/esm/components/layout/list/Header.module.scss +0 -8
- package/esm/components/layout/list/Item.module.scss +0 -46
- package/esm/components/layout/list/Label.module.scss +0 -9
- package/esm/components/layout/list/List.module.scss +0 -8
- package/esm/components/layout/list/Value.styled.d.ts +0 -74
- package/esm/components/layout/list/Value.styled.d.ts.map +0 -1
- package/esm/components/layout/list/Value.styled.js +0 -10
- package/esm/components/layout/list/Value.styled.js.map +0 -1
- package/esm/components/layout/section/Section.module.scss +0 -24
- package/esm/components/layout/section/SectionContainer.module.scss +0 -4
- package/src/components/layout/list/Header.module.scss +0 -8
- package/src/components/layout/list/Item.module.scss +0 -46
- package/src/components/layout/list/Label.module.scss +0 -9
- package/src/components/layout/list/List.module.scss +0 -8
- package/src/components/layout/list/Value.styled.ts +0 -13
- package/src/components/layout/section/Section.module.scss +0 -24
- package/src/components/layout/section/SectionContainer.module.scss +0 -4
- package/src/demo/components/form/Input.tsx +0 -28
- package/src/demo/components/layout/list/Header.tsx +0 -23
- package/src/demo/components/layout/list/Inset.tsx +0 -23
- package/src/demo/components/layout/list/ItemRatio.tsx +0 -20
- package/src/demo/components/layout/list/Label.tsx +0 -31
- package/src/demo/components/layout/list/List.Item.module.scss +0 -7
- package/src/demo/components/layout/list/List.Item.tsx +0 -24
- package/src/demo/components/layout/list/Selection.tsx +0 -16
- package/src/demo/components/layout/list/Value.module.scss +0 -4
- package/src/demo/components/layout/list/Value.tsx +0 -25
- package/src/demo/components/layout/section/Section.tsx +0 -33
- package/src/demo/components/ui/message/Message.tsx +0 -27
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
import type { StoryObj, Meta } from "@storybook/react";
|
|
4
|
+
|
|
5
|
+
import { NextLink } from "../../../demo/NextLink.js";
|
|
6
|
+
|
|
7
|
+
import { Item } from "./Item.js";
|
|
8
|
+
import { List } from "./List.js";
|
|
9
|
+
|
|
10
|
+
const meta: Meta = {
|
|
11
|
+
title: "Components/Layout/List/Item",
|
|
12
|
+
component: Item,
|
|
13
|
+
tags: ["autodocs", "layout"],
|
|
14
|
+
argTypes: {
|
|
15
|
+
inset: {
|
|
16
|
+
type: "boolean",
|
|
17
|
+
},
|
|
18
|
+
Link: {
|
|
19
|
+
controls: "none",
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
type Story = StoryObj<typeof Item>;
|
|
25
|
+
|
|
26
|
+
const Primary: Story = {
|
|
27
|
+
args: {
|
|
28
|
+
children: "I am a list item",
|
|
29
|
+
inset: false,
|
|
30
|
+
Link: NextLink,
|
|
31
|
+
},
|
|
32
|
+
render: (args) => {
|
|
33
|
+
return <List><Item {...args} /></List>;
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const Alignment: Story = {
|
|
38
|
+
args: {
|
|
39
|
+
children: [
|
|
40
|
+
<div key={"1st"}>first</div>,
|
|
41
|
+
<div key={"2nd"}>2nd</div>,
|
|
42
|
+
<div key={"3rd"}>last</div>,
|
|
43
|
+
],
|
|
44
|
+
ratio: "1/2/1",
|
|
45
|
+
},
|
|
46
|
+
render: (args) => {
|
|
47
|
+
return <List><Item {...args} /></List>;
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const OnClick: Story = {
|
|
52
|
+
args: {
|
|
53
|
+
children: "I am a list item, but I will render a button, click me",
|
|
54
|
+
onClick: () => {
|
|
55
|
+
alert("Clicked!");
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
render: (args) => {
|
|
59
|
+
return <List><Item {...args} /></List>;
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export {
|
|
64
|
+
Primary,
|
|
65
|
+
Alignment,
|
|
66
|
+
OnClick,
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
export default meta;
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
|
|
3
|
-
import classnames from "classnames";
|
|
4
|
-
|
|
5
|
-
import { makeVariants } from "../../../utils/index.js";
|
|
6
3
|
import { ICON, Icon } from "../../icons/Icon.js";
|
|
4
|
+
import { dimensionsPxToRem, fontPxToRem, pxToRem, styled } from "../../../theme.js";
|
|
7
5
|
|
|
8
|
-
import styles from "./Item.module.scss";
|
|
9
6
|
import { Value } from "./Value.js";
|
|
10
7
|
import { Label } from "./Label.js";
|
|
11
8
|
|
|
@@ -14,18 +11,12 @@ interface LinkProps {
|
|
|
14
11
|
children: React.ReactNode;
|
|
15
12
|
}
|
|
16
13
|
|
|
17
|
-
type Variant = "inset";
|
|
18
|
-
|
|
19
14
|
interface Props {
|
|
20
15
|
href?: string;
|
|
21
16
|
to?: string;
|
|
22
17
|
onClick?: () => void;
|
|
23
|
-
className?: string;
|
|
24
18
|
Link?: React.ComponentClass<LinkProps> | React.FC<LinkProps>;
|
|
25
19
|
ratio?: string; // @TODO number/number/number/.. type?
|
|
26
|
-
variant?: Variant | Variant[];
|
|
27
|
-
selected?: boolean | undefined;
|
|
28
|
-
children: React.ReactNode;
|
|
29
20
|
}
|
|
30
21
|
|
|
31
22
|
interface SubComponents {
|
|
@@ -33,32 +24,101 @@ interface SubComponents {
|
|
|
33
24
|
Value: typeof Value;
|
|
34
25
|
}
|
|
35
26
|
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
// eslint-disable-next-line
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
27
|
+
const iconStyles = {
|
|
28
|
+
// eslint-disable-next-line @typescript-eslint/no-magic-numbers
|
|
29
|
+
width: pxToRem(7),
|
|
30
|
+
// eslint-disable-next-line @typescript-eslint/no-magic-numbers
|
|
31
|
+
marginRight: pxToRem(10),
|
|
32
|
+
display: "inline-block",
|
|
33
|
+
}; // TODO satisfies
|
|
34
|
+
|
|
35
|
+
const StyledIcon = styled(Icon, iconStyles);
|
|
36
|
+
const StyledNoIcon = styled("span", iconStyles);
|
|
37
|
+
|
|
38
|
+
const icon = <StyledIcon name={ICON.forward} />;
|
|
39
|
+
const noIcon = <StyledNoIcon />;
|
|
40
|
+
|
|
41
|
+
const StyledInnerContainer = styled("div", {
|
|
42
|
+
display: "flex",
|
|
43
|
+
// eslint-disable-next-line @typescript-eslint/no-magic-numbers
|
|
44
|
+
minHeight: dimensionsPxToRem(174),
|
|
45
|
+
alignItems: "center",
|
|
46
|
+
gap: "1rem",
|
|
47
|
+
|
|
48
|
+
border: "none",
|
|
49
|
+
background: "none",
|
|
50
|
+
width: "100%",
|
|
51
|
+
textAlign: "left",
|
|
52
|
+
fontFamily: "inherit",
|
|
53
|
+
fontSize: "inherit",
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
const ItemInnerContainerClassName = StyledInnerContainer.toString();
|
|
57
|
+
|
|
58
|
+
const StyledItem = styled("li", {
|
|
59
|
+
"listStyleType": "none",
|
|
60
|
+
"margin": 0,
|
|
61
|
+
"padding": 0,
|
|
62
|
+
// eslint-disable-next-line @typescript-eslint/no-magic-numbers
|
|
63
|
+
"fontSize": fontPxToRem(34),
|
|
64
|
+
|
|
65
|
+
"&:not(:first-child)": {
|
|
66
|
+
borderTop: "0.37px solid $headerBorder",
|
|
67
|
+
},
|
|
68
|
+
|
|
69
|
+
"> *": {
|
|
70
|
+
display: "block",
|
|
71
|
+
padding: 0,
|
|
72
|
+
textDecoration: "none",
|
|
73
|
+
},
|
|
74
|
+
|
|
75
|
+
"variants": {
|
|
76
|
+
inset: {
|
|
77
|
+
true: {
|
|
78
|
+
// eslint-disable-next-line @typescript-eslint/no-magic-numbers
|
|
79
|
+
paddingLeft: dimensionsPxToRem(37),
|
|
80
|
+
// eslint-disable-next-line @typescript-eslint/no-magic-numbers
|
|
81
|
+
paddingRight: dimensionsPxToRem(37),
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
selected: {
|
|
85
|
+
true: {
|
|
86
|
+
color: "$mainColor",
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
type StyledItemProps = React.ComponentProps<typeof StyledItem>;
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Represents a single item in a list.
|
|
96
|
+
*
|
|
97
|
+
* It has two subcomponents:
|
|
98
|
+
* - `Label`: for rendering the label with sublabel (usually on the left)
|
|
99
|
+
* - `Value`: for rendering the value (usually on the right)
|
|
100
|
+
*
|
|
101
|
+
* It can be however used with any children, its children are rendered in a flexbox container, `ratio` prop can be used
|
|
102
|
+
* to set the flex ratio of each child.
|
|
103
|
+
*
|
|
104
|
+
* It has two variants:
|
|
105
|
+
* - `inset`: which adds padding to the left and right side of the item - it should be used when the list is inset (it's
|
|
106
|
+
* applied automatically if used within `List` component)
|
|
107
|
+
* - `selected`: which renders an arrow on the left side, useful when creating a radio-like list (please note that not
|
|
108
|
+
* sending `selected` is different from sending `false`)
|
|
109
|
+
*
|
|
110
|
+
* It accepts few more props:
|
|
111
|
+
* - `href`: if given it will render an anchor tag with the given href
|
|
112
|
+
* - `to`: if given it will render an anchor tag wrapped in a link using the given `Link` component
|
|
113
|
+
* - `onClick`: if given it will render a button tag with the given onClick handler (it can be passed with `href` too)
|
|
114
|
+
*/
|
|
115
|
+
const Item: React.FC<StyledItemProps & Props> & SubComponents = ({ href, to, onClick, Link, ratio, ...props }) => {
|
|
116
|
+
const r = ratio ? ratio.split("/") : [];
|
|
49
117
|
|
|
50
|
-
const pre = typeof selected === "boolean"
|
|
51
|
-
? (
|
|
52
|
-
selected ? icon : noIcon
|
|
53
|
-
)
|
|
118
|
+
const pre = typeof props.selected === "boolean"
|
|
119
|
+
? (props.selected ? icon : noIcon)
|
|
54
120
|
: null;
|
|
55
121
|
|
|
56
|
-
const liProps = {
|
|
57
|
-
className: cls,
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
const r = ratio ? ratio.split("/") : [];
|
|
61
|
-
|
|
62
122
|
const ren = React.Children.map(props.children, (child, index) => {
|
|
63
123
|
let flex = undefined;
|
|
64
124
|
if (!r.length && child && typeof child === "object" && "type" in child && child.type === Value) {
|
|
@@ -75,28 +135,40 @@ const Item: React.FC<Props> & SubComponents = (props) => {
|
|
|
75
135
|
throw new TypeError("`to` prop given without `Link` component");
|
|
76
136
|
}
|
|
77
137
|
|
|
78
|
-
return
|
|
138
|
+
return (
|
|
139
|
+
<StyledItem {...props}>
|
|
140
|
+
<Link href={to}><StyledInnerContainer as={"a"} href={to}>{ren}</StyledInnerContainer></Link>
|
|
141
|
+
</StyledItem>
|
|
142
|
+
);
|
|
79
143
|
}
|
|
144
|
+
|
|
80
145
|
if (href) {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
146
|
+
return (
|
|
147
|
+
<StyledItem {...props}>
|
|
148
|
+
{/* eslint-disable-next-line react/jsx-handler-names */}
|
|
149
|
+
<StyledInnerContainer as={"a"} href={href} onClick={onClick}>{ren}</StyledInnerContainer>
|
|
150
|
+
</StyledItem>
|
|
151
|
+
);
|
|
86
152
|
}
|
|
153
|
+
|
|
87
154
|
if (onClick) {
|
|
88
155
|
return (
|
|
89
|
-
<
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
</li>
|
|
156
|
+
<StyledItem {...props}>
|
|
157
|
+
{/* eslint-disable-next-line react/jsx-handler-names */}
|
|
158
|
+
<StyledInnerContainer as={"button"} onClick={onClick}>{ren}</StyledInnerContainer>
|
|
159
|
+
</StyledItem>
|
|
94
160
|
);
|
|
95
161
|
}
|
|
96
|
-
|
|
162
|
+
|
|
163
|
+
return <StyledItem {...props}><StyledInnerContainer>{ren}</StyledInnerContainer></StyledItem>;
|
|
97
164
|
};
|
|
98
165
|
|
|
99
166
|
Item.Label = Label;
|
|
100
167
|
Item.Value = Value;
|
|
101
168
|
|
|
102
|
-
export { Item };
|
|
169
|
+
export { Item, ItemInnerContainerClassName };
|
|
170
|
+
|
|
171
|
+
export type {
|
|
172
|
+
Props as ItemProps,
|
|
173
|
+
SubComponents as ItemSubComponents,
|
|
174
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
import type { StoryObj, Meta } from "@storybook/react";
|
|
4
|
+
|
|
5
|
+
import { Label } from "./Label.js";
|
|
6
|
+
import { List } from "./List.js";
|
|
7
|
+
import { Item } from "./Item.js";
|
|
8
|
+
|
|
9
|
+
const meta: Meta = {
|
|
10
|
+
title: "Components/Layout/List/Label",
|
|
11
|
+
component: Label,
|
|
12
|
+
tags: ["autodocs", "layout"],
|
|
13
|
+
argTypes: {
|
|
14
|
+
sub: {
|
|
15
|
+
type: "string",
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
type Story = StoryObj<typeof Label>;
|
|
21
|
+
|
|
22
|
+
const Primary: Story = {
|
|
23
|
+
args: {
|
|
24
|
+
children: "I am a label",
|
|
25
|
+
sub: "Sub text",
|
|
26
|
+
},
|
|
27
|
+
render: (args) => {
|
|
28
|
+
return (
|
|
29
|
+
<List>
|
|
30
|
+
<Item>
|
|
31
|
+
<Label {...args} />
|
|
32
|
+
</Item>
|
|
33
|
+
<Item>
|
|
34
|
+
I am classic list item
|
|
35
|
+
</Item>
|
|
36
|
+
</List>
|
|
37
|
+
);
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export {
|
|
42
|
+
Primary,
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export default meta;
|
|
@@ -1,24 +1,33 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import type { ReactNode } from "react";
|
|
3
3
|
|
|
4
|
-
import
|
|
4
|
+
import { dimensionsPxToRem, fontPxToRem, styled } from "../../../theme.js";
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
const SubLabel = styled("div", {
|
|
7
|
+
// eslint-disable-next-line @typescript-eslint/no-magic-numbers
|
|
8
|
+
fontSize: fontPxToRem(27),
|
|
9
|
+
color: "$sub",
|
|
10
|
+
// eslint-disable-next-line @typescript-eslint/no-magic-numbers
|
|
11
|
+
marginTop: fontPxToRem(27 / 3),
|
|
12
|
+
});
|
|
7
13
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
14
|
+
const StyledLabel = styled("div", {
|
|
15
|
+
// eslint-disable-next-line @typescript-eslint/no-magic-numbers
|
|
16
|
+
padding: `${dimensionsPxToRem(54)} 0`,
|
|
17
|
+
});
|
|
13
18
|
|
|
14
|
-
|
|
15
|
-
const sub = props.sub ? <div className={styles.sub}>{props.sub}</div> : null;
|
|
19
|
+
type StyledLabelProps = React.ComponentProps<typeof StyledLabel>;
|
|
16
20
|
|
|
21
|
+
/**
|
|
22
|
+
* Use this to render a label within `Item`, optionally you can render a sublabel as well (with a tip message for
|
|
23
|
+
* example).
|
|
24
|
+
*/
|
|
25
|
+
const Label: React.FC<StyledLabelProps & { sub?: ReactNode }> = ({ sub, ...props }) => {
|
|
17
26
|
return (
|
|
18
|
-
<
|
|
27
|
+
<StyledLabel {...props}>
|
|
19
28
|
<div>{props.children}</div>
|
|
20
|
-
{sub}
|
|
21
|
-
</
|
|
29
|
+
{sub && <SubLabel>{sub}</SubLabel>}
|
|
30
|
+
</StyledLabel>
|
|
22
31
|
);
|
|
23
32
|
};
|
|
24
33
|
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
import type { StoryObj, Meta } from "@storybook/react";
|
|
4
|
+
|
|
5
|
+
import { Icon, ICON } from "../../icons/Icon.js";
|
|
6
|
+
|
|
7
|
+
import { List } from "./List.js";
|
|
8
|
+
|
|
9
|
+
const meta: Meta = {
|
|
10
|
+
title: "Components/Layout/List/List",
|
|
11
|
+
component: List,
|
|
12
|
+
tags: ["autodocs", "layout"],
|
|
13
|
+
argTypes: {
|
|
14
|
+
inset: {
|
|
15
|
+
type: "boolean",
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
type Story = StoryObj<typeof List>;
|
|
21
|
+
|
|
22
|
+
const Primary: Story = {
|
|
23
|
+
args: {
|
|
24
|
+
inset: false,
|
|
25
|
+
},
|
|
26
|
+
render: (args) => {
|
|
27
|
+
return (
|
|
28
|
+
<List {...args}>
|
|
29
|
+
<List.Item>I am a list item</List.Item>
|
|
30
|
+
<List.Item>I am a list item</List.Item>
|
|
31
|
+
</List>
|
|
32
|
+
);
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const FullFeaturedExample: Story = {
|
|
37
|
+
render: (args) => {
|
|
38
|
+
return (
|
|
39
|
+
<List>
|
|
40
|
+
<List.Header>GPS settings</List.Header>
|
|
41
|
+
<List.Item>
|
|
42
|
+
<List.Item.Label sub={"Higher precision means higher battery usage"}>
|
|
43
|
+
GPS precision
|
|
44
|
+
</List.Item.Label>
|
|
45
|
+
<List.Item.Value>
|
|
46
|
+
Low
|
|
47
|
+
</List.Item.Value>
|
|
48
|
+
<Icon name={ICON.forward} />
|
|
49
|
+
</List.Item>
|
|
50
|
+
<List.Item>
|
|
51
|
+
<List.Item>
|
|
52
|
+
Something
|
|
53
|
+
</List.Item>
|
|
54
|
+
</List.Item>
|
|
55
|
+
<List.Header>
|
|
56
|
+
Last trips
|
|
57
|
+
</List.Header>
|
|
58
|
+
<List.Item>
|
|
59
|
+
Portugal
|
|
60
|
+
</List.Item>
|
|
61
|
+
<List.Item>
|
|
62
|
+
<List.Item.Label sub={"Visited 2 times in last year"}>
|
|
63
|
+
Poland
|
|
64
|
+
</List.Item.Label>
|
|
65
|
+
</List.Item>
|
|
66
|
+
<List.Item>
|
|
67
|
+
Sweden
|
|
68
|
+
</List.Item>
|
|
69
|
+
<List.Header>
|
|
70
|
+
Choose one option
|
|
71
|
+
</List.Header>
|
|
72
|
+
<List.Item selected={true}>yes</List.Item>
|
|
73
|
+
<List.Item selected={false}>no</List.Item>
|
|
74
|
+
</List>
|
|
75
|
+
);
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
export {
|
|
80
|
+
Primary,
|
|
81
|
+
FullFeaturedExample,
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
export default meta;
|
|
@@ -1,47 +1,58 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
import { makeVariants } from "../../../utils/index.js";
|
|
3
|
+
import { pxToRem, styled } from "../../../theme.js";
|
|
6
4
|
|
|
7
5
|
import { Header } from "./Header.js";
|
|
8
6
|
import { Item } from "./Item.js";
|
|
9
|
-
import styles from "./List.module.scss";
|
|
10
|
-
|
|
11
|
-
type Variant = "inset";
|
|
12
|
-
|
|
13
|
-
interface Props {
|
|
14
|
-
className?: string;
|
|
15
|
-
variant?: Variant | Variant[];
|
|
16
|
-
children: React.ReactNode;
|
|
17
|
-
}
|
|
18
7
|
|
|
19
8
|
interface SubComponents {
|
|
20
9
|
Header: typeof Header;
|
|
10
|
+
Item: typeof Item;
|
|
21
11
|
}
|
|
22
12
|
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
13
|
+
const StyledList = styled("ul", {
|
|
14
|
+
// eslint-disable-next-line @typescript-eslint/no-magic-numbers
|
|
15
|
+
margin: `0 ${pxToRem(23)}`,
|
|
16
|
+
padding: 0,
|
|
17
|
+
|
|
18
|
+
variants: {
|
|
19
|
+
inset: {
|
|
20
|
+
true: {
|
|
21
|
+
margin: 0,
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
type StyledListProps = React.ComponentProps<typeof StyledList>;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Component for rendering menu lists.
|
|
31
|
+
*
|
|
32
|
+
* It has two subcomponents:
|
|
33
|
+
* - `Item`: for rendering list items
|
|
34
|
+
* - `Header`: for rendering list headers
|
|
35
|
+
*
|
|
36
|
+
* List has one variant: `inset`, which removes the margin from the list. If used it will be automatically applied to
|
|
37
|
+
* all children.
|
|
38
|
+
*
|
|
39
|
+
* See `Item` and `Header` for more information about their usage.
|
|
40
|
+
*/
|
|
41
|
+
const List: React.FC<StyledListProps> & SubComponents = (props) => {
|
|
26
42
|
const chld = React.Children.map(props.children, (child) => {
|
|
27
43
|
if (child && typeof child === "object" && "type" in child && (child.type === Item || child.type === Header)) {
|
|
28
44
|
return React.cloneElement(child, {
|
|
29
|
-
|
|
30
|
-
variant: props.variant,
|
|
45
|
+
inset: props.inset,
|
|
31
46
|
});
|
|
32
47
|
}
|
|
33
48
|
return child;
|
|
34
49
|
});
|
|
35
50
|
|
|
36
|
-
const cls = classnames(props.className, styles.list, {
|
|
37
|
-
[styles.inset]: v.includes("inset"),
|
|
38
|
-
});
|
|
39
|
-
|
|
40
51
|
return (
|
|
41
|
-
<
|
|
52
|
+
<StyledList {...props}>{chld}</StyledList>
|
|
42
53
|
);
|
|
43
54
|
};
|
|
44
|
-
|
|
45
55
|
List.Header = Header;
|
|
56
|
+
List.Item = Item;
|
|
46
57
|
|
|
47
58
|
export { List };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
import type { StoryObj, Meta } from "@storybook/react";
|
|
4
|
+
|
|
5
|
+
import { Value } from "./Value.js";
|
|
6
|
+
import { List } from "./List.js";
|
|
7
|
+
import { Item } from "./Item.js";
|
|
8
|
+
|
|
9
|
+
const meta: Meta = {
|
|
10
|
+
title: "Components/Layout/List/Value",
|
|
11
|
+
component: Value,
|
|
12
|
+
tags: ["autodocs", "layout"],
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
type Story = StoryObj<typeof Value>;
|
|
16
|
+
|
|
17
|
+
const Primary: Story = {
|
|
18
|
+
args: {
|
|
19
|
+
children: "23,4*C",
|
|
20
|
+
},
|
|
21
|
+
render: (args) => {
|
|
22
|
+
return (
|
|
23
|
+
<List>
|
|
24
|
+
<Item>
|
|
25
|
+
<div>Some label</div>
|
|
26
|
+
<Value {...args} />
|
|
27
|
+
</Item>
|
|
28
|
+
</List>
|
|
29
|
+
);
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export {
|
|
34
|
+
Primary,
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export default meta;
|
|
@@ -1 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
import { fontPxToRem, styled } from "../../../theme.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Use this to render a value within `Item`. It's most useful when used with `Item.Label`.
|
|
5
|
+
*/
|
|
6
|
+
const Value = styled("div", {
|
|
7
|
+
color: "$icon",
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/no-magic-numbers
|
|
9
|
+
fontSize: fontPxToRem(26),
|
|
10
|
+
display: "flex",
|
|
11
|
+
justifyContent: "flex-end",
|
|
12
|
+
flex: 1,
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
export { Value };
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
import type { StoryObj, Meta } from "@storybook/react";
|
|
4
|
+
|
|
5
|
+
import { List } from "../list/List.js";
|
|
6
|
+
import { Item } from "../list/Item.js";
|
|
7
|
+
|
|
8
|
+
import { Section } from "./Section.js";
|
|
9
|
+
|
|
10
|
+
const meta: Meta = {
|
|
11
|
+
title: "Components/Layout/Section",
|
|
12
|
+
component: Section,
|
|
13
|
+
tags: ["autodocs", "layout"],
|
|
14
|
+
argTypes: {
|
|
15
|
+
vertical: {
|
|
16
|
+
type: "boolean",
|
|
17
|
+
},
|
|
18
|
+
horizontal: {
|
|
19
|
+
type: "boolean",
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
type Story = StoryObj<typeof Section>;
|
|
25
|
+
|
|
26
|
+
const Primary: Story = {
|
|
27
|
+
args: {},
|
|
28
|
+
render: (args) => (
|
|
29
|
+
<div style={{ border: "1px solid #ddd" }}>
|
|
30
|
+
<Section.Container>
|
|
31
|
+
<Section {...args}>
|
|
32
|
+
This is an example section, arguments in the arguments table are applied only to this
|
|
33
|
+
section. By default sections do not have any padding, so you can place elements that should touch
|
|
34
|
+
the edges. Use `vertical` and `horizontal` arguments to add padding.
|
|
35
|
+
</Section>
|
|
36
|
+
<Section vertical={true} horizontal={true}>
|
|
37
|
+
Some section
|
|
38
|
+
</Section>
|
|
39
|
+
<Section>
|
|
40
|
+
<List>
|
|
41
|
+
<Item>Some item</Item>
|
|
42
|
+
<Item>Some item</Item>
|
|
43
|
+
</List>
|
|
44
|
+
</Section>
|
|
45
|
+
</Section.Container>
|
|
46
|
+
</div>
|
|
47
|
+
),
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export {
|
|
51
|
+
Primary,
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export default meta;
|