Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(list): fix list item spacing #598

Merged
merged 2 commits into from
Dec 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/components/src/components/list/list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class SelectList extends React.Component<SelectListProps & ConfigConsumerProps>
key={option.label}
name={option.label}
option={option}
style={{ ...style, height: (style.height as number) - 4, paddingTop: index !== 0 ? '16px' : '0px' }}
style={{ ...style, height: (style.height as number) - 4, paddingTop: index !== 0 ? '20px' : '0px' }}
icon={groupIcon}
isSelected={this.getSelected(option)}
isMultiple={!!isMultiple}
Expand Down
14 changes: 12 additions & 2 deletions packages/components/src/components/list/style/option.less
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,25 @@
&.group {
padding: 0 15px 0 15px;
font-size: 12px;
line-height: inherit;
line-height: 20.5px;
}

&.group:not(:nth-child(1)) {
border-top: 1px solid #ebedf5;
border-top: 0;
border-top-left-radius: 0;
border-top-right-radius: 0;
}

&.group:not(:nth-child(1))::before {
position: absolute;
top: 4px;
left: 0;
width: 100%;
height: 1px;
background: #ebedf5;
content: '';
}

&.indented {
padding-left: 43px;
}
Expand Down
13 changes: 2 additions & 11 deletions packages/website/src/components/functional/list/demo/avatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,8 @@ const WrapperStyle = {
const optionWrapper = {
display: 'flex',
alignItems: 'center',
height:'60px'
};

const getRowHeight = (option: any) => {
if (option.type === 'groupLabel') {
return 34;
}

return 60;
};

const labelRenderer = (option: any, isGroup: boolean) => {
if (isGroup) {
return option.name;
Expand All @@ -62,15 +54,14 @@ const labelRenderer = (option: any, isGroup: boolean) => {
export default () => (
<>
<div style={WrapperStyle} className="gio-list_avatar">
<List dataSource={options} width={220} labelRenderer={labelRenderer} rowHeight={getRowHeight} />
<List dataSource={options} width={220} labelRenderer={labelRenderer} />
</div>
<div style={{ display: 'inline-block', width: 20 }} />
<div style={WrapperStyle} className="gio-list_avatar">
<List
dataSource={options}
width={220}
labelRenderer={labelRenderer}
rowHeight={getRowHeight}
isMultiple
value={['a']}
/>
Expand Down