Skip to content
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

Merged
merged 23 commits into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
7c3d841
chore: Underline styles for popover text trigger
georgylobko Nov 26, 2024
b2c3f2d
Merge branch 'main' into chore/popover-text-trigger-styles
georgylobko Dec 2, 2024
11f3222
chore: Styles adjustment
georgylobko Dec 4, 2024
cb6a3d3
chore: Add transparent border to keep text trigger's size
georgylobko Dec 5, 2024
587d50e
Merge branch 'main' into chore/popover-text-trigger-styles
georgylobko Dec 5, 2024
f1e42b9
chore: Apply text decoration for child span
georgylobko Dec 5, 2024
45d0a16
chore: Handle wrapTriggerText differently
georgylobko Dec 10, 2024
639d40f
Merge branch 'main' into chore/popover-text-trigger-styles
georgylobko Jan 14, 2025
a9143a1
Merge branch 'main' into chore/popover-text-trigger-styles
georgylobko Jan 15, 2025
178c7ce
feat: Introduce unified styles for both text wrapped and unwrapped po…
georgylobko Jan 15, 2025
f3476b8
chore: Introduce a transparent border-bottom to maintain space betwee…
georgylobko Jan 15, 2025
4109139
Merge branch 'main' into chore/popover-text-trigger-styles
georgylobko Jan 16, 2025
7fc1f38
Merge branch 'main' into chore/popover-text-trigger-styles
georgylobko Jan 16, 2025
5b8d48b
Merge branch 'main' into chore/popover-text-trigger-styles
georgylobko Jan 16, 2025
ac0d820
Merge branch 'main' into chore/popover-text-trigger-styles
georgylobko Jan 20, 2025
05282ff
chore: Change styles specificity
georgylobko Jan 20, 2025
9ee34f4
chore: Add a comment to explain the css rule to propagate down underl…
georgylobko Jan 21, 2025
6c46557
Merge branch 'main' into chore/popover-text-trigger-styles
georgylobko Jan 21, 2025
c329d84
feat: New triggerType in Popover component
georgylobko Jan 22, 2025
3cefaa0
Merge branch 'main' into chore/popover-text-trigger-styles
georgylobko Jan 22, 2025
41ba7a4
chore: Styles refactoring
georgylobko Jan 22, 2025
c5fc150
chore: Update api description
georgylobko Jan 22, 2025
8860f8c
Merge branch 'main' into chore/popover-text-trigger-styles
georgylobko Jan 23, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pages/popover/text-wrap.page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const triggerPermutations = createPermutations<PopoverProps & { size: PopoverPro
'Reallylongpopovercontentwithalotoftextbutnospacesthatwillprobablyoverflowthepopovertrigger',
],
wrapTriggerText: [true, false],
triggerType: ['text', 'text-inline'],
},
]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12172,13 +12172,15 @@ that don't have visible text, and to distinguish between multiple triggers with
{
"defaultValue": "'text'",
"description": "Specifies the type of content inside the trigger region. The following types are available:
- \`text\` - Use for inline text triggers.
- \`text\` - Use for triggers containing inline components, like status indicator.
- \`text-inline\` - Use for triggers containing plain text only.
- \`custom\` - Use for the [button](/components/button/) component.",
"inlineType": {
"name": "PopoverProps.TriggerType",
"type": "union",
"values": [
"text",
"text-inline",
"custom",
],
},
Expand Down
5 changes: 3 additions & 2 deletions src/popover/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ export interface PopoverProps extends BaseComponentProps {

/**
* Specifies the type of content inside the trigger region. The following types are available:
* - `text` - Use for inline text triggers.
* - `text` - Use for triggers containing inline components, like status indicator.
* - `text-inline` - Use for triggers containing plain text only.
* - `custom` - Use for the [button](/components/button/) component.
*/
triggerType?: PopoverProps.TriggerType;
Expand Down Expand Up @@ -114,7 +115,7 @@ export type Rect = BoundingBox & {
export namespace PopoverProps {
export type Position = 'top' | 'right' | 'bottom' | 'left';
export type Size = 'small' | 'medium' | 'large';
export type TriggerType = 'text' | 'custom';
export type TriggerType = 'text' | 'text-inline' | 'custom';

export interface Ref {
/**
Expand Down
4 changes: 2 additions & 2 deletions src/popover/internal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ function InternalPopover(
const [visible, setVisible] = useState(false);

const focusTrigger = useCallback(() => {
if (triggerType === 'text') {
if (['text', 'text-inline'].includes(triggerType)) {
triggerRef.current?.focus();
} else {
triggerRef.current && getFirstFocusable(triggerRef.current)?.focus();
Expand Down Expand Up @@ -198,7 +198,7 @@ function InternalPopover(
});
}}
>
{triggerType === 'text' ? (
{['text', 'text-inline'].includes(triggerType) ? (
<button
{...triggerProps}
className={clsx(triggerProps.className, wrapTriggerText === false && styles['overflow-ellipsis'])}
Expand Down
26 changes: 25 additions & 1 deletion src/popover/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
@import './container';
@import './motion';

$trigger-underline-offset: 0.25em;
Copy link
Contributor Author

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


.root {
@include styles.styles-reset;
color: inherit;
Expand All @@ -36,8 +38,31 @@
@include styles.text-wrapping;
}

.trigger-type-text-inline {
border-block: 0;
/*
This transparent border is necessary to maintain space between the trigger and the bottom-positioned popover.
*/
border-block-end: awsui.$border-divider-list-width dashed transparent;
text-decoration: underline dashed currentColor;
text-decoration-thickness: awsui.$border-divider-list-width;
text-underline-offset: $trigger-underline-offset;

&.overflow-ellipsis {
/*
This line-height needs to be overridden because the overflow: hidden would otherwise conceal the underline styles.
*/
line-height: calc(1 + #{$trigger-underline-offset} + #{awsui.$border-divider-list-width});
}
}

.trigger-type-text {
border-block: 0;
border-block-end: awsui.$border-divider-list-width dashed currentColor;
}

.trigger-type-text-inline,
.trigger-type-text {
border-inline: 0;
margin-block: 0;
margin-inline: 0;
Expand All @@ -46,7 +71,6 @@
background-color: transparent;

cursor: pointer;
border-block-end: awsui.$border-divider-list-width dashed currentColor;

&:focus {
outline: none;
Expand Down
Loading