Skip to content

Commit

Permalink
docs(description-list, tab): storybook docs
Browse files Browse the repository at this point in the history
  • Loading branch information
clukhei committed Dec 23, 2024
1 parent 4314a2d commit 3911965
Show file tree
Hide file tree
Showing 10 changed files with 168 additions and 89 deletions.
4 changes: 2 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ <h3>Size</h3>
</sgds-table>
</div>
<div class="container">
<sgds-tab-group variant="tabs-info-toggle">
<sgds-tab-group>
<sgds-tab slot="nav" panel="apple">
<sgds-icon slot="icon" name="map"></sgds-icon>
<span slot="count">1</span>
Expand All @@ -489,7 +489,7 @@ <h3>Size</h3>
<sgds-tab-panel name="banana">Banana</sgds-tab-panel>
<sgds-tab-panel name="carrot">Carrot</sgds-tab-panel>
</sgds-tab-group>
<sgds-tab-group variant="tabs-basic-toggle">
<sgds-tab-group>
<sgds-tab slot="nav" panel="12">
<sgds-icon slot="icon" name="map"></sgds-icon>
<span>12</span>
Expand Down
2 changes: 1 addition & 1 deletion scripts/generateStories.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ ${ArgsType.join('\n')}
${methodsMeta.map(meta => {
if (meta.methods.length > 0){
return `## Methods \n### ${meta.tagName}\n<table>
return `## Methods \n ### ${meta.tagName}\n<table>
<thead>
<tr>
<th>Name</th>
Expand Down
2 changes: 1 addition & 1 deletion src/components/DescriptionList/sgds-description-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ let id = 0;

/**
*
* @summary Description Lists are used with description list group as list components
* @summary Description Lists are used with description list group as list components. A description list (often referred to as a “definition list”) is a type of list used in web design and documentation to pair terms with their corresponding descriptions or values.
*
* @slot default - The slot for the label
* @slot data - The slot for the data
Expand Down
27 changes: 27 additions & 0 deletions stories/templates/DescriptionList/additional.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
## Title and subtitle slots

Title and subtitle are optional items. They provide more context to the subtitle list as a group

Use `slot=title` and `slot=subtitle` to pass in title and subtitle

<Canvas of={DescriptionListStories.OptionalTitleDescription}>
<Story of={DescriptionListStories.OptionalTitleDescription} />
</Canvas>


## Stacked layout

By default, the layout of description list is inline. Add boolean `stacked` attribute to `SgdsDescriptionListGroup` for a stacked layout

<Canvas of={DescriptionListStories.Stacked}>
<Story of={DescriptionListStories.Stacked} />
</Canvas>


## Bordered

By default, there are no borders to the description list. Add `bordered` attribute to `SgdsDescriptionListGroup` for a bordered description list

<Canvas of={DescriptionListStories.Bordered}>
<Story of={DescriptionListStories.Bordered} />
</Canvas>
21 changes: 21 additions & 0 deletions stories/templates/DescriptionList/additional.stories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
export const OptionalTitleDescription = {
render: Template.bind({}),
name: "Optional title and subtitle",
args: { title: true, subtitle: true },
parameters: {},
tags: ["!dev"]
};
export const Stacked = {
render: Template.bind({}),
name: "Stacked layout",
args: { stacked: true },
parameters: {},
tags: ["!dev"]
};
export const Bordered = {
render: Template.bind({}),
name: "Bordered",
args: { bordered: true },
parameters: {},
tags: ["!dev"]
};
25 changes: 23 additions & 2 deletions stories/templates/DescriptionList/basic.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,27 @@
import { html } from "lit-html";
import { html, nothing } from "lit-html";

export const Template = args => html`<sgds-description-list></sgds-description-list>`;
export const Template = args => html`
<sgds-description-list-group ?stacked=${args.stacked} ?bordered=${args.bordered}>
${args.title ? html`<span slot="title"> Title</span>` : nothing}
${args.subtitle ? html`<span slot="subtitle">Description</span>` : nothing}
<sgds-description-list>
Label 1
<span slot="data">Value Text Description List 1</span>
</sgds-description-list>
<sgds-description-list>
Label 2
<span slot="data">Value Text Description List 2</span>
</sgds-description-list>
<sgds-description-list>
Label 3
<span slot="data">Value Text Description List 3</span>
</sgds-description-list>
<sgds-description-list>
Label 4
<span slot="data">Value Text Description List 4</span>
</sgds-description-list>
</sgds-description-list-group>
`;

export const args = {};

Expand Down
7 changes: 0 additions & 7 deletions stories/templates/DescriptionListGroup/basic.js

This file was deleted.

51 changes: 51 additions & 0 deletions stories/templates/Tab/additional.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
## Variants

The variants of tab is controlled by `SgdsTabGroup`
The default tab variant is `underlined`. Modify the `variant` prop to achieve solid tabs

### Underlined tabs (default)

<Canvas of={TabStories.Basic}>
<Story of={TabStories.Basic} />
</Canvas>

### Solid tabs

<Canvas of={TabStories.SolidVariant}>
<Story of={TabStories.SolidVariant} />
</Canvas>

## Density

The density of tabs is controlled by `SgdsTabGroup`. For a more compact tabs, modify `density` prop to `compact`


### Compact underlined tabs

<Canvas of={TabStories.UnderlinedDensityCompact}>
<Story of={TabStories.UnderlinedDensityCompact} />
</Canvas>

### Compact solid tabs

<Canvas of={TabStories.SolidDensityCompact}>
<Story of={TabStories.SolidDensityCompact} />
</Canvas>

## Orientation

Tabs can also be of horizontal or vertical orientation.
The orientation of tabs is controlled by `SgdsTabGroup`.
By default, tabs are presented horizontally. Set `orientation` to `vertical` for vertical tabs

### Vertical underlined tabs

<Canvas of={TabStories.OrientationUnderlined}>
<Story of={TabStories.OrientationUnderlined} />
</Canvas>

### Vertical solid tabs

<Canvas of={TabStories.OrientationSolid}>
<Story of={TabStories.OrientationSolid} />
</Canvas>
36 changes: 36 additions & 0 deletions stories/templates/Tab/additional.stories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
export const SolidVariant = {
render: Template.bind({}),
name: "Solid variant",
args: { variant: "solid" },
parameters: {},
tags: ["!dev"]
};
export const UnderlinedDensityCompact = {
render: Template.bind({}),
name: "Compact density for underlined tabs",
args: { density: "compact" },
parameters: {},
tags: ["!dev"]
};
export const SolidDensityCompact = {
render: Template.bind({}),
name: "Compact density for solid tabs",
args: { density: "compact", variant: "solid" },
parameters: {},
tags: ["!dev"]
};

export const OrientationUnderlined = {
render: Template.bind({}),
name: "Vertical orientation for underlined tabs",
args: { orientation: "vertical" },
parameters: {},
tags: ["!dev"]
};
export const OrientationSolid = {
render: Template.bind({}),
name: "Vertical orientation for solid tabs",
args: { orientation: "vertical", variant: "solid" },
parameters: {},
tags: ["!dev"]
};
82 changes: 6 additions & 76 deletions stories/templates/Tab/basic.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { html } from "lit-html";
import { ifDefined } from "lit/directives/if-defined.js";

export const Template = ({ disabled }) => html`
<h5>Default toggle</h5>
<sgds-tab-group>
export const Template = ({ variant, orientation, density }) => html`
<sgds-tab-group variant=${ifDefined(variant)} orientation=${ifDefined(orientation)} density=${ifDefined(density)}>
<sgds-tab slot="nav" panel="home">Home</sgds-tab>
<sgds-tab slot="nav" panel="profile" active ?disabled=${disabled}>Profile</sgds-tab>
<sgds-tab slot="nav" panel="profile">Profile</sgds-tab>
<sgds-tab slot="nav" panel="contact">Contact</sgds-tab>
<sgds-tab-panel name="home"
>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's
Expand All @@ -19,82 +18,13 @@ export const Template = ({ disabled }) => html`
>
<sgds-tab-panel name="contact">Contact information</sgds-tab-panel>
</sgds-tab-group>
<br />
<h5>Basic toggle</h5>
<sgds-tab-group variant="tabs-basic-toggle">
<sgds-tab slot="nav" panel="home" ?disabled=${disabled}
><svg
xmlns="http://www.w3.org/2000/svg"
width="16"
height="16"
fill="currentColor"
class="bi bi-house"
viewBox="0 0 16 16"
>
<path
d="M8.707 1.5a1 1 0 0 0-1.414 0L.646 8.146a.5.5 0 0 0 .708.708L2 8.207V13.5A1.5 1.5 0 0 0 3.5 15h9a1.5 1.5 0 0 0 1.5-1.5V8.207l.646.647a.5.5 0 0 0 .708-.708L13 5.793V2.5a.5.5 0 0 0-.5-.5h-1a.5.5 0 0 0-.5.5v1.293L8.707 1.5ZM13 7.207V13.5a.5.5 0 0 1-.5.5h-9a.5.5 0 0 1-.5-.5V7.207l5-5 5 5Z"
/>
</svg>
Home
</sgds-tab>
<sgds-tab active slot="nav" panel="profile">Profile</sgds-tab>
<sgds-tab slot="nav" panel="contact">Contact</sgds-tab>
<sgds-tab-panel name="home"
>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's
standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a
type specimen book.</sgds-tab-panel
>
<sgds-tab-panel name="profile"
>It is a long established fact that a reader will be distracted by the readable content of a page when looking at
its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as
opposed to using 'Content here, content here',</sgds-tab-panel
>
<sgds-tab-panel name="contact">Contact information</sgds-tab-panel>
<br />
<h5>Info toggle</h5>
<sgds-tab-group variant="tabs-info-toggle">
<sgds-tab slot="nav" panel="home" ?disabled=${disabled}>
<svg
slot="icon"
xmlns="http://www.w3.org/2000/svg"
width="16"
height="16"
fill="currentColor"
class="bi bi-house"
viewBox="0 0 16 16"
>
<path
d="M8.707 1.5a1 1 0 0 0-1.414 0L.646 8.146a.5.5 0 0 0 .708.708L2 8.207V13.5A1.5 1.5 0 0 0 3.5 15h9a1.5 1.5 0 0 0 1.5-1.5V8.207l.646.647a.5.5 0 0 0 .708-.708L13 5.793V2.5a.5.5 0 0 0-.5-.5h-1a.5.5 0 0 0-.5.5v1.293L8.707 1.5ZM13 7.207V13.5a.5.5 0 0 1-.5.5h-9a.5.5 0 0 1-.5-.5V7.207l5-5 5 5Z"
/>
</svg>
<span slot="count">1</span><span slot="label">Home</span>
</sgds-tab>
<sgds-tab slot="nav" panel="profile"><span slot="count">2</span><span slot="label">Profile</span></sgds-tab>
<sgds-tab slot="nav" panel="contact"
><sgds-badge slot="count" variant="light" badgeClasses="text-dark">100</sgds-badge
><span slot="label">Contact</span></sgds-tab
>
<sgds-tab-panel name="home"
>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's
standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make
a type specimen book.</sgds-tab-panel
>
<sgds-tab-panel name="profile"
>It is a long established fact that a reader will be distracted by the readable content of a page when looking
at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as
opposed to using 'Content here, content here',</sgds-tab-panel
>
<sgds-tab-panel name="contact">Contact information</sgds-tab-panel>
</sgds-tab-group>
</sgds-tab-group>
`;

export const args = {
name: "home",
panel: "home"
// name: "home",
// panel: "home"
};

export const parameters = {
controls: { exclude: ["name", "panel", "active", "variant"] }
// controls: { exclude: ["name", "panel", "active", "variant"] }
};

0 comments on commit 3911965

Please sign in to comment.