Skip to content

Commit

Permalink
feat: ✨ add sd-step & sd-step-group (#1007)
Browse files Browse the repository at this point in the history
  • Loading branch information
Vahid1919 committed May 24, 2024
1 parent 7fd81fe commit d42c66f
Show file tree
Hide file tree
Showing 18 changed files with 1,316 additions and 21 deletions.
2 changes: 1 addition & 1 deletion packages/components/src/components/checkbox/checkbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ export default class SdCheckbox extends SolidElement implements SolidFormControl
>
${this.checked
? html`
<sd-icon part="checked-icon" class="text-white w-3 h-3" library="system" name="status-hook"></sd-icon>
<sd-icon part="checked-icon" class="text-white w-3 h-3" library="system" name="status-check"></sd-icon>
`
: ''}
${!this.checked && this.indeterminate
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/components/icon/icon.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export const LibraryDefault = {
})
}; /**
* System icons are an integrated library of the Solid Components to ensure they're always available.
* They are a subset of Union Investment's official icons. As these may change over time, we don't recommend using them directly.
* They are a subset of Union Investment's official icons. As these may change over time, system icons should NOT be used directly.
*
* The story below shows all available icons.
*/
Expand Down
9 changes: 2 additions & 7 deletions packages/components/src/components/icon/library.system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,6 @@ export const icons = {
<path d="M12 2C6.477 2 2 6.477 2 12s4.477 10 10 10 10-4.477 10-10S17.523 2 12 2Zm0 18a8 8 0 1 1 0-16 8 8 0 0 1 0 16Z"/>
<path d="M16.373 7.627a1 1 0 0 0-1.414 0l-2.96 2.96-2.96-2.96a1 1 0 0 0-1.413 1.414l-.001-.001 2.96 2.96-2.96 2.96a1 1 0 0 0 1.414 1.414l2.96-2.96 2.96 2.96a1 1 0 0 0 1.414-1.414L13.413 12l2.96-2.96a1 1 0 0 0 0-1.414v.001Z"/>
</svg>`,
confirm: `
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<path d="M21.528 2.167a1 1 0 0 0-1.384.277l-.002.004-11.333 17-5.127-5.153a1 1 0 0 0-1.413 1.414l-.001-.001 6 6a.997.997 0 0 0 .707.293h.1c.307-.032.57-.199.731-.44l.002-.004 12-18a1 1 0 0 0-.276-1.388l-.004-.002Z"/>
</svg>
`,
eye: `
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<path d="M12 18.96c-5.263 0-10-5.68-10-6.96 0-1.28 4.737-6.96 10-6.96S22 10.72 22 12c0 1.28-4.737 6.96-10 6.96ZM4.1 12c.76 1.197 4.07 4.96 7.9 4.96s7.14-3.767 7.9-4.96c-.76-1.197-4.07-4.96-7.9-4.96S4.86 10.807 4.1 12Z"/>
Expand All @@ -59,8 +54,8 @@ export const icons = {
</svg>
`,
'info-circle': `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 2C6.477 2 2 6.477 2 12s4.477 10 10 10 10-4.477 10-10S17.523 2 12 2Zm0 18a8 8 0 1 1 0-16 8 8 0 0 1 0 16Z"/><path d="M13.333 7.833a1.5 1.5 0 1 1-3.001-.001 1.5 1.5 0 0 1 3.001.001ZM13 11.667a1 1 0 0 0-1-1h-1a1 1 0 0 0 0 2v2.667h2v-3.667Z"/><path d="M11 16.333v-1h-1a1 1 0 0 0 0 2h2a1 1 0 0 1-1-1Zm3-1h-1v1a1 1 0 0 1-1 1h2a1 1 0 0 0 0-2Z"/><path d="M13 16.333v-1h-2v1a1 1 0 0 0 2 0Z"/></svg>`,
'status-hook': `
<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" fill="none">
'status-check': `
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 12 13">
<path fill="currentColor" d="m9.947 1.138-.005.008-.001.003-5.56 8.34-2.434-2.447-.004-.004a.648.648 0 0 0-1.093.475c0 .172.066.328.175.444l.003.004 3 2.999c.117.117.28.19.46.19h.065c.2-.021.37-.13.475-.286l.005-.008.001-.002 5.994-8.992a.65.65 0 0 0-.18-.902l-.007-.005-.002-.002a.65.65 0 0 0-.892.185Z"/>
</svg>
`,
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/components/input/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@ export default class SdInput extends SolidElement implements SolidFormControl {
<sd-icon
class=${cx('text-success flex-shrink-0', iconMarginLeft, iconSize)}
library="system"
name="confirm"
name="status-check"
part="valid-icon"
></sd-icon>
`
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/components/option/option.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ export default class SdOption extends SolidElement {
part="checked-icon"
class="text-white w-3 h-3"
library="system"
name="status-hook"
name="status-check"
></sd-icon>
`
: ''}
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/components/select/select.ts
Original file line number Diff line number Diff line change
Expand Up @@ -991,7 +991,7 @@ export default class SdSelect extends SolidElement implements SolidFormControl {
part="valid-icon"
class=${cx('flex-shrink-0', iconMarginLeft, iconSize)}
library="system"
name="confirm"
name="status-check"
></sd-icon>
`
: ''}
Expand Down
283 changes: 283 additions & 0 deletions packages/components/src/components/step-group/step-group.stories.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,283 @@
import '../../solid-components';
import { html } from 'lit-html';
import { storybookDefaults, storybookHelpers, storybookTemplate } from '../../../scripts/storybook/helper';
import { waitUntil } from '@open-wc/testing-helpers';
import { withActions } from '@storybook/addon-actions/decorator';

const { argTypes, parameters } = storybookDefaults('sd-step-group');
const { overrideArgs } = storybookHelpers('sd-step-group');
const { generateTemplate } = storybookTemplate('sd-step-group');

export default {
title: 'Components/sd-step-group',
component: 'sd-step-group',
args: overrideArgs([
{
type: 'slot',
name: 'default',
value: `
<sd-step size="lg" orientation="horizontal" state="default">
<p slot="label">Lorem ipsum dolor sit</p>
</sd-step>
<sd-step size="lg" orientation="horizontal" state="current">
<p slot="label">Exercitation ullamco laboris</p>
</sd-step>
<sd-step size="lg" orientation="horizontal" state="disabled">
<p slot="label">Reprehenderit qui in e name</p>
</sd-step>`
},
{
type: 'attribute',
name: 'active-step',
value: `1`
}
]),
argTypes,
parameters: { ...parameters },
decorators: [withActions] as any
};

/**
* Default: This shows sd-step-group in its default state.
*/

export const Default = {
render: (args: any) => {
return html`<div style="height:250px">${generateTemplate({ args })}</div>`;
}
};

/**
* Use the orientation attribute to set the axis of a step-group.
*/

export const Orientation = {
parameters: { controls: { exclude: 'orientation' } },
render: (args: any) => {
return generateTemplate({
axis: {
y: { type: 'attribute', name: 'orientation' }
},
args
});
},
decorators: [
(story: () => typeof html) => html`
<style>
td.template {
width: 100%;
height: 250px;
}
</style>
${story()}
`
]
};

/**
* Use the not-interactive attribute to create a non-interactive step group.
*/

export const notInteractive = {
name: 'Not Interactive X Size',
parameters: { controls: { exclude: 'not-interactive' } },
render: (args: any) => {
return generateTemplate({
axis: {
x: { type: 'attribute', name: 'not-interactive' },
y: { type: 'attribute', name: 'size' }
},
args
});
},
decorators: [
(story: () => typeof html) => html`
<style>
td.template {
width: 100%;
}
</style>
${story()}
`
]
};

/**
* Use the 'base' and 'body' parts to style the step-group.
*/
export const Parts = {
parameters: {
controls: {
exclude: ['base', 'body']
}
},
render: () => {
return generateTemplate({
axis: {
x: { type: 'attribute', name: 'orientation' },
y: {
type: 'template',
name: 'sd-step-group::part(...){outline: solid 2px red}',
values: ['base', 'body'].map(part => {
return {
title: part,
value: `<style>#part-${part} sd-step-group::part(${part}){outline: solid 2px red; outline-offset: 0px;}</style><div id="part-${part}">%TEMPLATE%</div>`
};
})
}
},
args: overrideArgs([
{
type: 'slot',
name: 'default',
value: `
<sd-step size="lg" orientation="horizontal" state="default">
<p slot="label">Lorem ipsum dolor sit</p>
Lorem ipsum est dolor sit amet
</sd-step>
<sd-step size="lg" orientation="horizontal" state="current">
<p slot="label">Exercitation ullamco laboris</p>
Lorem ipsum est dolor sit amet
</sd-step>
<sd-step size="lg" orientation="horizontal" state="disabled">
<p slot="label">Reprehenderit qui in e name</p>
Lorem ipsum est dolor sit amet
</sd-step>`
},
{
type: 'attribute',
name: 'active-step',
value: `1`
}
])
});
}
};

/**
* sd-steps are fully accessibile via keyboard.
*/

export const Mouseless = {
render: (args: any) => {
return html`<div class="mouseless">
${generateTemplate({
args
})}
</div>`;
},

play: async ({ canvasElement }: { canvasElement: HTMLUnknownElement }) => {
const el = canvasElement.querySelector('.mouseless sd-step-group');
await waitUntil(() => el?.querySelector('sd-step')?.shadowRoot?.querySelector('button'));

el?.querySelector('sd-step')?.shadowRoot?.querySelector('button')!.focus();
}
};

/**
* This sample shows how to set the active step programmatically.
*/

export const SetActiveStep = {
parameters: { controls: { include: [] } },
name: 'Sample: Set Active Step',
render: () => {
return html`
<sd-step-group id="set-active" size="lg" orientation="horizontal" active-step="0">
<sd-step size="lg" orientation="horizontal">
<p slot="label">Lorem ipsum dolor sit</p>
</sd-step>
<sd-step size="lg" orientation="horizontal">
<p slot="label">Exercitation ullamco laboris</p>
</sd-step>
<sd-step size="lg" orientation="horizontal">
<p slot="label">Reprehenderit qui in e name</p>
</sd-step>
</sd-step-group>
<sd-button class="w-20 mt-8" size="sm" id="previous">Previous</sd-button>
<sd-button class="w-20 mt-8" size="sm" id="next">Next</sd-button>
<script type="module">
const stepGroup = await document.querySelector('sd-step-group#set-active');
const nextBtn = document.querySelector('sd-button#next');
const prevBtn = document.querySelector('sd-button#previous');
nextBtn.addEventListener('click', () => {
stepGroup.setActiveStep(stepGroup.activeStep + 1);
});
prevBtn.addEventListener('click', () => {
stepGroup.setActiveStep(stepGroup.activeStep - 1);
});
</script>
`;
}
};

/**
* This sample shows how to use the not-interactive attribute with content icons. The border-radius of an sd-step is larger when the not-interactive attribute is set to `true`.
* The size of the icon is recommended to be 48px for the 'lg' size and 32px for the 'sm' size. The size can be set using font-size.
*/

export const SampleNotInteractive = {
parameters: { controls: { include: [] } },
name: 'Sample: Not Interactive',
render: () => {
return html`
<style>
.headline {
padding: 16px;
background: #e0e0e0;
text-align: left;
font-size: 14px;
font-weight: bold;
width: 100%;
box-sizing: border-box;
}
</style>
<div class="headline">size = 'lg'</div>
<sd-step-group size="lg" orientation="horizontal" not-interactive>
<sd-step orientation="horizontal">
<p slot="label">Lorem ipsum dolor sit</p>
<sd-icon class="text-[48px]" name="content/image" slot="circle-content"></sd-icon>
</sd-step>
<sd-step orientation="horizontal">
<p slot="label">Exercitation ullamco laboris</p>
<sd-icon class="text-[48px]" name="content/image" slot="circle-content"></sd-icon>
</sd-step>
<sd-step orientation="horizontal">
<p slot="label">Reprehenderit qui in e name</p>
<sd-icon class="text-[48px]" name="content/image" slot="circle-content"></sd-icon>
</sd-step>
</sd-step-group>
<div class="headline">size = 'sm'</div>
<sd-step-group size="sm" orientation="horizontal" not-interactive>
<sd-step orientation="horizontal">
<p slot="label">Lorem ipsum dolor sit</p>
<sd-icon class="text-3xl" name="content/image" slot="circle-content"></sd-icon>
</sd-step>
<sd-step orientation="horizontal">
<p slot="label">Exercitation ullamco laboris</p>
<sd-icon class="text-3xl" name="content/image" slot="circle-content"></sd-icon>
</sd-step>
<sd-step orientation="horizontal">
<p slot="label">Reprehenderit qui in e name</p>
<sd-icon class="text-3xl" name="content/image" slot="circle-content"></sd-icon>
</sd-step>
</sd-step-group>
`;
}
};

0 comments on commit d42c66f

Please sign in to comment.