-
Notifications
You must be signed in to change notification settings - Fork 205
refactor: Apply padding to option-content-div instead of selectable-item outer-div #4070
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 17 commits
456ebf7
72f67d4
0ef250b
c92571d
6bbd824
4d9ed48
edbdcf8
08c816f
a47c0d8
1a5e12d
fea65f8
537bdcf
2c100cd
931e7dc
aae6750
aa6681a
d3fcd3d
858ad32
1c79026
5ec8b6b
0f14628
bc825d9
b87a2b4
fecea21
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 |
|---|---|---|
|
|
@@ -29,6 +29,7 @@ const SelectableItem = ( | |
| isSelectAll, | ||
| virtualPosition, | ||
| padBottom, | ||
| disableContentStyling, | ||
|
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. Why do we need both approaches to remove the padding when the content is custom:
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. +1 - If all the "business" padding is now on this classname now, it seems easier to just remove the
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. That is a good point, will think about it again
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. Damn, i don't know why i didn't think about that 😃 |
||
| isNextSelected, | ||
| isPreviousSelected, | ||
| useInteractiveGroups, | ||
|
|
@@ -67,6 +68,10 @@ const SelectableItem = ( | |
| [styles['visual-refresh']]: isVisualRefresh, | ||
| }); | ||
|
|
||
| const contentClassNames = clsx(styles['option-content'], analyticsSelectors['option-content'], { | ||
| [styles['selectable-item-content']]: !disableContentStyling, | ||
| }); | ||
|
Comment on lines
+71
to
+73
|
||
|
|
||
| const contentRef = useRef<HTMLDivElement>(null); | ||
| const screenReaderContentRef = useRef<HTMLDivElement>(null); | ||
|
|
||
|
|
@@ -130,7 +135,7 @@ const SelectableItem = ( | |
| ? {} | ||
| : getAnalyticsMetadataAttribute(getAnalyticsSelectActionMetadata({ isChild, value, ...restProps })))} | ||
| > | ||
| <div className={clsx(styles['option-content'], analyticsSelectors['option-content'])} ref={contentRef}> | ||
| <div className={contentClassNames} ref={contentRef}> | ||
| {content} | ||
| </div> | ||
| <div className={styles['measure-strut']} ref={ref} /> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,12 +26,23 @@ | |
| border-inline-end-width: 0; | ||
| // to compensate for the loss of padding due to the removal of the left and right borders | ||
| // and differences in default divider + selected border widths (visual refresh) | ||
| padding-block: styles.$option-padding-with-border-placeholder-vertical; | ||
| padding-inline: calc(#{styles.$control-padding-horizontal} + #{awsui.$border-item-width}); | ||
| padding-block: calc(#{awsui.$border-item-width} - #{awsui.$border-divider-list-width}); | ||
| padding-inline: awsui.$border-item-width; | ||
|
|
||
| // For custom styles and background on the selectable-item-content, the content should not clip through the selectable-item borders.. | ||
| overflow: hidden; | ||
jperals marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| > .selectable-item-content { | ||
| padding-block: styles.$option-padding-vertical; | ||
| padding-inline: styles.$control-padding-horizontal; | ||
| } | ||
|
|
||
| &.pad-bottom { | ||
| padding-block-end: calc(#{styles.$option-padding-with-border-placeholder-vertical} + #{awsui.$space-xxxs}); | ||
| padding-block-end: calc(#{awsui.$border-item-width} - #{awsui.$border-divider-list-width}); | ||
| border-block-end-color: transparent; | ||
| > .selectable-item-content { | ||
| padding-block-end: calc(#{styles.$option-padding-vertical} + #{awsui.$space-xxxs}); | ||
| } | ||
| } | ||
|
|
||
| &:not(:first-child), | ||
|
|
@@ -42,6 +53,16 @@ | |
| &.has-background { | ||
| background-color: awsui.$color-background-dropdown-item-hover; | ||
| } | ||
| &.child { | ||
| padding-inline-start: awsui.$border-item-width; | ||
| > .selectable-item-content { | ||
| padding-inline-start: awsui.$space-xxl; | ||
| } | ||
| } | ||
|
|
||
| &.disabled > .selectable-item-content { | ||
| color: awsui.$color-text-dropdown-item-disabled; | ||
| } | ||
|
|
||
| &.highlighted, | ||
| &.selected { | ||
|
|
@@ -51,22 +72,36 @@ | |
| border-start-end-radius: awsui.$border-radius-item; | ||
| border-end-start-radius: awsui.$border-radius-item; | ||
| border-end-end-radius: awsui.$border-radius-item; | ||
| padding-block: styles.$option-padding-vertical; | ||
| padding-inline: styles.$control-padding-horizontal; | ||
| padding-block: 0; | ||
| padding-inline: 0; | ||
|
|
||
| > .selectable-item-content { | ||
| padding-block: styles.$option-padding-vertical; | ||
| padding-inline: styles.$control-padding-horizontal; | ||
| } | ||
| &.child { | ||
| padding-inline-start: 0; | ||
| > .selectable-item-content { | ||
| padding-inline-start: awsui.$space-xxl; | ||
| } | ||
| } | ||
| &.pad-bottom { | ||
| padding-block-end: (calc(#{styles.$option-padding-vertical} + #{awsui.$space-xxxs})); | ||
| padding-block-end: 0; | ||
| > .selectable-item-content { | ||
| padding-block-end: (calc(#{styles.$option-padding-vertical} + #{awsui.$space-xxxs})); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| &.highlighted { | ||
| z-index: 3; | ||
| background-color: awsui.$color-background-dropdown-item-hover; | ||
| border-color: awsui.$color-border-dropdown-item-hover; | ||
| &.disabled { | ||
| color: awsui.$color-text-dropdown-item-dimmed; | ||
| border-color: awsui.$color-border-dropdown-item-dimmed-hover; | ||
| background-color: awsui.$color-background-dropdown-item-dimmed; | ||
| > .selectable-item-content { | ||
| color: awsui.$color-text-dropdown-item-dimmed; | ||
| } | ||
| } | ||
| &.is-keyboard { | ||
| border-color: awsui.$color-border-dropdown-item-focused; | ||
|
|
@@ -112,35 +147,47 @@ | |
| } | ||
|
|
||
| &.parent { | ||
| font-weight: bold; | ||
| color: awsui.$color-text-dropdown-group-label; | ||
| &:not(.disabled) { | ||
| > .selectable-item-content { | ||
| color: awsui.$color-text-dropdown-group-label; | ||
| } | ||
| } | ||
| &:not(.interactiveGroups) { | ||
| border-block-start-color: awsui.$color-border-dropdown-group; | ||
| padding-block: awsui.$space-xs; | ||
| padding-inline: awsui.$space-xs; | ||
| padding-block: 0; | ||
| padding-inline: 0; | ||
| &:not(:has(> .selectable-item-content)) { | ||
| padding-block: calc(#{awsui.$border-item-width} - #{awsui.$border-divider-list-width}); | ||
| padding-inline: awsui.$border-item-width; | ||
| } | ||
|
|
||
| > .selectable-item-content { | ||
| padding-block: awsui.$space-xs; | ||
| padding-inline: awsui.$space-xs; | ||
| font-weight: bold; | ||
| } | ||
| } | ||
| &.interactiveGroups { | ||
| padding-block: styles.$group-option-padding-with-border-placeholder-vertical; | ||
| padding-inline: calc(#{styles.$control-padding-horizontal} + #{awsui.$border-item-width}); | ||
| > .selectable-item-content { | ||
| padding-block: styles.$group-option-padding-vertical; | ||
| padding-inline: styles.$control-padding-horizontal; | ||
SpyZzey marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| &.highlighted { | ||
| color: awsui.$color-text-dropdown-item-highlighted; | ||
| > .selectable-item-content { | ||
|
||
| color: awsui.$color-text-dropdown-item-highlighted; | ||
| } | ||
| } | ||
| &.highlighted, | ||
| &.selected { | ||
| padding-block: styles.$group-option-padding-vertical; | ||
| padding-inline: styles.$control-padding-horizontal; | ||
| padding-block: 0; | ||
| padding-inline: 0; | ||
| > .selectable-item-content { | ||
| padding-block: styles.$group-option-padding-vertical; | ||
SpyZzey marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| &.child { | ||
| padding-inline-start: calc(#{awsui.$space-xxl} + #{awsui.$border-item-width}); | ||
| &.highlighted, | ||
| &.selected { | ||
| padding-inline-start: awsui.$space-xxl; | ||
| } | ||
| } | ||
|
|
||
| &.sticky { | ||
| position: sticky; | ||
| inset-block-start: 0; | ||
|
|
@@ -156,7 +203,10 @@ | |
| border-inline-start-width: awsui.$border-item-width; | ||
| border-inline-start-color: awsui.$color-border-dropdown-container; | ||
| border-inline-end-color: awsui.$color-border-dropdown-container; | ||
| padding-inline: styles.$control-padding-horizontal; | ||
| padding-inline: 0; | ||
| > .selectable-item-content { | ||
| padding-inline: styles.$control-padding-horizontal; | ||
| } | ||
|
|
||
| &:not(.with-scrollbar) { | ||
| border-inline-end-width: awsui.$border-item-width; | ||
|
|
@@ -187,10 +237,6 @@ | |
| } | ||
| } | ||
|
|
||
| &.disabled { | ||
| color: awsui.$color-text-dropdown-item-disabled; | ||
| } | ||
|
|
||
| &:not(.disabled):not(.parent) { | ||
| cursor: pointer; | ||
| } | ||
|
|
||
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.
Note that adding these permutations will cause some operational friction as the visual regression tests will fail. My recommendation is to move the new permutation to a new page. And IMO they don't need to be covered by visual regression, because this is an internal option, not customer-facing.
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.
It will be customer facing once the arbitrary content for select/multiselect will go live
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.
Still,
disableContentStylingwill keep being internal implementation of an internal component. I think it makes more sense to cover the customer-facing components using the new props.