-
Notifications
You must be signed in to change notification settings - Fork 537
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
Adds NavList.GroupHeading component #5106
Changes from 6 commits
fce0940
fb57717
4f26784
d178119
b485e2d
38c76a0
0feefef
d372356
93fc0f3
5765a19
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/react': minor | ||
--- | ||
|
||
Adds NavList.GroupHeading component that can be used instead of the ActionList.Group 'title' prop if you need to render something besides a string |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ import type { | |
ActionListDividerProps, | ||
ActionListLeadingVisualProps, | ||
ActionListTrailingVisualProps, | ||
ActionListGroupHeadingProps, | ||
} from '../ActionList' | ||
import {ActionList} from '../ActionList' | ||
import {ActionListContainerContext} from '../ActionList/ActionListContainerContext' | ||
|
@@ -290,6 +291,31 @@ const Group: React.FC<NavListGroupProps> = ({title, children, sx: sxProp = defau | |
|
||
Group.displayName = 'NavList.Group' | ||
|
||
export type NavListGroupHeadingProps = ActionListGroupHeadingProps | ||
|
||
/** | ||
* This is an alternative to the `title` prop on `NavList.Group`. | ||
* It was primarily added to allow links in group headings. | ||
*/ | ||
const GroupHeading: React.FC<NavListGroupHeadingProps> = ({sx: sxProp = defaultSxProp, ...rest}) => { | ||
return ( | ||
<ActionList.GroupHeading | ||
as="h3" | ||
sx={merge<SxProp['sx']>( | ||
{ | ||
'> a {': { | ||
color: 'var(--fgColor-default)', | ||
textDecoration: 'inherit', | ||
':hover': {textDecoration: 'underline'}, | ||
}, | ||
}, | ||
sxProp, | ||
)} | ||
Comment on lines
+316
to
+325
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. Do we still want to use 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. Is it possible to use regular CSS for component styling in PRC yet? 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. If you're adding new styles I think it's safe to go directly to CSS modules. The risk is entirely around the fact that there could be other styles in dotcom relying on the existing sx styling architecture. |
||
{...rest} | ||
/> | ||
) | ||
} | ||
|
||
// ---------------------------------------------------------------------------- | ||
// Export | ||
|
||
|
@@ -301,4 +327,5 @@ export const NavList = Object.assign(Root, { | |
TrailingAction, | ||
Divider, | ||
Group, | ||
GroupHeading, | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(nit) optional suggestion:
from line 285:
Maybe this is a good opportunity to do that here? (take
as
as a prop that defaults toh3
and can be overriden if necessary). We could then use this same component for thetitle
prop instead ofActionList.GroupHeading
as well 🤔Wouldn't make the
title
's prop heading level itself configurable, but might offer an alternative manually through the newGroupHeading