import { CommonModule } from "@angular/common"; import { Component, importProvidersFrom } from "@angular/core"; import { RouterModule } from "@angular/router"; import { applicationConfig, Meta, moduleMetadata, StoryObj } from "@storybook/angular"; import { ButtonModule } from "../button"; import { FormFieldModule } from "../form-field"; import { TabGroupComponent } from "./tab-group/tab-group.component"; import { TabsModule } from "./tabs.module"; @Component({ selector: "bit-tab-active-dummy", template: "Router - Active selected", }) class ActiveDummyComponent {} @Component({ selector: "bit-tab-item-2-dummy", template: "Router - Item 2 selected", }) class ItemTwoDummyComponent {} @Component({ selector: "bit-tab-item-3-dummy", template: "Router - Item 3 selected", }) class ItemThreeDummyComponent {} @Component({ selector: "bit-tab-disabled-dummy", template: "Router - Disabled selected", }) class DisabledDummyComponent {} export default { title: "Component Library/Tabs", component: TabGroupComponent, decorators: [ moduleMetadata({ declarations: [ ActiveDummyComponent, ItemTwoDummyComponent, ItemThreeDummyComponent, DisabledDummyComponent, ], imports: [CommonModule, TabsModule, ButtonModule, FormFieldModule, RouterModule], }), applicationConfig({ providers: [ importProvidersFrom( RouterModule.forRoot( [ { path: "", redirectTo: "active", pathMatch: "full" }, { path: "active", component: ActiveDummyComponent }, { path: "item-2", component: ItemTwoDummyComponent }, { path: "item-3", component: ItemThreeDummyComponent }, { path: "disabled", component: DisabledDummyComponent }, ], { useHash: true } ) ), ], }), ], parameters: { design: { type: "figma", url: "https://www.figma.com/file/Zt3YSeb6E6lebAffrNLa0h/Tailwind-Component-Library?node-id=1881%3A17922", }, }, } as Meta; type Story = StoryObj; export const ContentTabs: Story = { render: (args: any) => ({ props: args, template: ` First Tab Content Second Tab Content Template Label Template Label Content Disabled Content `, }), }; export const NavigationTabs: Story = { render: (args: TabGroupComponent) => ({ props: args, template: ` Active Item 2 Item 3 Disabled
`, }), }; export const PreserveContentTabs: Story = { render: (args: any) => ({ props: args, template: `

Play the video in the other tab and switch back to hear the video is still playing.

`, }), }; export const KeyboardNavigation: Story = { render: (args: any) => ({ props: args, template: `

You can navigate through all tab labels, form inputs, and the button that is outside the tab group via the keyboard.

First Input Second Input

This tab has no focusable content, but the panel should still be focusable

`, }), };