-
Notifications
You must be signed in to change notification settings - Fork 161
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
chore: Underline styles for popover text trigger #3060
base: main
Are you sure you want to change the base?
Changes from 10 commits
7c3d841
b2c3f2d
11f3222
cb6a3d3
587d50e
f1e42b9
45d0a16
639d40f
a9143a1
178c7ce
f3476b8
4109139
7fc1f38
5b8d48b
ac0d820
05282ff
9ee34f4
6c46557
c329d84
3cefaa0
41ba7a4
c5fc150
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 |
---|---|---|
|
@@ -12,6 +12,14 @@ | |
@import './container'; | ||
@import './motion'; | ||
|
||
$trigger-underline-offset: 0.25em; | ||
|
||
@mixin trigger-underline-styles { | ||
text-decoration: underline dashed currentColor; | ||
text-decoration-thickness: awsui.$border-divider-list-width; | ||
text-underline-offset: $trigger-underline-offset; | ||
} | ||
|
||
.root { | ||
@include styles.styles-reset; | ||
color: inherit; | ||
|
@@ -46,7 +54,21 @@ | |
background-color: transparent; | ||
|
||
cursor: pointer; | ||
border-block-end: awsui.$border-divider-list-width dashed currentColor; | ||
|
||
@include trigger-underline-styles; | ||
|
||
&.overflow-ellipsis { | ||
/* | ||
this line-height must be overridden, because of the overflow: hidden, | ||
otherwise the underline styles would be hidden | ||
*/ | ||
line-height: calc(1 + #{$trigger-underline-offset} + #{awsui.$border-divider-list-width}); | ||
} | ||
|
||
/* stylelint-disable selector-combinator-disallowed-list, selector-max-type, selector-max-universal */ | ||
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 would add a code comment explaining that the combinator actually targets the custom content |
||
& span { | ||
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. Would it make sense to add a span for both in-place and portal variants of the popover to avoid the condition in styles? I also see no reason to violate the stylelint rules: you can add a class name to the span element and target it directly. 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. Unfortunately, that is not a case, because the styles are applied when we are dealing with 'external' component which we have no control over. See the example below: <Popover
size="medium"
position="right"
header="Memory error"
content={<DynamicContent />}
dismissAriaLabel="Close"
renderWithPortal={renderWithPortal}
>
<StatusIndicator type="error">Error</StatusIndicator>
</Popover> The current implementation applies border styles directly to the popover trigger, which is a block element, while underline styles are not inherited down the block elements, only for inline elements. Therefore, I realized that the only way to apply the styles to the block element is by using this selector. 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. What if the nested element is not a span? 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. Since this change specifically applies to |
||
@include trigger-underline-styles; | ||
} | ||
|
||
&:focus { | ||
outline: none; | ||
|
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.
0.25 is used instead of 0.2 because an underline at 0.2 overlaps with the text