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

IT-6082 text group support tooltip #454

Merged
merged 10 commits into from
Feb 4, 2025
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ const expandStory = (story: StoryFn<typeof BasicRichListItem>, args = {}) => {
supportingTextEllipsis: {
control: 'boolean',
},
isSupportingTextTooltipEnabled: {
control: 'boolean',
},
metadata: {
control: 'text',
},
Expand Down Expand Up @@ -131,6 +134,7 @@ const expandStory = (story: StoryFn<typeof BasicRichListItem>, args = {}) => {
textEllipsis: false,
supportingText: 'null',
supportingTextEllipsis: false,
isSupportingTextTooltipEnabled: false,

metadata: 'Metadata Slot',
actions: 'ACS',
Expand Down Expand Up @@ -191,6 +195,7 @@ const InteractiveStoryTemplate: StoryFn<typeof BasicRichListItem> = (args) => {
:text-ellipsis="textEllipsis"
:supporting-text="supportingText === 'null' ? null : supportingText"
:supporting-text-ellipsis="supportingTextEllipsis"
:is-supporting-text-tooltip-enabled="isSupportingTextTooltipEnabled"
:background-color="backgroundColor"
:elevation="elevation"
:has-draggable-handler="hasDraggableHandler"
Expand Down Expand Up @@ -251,6 +256,7 @@ const WithMediaStoryTemplate: StoryFn<typeof BasicRichListItem> = (args) => {
:text-ellipsis="textEllipsis"
:supporting-text="supportingText === 'null' ? null : supportingText"
:supporting-text-ellipsis="supportingTextEllipsis"
:is-supporting-text-tooltip-enabled="isSupportingTextTooltipEnabled"
:background-color="backgroundColor"
:elevation="elevation"
:has-draggable-handler="hasDraggableHandler"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
:supporting-text-ellipsis="supportingTextEllipsis"
:size="textGroupSize"
:state="textGroupState"
:is-supporting-text-tooltip-enabled="isSupportingTextTooltipEnabled"
/>
</div>
</template>
Expand Down Expand Up @@ -218,6 +219,10 @@ export default defineComponent({
type: Boolean,
default: false,
},
isSupportingTextTooltipEnabled: {
type: Boolean,
default: false,
},
backgroundColor: {
type: String as PropType<RichListItemBackgroundColor>,
default: RICH_LIST_ITEM_BACKGROUND_COLOR.NEUTRAL,
Expand Down
20 changes: 20 additions & 0 deletions lib/js/components/TextGroup/TextGroup.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ const StoryTemplate: StoryFn<typeof DsTextGroup> = (args) => ({
:skeleton-loading-size="skeletonLoadingSize"
:is-selected="isSelected"
:state="state"
:is-supporting-text-tooltip-enabled="isSupportingTextTooltipEnabled"
:is-supporting-text-tooltip-enabled-on-mobile="isSupportingTextTooltipEnabledOnMobile"
:is-supporting-text-tooltip-auto-filled-with-content="isSupportingTextTooltipAutoFilledWithContent"
:supporting-text-tooltip-content="supportingTextTooltipContent"
/>
<div style="margin-top: 100px; color: #888">
<ds-divider />
Expand All @@ -57,6 +61,10 @@ Interactive.args = {
skeletonLoadingSize: TEXT_GROUP_LOADING_SIZES.LARGE,
isSelected: false,
state: TEXT_GROUP_STATES.DEFAULT,
isSupportingTextTooltipEnabled: false,
isSupportingTextTooltipEnabledOnMobile: true,
isSupportingTextTooltipAutoFilledWithContent: true,
supportingTextTooltipContent: '',
} as Args;

Interactive.argTypes = {
Expand Down Expand Up @@ -103,6 +111,18 @@ Interactive.argTypes = {
control: 'select',
options: Object.values(TEXT_GROUP_STATES),
},
isSupportingTextTooltipEnabled: {
control: 'boolean',
},
isSupportingTextTooltipEnabledOnMobile: {
control: 'boolean',
},
isSupportingTextTooltipAutoFilledWithContent: {
control: 'boolean',
},
supportingTextTooltipContent: {
control: 'text',
},
} as ArgTypes;

Interactive.parameters = {
Expand Down
59 changes: 51 additions & 8 deletions lib/js/components/TextGroup/TextGroup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,33 @@
<span v-else-if="mainText === ''">&nbsp;</span>
<span v-else>{{ mainText }}</span>
</div>
<div
v-if="supportingText !== null"
class="ds-textGroup__supporting"
:class="{
'-ds-ellipsis': supportingTextEllipsis,
}"
>
<div v-if="supportingText !== null" class="ds-textGroup__supportingWrapper">
<div v-if="isLoading" class="ds-textGroup__skeletonWrapper">
<ds-skeleton width="100%" height="100%" />
</div>
<span v-else-if="supportingText === ''">&nbsp;</span>
<span v-else v-html="supportingText" />
<template v-else>
<ds-tooltip
class="ds-textGroup__supportingTooltip"
:text="
isSupportingTextTooltipAutoFilledWithContent
? supportingText
: supportingTextTooltipContent
"
:is-disabled="!isSupportingTextTooltipEnabled"
:is-hidden-on-mobile="!isSupportingTextTooltipEnabledOnMobile"
inline
>
<div
class="ds-textGroup__supporting"
:class="{
'-ds-ellipsis': supportingTextEllipsis,
}"
>
<span v-html="supportingText" />
</div>
</ds-tooltip>
</template>
</div>
</div>
</template>
Expand Down Expand Up @@ -172,6 +187,16 @@ $text-group-colors: (
@include text-m-compact-bold;
}

&__supportingWrapper {
display: flex;
}

&__supportingTooltip {
display: inline-flex;
max-width: 100%;
overflow: hidden;
}

&__supporting {
@include text-s-compact-regular;
}
Expand Down Expand Up @@ -251,11 +276,13 @@ import {
TextGroupSize,
TextGroupState,
} from './TextGroup.consts';
import DsTooltip from '../Tooltip';

export default defineComponent({
name: 'TextGroup',
components: {
DsSkeleton,
DsTooltip,
},
props: {
size: {
Expand Down Expand Up @@ -310,6 +337,22 @@ export default defineComponent({
type: String as PropType<TextGroupState>,
default: TEXT_GROUP_STATES.DEFAULT,
},
isSupportingTextTooltipEnabled: {
type: Boolean,
default: false,
},
isSupportingTextTooltipEnabledOnMobile: {
type: Boolean,
default: true,
},
isSupportingTextTooltipAutoFilledWithContent: {
type: Boolean,
default: true,
},
supportingTextTooltipContent: {
tweetgeek marked this conversation as resolved.
Show resolved Hide resolved
type: [String, null],
default: null,
},
},
data() {
return {
Expand Down
16 changes: 15 additions & 1 deletion lib/js/components/Tooltip/Tooltip.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

<style lang="scss">
@import '../../../styles/settings/typography/tokens';
@import '../../../styles/settings/media-queries';

.ds-tooltip-text {
@include text-s-compact-bold;
Expand All @@ -17,6 +18,14 @@
.ds-tooltip-arrow-hide {
display: none;
}

.ds-tooltip-hide-on-mobile {
display: none !important;

@media #{breakpoint-l()} {
display: inline-block !important;
}
}
</style>

<script lang="ts">
Expand Down Expand Up @@ -50,6 +59,10 @@ export default defineComponent({
type: Boolean,
default: false,
},
isHiddenOnMobile: {
type: Boolean,
default: false,
},
},
computed: {
tooltipParams() {
Expand All @@ -68,8 +81,9 @@ export default defineComponent({
background: 'var(--neutral-background-medium, #E5E7ED)',
color: 'var(--neutral-text-heavy, #343C50)',
borderRadius: '4px',
maxWidth: '240px',
maxWidth: '900px',
},
class: this.isHiddenOnMobile ? 'ds-tooltip-hide-on-mobile' : null,
ptOptions: {
mergeProps: true,
},
Expand Down