Skip to content

Commit fed1d9e

Browse files
committed
[List] Add spacing property
1 parent 81fd3fd commit fed1d9e

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

polaris-react/src/components/List/List.scss

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
}
1616

1717
.Item {
18-
margin-bottom: var(--p-space-2);
19-
2018
&:last-child {
2119
margin-bottom: 0;
2220
}
@@ -25,3 +23,9 @@
2523
margin-top: var(--p-space-2);
2624
}
2725
}
26+
27+
.spacingLoose {
28+
.Item {
29+
margin-bottom: var(--p-space-2);
30+
}
31+
}

polaris-react/src/components/List/List.stories.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,13 @@ export function Numbered() {
2525
</List>
2626
);
2727
}
28+
29+
export function ExtraTight() {
30+
return (
31+
<List spacing="extraTight">
32+
<List.Item>First item</List.Item>
33+
<List.Item>Second item</List.Item>
34+
<List.Item>Third Item</List.Item>
35+
</List>
36+
);
37+
}

polaris-react/src/components/List/List.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,14 @@ import styles from './List.scss';
77

88
type Type = 'bullet' | 'number';
99

10+
type Spacing = 'extraTight' | 'loose';
11+
1012
export interface ListProps {
13+
/**
14+
* Determines the space between list items
15+
* @default 'loose'
16+
*/
17+
spacing?: Spacing;
1118
/**
1219
* Type of list to display
1320
* @default 'bullet'
@@ -19,9 +26,10 @@ export interface ListProps {
1926

2027
export const List: React.FunctionComponent<ListProps> & {
2128
Item: typeof Item;
22-
} = function List({children, type = 'bullet'}: ListProps) {
29+
} = function List({children, spacing = 'loose', type = 'bullet'}: ListProps) {
2330
const className = classNames(
2431
styles.List,
32+
spacing && styles[variationName('spacing', spacing)],
2533
type && styles[variationName('type', type)],
2634
);
2735

0 commit comments

Comments
 (0)