-
Notifications
You must be signed in to change notification settings - Fork 1.4k
feat: S2 ListView HCM #9760
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
feat: S2 ListView HCM #9760
Changes from all commits
866c574
242dfbf
134701d
8415194
9c97841
4bdb3ad
a98458f
0d42e3b
08bd38a
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 |
|---|---|---|
|
|
@@ -289,9 +289,15 @@ const listitem = style<GridListItemRenderProps & { | |
| color: { | ||
| default: baseColor('neutral-subdued'), | ||
| isSelected: baseColor('neutral'), | ||
| isDisabled: { | ||
| default: 'disabled', | ||
| forcedColors: 'GrayText' | ||
| isDisabled: 'disabled', | ||
| forcedColors: { | ||
| default: 'ButtonText', | ||
| selectionStyle: { | ||
| highlight: { | ||
| isSelected: 'HighlightText' | ||
| } | ||
| }, | ||
| isDisabled: 'GrayText' | ||
| } | ||
| }, | ||
| position: 'relative', | ||
|
|
@@ -346,12 +352,14 @@ const listitem = style<GridListItemRenderProps & { | |
| borderColor: { | ||
| default: '--borderColor', | ||
| isNextSelected: 'transparent', | ||
| isSelected: 'transparent' | ||
| isSelected: 'transparent', | ||
| forcedColors: 'ButtonBorder' | ||
| }, | ||
| '--radius': { | ||
| type: 'borderTopStartRadius', | ||
| value: 'default' | ||
| } | ||
| }, | ||
| forcedColorAdjust: 'none' | ||
| }); | ||
|
|
||
| const insetBorderRadius = 'calc(var(--radius) - 1px)'; | ||
|
|
@@ -373,7 +381,8 @@ const listRowBackground = style<GridListItemRenderProps & { | |
| isSelected: '[-1px]', | ||
| // Don't overlap focus ring of row above. | ||
| isPrevSelected: 0, | ||
| isFirstItem: 0 | ||
| isFirstItem: 0, | ||
| forcedColors: 0 | ||
| }, | ||
| left: 0, | ||
| right: 0, | ||
|
|
@@ -412,7 +421,12 @@ const listRowBackground = style<GridListItemRenderProps & { | |
| } | ||
| }, | ||
| forcedColors: { | ||
| default: 'Background' | ||
| default: 'Background', | ||
| selectionStyle: { | ||
| highlight: { | ||
| isSelected: 'Highlight' | ||
| } | ||
| } | ||
| } | ||
| }, | ||
| borderTopStartRadius: { | ||
|
|
@@ -513,9 +527,34 @@ const listRowBackground = style<GridListItemRenderProps & { | |
| } | ||
| }); | ||
|
|
||
| let listRowFocusRing = style({ | ||
| let listRowFocusRing = style<GridListItemRenderProps & { | ||
| selectionStyle?: 'highlight' | 'checkbox', | ||
| isFirstItem?: boolean, | ||
| isPrevSelected?: boolean, | ||
| isPrevNotSelected?: boolean, | ||
| isNextSelected?: boolean, | ||
| isNextNotSelected?: boolean, | ||
| isLastItem?: boolean, | ||
| isQuiet?: boolean | ||
| }>({ | ||
| ...focusRing(), | ||
| outlineOffset: -2, | ||
| outlineOffset: { | ||
|
Member
Author
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 like this "style" in HCM? or is it not clear enough?
Member
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. i think it's fine for now? it's def better than using the normal focus ring hcm and i can tell that it's a little thicker |
||
| default: -2, | ||
| forcedColors: -3 | ||
| }, | ||
| outlineWidth: { | ||
| default: 2, | ||
| forcedColors: '[3px]' | ||
| }, | ||
| outlineColor: { | ||
| default: 'focus-ring', | ||
| forcedColors: { | ||
| default: 'Highlight', | ||
| selectionStyle: { | ||
| highlight: 'ButtonBorder' | ||
| } | ||
| } | ||
| }, | ||
| position: 'absolute', | ||
| inset: 0, | ||
| top: { | ||
|
|
@@ -567,7 +606,8 @@ export let description = style({ | |
| font: 'ui-sm', | ||
| color: { | ||
| default: baseColor('neutral-subdued'), | ||
| isDisabled: 'disabled' | ||
| isDisabled: 'disabled', | ||
| forcedColors: 'inherit' | ||
| }, | ||
| transition: 'default' | ||
| }); | ||
|
|
@@ -770,7 +810,7 @@ export function ListViewItem(props: ListViewItemProps): ReactNode { | |
| isLastItem: isLastItem(id, state) | ||
| }) | ||
| } /> | ||
| {renderProps.isFocusVisible && | ||
| {renderProps.isFocusVisible && | ||
| <div | ||
| className={listRowFocusRing({ | ||
| ...renderProps, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -366,6 +366,23 @@ describe('style-macro', () => { | |
| expect(js({isSelected: true})).toMatchInlineSnapshot('" ple12 -macro-dynamic-37zkvn"'); | ||
| }); | ||
|
|
||
| it('inherits parent default when nested branch has no default key', () => { | ||
|
Member
Author
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. How do people feel about changing the style macro to support inheriting the nearest default? I think it makes more sense and I've continually forgotten about it.
Member
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. yeah i've run into this too |
||
| let {css, js} = testStyle({ | ||
| color: { | ||
| forcedColors: { | ||
| default: 'ButtonText', | ||
| variant: { | ||
| highlight: {isSelected: 'HighlightText'} | ||
| } | ||
| } | ||
| } | ||
| }); | ||
| // forcedColors.default should apply when variant=highlight but !isSelected | ||
| expect(css).toContain('ButtonText'); | ||
| expect(js({variant: 'highlight'})).toMatchInlineSnapshot('" plb12 -macro-dynamic-1owjb9s"'); | ||
| expect(js({variant: 'highlight', isSelected: true})).toMatchInlineSnapshot('" ple12 -macro-dynamic-37zkvn"'); | ||
| }); | ||
|
|
||
| it('should expand shorthand properties to longhands', () => { | ||
| let {js, css} = testStyle({ | ||
| padding: 24 | ||
|
|
||
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.
Should the description text styles match the label text styles?