Skip to content

Commit c30961a

Browse files
committed
feat(list): add bordered style
1 parent f0ca636 commit c30961a

File tree

4 files changed

+48
-7
lines changed

4 files changed

+48
-7
lines changed

src/components/List/List.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export type ListProps = {
99
export const List: React.FC<ListProps> = (props) => {
1010
const { bordered = false, className, children } = props;
1111
return (
12-
<div className={clsx('List', { bordered }, className)} role="list">
12+
<div className={clsx('List', { 'List--bordered': bordered }, className)} role="list">
1313
{children}
1414
</div>
1515
);

src/components/List/style.less

+11-6
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
.List {
2-
background: var(--white);
2+
background: @list-bg;
3+
4+
&--bordered {
5+
border: @list-border-width solid @list-border-color;
6+
border-radius: @list-border-radius;
7+
}
38
}
49

510
.ListItem {
611
display: flex;
712
align-items: center;
8-
padding: 10px 15px;
9-
border-top: 1px solid var(--gray-7);
10-
color: var(--gray-1);
13+
padding: @list-item-padding;
14+
border-top: @list-border-width solid @list-border-color;
15+
color: @list-item-color;
1116
transition: 0.3s;
1217

1318
&:first-child {
@@ -16,8 +21,8 @@
1621
}
1722

1823
a.ListItem:hover {
19-
background: var(--light-2);
20-
color: var(--brand-1);
24+
background: @list-item-hover-bg;
25+
color: @list-item-hover-color;
2126
cursor: pointer;
2227
}
2328

src/styles/var.less

+11
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,17 @@
115115
@btn-float-box-shadow: var(--shadow-4);
116116
@btn-float-color: var(--brand-1);
117117

118+
// List
119+
@list-bg: var(--white);
120+
@list-border-width: @border-width;
121+
@list-border-color: var(--gray-7);
122+
@list-border-radius: 2px;
123+
124+
@list-item-padding: 10px 15px;
125+
@list-item-color: var(--gray-1);
126+
@list-item-hover-bg: var(--light-2);
127+
@list-item-hover-color: var(--brand-1);
128+
118129
// Navbar
119130
@navbar-height: 44px;
120131
@navbar-padding: 0 6px;

storybook/stories/List.stories.tsx

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import React from 'react';
2+
import { Story, Meta } from '@storybook/react/types-6-0';
3+
4+
import { List, ListItem, ListProps, ListItemProps } from '../../src';
5+
import '../../src/styles/index.less';
6+
7+
export default {
8+
title: 'List',
9+
component: List,
10+
argTypes: {
11+
bordered: { control: 'boolean' },
12+
},
13+
} as Meta;
14+
15+
export const Empty: Story<ListProps> = (args) => <List {...args} />;
16+
17+
export const ManyItems = (args: ListProps) => {
18+
return (
19+
<List {...args}>
20+
<ListItem content="item-1" />
21+
<ListItem content="item-2" />
22+
<ListItem content="item-3" />
23+
</List>
24+
);
25+
};

0 commit comments

Comments
 (0)