diff --git a/stories/accordion.stories.ts b/stories/accordion.stories.ts index d4b7a273f..c1a9e2ef6 100644 --- a/stories/accordion.stories.ts +++ b/stories/accordion.stories.ts @@ -4,11 +4,30 @@ import { range } from 'lit/directives/range.js'; import { IgcAccordionComponent, + IgcButtonComponent, + IgcIconComponent, IgcInputComponent, defineComponents, + registerIconFromText, } from 'igniteui-webcomponents'; +import { disableStoryControls } from './story.js'; -defineComponents(IgcAccordionComponent, IgcInputComponent); +defineComponents( + IgcAccordionComponent, + IgcButtonComponent, + IgcIconComponent, + IgcInputComponent +); + +registerIconFromText( + 'chevron-down', + `` +); + +registerIconFromText( + 'chevron-up', + `` +); // region default const metadata: Meta = { @@ -43,52 +62,242 @@ type Story = StoryObj; // endregion -Object.assign(metadata.parameters!, { - actions: { - handles: ['igcOpening', 'igcOpened', 'igcClosing', 'igcClosed'], - }, -}); +const loremShort = + 'Lorem ipsum dolor sit amet consectetur adipisicing elit. Sequi adipisci, ratione ut praesentium qui similique molestiae voluptate at excepturi.'; + +const loremLong = + 'Lorem ipsum dolor sit amet consectetur adipisicing elit. Cum quia placeat natus illo voluptatum, praesentium similique excepturi corporis sequi at earum labore provident asperiores dolorem fugit explicabo ipsa distinctio doloremque?'; export const Default: Story = { render: (args) => html` ${Array.from(range(1, 4)).map( (i) => - html` -

Title ${i}

-

Subtitle ${i}

-

- Lorem ipsum, dolor sit amet consectetur adipisicing elit. Sequi - adipisci, ratione ut praesentium qui, similique molestiae - voluptate at excepturi, a animi quam blanditiis. Tenetur tempore - explicabo blanditiis harum ut delectus! -

+ html` + Panel ${i} + Subtitle ${i} +

${loremShort}

+
` + )} +
+ `, +}; + +export const SingleExpand: Story = { + argTypes: disableStoryControls(metadata), + render: () => html` +

+ Only one panel can be open at a time. Opening another panel closes the + current one. +

+ + + Getting Started + Installation and setup +

${loremShort}

+
+ + Configuration + Customize your instance +

${loremLong}

+
+ + Advanced Usage + Tips and tricks +

${loremShort}

+
+ + FAQ + Frequently asked questions +

${loremLong}

+
+
+ `, +}; + +export const DisabledPanels: Story = { + argTypes: disableStoryControls(metadata), + render: () => html` +

+ Disabled panels are skipped during keyboard navigation and cannot be + toggled. +

+ + + Active Panel + This panel is interactive +

${loremShort}

+
+ + Disabled Panel + This panel cannot be toggled +

${loremShort}

+
+ + Another Active Panel + This panel is interactive +

${loremShort}

+
+ + Disabled & Open Panel + Visible but cannot be closed by the user +

${loremShort}

+
+
+ `, +}; + +export const IndicatorPosition: Story = { + argTypes: disableStoryControls(metadata), + render: () => html` +

Indicator at start (default)

+ + + Start Position + The expand indicator is placed before the title +

${loremShort}

+
+
+ +

Indicator at end

+ + + End Position + The expand indicator is placed after the title +

${loremShort}

+
+
+ +

Indicator hidden (none)

+ + + No Indicator + The expand/collapse indicator is hidden +

${loremShort}

+
+
+ `, +}; + +export const CustomIndicator: Story = { + argTypes: disableStoryControls(metadata), + render: () => html` +

+ Use the indicator and indicator-expanded slots + for custom icons. +

+ + + Custom chevron icons + Using the indicator and indicator-expanded slots + + +

${loremShort}

+
+ + Custom emoji indicators + Any content can be used as an indicator + + +

${loremLong}

+
+ + Indicator at end with custom icon + Combining indicator-position="end" with a custom slot + + +

${loremShort}

+
+
+ `, +}; + +export const ProgrammaticControl: Story = { + argTypes: disableStoryControls(metadata), + render: () => { + const showAll = () => { + document + .querySelector('#ctrl-accordion') + ?.showAll(); + }; + + const hideAll = () => { + document + .querySelector('#ctrl-accordion') + ?.hideAll(); + }; + + return html` +
+ Expand All + Collapse All +
+ + ${Array.from(range(1, 5)).map( + (i) => + html` + Section ${i} + Programmatically controlled +

${loremShort}

+
` + )} +
+ `; + }, +}; + +export const NestedAccordions: Story = { + render: (args) => html` + + ${Array.from(range(1, 3)).map( + (i) => + html` + Top-level Panel ${i} + Click to expand +

${loremShort}

` )} -

Title 4

-

Subtitle 4

+ Panel with nested accordion + Contains its own independent accordion -

Title 4.1 title

-

Subtitle 4.1 subtitle

-

- Lorem ipsum dolor sit amet consectetur adipisicing elit. Cum quia - placeat natus illo voluptatum, praesentium similique excepturi - corporis sequi at earum labore provident asperiores dolorem fugit - explicabo ipsa distinctio doloremque? -

+ Nested Panel 1 + Inner accordion item +

${loremShort}

-

Title 4.2

-

Subtitle 4.2

- -

- Lorem ipsum dolor sit amet consectetur, adipisicing elit. - Similique modi, cumque consequuntur omnis quis odio id facere - placeat amet velit quos natus ipsam quasi, consequatur qui impedit - ullam officiis earum. -

+ Nested Panel 2 + Inner accordion item with input + +

${loremLong}

diff --git a/stories/avatar.stories.ts b/stories/avatar.stories.ts index dd0a702cf..33b491f4d 100644 --- a/stories/avatar.stories.ts +++ b/stories/avatar.stories.ts @@ -4,11 +4,23 @@ import { IgcAvatarComponent, IgcIconComponent, defineComponents, + registerIconFromText, } from 'igniteui-webcomponents'; import { html } from 'lit'; +import { disableStoryControls } from './story.js'; defineComponents(IgcAvatarComponent, IgcIconComponent); +registerIconFromText( + 'home', + `` +); + +registerIconFromText( + 'person', + `` +); + // region default const metadata: Meta = { title: 'Avatar', @@ -64,23 +76,213 @@ type Story = StoryObj; // endregion +const avatarStyle = + 'display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;'; +const sectionStyle = 'display: flex; flex-direction: column; gap: 1.5rem;'; + +const imageUrl = (id: number, gender: 'men' | 'women' = 'men') => + `https://www.infragistics.com/angular-demos/assets/images/${gender}/${id}.jpg`; + export const Image: Story = { args: { - src: 'https://www.infragistics.com/angular-demos/assets/images/men/1.jpg', + src: imageUrl(1), alt: 'Image of a man', }, + render: (args) => html` + + `, +}; + +export const Initials: Story = { + args: { initials: 'JD' }, + render: (args) => html` + + `, }; export const WithIcon: Story = { - render: () => html` - + render: (args) => html` + `, }; -export const WithInitials: Story = { - args: { - initials: 'RK', - }, +export const Shapes: Story = { + argTypes: disableStoryControls(metadata), + render: () => html` +
+
+

Image

+
+ + + +
+
+
+

Initials

+
+ + + +
+
+
+

Icon

+
+ + + +
+
+
+ `, +}; + +export const Sizes: Story = { + argTypes: disableStoryControls(metadata), + render: () => html` +
+
+

Small / Medium / Large — Image

+
+ + + +
+
+
+

Small / Medium / Large — Initials

+
+ + + +
+
+
+

Small / Medium / Large — Icon

+
+ + + +
+
+
+ `, +}; + +export const FallbackChain: Story = { + argTypes: disableStoryControls(metadata), + render: () => html` +

+ When src is omitted or fails to load, the avatar falls back + to initials, then to the default slot content. +

+
+
+ + Valid image +
+
+ + Broken src → initials +
+
+ + + + No src → icon slot +
+
+ `, +}; + +export const AvatarGroup: Story = { + argTypes: disableStoryControls(metadata), + render: () => html` +

+ Avatars can be grouped together to represent a team or set of users. +

+
+ ${[ + { src: imageUrl(1), alt: 'User 1' }, + { src: imageUrl(2), alt: 'User 2' }, + { src: imageUrl(3), alt: 'User 3' }, + { src: imageUrl(1, 'women'), alt: 'User 4' }, + { src: imageUrl(2, 'women'), alt: 'User 5' }, + ].map( + ({ src, alt }) => + html`` + )} + +
+ `, }; diff --git a/stories/badge.stories.ts b/stories/badge.stories.ts index 9fac9f298..f9847833b 100644 --- a/stories/badge.stories.ts +++ b/stories/badge.stories.ts @@ -2,14 +2,42 @@ import type { Meta, StoryObj } from '@storybook/web-components-vite'; import { html } from 'lit'; import { + IgcAvatarComponent, IgcBadgeComponent, IgcIconComponent, IgcTabsComponent, defineComponents, - registerIcon, + registerIconFromText, } from 'igniteui-webcomponents'; +import { disableStoryControls } from './story.js'; -defineComponents(IgcBadgeComponent, IgcIconComponent, IgcTabsComponent); +defineComponents( + IgcAvatarComponent, + IgcBadgeComponent, + IgcIconComponent, + IgcTabsComponent +); + +registerIconFromText( + 'home', + `` +); +registerIconFromText( + 'notifications', + `` +); +registerIconFromText( + 'mail', + `` +); +registerIconFromText( + 'person', + `` +); +registerIconFromText( + 'shopping-cart', + `` +); // region default const metadata: Meta = { @@ -74,29 +102,7 @@ type Story = StoryObj; // endregion -registerIcon( - 'home', - 'https://unpkg.com/material-design-icons@3.0.1/action/svg/production/ic_home_24px.svg' -); - -function renderTabs(args: IgcBadgeArgs) { - return ['primary', 'info', 'success', 'warning', 'danger'].map( - (variant, idx) => html` - - - ${variant.toUpperCase()} - ${idx + 1} - - - ` - ); -} +const variants = ['primary', 'info', 'success', 'warning', 'danger'] as const; export const Basic: Story = { render: ({ outlined, shape, variant, dot }) => html` @@ -106,19 +112,289 @@ export const Basic: Story = { variant=${variant} ?dot=${dot} > - + `, }; export const Variants: Story = { - render: (args) => - html` - ${renderTabs(args)}`, + argTypes: disableStoryControls(metadata), + render: () => html` +

The badge supports five semantic color variants.

+
+ ${variants.map( + (v, i) => html` +
+ ${i + 1} + ${v} +
+ ` + )} +
+ `, +}; + +export const Outlined: Story = { + argTypes: disableStoryControls(metadata), + render: () => html` +

+ The outlined attribute draws a border around the badge, + useful when placing badges over colored or patterned surfaces. +

+
+
+

Filled

+
+ ${variants.map( + (v, i) => html`${i + 1}` + )} +
+
+
+

Outlined

+
+ ${variants.map( + (v, i) => + html`${i + 1}` + )} +
+
+
+ `, +}; + +export const Shapes: Story = { + argTypes: disableStoryControls(metadata), + render: () => html` +

+ Badges can be rounded (default) for a pill-shaped label or + square for a more rectangular appearance. +

+
+
+

Rounded

+
+ ${variants.map( + (v, i) => + html`${i + 1}` + )} +
+
+
+

Square

+
+ ${variants.map( + (v, i) => + html`${i + 1}` + )} +
+
+
+ `, +}; + +export const Dot: Story = { + argTypes: disableStoryControls(metadata), + render: () => html` +

+ The dot attribute renders the badge as a compact indicator + without content — ideal for unread or online status cues. +

+
+ ${variants.map( + (v) => html` +
+ + ${v} +
+ ` + )} +
+ `, +}; + +export const WithIcon: Story = { + argTypes: disableStoryControls(metadata), + render: () => html` +

+ Any content can be slotted into the badge. When an + igc-icon is the only slotted element, the + icon CSS part is activated for targeted styling. +

+
+ + + + + + + + + + + + + + + +
+ `, +}; + +export const InContext: Story = { + argTypes: disableStoryControls(metadata), + render: () => html` +

+ Badges are typically overlaid on a host element using + position: absolute on the badge and + position: relative on the container. +

+
+
+
+ + 5 +
+ Notifications +
+ +
+
+ + 12 +
+ Messages +
+ +
+
+ + 3 +
+ Count badge +
+ +
+
+ + +
+ Online (dot) +
+ +
+
+ + 99+ +
+ Cart (square) +
+
+ `, +}; + +export const InTabs: Story = { + argTypes: disableStoryControls(metadata), + render: () => html` +

+ Badges can be embedded in tab labels to communicate counts or status at a + glance within navigation. +

+ + + + Inbox + 4 + + + + + Notifications + 7 + + + + + Updates + New + + + + Settings + + + `, }; diff --git a/stories/banner.stories.ts b/stories/banner.stories.ts index 8c8a73847..d7ea89859 100644 --- a/stories/banner.stories.ts +++ b/stories/banner.stories.ts @@ -9,6 +9,7 @@ import { defineComponents, registerIconFromText, } from 'igniteui-webcomponents'; +import { disableStoryControls } from './story.js'; defineComponents( IgcBannerComponent, @@ -17,6 +18,31 @@ defineComponents( IgcNavbarComponent ); +registerIconFromText( + 'info', + `` +); +registerIconFromText( + 'warning', + `` +); +registerIconFromText( + 'error', + `` +); +registerIconFromText( + 'check-circle', + `` +); +registerIconFromText( + 'wifi-off', + `` +); +registerIconFromText( + 'update', + `` +); + // region default const metadata: Meta = { title: 'Banner', @@ -51,45 +77,211 @@ type Story = StoryObj; // endregion -const checkIcon = - ''; - -registerIconFromText('success', checkIcon, 'material'); - export const Basic: Story = { render: (args) => html` - - -

Title

+ +

My Application

- Toggle Banner +
+ Toggle Banner +
`, }; -export const SlottedContent: Story = { - render: (args) => html` - -