Skip to content

Commit

Permalink
ActionList: Visual update for disabled Items (#1629)
Browse files Browse the repository at this point in the history
* add styles for disabled state

* Create actionlist-disabled-items.md
  • Loading branch information
siddharthkp authored Nov 19, 2021
1 parent 250e4b0 commit 47fdbf4
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
5 changes: 5 additions & 0 deletions .changeset/actionlist-disabled-items.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@primer/components": patch
---

ActionList: Visual update for disabled Items to make them more obvious
11 changes: 7 additions & 4 deletions src/ActionList2/Description.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ export type DescriptionProps = {

export const Description: React.FC<DescriptionProps> = ({variant = 'inline', sx = {}, ...props}) => {
const styles = {
color: 'fg.muted',
fontSize: 0,
lineHeight: '16px',
flexGrow: 1,
Expand All @@ -27,15 +26,19 @@ export const Description: React.FC<DescriptionProps> = ({variant = 'inline', sx

return (
<Slot name={variant === 'block' ? 'BlockDescription' : 'InlineDescription'}>
{({blockDescriptionId, inlineDescriptionId}: ItemContext) =>
{({blockDescriptionId, inlineDescriptionId, disabled}: ItemContext) =>
variant === 'block' ? (
<Box as="span" sx={merge(styles, sx as SxProp)} id={blockDescriptionId}>
<Box
as="span"
sx={merge({...styles, color: disabled ? 'fg.disabled' : 'fg.muted'}, sx as SxProp)}
id={blockDescriptionId}
>
{props.children}
</Box>
) : (
<Truncate
id={inlineDescriptionId}
sx={merge(styles, sx as SxProp)}
sx={merge({...styles, color: disabled ? 'fg.disabled' : 'fg.muted'}, sx as SxProp)}
title={props.children as string}
inline={true}
maxWidth="100%"
Expand Down
11 changes: 6 additions & 5 deletions src/ActionList2/Item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import {Selection} from './Selection'
export const getVariantStyles = (variant: ItemProps['variant'], disabled: ItemProps['disabled']) => {
if (disabled) {
return {
color: 'fg.muted',
iconColor: 'fg.muted',
annotationColor: 'fg.muted'
color: 'primer.fg.disabled',
iconColor: 'primer.fg.disabled',
annotationColor: 'primer.fg.disabled'
}
}

Expand Down Expand Up @@ -114,8 +114,9 @@ export const Item = React.forwardRef<HTMLLIElement, ItemProps>(
borderRadius: listVariant === 'inset' ? 2 : 0,
transition: 'background 33.333ms linear',
color: getVariantStyles(variant, disabled).color,
textDecoration: 'none', // for as="a"
':not([aria-disabled])': {cursor: 'pointer'},
cursor: 'pointer',
'&[aria-disabled]': {cursor: 'not-allowed'},

'@media (hover: hover) and (pointer: fine)': {
':hover:not([aria-disabled])': {
backgroundColor: `actionListItem.${variant}.hoverBg`,
Expand Down

0 comments on commit 47fdbf4

Please sign in to comment.