Skip to content

Commit f7a9a45

Browse files
List: Reduce default space (#1625)
Co-authored-by: Michael Taranto <[email protected]>
1 parent 5b12769 commit f7a9a45

File tree

3 files changed

+69
-8
lines changed

3 files changed

+69
-8
lines changed

.changeset/witty-donuts-sort.md

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
'braid-design-system': major
3+
---
4+
5+
---
6+
updated:
7+
- List
8+
---
9+
10+
**List**: Reduce default space between list items
11+
12+
Reduce the default space between list items from `medium` to `small` or `xsmall` if the `size` prop is set to either `small` or `xsmall`.

packages/braid-design-system/src/lib/components/List/List.docs.tsx

+51-7
Original file line numberDiff line numberDiff line change
@@ -113,40 +113,84 @@ const docs: ComponentDocs = {
113113
),
114114
},
115115
{
116-
label: 'Tone, size and space',
116+
label: 'Tone and size',
117117
description: (
118118
<Text>
119119
Lists support the same sizes and tones as{' '}
120-
<TextLink href="/components/Text">Text</TextLink>, and the same
121-
spacing as <TextLink href="/components/Stack">Stack</TextLink>.
120+
<TextLink href="/components/Text">Text</TextLink>.
122121
</Text>
123122
),
124123
Example: () =>
125124
source(
126125
<Columns space="large" collapseBelow="desktop">
127126
<Column>
128-
<List tone="secondary" size="large" space="gutter">
127+
<List tone="secondary" size="large">
129128
<Text>Large</Text>
130129
<Text>Large</Text>
131130
<Text>Large</Text>
132131
</List>
133132
</Column>
134133
<Column>
135-
<List tone="secondary" size="standard" space="medium">
134+
<List tone="secondary" size="standard">
136135
<Text>Standard</Text>
137136
<Text>Standard</Text>
138137
<Text>Standard</Text>
139138
</List>
140139
</Column>
141140
<Column>
142-
<List tone="secondary" size="small" space="small">
141+
<List tone="secondary" size="small">
143142
<Text>Small</Text>
144143
<Text>Small</Text>
145144
<Text>Small</Text>
146145
</List>
147146
</Column>
148147
<Column>
149-
<List tone="secondary" size="xsmall" space="small">
148+
<List tone="secondary" size="xsmall">
149+
<Text>Xsmall</Text>
150+
<Text>Xsmall</Text>
151+
<Text>Xsmall</Text>
152+
</List>
153+
</Column>
154+
</Columns>,
155+
),
156+
},
157+
{
158+
label: 'Spacing',
159+
description: (
160+
<Text>
161+
By default, Lists will use <Strong>small</Strong> spacing, or{' '}
162+
<Strong>xsmall</Strong> spacing if the <Strong>size</Strong> prop is
163+
set to either <Strong>small</Strong> or <Strong>xsmall</Strong>. This
164+
can be changed via the <Strong>space</Strong> prop, which supports the
165+
same spacing as <TextLink href="/components/Stack">Stack</TextLink>.
166+
</Text>
167+
),
168+
Example: () =>
169+
source(
170+
<Columns space="large" collapseBelow="desktop">
171+
<Column>
172+
<List space="large">
173+
<Text>Large</Text>
174+
<Text>Large</Text>
175+
<Text>Large</Text>
176+
</List>
177+
</Column>
178+
<Column>
179+
<List space="medium">
180+
<Text>Standard</Text>
181+
<Text>Standard</Text>
182+
<Text>Standard</Text>
183+
</List>
184+
</Column>
185+
<Column>
186+
<List space="small">
187+
<Text>Small</Text>
188+
<Text>Small</Text>
189+
<Text>Small</Text>
190+
</List>
191+
</Column>
192+
<Column>
193+
<List space="xsmall">
150194
<Text>Xsmall</Text>
151195
<Text>Xsmall</Text>
152196
<Text>Xsmall</Text>

packages/braid-design-system/src/lib/components/List/List.tsx

+6-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ export const List = ({
9898
children,
9999
size: sizeProp,
100100
tone: toneProp,
101-
space = 'medium',
101+
space: spaceProp,
102102
type = 'bullet',
103103
start = 1,
104104
data,
@@ -108,6 +108,11 @@ export const List = ({
108108
size: sizeProp,
109109
tone: toneProp,
110110
});
111+
112+
const defaultSpace =
113+
size === 'xsmall' || size === 'small' ? 'xsmall' : 'small';
114+
const space = spaceProp || defaultSpace;
115+
111116
const listItems = flattenChildren(children) as ReactNodeNoStrings[];
112117
const lastNumberLength =
113118
type === 'number' ? (listItems.length + (start - 1)).toString().length : -1;

0 commit comments

Comments
 (0)