Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(selection-panel): improved open/close flow and animation #2360

Merged
merged 20 commits into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
4756494
chore(selection-panel): set chromatic min-height
TomMenga Jan 23, 2024
d56d30b
chore(selection-panel): set chromatic min-height
TomMenga Jan 23, 2024
b939828
refactor(selection-panel): improved open/close flow and animation
TomMenga Jan 22, 2024
218b13a
refactor(selection-panel): removed ref usage
TomMenga Jan 22, 2024
656a783
refactor(selection-panel): now only reacts to main input changes
TomMenga Jan 22, 2024
94d5d4b
chore(selection-panel): chromatic fix
TomMenga Jan 22, 2024
dbe7fdb
test(selection-panel): enhance robusteness
TomMenga Jan 22, 2024
bed60e3
refactor(selection-panel): fix ts
TomMenga Jan 22, 2024
0bbe0aa
chore(selection-panel): set chromatic min-height
TomMenga Jan 22, 2024
8b259ca
chore(selection-panel): set chromatic min-height
TomMenga Jan 23, 2024
626d133
chore(selection-panel): set chromatic min-height
TomMenga Jan 23, 2024
9c2f17b
chore(selection-panel): set chromatic min-height pt.2
TomMenga Jan 23, 2024
f40ab09
chore(selection-panel): set chromatic min-height pt.3
TomMenga Jan 23, 2024
8f6f546
chore(selection-panel): set chromatic min-height pt.4
TomMenga Jan 23, 2024
c95ce9c
feat(chromatic-stories): implemented 'fixedHeight' chromatic param
TomMenga Jan 23, 2024
b1b05cd
chore(selection-panel): set chromatic min-height pt.5
TomMenga Jan 23, 2024
5ceddca
feat(chromatic-stories): implemented 'fixedHeight' chromatic param
TomMenga Jan 23, 2024
59ce0bc
chore(selection-panel, notification): set chromatic min-height
TomMenga Jan 23, 2024
c7141c5
refactor(selection-panel): disabled open/close animation before initi…
TomMenga Jan 25, 2024
a0be039
docs(selection-panel): update docs
TomMenga Jan 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion scripts/chromatic-stories-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ async function generateChromaticStory(
return 'no params found';
}

const { disableSnapshot, ...chromaticParameters } = parameters?.chromatic ?? {};
const { disableSnapshot, fixedHeight, ...chromaticParameters } = parameters?.chromatic ?? {};
if (!parameters) {
return 'no params found';
} else if (disableSnapshot !== undefined) {
Expand All @@ -74,14 +74,35 @@ async function generateChromaticStory(
const relativeImport = basename(storyFile).replace(/\.ts$/, '');
const chromaticImport = relative(dirname(targetStoryFile), chromaticFile).replace(/\.ts$/, '');

/**
* The `fixedHeight` param forces the height of the snapshot on chromatic.
* It might be useful in cases where some content is cut off at the end of a snapshot
* The max fixedHeight we can use is 17'000 (17k * 1440 =~ 25kk)
* Now, the max snapshot size is 25'000'000px.
*
* Example:
* ```
* ...
* parameters: {
* chromatic: { fixedHeight: '17000px', ... },
* ...
* }
* ```
*/
const fixedHeightStyle = fixedHeight ? `style="min-height: ${fixedHeight}"` : '';

const chromaticConfig = Object.entries(chromaticParameters)
.map(([key, value]) => `${key}: ${JSON.stringify(value)}, `)
.join('');
const storyFileContent = `import type { Meta, StoryObj } from '@storybook/web-components';
import config, * as stories from './${relativeImport}';
import { combineStories } from '${chromaticImport}';
import { html } from 'lit';

const meta: Meta = {
decorators: [
(story) => html\` <div ${fixedHeightStyle}>\${story()}</div> \`,
],
parameters: {
backgrounds: {
disable: true,
Expand Down
8 changes: 7 additions & 1 deletion src/components/checkbox/checkbox/checkbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,13 @@ export class SbbCheckboxElement extends UpdateScheduler(LitElement) {
}
private _size: SbbCheckboxSize = 'm';

/** Whether the input is the main input of a selection panel. */
/**
* Whether the input is the main input of a selection panel.
* @internal
*/
public get isSelectionPanelInput(): boolean {
return this._isSelectionPanelInput;
}
@state() private _isSelectionPanelInput = false;

/** The label describing whether the selection panel is expanded (for screen readers only). */
Expand Down
5 changes: 2 additions & 3 deletions src/components/notification/notification.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,9 +237,7 @@ const meta: Meta = {
decorators: [
(story, context) =>
html`<div
style="padding: 2rem;display: flex;gap: var(--sbb-spacing-fixed-4x);flex-direction: column;${isChromatic()
? 'min-height: 1000px;'
: ''}"
style="padding: 2rem;display: flex;gap: var(--sbb-spacing-fixed-4x);flex-direction: column;"
>
${trigger(context.args)}
<div class="notification-container" style="display: flex; flex-direction: column;">
Expand All @@ -250,6 +248,7 @@ const meta: Meta = {
withActions as Decorator,
],
parameters: {
chromatic: { fixedHeight: '7500px' },
actions: {
handles: [
SbbNotificationElement.events.didOpen,
Expand Down
4 changes: 4 additions & 0 deletions src/components/radio-button/radio-button/radio-button.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,11 @@ export class SbbRadioButtonElement extends UpdateScheduler(LitElement) {

/**
* Whether the input is the main input of a selection panel.
* @internal
*/
public get isSelectionPanelInput(): boolean {
return this._isSelectionPanelInput;
}
@state() private _isSelectionPanelInput = false;

/**
Expand Down
12 changes: 6 additions & 6 deletions src/components/selection-panel/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,12 @@ It's also possible to display the `sbb-selection-panel` without border by settin

## Events

| Name | Type | Description | Inherited From |
| ----------- | ------------------------------------------- | ----------------------------------------------------------------- | -------------- |
| `willOpen` | `CustomEvent<void>` | Emits whenever the content section starts the opening transition. | |
| `didOpen` | `CustomEvent<void>` | Emits whenever the content section is opened. | |
| `willClose` | `CustomEvent<{ closeTarget: HTMLElement }>` | Emits whenever the content section begins the closing transition. | |
| `didClose` | `CustomEvent<{ closeTarget: HTMLElement }>` | Emits whenever the content section is closed. | |
| Name | Type | Description | Inherited From |
| ----------- | ------------------- | ----------------------------------------------------------------- | -------------- |
| `willOpen` | `CustomEvent<void>` | Emits whenever the content section starts the opening transition. | |
| `didOpen` | `CustomEvent<void>` | Emits whenever the content section is opened. | |
| `willClose` | `CustomEvent<void>` | Emits whenever the content section begins the closing transition. | |
| `didClose` | `CustomEvent<void>` | Emits whenever the content section is closed. | |

## Slots

Expand Down
Loading