mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
chore(editor): Support new props in TabOptions (#17822)
This commit is contained in:
@@ -2,6 +2,7 @@ import { action } from '@storybook/addon-actions';
|
|||||||
import type { StoryFn } from '@storybook/vue3';
|
import type { StoryFn } from '@storybook/vue3';
|
||||||
|
|
||||||
import N8nTabs from './Tabs.vue';
|
import N8nTabs from './Tabs.vue';
|
||||||
|
import type { TabOptions } from '../../types/tabs';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
title: 'Atoms/Tabs',
|
title: 'Atoms/Tabs',
|
||||||
@@ -56,3 +57,71 @@ Example.args = {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const options: Array<TabOptions<string>> = [
|
||||||
|
{
|
||||||
|
label: 'First',
|
||||||
|
value: 'first',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Second',
|
||||||
|
value: 'second',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'External Link',
|
||||||
|
value: 'external',
|
||||||
|
href: 'https://github.com/',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Danger',
|
||||||
|
value: 'danger',
|
||||||
|
variant: 'danger',
|
||||||
|
icon: 'triangle-alert',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Right Icon',
|
||||||
|
value: 'rightIcon',
|
||||||
|
icon: 'circle',
|
||||||
|
iconPosition: 'right',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: 'iconOnly',
|
||||||
|
tooltip: 'Icon only tab',
|
||||||
|
icon: 'circle',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Notification',
|
||||||
|
value: 'notification',
|
||||||
|
notification: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Settings',
|
||||||
|
value: 'settings',
|
||||||
|
icon: 'cog',
|
||||||
|
align: 'right',
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
export const TabVariants = Template.bind({});
|
||||||
|
TabVariants.args = {
|
||||||
|
options,
|
||||||
|
};
|
||||||
|
|
||||||
|
export const WithSmallSize = Template.bind({});
|
||||||
|
WithSmallSize.args = {
|
||||||
|
options,
|
||||||
|
size: 'small',
|
||||||
|
};
|
||||||
|
|
||||||
|
export const WithModernVariant = Template.bind({});
|
||||||
|
WithModernVariant.args = {
|
||||||
|
variant: 'modern',
|
||||||
|
options,
|
||||||
|
};
|
||||||
|
|
||||||
|
export const WithSmallAndModern = Template.bind({});
|
||||||
|
WithSmallAndModern.args = {
|
||||||
|
variant: 'modern',
|
||||||
|
options,
|
||||||
|
size: 'small',
|
||||||
|
};
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ const scrollRight = () => scroll(50);
|
|||||||
:key="option.value"
|
:key="option.value"
|
||||||
:class="{ [$style.alignRight]: option.align === 'right' }"
|
:class="{ [$style.alignRight]: option.align === 'right' }"
|
||||||
>
|
>
|
||||||
<N8nTooltip :disabled="!option.tooltip" placement="bottom">
|
<N8nTooltip :disabled="!option.tooltip" placement="bottom" :show-after="100">
|
||||||
<template #content>
|
<template #content>
|
||||||
<div v-n8n-html="option.tooltip" @click="handleTooltipClick(option.value, $event)" />
|
<div v-n8n-html="option.tooltip" @click="handleTooltipClick(option.value, $event)" />
|
||||||
</template>
|
</template>
|
||||||
@@ -100,35 +100,57 @@ const scrollRight = () => scroll(50);
|
|||||||
v-if="option.href"
|
v-if="option.href"
|
||||||
target="_blank"
|
target="_blank"
|
||||||
:href="option.href"
|
:href="option.href"
|
||||||
:class="[$style.link, $style.tab]"
|
rel="noopener noreferrer"
|
||||||
|
:class="[$style.link, $style.tab, option.label ? '' : $style.noText]"
|
||||||
@click="() => handleTabClick(option.value)"
|
@click="() => handleTabClick(option.value)"
|
||||||
>
|
>
|
||||||
<div>
|
<div>
|
||||||
{{ option.label }}
|
{{ option.label }}
|
||||||
<span :class="$style.external">
|
<N8nIcon
|
||||||
<N8nIcon icon="external-link" size="small" />
|
:class="$style.external"
|
||||||
</span>
|
:icon="option.icon ?? 'external-link'"
|
||||||
|
size="small"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
<RouterLink
|
<RouterLink
|
||||||
v-else-if="option.to"
|
v-else-if="option.to"
|
||||||
:to="option.to"
|
:to="option.to"
|
||||||
:class="[$style.tab, { [$style.activeTab]: modelValue === option.value }]"
|
:class="[
|
||||||
|
$style.tab,
|
||||||
|
{ [$style.activeTab]: modelValue === option.value, [$style.noText]: !option.label },
|
||||||
|
]"
|
||||||
>
|
>
|
||||||
<N8nIcon v-if="option.icon" :icon="option.icon" size="medium" />
|
<N8nIcon v-if="option.icon" :icon="option.icon" size="medium" />
|
||||||
<span v-if="option.label">{{ option.label }}</span>
|
<span v-if="option.label">{{ option.label }}</span>
|
||||||
</RouterLink>
|
</RouterLink>
|
||||||
<div
|
<div
|
||||||
v-else
|
v-else
|
||||||
:class="{ [$style.tab]: true, [$style.activeTab]: modelValue === option.value }"
|
:class="{
|
||||||
|
[$style.tab]: true,
|
||||||
|
[$style.activeTab]: modelValue === option.value,
|
||||||
|
[$style.noText]: !option.label,
|
||||||
|
[$style.dangerTab]: option.variant === 'danger',
|
||||||
|
}"
|
||||||
:data-test-id="`tab-${option.value}`"
|
:data-test-id="`tab-${option.value}`"
|
||||||
@click="() => handleTabClick(option.value)"
|
@click="() => handleTabClick(option.value)"
|
||||||
>
|
>
|
||||||
<N8nIcon v-if="option.icon" :icon="option.icon" size="small" />
|
<N8nIcon
|
||||||
<span v-if="option.label" :class="$style.notificationContainer"
|
v-if="option.icon && option.iconPosition !== 'right'"
|
||||||
>{{ option.label }}
|
:icon="option.icon"
|
||||||
<div v-if="option.notification" :class="$style.notification"><div></div></div
|
:class="$style.icon"
|
||||||
></span>
|
size="small"
|
||||||
|
/>
|
||||||
|
<span v-if="option.label" :class="$style.notificationContainer">
|
||||||
|
{{ option.label }}
|
||||||
|
<div v-if="option.notification" :class="$style.notification" />
|
||||||
|
</span>
|
||||||
|
<N8nIcon
|
||||||
|
v-if="option.icon && option.iconPosition === 'right'"
|
||||||
|
:icon="option.icon"
|
||||||
|
:class="$style.icon"
|
||||||
|
size="small"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</N8nTooltip>
|
</N8nTooltip>
|
||||||
</div>
|
</div>
|
||||||
@@ -170,7 +192,9 @@ const scrollRight = () => scroll(50);
|
|||||||
|
|
||||||
.tab {
|
.tab {
|
||||||
--active-tab-border-width: 2px;
|
--active-tab-border-width: 2px;
|
||||||
display: block;
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: var(--spacing-4xs);
|
||||||
padding: 0 var(--spacing-s);
|
padding: 0 var(--spacing-s);
|
||||||
padding-bottom: calc(var(--spacing-2xs) + var(--active-tab-border-width));
|
padding-bottom: calc(var(--spacing-2xs) + var(--active-tab-border-width));
|
||||||
font-size: var(--font-size-s);
|
font-size: var(--font-size-s);
|
||||||
@@ -223,6 +247,23 @@ const scrollRight = () => scroll(50);
|
|||||||
.external {
|
.external {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
margin-left: var(--spacing-5xs);
|
margin-left: var(--spacing-5xs);
|
||||||
|
|
||||||
|
.noText & {
|
||||||
|
display: block;
|
||||||
|
margin-left: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.noText .icon {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dangerTab {
|
||||||
|
color: var(--color-danger);
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
color: var(--color-danger);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.button {
|
.button {
|
||||||
@@ -248,7 +289,9 @@ const scrollRight = () => scroll(50);
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
|
|
||||||
div {
|
&:after {
|
||||||
|
content: '';
|
||||||
|
display: block;
|
||||||
height: 0.3em;
|
height: 0.3em;
|
||||||
width: 0.3em;
|
width: 0.3em;
|
||||||
background-color: var(--color-primary);
|
background-color: var(--color-primary);
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ export interface TabOptions<Value extends string | number> {
|
|||||||
value: Value;
|
value: Value;
|
||||||
label?: string;
|
label?: string;
|
||||||
icon?: IconName;
|
icon?: IconName;
|
||||||
|
iconPosition?: 'left' | 'right';
|
||||||
|
variant?: 'default' | 'danger';
|
||||||
href?: string;
|
href?: string;
|
||||||
tooltip?: string;
|
tooltip?: string;
|
||||||
align?: 'left' | 'right';
|
align?: 'left' | 'right';
|
||||||
|
|||||||
Reference in New Issue
Block a user