-
Notifications
You must be signed in to change notification settings - Fork 616
ActionList Composable API #1517
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
Changes from all commits
0876cef
6866c09
4d9d014
9119eea
e519b85
2224f84
fed8f51
0630556
4d1cc22
1c3ce94
b07feef
a6acb35
4dae4c7
ef8f3a2
cfd7e2d
1748dcf
bcdff11
a07abf3
0fc658d
2f3a8cd
0260e3a
72ef62d
d065a63
a82a3c5
1d57ed1
b7926ce
6a7110e
f69b7d5
3f77738
5ad3004
5c46373
d775083
901c109
769edb2
6840f12
ae97e51
199605e
be70024
8af4571
fce4049
249936a
3eb2c3e
c14da85
15334ef
69190d9
9462f46
fe56433
32a729d
00cbf63
2358926
9a9489e
569f633
868ebfd
fd99704
4d782d7
01ae72d
1b1d393
39cdf97
5bcb3a6
b08807d
96eb536
a8cf98e
dcc3baf
4acaa54
e5ae5e4
897d308
19b430b
853569c
8473500
9cb3517
01eab7c
4bd3c2d
f76d9c5
ee9b795
2ef3be1
76007b2
a86b13b
31b6809
3b83549
15ae268
c5cdff5
2541c94
8e538c0
02168c1
9672f10
0d97f39
1cd0d32
3dc13a2
2d13781
e8c3a5d
12da5b1
4870da1
b8ded7b
143e4c6
221edfe
5fb716d
cace4bb
99caa36
605044c
c812437
cacaec9
0e66876
dee7775
d16d2d9
ca4e451
1be1095
93561e7
4809068
0d0d1cb
5f38e76
1432420
9d14e5a
71bc34e
bacd12c
859008e
6d6ddf5
3cfc4f7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@primer/components': minor | ||
--- | ||
|
||
Add experimental `ActionList` with composable API |
Large diffs are not rendered by default.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import React from 'react' | ||
import Box from '../Box' | ||
import {SxProp, merge} from '../sx' | ||
import Truncate from '../Truncate' | ||
import {Slot, ItemContext} from './Item' | ||
|
||
export type DescriptionProps = { | ||
/** | ||
* Secondary text style variations. | ||
* | ||
* - `"inline"` - Secondary text is positioned beside primary text. | ||
* - `"block"` - Secondary text is positioned below primary text. | ||
*/ | ||
variant?: 'inline' | 'block' | ||
siddharthkp marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} & SxProp | ||
|
||
export const Description: React.FC<DescriptionProps> = ({variant = 'inline', sx = {}, ...props}) => { | ||
const styles = { | ||
color: 'fg.muted', | ||
fontSize: 0, | ||
lineHeight: '16px', | ||
flexGrow: 1, | ||
flexBasis: 0, | ||
minWidth: 0, | ||
marginLeft: variant === 'block' ? 0 : 2 | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💁♀️ Note: New component style: Using I'd like to make this more of a pattern, where we compose our components like Box and Text and the |
||
|
||
return ( | ||
<Slot name={variant === 'block' ? 'BlockDescription' : 'InlineDescription'}> | ||
{({blockDescriptionId, inlineDescriptionId}: ItemContext) => | ||
variant === 'block' ? ( | ||
<Box as="span" sx={merge(styles, sx as SxProp)} id={blockDescriptionId}> | ||
{props.children} | ||
</Box> | ||
) : ( | ||
<Truncate | ||
id={inlineDescriptionId} | ||
sx={merge(styles, sx as SxProp)} | ||
title={props.children as string} | ||
inline={true} | ||
maxWidth="100%" | ||
> | ||
{props.children} | ||
</Truncate> | ||
) | ||
} | ||
</Slot> | ||
) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import React from 'react' | ||
import Box from '../Box' | ||
import {get} from '../constants' | ||
import {Theme} from '../ThemeProvider' | ||
|
||
/** | ||
* Visually separates `Item`s or `Group`s in an `ActionList`. | ||
*/ | ||
export function Divider(): JSX.Element { | ||
return ( | ||
<Box | ||
as="li" | ||
role="separator" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TIL I assume this means assistive technology will be smart enough not to count this when it tells the user how many items are in the list? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure if it's consistent across screen readers. Will have more info after a11y audit this week :) |
||
sx={{ | ||
height: 1, | ||
backgroundColor: 'actionListItem.inlineDivider', | ||
marginTop: (theme: Theme) => `calc(${get('space.2')(theme)} - 1px)`, | ||
marginBottom: 2, | ||
listStyle: 'none' // hide the ::marker inserted by browser's stylesheet | ||
}} | ||
data-component="ActionList.Divider" | ||
siddharthkp marked this conversation as resolved.
Show resolved
Hide resolved
|
||
/> | ||
) | ||
} |
Uh oh!
There was an error while loading. Please reload this page.