-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(list): add story for list component
- Loading branch information
patrickjahr
committed
Apr 16, 2024
1 parent
21b26da
commit 153edf8
Showing
1 changed file
with
123 additions
and
0 deletions.
There are no files selected for viewing
123 changes: 123 additions & 0 deletions
123
libs/sketch/src/lib/components/list/list.component.stories.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
import { | ||
applicationConfig, | ||
Meta, | ||
moduleMetadata, | ||
StoryObj, | ||
} from '@storybook/angular'; | ||
import { ListComponent } from './list.component'; | ||
import { provideRouter } from '@angular/router'; | ||
import { CommonModule } from '@angular/common'; | ||
import { ListItemComponent } from './components/list-item/list-item.component'; | ||
import { ListProviderDirective } from './directives/list-provider.directive'; | ||
import { ListItemActiveDirective } from './directives/list-item-active.directive'; | ||
|
||
const meta: Meta<ListComponent> = { | ||
component: ListComponent, | ||
title: 'ListComponent', | ||
decorators: [ | ||
applicationConfig({ | ||
providers: [ | ||
provideRouter([ | ||
{ | ||
matcher: (segments) => | ||
segments.length && segments[0].path | ||
? { consumed: segments } | ||
: null, | ||
component: ListComponent, | ||
}, | ||
]), | ||
], | ||
}), | ||
moduleMetadata({ | ||
imports: [ | ||
CommonModule, | ||
ListItemComponent, | ||
ListProviderDirective, | ||
ListItemActiveDirective, | ||
], | ||
}), | ||
], | ||
}; | ||
export default meta; | ||
type Story = StoryObj<ListComponent>; | ||
|
||
export const Default: Story = { | ||
render: (args) => ({ | ||
props: args, | ||
template: `<sk-list skListProvider> | ||
<sk-list-item skListItemId="1"> | ||
<span skLabel>Label 1</span> | ||
</sk-list-item> | ||
<sk-list-item skListItemId="2"> | ||
<span skLabel>Label 2</span> | ||
</sk-list-item> | ||
<sk-list-item skListItemId="3"> | ||
<span skLabel>Label 3</span> | ||
</sk-list-item> | ||
<sk-list-item skListItemId="4"> | ||
<span skLabel>Label 4</span> | ||
</sk-list-item> | ||
</sk-list>`, | ||
}), | ||
}; | ||
|
||
export const Nested: Story = { | ||
render: (args) => ({ | ||
props: args, | ||
template: `<sk-list skListProvider skEnableRouting> | ||
<sk-list-item skListItemId="1"> | ||
<span skLabel>Label 1</span> | ||
<sk-list skChilds> | ||
<sk-list-item skListItemId="11"> | ||
<span skLabel>Label 11</span> | ||
</sk-list-item> | ||
<sk-list-item skListItemId="12"> | ||
<span skLabel>Label 12</span> | ||
</sk-list-item> | ||
<sk-list-item skListItemId="13"> | ||
<span skLabel>Label 13</span> | ||
</sk-list-item> | ||
<sk-list-item skListItemId="14"> | ||
<span skLabel>Label 14</span> | ||
</sk-list-item> | ||
</sk-list> | ||
</sk-list-item> | ||
<sk-list-item skListItemId="2"> | ||
<span skLabel>Label 2</span> | ||
<sk-list skChilds> | ||
<sk-list-item skListItemId="21"> | ||
<span skLabel>Label 21</span> | ||
</sk-list-item> | ||
<sk-list-item skListItemId="22"> | ||
<span skLabel>Label 22</span> | ||
</sk-list-item> | ||
</sk-list> | ||
</sk-list-item> | ||
<sk-list-item skListItemId="3"> | ||
<span skLabel>Label 3</span> | ||
<sk-list skChilds> | ||
<sk-list-item skListItemId="31"> | ||
<span skLabel>Label 31</span> | ||
</sk-list-item> | ||
<sk-list-item skListItemId="32"> | ||
<span skLabel>Label 32</span> | ||
</sk-list-item> | ||
<sk-list-item skListItemId="33"> | ||
<span skLabel>Label 33</span> | ||
</sk-list-item> | ||
</sk-list> | ||
</sk-list-item> | ||
<sk-list-item skListItemId="4"> | ||
<span skLabel>Label 4</span> | ||
<sk-list skChilds> | ||
<sk-list-item skListItemId="41"> | ||
<span skLabel>Label 41</span> | ||
</sk-list-item> | ||
<sk-list-item skListItemId="42"> | ||
<span skLabel>Label 42</span> | ||
</sk-list-item> | ||
</sk-list> | ||
</sk-list-item> | ||
</sk-list>`, | ||
}), | ||
}; |