From f8ef04fecf8f1358e09c89472bc818523d0698b0 Mon Sep 17 00:00:00 2001 From: AndyKIron Date: Wed, 27 Nov 2024 17:22:33 +0200 Subject: [PATCH] chore(sb-8): fix story for tooltip v3 --- .../tooltip/v3/tooltip.component.stories.ts | 145 ++++++++++ .../v3/tooltip.implementation.stories.ts | 248 ++++++++++++++++++ 2 files changed, 393 insertions(+) create mode 100644 projects/fusion-ui/components/tooltip/v3/tooltip.component.stories.ts create mode 100644 projects/fusion-ui/components/tooltip/v3/tooltip.implementation.stories.ts diff --git a/projects/fusion-ui/components/tooltip/v3/tooltip.component.stories.ts b/projects/fusion-ui/components/tooltip/v3/tooltip.component.stories.ts new file mode 100644 index 000000000..3fdb4b630 --- /dev/null +++ b/projects/fusion-ui/components/tooltip/v3/tooltip.component.stories.ts @@ -0,0 +1,145 @@ +import {StoryFn, Meta} from '@storybook/angular'; +import {moduleMetadata} from '@storybook/angular'; +import {CommonModule} from '@angular/common'; +import {TooltipContentComponent, TooltipModule} from './'; +import {TooltipComponentStyleConfiguration, TooltipPosition} from '@ironsource/fusion-ui/components/tooltip/common/base'; +import {dedent} from 'ts-dedent'; + +export default { + title: 'V3/Components/Tooltip/Tooltip', + component: TooltipContentComponent, + decorators: [ + moduleMetadata({ + declarations: [], + imports: [CommonModule, TooltipModule] + }) + ], + tags: ['autodocs'], + parameters: { + docs: { + description: { + component: dedent`**Tooltip component** Use tooltips to showcase additional information to help users understand what is going on in a particular section of our planetary system.` + } + } + } +} as Meta; + +const TooltipTemplate: StoryFn = (args: TooltipContentComponent) => ({ + props: args, + template: `` +}); + +export const Default = { + render: TooltipTemplate, + + args: { + tooltipTextContent: 'This is a single line tooltip with no wrapping text' + } +}; + +export const Top = { + render: TooltipTemplate, + + args: { + tooltipTextContent: 'This is a single line tooltip with no wrapping text', + tooltipPositionClass: TooltipPosition.Top + } +}; + +export const TopLeft = { + render: TooltipTemplate, + + args: { + tooltipTextContent: 'This is a single line tooltip with no wrapping text', + tooltipPositionClass: TooltipPosition.TopLeft + } +}; + +export const TopRight = { + render: TooltipTemplate, + + args: { + tooltipTextContent: 'This is a single line tooltip with no wrapping text', + tooltipPositionClass: TooltipPosition.TopRight + } +}; + +export const Bottom = { + render: TooltipTemplate, + + args: { + tooltipTextContent: 'This is a single line tooltip with no wrapping text', + tooltipPositionClass: TooltipPosition.Bottom + } +}; + +export const BottomLeft = { + render: TooltipTemplate, + + args: { + tooltipTextContent: 'This is a single line tooltip with no wrapping text', + tooltipPositionClass: TooltipPosition.BottomLeft + } +}; + +export const BottomRight = { + render: TooltipTemplate, + + args: { + tooltipTextContent: 'This is a single line tooltip with no wrapping text', + tooltipPositionClass: TooltipPosition.BottomRight + } +}; + +export const Left = { + render: TooltipTemplate, + + args: { + tooltipTextContent: 'This is a single line tooltip with no wrapping text', + tooltipPositionClass: TooltipPosition.Left + } +}; + +export const Right = { + render: TooltipTemplate, + + args: { + tooltipTextContent: 'This is a single line tooltip with no wrapping text', + tooltipPositionClass: TooltipPosition.Right + } +}; + +export const WithCustomWidth = { + render: TooltipTemplate, + + args: { + tooltipTextContent: 'Well done! You successfully read this alert message.', + tooltipStyleConfiguration: { + width: '150px' + } as TooltipComponentStyleConfiguration + } +}; + +export const WithCustomWidthAndContentCentered = { + render: TooltipTemplate, + + args: { + tooltipTextContent: 'Well done! You successfully read this alert message.', + tooltipStyleConfiguration: { + width: '150px', + 'text-align': 'center' + } as TooltipComponentStyleConfiguration + } +}; + +export const WithCustomBackground = { + render: TooltipTemplate, + + args: { + tooltipTextContent: 'Well done! You successfully read this alert message.', + tooltipStyleConfiguration: { + width: '150px', + backgroundColor: '#3083FF' + } as TooltipComponentStyleConfiguration + } +}; diff --git a/projects/fusion-ui/components/tooltip/v3/tooltip.implementation.stories.ts b/projects/fusion-ui/components/tooltip/v3/tooltip.implementation.stories.ts new file mode 100644 index 000000000..7bac5e193 --- /dev/null +++ b/projects/fusion-ui/components/tooltip/v3/tooltip.implementation.stories.ts @@ -0,0 +1,248 @@ +import {StoryFn, Meta} from '@storybook/angular'; +import {moduleMetadata} from '@storybook/angular'; +import {CommonModule} from '@angular/common'; +import {TooltipComponent, TooltipModule} from './'; +import {dedent} from 'ts-dedent'; + +export default { + title: 'V3/Components/Tooltip/Implementation', + component: TooltipComponent, + decorators: [ + moduleMetadata({ + declarations: [], + imports: [CommonModule, TooltipModule] + }) + ], + tags: ['autodocs'], + parameters: { + docs: { + description: { + component: dedent`**Tooltip directive** Use directive ***[fusionTooltip]*** to set tooltip text for element. + If element has class mane 'truncate', but element content entered to place, tooltip will not shown. + + Position will calculated automatically` + } + }, + layout: 'centered' + }, + args: { + fusionTooltip: 'Well done! You successfully read this alert message' + } +} as Meta; + +const TooltipTemplate: StoryFn = (args: TooltipComponent) => ({ + props: args, + template: ` + +
Element with tooltip
+` +}); + +export const Directive = { + render: TooltipTemplate, + + parameters: { + docs: { + source: { + language: 'typescript', + code: dedent` + import { Component } from '@angular/core'; + import { TooltipModule } from '@ironsource/fusion-ui/components/tooltip/v3'; + + @Component({ + selector: 'fusion-story-wrapper', + template: \`
Element with tooltip
\`, + standalone: true, + imports: [TooltipModule], + }) + export class FusionStoryWrapperComponent { + tooltipText = 'Well done! You successfully read this alert message'; + } + `, + format: true, + type: 'code' + } + } + } +}; + +// endregion + +// region Inline +const TooltipInlineTemplate: StoryFn = (args: TooltipComponent) => ({ + props: args, + template: ` + +
+
Element with tooltip
+
+
+
Tooltip title
+
{{fusionTooltip}}
+
+
+` +}); + +export const Inline = { + render: TooltipInlineTemplate, + + parameters: { + docs: { + description: { + story: dedent`**Tooltip component** Use ***TooltipComponent*** (). In this case you can put in tooltip ***any*** content. + * Inner element with class ***"fusionTooltipTrigger"*** has trigger for tooltip. + * Inner element with class ***"fusionTooltipContent"*** has tooltip content. + ` + }, + source: { + language: 'typescript', + code: dedent` + import { Component } from '@angular/core'; + import { TooltipModule } from '@ironsource/fusion-ui/components/tooltip/v3'; + + @Component({ + selector: 'fusion-story-wrapper', + template: \`
+
+
Element with tooltip
+
+
+
Tooltip title
+
Well done! You successfully read this alert message
+
+
\`, + standalone: true, + imports: [TooltipModule], + }) + export class FusionStoryWrapperComponent { + tooltipText = 'Well done! You successfully read this alert message'; + } + `, + format: true, + type: 'code' + } + } + } +}; + +const TooltipInlineWithLinkTemplate: StoryFn = (args: TooltipComponent) => ({ + props: args, + template: ` + +
+
Element with tooltip
+
+
+
Tooltip title
+
{{fusionTooltip}} click me
+
+
+` +}); + +export const InlinePreventToClose = { + render: TooltipInlineWithLinkTemplate, + + args: { + tooltipConfiguration: { + preventTooltipToClose: true + } + }, + + parameters: { + docs: { + description: { + story: dedent`**Tooltip component** with link in tooltip content + + In this case need "prevent" hide tooltip on "tooltiped" element "mouseleave" event. + For this need to add to the tooltipConfiguration \`preventTooltipToClose: true\` + ` + }, + source: { + language: 'typescript', + code: dedent` + import { Component } from '@angular/core'; + import { TooltipModule } from '@ironsource/fusion-ui/components/tooltip/v3'; + + @Component({ + selector: 'fusion-story-wrapper', + template: \`
+ +
+
Element with tooltip
+
+
+
Tooltip title
+
Well done! You successfully read this alert message click me
+
+
+
\`, + standalone: true, + imports: [TooltipModule], + }) + export class FusionStoryWrapperComponent { + tooltipText = 'Well done! You successfully read this alert message'; + } + `, + format: true, + type: 'code' + } + } + } +}; + +export const InlineCustomization = { + render: TooltipInlineTemplate, + + args: { + tooltipConfiguration: { + backgroundColor: '#3083FF' + } + }, + + parameters: { + docs: { + description: { + story: dedent`**Tooltip customization** Use ***[tooltipConfiguration]*** for change tooltip default background color` + }, + source: { + language: 'typescript', + code: dedent` + import { Component } from '@angular/core'; + import { TooltipModule } from '@ironsource/fusion-ui/components/tooltip/v3'; + + @Component({ + selector: 'fusion-story-wrapper', + template: \`
+ +
+
Element with tooltip
+
+
+
Tooltip title
+
Well done! You successfully read this alert message
+
+
+
\`, + standalone: true, + imports: [TooltipModule], + }) + export class FusionStoryWrapperComponent { + tooltipText = 'Well done! You successfully read this alert message'; + } + `, + format: true, + type: 'code' + } + } + } +};