Skip to content

Commit 59e969e

Browse files
authored
Extract InfoListItem into its own component, scope sibling spacing (#329)
1 parent 6fe9284 commit 59e969e

File tree

6 files changed

+52
-16
lines changed

6 files changed

+52
-16
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { VuiFlexContainer, VuiInfoListItem } from "../../../lib";
2+
3+
export const HorizontalList = () => {
4+
return (
5+
<VuiFlexContainer direction="row" spacing="l">
6+
<VuiInfoListItem title="Email" value="[email protected]" />
7+
<VuiInfoListItem title="Account number" value="1234567890" />
8+
<VuiInfoListItem title="Account size" value="22 MB" />
9+
</VuiFlexContainer>
10+
);
11+
};

src/docs/pages/infoList/index.tsx

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,22 @@
11
import { InfoList } from "./InfoList";
2+
import { HorizontalList } from "./HorizontalList";
3+
24
const InfoListSource = require("!!raw-loader!./InfoList");
5+
const HorizontalListSource = require("!!raw-loader!./HorizontalList");
36

47
export const infoList = {
58
name: "Info List",
69
path: "/InfoList",
7-
example: {
8-
component: <InfoList />,
9-
source: InfoListSource.default.toString()
10-
}
10+
examples: [
11+
{
12+
name: "Vertical",
13+
component: <InfoList />,
14+
source: InfoListSource.default.toString()
15+
},
16+
{
17+
name: "Horizontal",
18+
component: <HorizontalList />,
19+
source: HorizontalListSource.default.toString()
20+
}
21+
]
1122
};

src/lib/components/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ import { ICON_COLOR, ICON_SIZE, ICON_TYPE } from "./icon/types";
5151
import { VuiImage } from "./image/Image";
5252
import { VuiImagePreview } from "./image/ImagePreview";
5353
import { InfoListType, VuiInfoList } from "./infoList/InfoList";
54+
import { InfoListItemType, VuiInfoListItem } from "./infoList/InfoListItem";
5455
import { VuiInfoMenu } from "./infoMenu/InfoMenu";
5556
import { VuiInfoTable, InfoTableColumnAlign, InfoTableRow, InfoTableRowType } from "./infoTable/InfoTable";
5657
import { VuiInProgress } from "./inProgress/InProgress";
@@ -114,6 +115,7 @@ export type {
114115
ChatStyle,
115116
ChatTurn,
116117
CodeLanguage,
118+
InfoListItemType,
117119
InfoListType,
118120
InfoTableColumnAlign,
119121
InfoTableRow,
@@ -192,6 +194,7 @@ export {
192194
VuiImage,
193195
VuiImagePreview,
194196
VuiInfoList,
197+
VuiInfoListItem,
195198
VuiInfoMenu,
196199
VuiInfoTable,
197200
VuiInProgress,
Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,17 @@
1-
export type InfoListType = Array<{
2-
title: string;
3-
value: React.ReactNode;
4-
}>;
1+
import { InfoListItemType, VuiInfoListItem } from "./InfoListItem";
2+
3+
export type InfoListType = Array<InfoListItemType>;
54

65
type Props = {
76
info: InfoListType;
87
};
98

109
export const VuiInfoList = ({ info }: Props) => {
1110
return (
12-
<>
11+
<div className="vuiInfoList">
1312
{info.map((item, index) => (
14-
<div key={index} className="vuiInfoListItem">
15-
<div className="vuiInfoListItem__title">{item.title}</div>
16-
<div className="vuiInfoListItem__value">{item.value}</div>
17-
</div>
13+
<VuiInfoListItem key={index} title={item.title} value={item.value} />
1814
))}
19-
</>
15+
</div>
2016
);
2117
};
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
export type InfoListItemType = {
2+
title: string;
3+
value: React.ReactNode;
4+
};
5+
6+
type Props = InfoListItemType;
7+
8+
export const VuiInfoListItem = ({ title, value }: Props) => {
9+
return (
10+
<div className="vuiInfoListItem">
11+
<div className="vuiInfoListItem__title">{title}</div>
12+
<div className="vuiInfoListItem__value">{value}</div>
13+
</div>
14+
);
15+
};

src/lib/components/infoList/_index.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
.vuiInfoListItem {
2-
& + & {
1+
.vuiInfoList {
2+
.vuiInfoListItem + .vuiInfoListItem {
33
margin-top: $sizeM;
44
}
55
}

0 commit comments

Comments
 (0)