-
Notifications
You must be signed in to change notification settings - Fork 535
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New ActionList component, bundled in @primer/components/unreleased Co-authored-by: Jonathan Fuchs <jfuchs@github.com> Co-authored-by: Cole Bemis <colebemis@github.com>
- Loading branch information
1 parent
8d3d491
commit 561c0bd
Showing
25 changed files
with
2,762 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' | ||
} & 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 | ||
} | ||
|
||
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> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
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" | ||
/> | ||
) | ||
} |
Oops, something went wrong.