Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
204 commits
Select commit Hold shift + click to select a range
6e24da4
Replace experimental_SIDEBAR_BOTTOM API with a core story status filt…
ghengeveld Jul 23, 2024
dd5e342
Merge branch 'next' into sidebar-bottom-filters
yannbf Jul 23, 2024
5a60cf5
Mark experimental_SIDEBAR_BOTTOM as deprecated
ghengeveld Jul 23, 2024
61a0223
Update stories
ghengeveld Jul 23, 2024
04bd79a
Mark experimental_SIDEBAR_TOP as deprecated
ghengeveld Jul 24, 2024
ed560db
Add migration notes for deprecated APIs
ghengeveld Jul 24, 2024
257f53d
Rename story for consistency
ghengeveld Jul 24, 2024
1964c2d
add Vitest integration tests to sandboxes
yannbf Jul 25, 2024
67a6a60
disable most CI checks (revert this commit)
yannbf Jul 25, 2024
8b309e4
skip html related sandboxes
yannbf Jul 25, 2024
eec554a
add svelte plugin
yannbf Jul 25, 2024
834647d
fix sandbox filter
yannbf Jul 25, 2024
8623b92
filter more sandboxes
yannbf Jul 26, 2024
d01d653
fix parallelization
yannbf Jul 26, 2024
ac1a81d
fix paths in sveltekit vitest config
yannbf Jul 26, 2024
f7f076c
add nextjs to vitest sandbox tests
yannbf Jul 29, 2024
ad09c0e
Update story status indicators and tooltips
ghengeveld Jul 29, 2024
1cb605f
Update summary logic
ghengeveld Jul 29, 2024
c5b2538
Update icons and fix some stories
ghengeveld Jul 29, 2024
7a7944a
Merge pull request #28693 from storybookjs/sidebar-bottom-filters
yannbf Jul 30, 2024
9b35a31
Merge branch 'vitest-integration' into sidebar-story-status-tooltips
yannbf Jul 30, 2024
84f5b63
Merge branch 'vitest-integration' into add-vitest-ci-task
yannbf Jul 30, 2024
abe32f6
set up nextjs
yannbf Jul 30, 2024
80b5481
Fix success icon
ghengeveld Jul 30, 2024
b644b1f
fix type usage in renderers
ndelangen Jul 29, 2024
3c6860b
Build: Use !test tag to disable test-runner tests
yannbf Jul 29, 2024
c3ede6b
Write changelog for 8.3.0-alpha.3 [skip ci]
storybook-bot Jul 29, 2024
fb78fc5
Bump version from "8.3.0-alpha.2" to "8.3.0-alpha.3" [skip ci]
storybook-bot Jul 29, 2024
fc6202e
Scaffold addon-vitest skeleton
ghengeveld Jul 29, 2024
39f688d
Setup addon-vitest in internal Storybook
ghengeveld Jul 29, 2024
b82c13a
Some fixes and cleanup
ghengeveld Jul 29, 2024
ac23ae6
Load Vitest results from JUnit report and update story statuses accor…
ghengeveld Jul 30, 2024
fe5a978
Add onClick handler
ghengeveld Jul 30, 2024
edef177
Update @storybook/icons dependency
ghengeveld Jul 30, 2024
1052856
Merge branch 'next' into vitest-integration
yannbf Jul 30, 2024
f3433c6
Merge branch 'vitest-integration' into add-vitest-ci-task
yannbf Jul 30, 2024
bd1d751
update scripts for nextjs
yannbf Jul 31, 2024
ecf1c85
fix
yannbf Jul 31, 2024
8caca19
Merge remote-tracking branch 'origin/next' into add-vitest-ci-task
valentinpalkovic Jul 31, 2024
503de44
Don't mess with the panel position
ghengeveld Jul 31, 2024
8f2c88d
Use internal renderToCanvas method if testingLibaryRender is not spec…
kasperpeulen Jul 31, 2024
afd11a8
Merge branch 'next' into kasper/render-agnostic
kasperpeulen Jul 31, 2024
ca74d8a
Merge remote-tracking branch 'refs/remotes/origin/next' into vitest-i…
kasperpeulen Jul 31, 2024
81b6775
Fix LinkWrapper on TooltipLinkList stories
ghengeveld Jul 31, 2024
d2965c9
Adjust snapshots
kasperpeulen Jul 31, 2024
b672f53
Merge remote-tracking branch 'origin/kasper/render-agnostic' into kas…
kasperpeulen Jul 31, 2024
5631f17
Adjust snapshots
kasperpeulen Jul 31, 2024
aa18abb
Merge branch 'vitest-integration' into add-vitest-ci-task
yannbf Jul 31, 2024
c6ebc2c
Fix hover behavior and search view
ghengeveld Aug 1, 2024
d57f328
Merge pull request #28739 from storybookjs/sidebar-story-status-tooltips
yannbf Aug 1, 2024
c4dbf12
Merge branch 'vitest-integration' into add-vitest-ci-task
yannbf Aug 1, 2024
a076ef1
Revert "disable most CI checks (revert this commit)"
yannbf Aug 1, 2024
ab76bac
pass rsc decorators but not the parameters
yannbf Aug 1, 2024
0841ad2
add remark on vitest file
yannbf Aug 1, 2024
2996b7f
Fix tests
kasperpeulen Aug 1, 2024
64a9fa3
Fix build
kasperpeulen Aug 1, 2024
8b59671
fix
yannbf Aug 1, 2024
d06ab28
Merge branch 'vitest-integration' into addon-vitest
ghengeveld Aug 1, 2024
07babfe
Fix act errors
kasperpeulen Aug 1, 2024
2241c54
yarn.lock
kasperpeulen Aug 1, 2024
87c6223
Merge pull request #28708 from storybookjs/add-vitest-ci-task
yannbf Aug 1, 2024
c62e41d
Merge branch 'vitest-integration' into addon-vitest
yannbf Aug 1, 2024
e30bfcc
Fix tests
kasperpeulen Aug 1, 2024
6289999
Merge remote-tracking branch 'refs/remotes/origin/vitest-integration'…
kasperpeulen Aug 1, 2024
21112bc
set up vitest addon in internal storybook
yannbf Aug 1, 2024
31183db
fix formatting
yannbf Aug 2, 2024
257a945
Allow vitest plugin to use composeStories from preview-api
kasperpeulen Aug 2, 2024
df69ef5
More reliable status reporting
ghengeveld Aug 2, 2024
89e4a1f
Merge branch 'next' into vitest-integration
yannbf Aug 2, 2024
c98e196
Merge branch 'vitest-integration' into addon-vitest
yannbf Aug 2, 2024
81c6a13
rename to experimental
yannbf Aug 2, 2024
072a951
Make it work with the plugin canary release
kasperpeulen Aug 2, 2024
76391dd
Merge remote-tracking branch 'refs/remotes/origin/vitest-integration'…
kasperpeulen Aug 2, 2024
89f3a13
Fix
kasperpeulen Aug 2, 2024
f90d77c
strip out junit logic (for now)
yannbf Aug 2, 2024
feccff5
Fix null pointer
kasperpeulen Aug 2, 2024
e532994
Fix check
kasperpeulen Aug 2, 2024
3f96682
Remove test
kasperpeulen Aug 2, 2024
4300175
wip: add vitest plugin to addon
yannbf Aug 4, 2024
ef94fa3
Merge branch 'next' into vitest-integration
yannbf Aug 5, 2024
0760555
Fix cypress test
kasperpeulen Aug 5, 2024
8fde44d
Fix more singleton issues
kasperpeulen Aug 5, 2024
43c0733
Remove redundant svelteVersion prop (was removed earlier)
kasperpeulen Aug 5, 2024
8f39a19
Remove write issue reminder
kasperpeulen Aug 5, 2024
92deb47
Merge pull request #28766 from storybookjs/kasper/render-agnostic
yannbf Aug 6, 2024
6556d03
setup bundling scripts for the vitest addon
yannbf Aug 6, 2024
52aa6fd
Merge branch 'vitest-integration' into yann/addon-vitest-barebones-wi…
yannbf Aug 6, 2024
385879e
fixes
yannbf Aug 6, 2024
7919ead
fix dependencies
yannbf Aug 6, 2024
f7de2e2
fix import
yannbf Aug 6, 2024
c748186
Merge branch 'next' into vitest-integration
yannbf Aug 6, 2024
632d0e4
Merge branch 'vitest-integration' into yann/addon-vitest-barebones-wi…
yannbf Aug 6, 2024
58dde10
fix version
yannbf Aug 6, 2024
dee15b2
fix types
yannbf Aug 6, 2024
6fd386b
fix check command
yannbf Aug 6, 2024
02d0789
fix type generation
yannbf Aug 6, 2024
17ba6e6
Merge branch 'next' into vitest-integration
yannbf Aug 6, 2024
f66506e
skip failing svelte tests for now
yannbf Aug 6, 2024
a3652bb
Merge branch 'vitest-integration' into yann/addon-vitest-barebones-wi…
yannbf Aug 6, 2024
b1e4f7c
enable browser mode
yannbf Aug 6, 2024
1368aef
fix default annotations from nextjs
yannbf Aug 7, 2024
3e33d2e
add storybook script
yannbf Aug 7, 2024
1b89fe1
use istanbul for coverage instead
yannbf Aug 7, 2024
e9db42a
add playwright to deps list
yannbf Aug 7, 2024
5f4ded2
Merge branch 'vitest-integration' into yann/fix-nextjs-issues
yannbf Aug 7, 2024
0007c42
Merge branch 'vitest-integration' into yann/addon-vitest-barebones-wi…
yannbf Aug 7, 2024
d62a856
use playwright machine for unit tests
yannbf Aug 7, 2024
433bbb5
fix exports order
yannbf Aug 7, 2024
12e0350
remove unnecessary flag from config
yannbf Aug 7, 2024
f4bf860
Merge pull request #28810 from storybookjs/yann/addon-vitest-barebone…
yannbf Aug 7, 2024
2e4b199
fix link mode
yannbf Aug 7, 2024
2ffd0d0
fix vue tests
yannbf Aug 7, 2024
a5ff402
update vue sandbox scripts
yannbf Aug 7, 2024
24e8a73
Merge branch 'vitest-integration' into yann/fix-nextjs-issues
yannbf Aug 7, 2024
e4320b1
Merge pull request #28825 from storybookjs/yann/fix-nextjs-issues
yannbf Aug 7, 2024
633f4b2
Merge branch 'vitest-integration' of github.com:storybookjs/storybook…
yannbf Aug 7, 2024
6d4caba
mock storybook channel in vitest plugin
yannbf Aug 7, 2024
9b4d61c
use vitest tag for filtering
yannbf Aug 7, 2024
d5995e3
Fix beforeAll type
kasperpeulen Aug 7, 2024
42d630e
fix issue with double error message
yannbf Aug 8, 2024
1c2888d
Merge branch 'next' into vitest-integration
yannbf Aug 9, 2024
81281ec
move from esbuild to jiti in vitest package.json
yannbf Aug 9, 2024
e8364db
support autotitle in vitest plugin
yannbf Aug 9, 2024
722e0d5
add error handling when configDir is incorrect
yannbf Aug 9, 2024
9dc93cc
improve storybook dir calculation
yannbf Aug 9, 2024
2a83669
fix
yannbf Aug 9, 2024
9728c77
cleanup
yannbf Aug 9, 2024
72164de
add browser interactivity api experiment
yannbf Aug 9, 2024
f31323d
fix nextjs test
yannbf Aug 9, 2024
40dfa9f
update flaky test
yannbf Aug 9, 2024
bffb920
Merge pull request #28847 from storybookjs/yann/support-autotitle
yannbf Aug 9, 2024
ee56cca
Merge branch 'next' into vitest-integration
yannbf Aug 10, 2024
53232db
add transformer tests
yannbf Aug 10, 2024
b617eb0
Merge remote-tracking branch 'refs/remotes/origin/vitest-integration'…
kasperpeulen Aug 12, 2024
14e18d9
Only set the parameter when the experimentalRSC feature is set
kasperpeulen Aug 12, 2024
4d0744f
Fix filename
kasperpeulen Aug 12, 2024
4c27387
Address feedback
kasperpeulen Aug 12, 2024
d1cb751
Address feedback
kasperpeulen Aug 12, 2024
1bf3c4c
fix lint and check issues
yannbf Aug 12, 2024
527e8ea
Merge remote-tracking branch 'refs/remotes/origin/vitest-integration'…
kasperpeulen Aug 12, 2024
49e7932
Merge branch 'refs/heads/vitest-integration' into kasper/refactor-rsc…
kasperpeulen Aug 12, 2024
f747943
Fix eslint
kasperpeulen Aug 12, 2024
603ea16
Fix eslint
kasperpeulen Aug 12, 2024
898405e
Merge pull request #28864 from storybookjs/beforeall
kasperpeulen Aug 12, 2024
be894e9
Merge pull request #28865 from storybookjs/kasper/refactor-rsc-support
kasperpeulen Aug 12, 2024
7798169
Merge branch 'next' into vitest-integration
yannbf Aug 12, 2024
f82153b
fix merge conflicts
yannbf Aug 12, 2024
e3f73c9
fix nextjs-vite sandbox generation
yannbf Aug 12, 2024
adc1cbb
Merge branch 'next' into vitest-integration
yannbf Aug 13, 2024
8aa5680
fix merge conflict
yannbf Aug 13, 2024
6c6268c
fix lint issue
yannbf Aug 13, 2024
c067329
fix test
yannbf Aug 13, 2024
b40b33e
fix parallelism
yannbf Aug 13, 2024
d3dae46
add vitest tag
yannbf Aug 13, 2024
b860bb5
hopefully fix the nextjs issue
yannbf Aug 13, 2024
e8805dd
first iteration - babel only
yannbf Aug 12, 2024
7ebafe1
wip
yannbf Aug 12, 2024
89b39a8
use csf-tools for transformation
yannbf Aug 12, 2024
0f15aa1
update lockfile
yannbf Aug 12, 2024
567f11f
fix test
yannbf Aug 13, 2024
3930877
move vitest transformation logic to csf-tools
yannbf Aug 13, 2024
c00a80f
reenable browser mode
yannbf Aug 13, 2024
8d0a92a
address review feedback
yannbf Aug 13, 2024
934cefb
readd properties and deprecate them
yannbf Aug 13, 2024
c066b8b
fix type issues
yannbf Aug 13, 2024
3861ac4
Merge pull request #28868 from storybookjs/yann/use-babel-in-transfor…
yannbf Aug 13, 2024
f2a90a9
Fix unit test
kasperpeulen Aug 13, 2024
af8c014
Remove timeout
kasperpeulen Aug 13, 2024
d2bc5fb
only set up optimizedeps for nextjs
yannbf Aug 13, 2024
1dbf820
fix plugin duplication
yannbf Aug 13, 2024
e2d63c5
fix story name
yannbf Aug 13, 2024
f508cc4
fix viewports issue
yannbf Aug 13, 2024
8c580c7
skip channel related tests
yannbf Aug 13, 2024
a687a68
fix autotitle
yannbf Aug 13, 2024
4af500e
fix vitest script (some stories might not have any tests)
yannbf Aug 13, 2024
4759c6a
fix viewports usage
yannbf Aug 13, 2024
f5f4f5a
warn on unconventional story exports
yannbf Aug 13, 2024
4969596
fix build error
yannbf Aug 13, 2024
8693eaf
fix unit test
yannbf Aug 13, 2024
da053e1
skip a few tests, try to fix flake
yannbf Aug 13, 2024
4bf0445
debug hanging nextjs tests
yannbf Aug 13, 2024
eb83b88
fix viewport setting
yannbf Aug 14, 2024
cb99e97
Add comment
kasperpeulen Aug 14, 2024
251d916
extra fixes
yannbf Aug 14, 2024
ba806c1
Merge branch 'vitest-integration' of github.com:storybookjs/storybook…
yannbf Aug 14, 2024
38a154e
Remove comment
kasperpeulen Aug 14, 2024
b48ac41
Clean up
kasperpeulen Aug 14, 2024
a6df95a
Fix lint
kasperpeulen Aug 14, 2024
1df2ab1
Remove BS
kasperpeulen Aug 14, 2024
13c5361
Cleanup
kasperpeulen Aug 14, 2024
45090b2
Add the composedStory to the context
kasperpeulen Aug 14, 2024
020b6c6
address PR feedback
yannbf Aug 14, 2024
67f5678
fix windows unit tests
yannbf Aug 14, 2024
fc07618
fix parallelism and skip more stories
yannbf Aug 14, 2024
f773687
increase test timeout
yannbf Aug 14, 2024
fddd3a5
fix script
yannbf Aug 14, 2024
c12e23e
skip sveltekit tests
yannbf Aug 14, 2024
6cade7d
skip vitest integration in nextjs sandbox
yannbf Aug 14, 2024
659994d
fix typescript issue
yannbf Aug 14, 2024
5f24e86
revamp sandbox setup to move to a workspace file
yannbf Aug 14, 2024
bd51a23
change pool options in sandboxes
yannbf Aug 14, 2024
1896a8c
fix style
yannbf Aug 14, 2024
f7ff019
more fixes
yannbf Aug 14, 2024
416cd00
Yeah... don't look at this
kasperpeulen Aug 14, 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
14 changes: 12 additions & 2 deletions MIGRATION.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<h1>Migration</h1>

- [From version 8.2.x to 8.3.x](#from-version-82x-to-83x)
- [Removed `experimental_SIDEBAR_BOTTOM` and deprecated `experimental_SIDEBAR_TOP` addon types](#removed-experimental_sidebar_bottom-and-deprecated-experimental_sidebar_top-addon-types)
Comment on lines +3 to +4
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check: Ensure that the new section for version 8.2.x to 8.3.x is correctly linked in the table of contents.

- [From version 8.1.x to 8.2.x](#from-version-81x-to-82x)
- [Failed to resolve import "@storybook/X" error](#failed-to-resolve-import-storybookx-error)
- [Preview.js globals renamed to initialGlobals](#previewjs-globals-renamed-to-initialglobals)
Expand Down Expand Up @@ -414,6 +416,14 @@
- [Packages renaming](#packages-renaming)
- [Deprecated embedded addons](#deprecated-embedded-addons)

## From version 8.2.x to 8.3.x

### Removed `experimental_SIDEBAR_BOTTOM` and deprecated `experimental_SIDEBAR_TOP` addon types

The experimental SIDEBAR_BOTTOM addon type was removed in favor of a built-in filter UI. The enum type definition will remain available until Storybook 9.0 but will be ignored. Similarly the experimental SIDEBAR_TOP addon type is deprecated and will be removed in a future version.

These APIs allowed addons to render arbitrary content in the Storybook sidebar. Due to potential conflicts between addons and challenges regarding styling, these APIs are/will be removed. In the future, Storybook will provide declarative API hooks to allow addons to add content to the sidebar without risk of conflicts or UI inconsistencies. One such API is `experimental_updateStatus` which allow addons to set a status for stories. The SIDEBAR_BOTTOM slot is now used to allow filtering stories with a given status.
Comment on lines +423 to +427
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check: Consider providing examples or more detailed guidance on how to migrate from the deprecated experimental_SIDEBAR_TOP and removed experimental_SIDEBAR_BOTTOM addon types.


## From version 8.1.x to 8.2.x

### Failed to resolve import "@storybook/X" error
Expand Down Expand Up @@ -2324,8 +2334,8 @@ export default config;

#### Vite builder uses Vite config automatically

When using a [Vite-based framework](#framework-field-mandatory), Storybook will automatically use your `vite.config.(ctm)js` config file starting in 7.0.
Some settings will be overridden by Storybook so that it can function properly, and the merged settings can be modified using `viteFinal` in `.storybook/main.js` (see the [Storybook Vite configuration docs](https://storybook.js.org/docs/react/builders/vite#configuration)).
When using a [Vite-based framework](#framework-field-mandatory), Storybook will automatically use your `vite.config.(ctm)js` config file starting in 7.0.
Some settings will be overridden by Storybook so that it can function properly, and the merged settings can be modified using `viteFinal` in `.storybook/main.js` (see the [Storybook Vite configuration docs](https://storybook.js.org/docs/react/builders/vite#configuration)).
If you were using `viteFinal` in 6.5 to simply merge in your project's standard Vite config, you can now remove it.

For Svelte projects this means that the `svelteOptions` property in the `main.js` config should be omitted, as it will be loaded automatically via the project's `vite.config.js`.
Expand Down
3 changes: 3 additions & 0 deletions code/core/src/core-events/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ enum events {
STORY_ARGS_UPDATED = 'storyArgsUpdated',
// Reset either a single arg of a story all args of a story
RESET_STORY_ARGS = 'resetStoryArgs',
// Emitted after a filter is set
SET_FILTER = 'setFilter',
Comment on lines +50 to +51
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Ensure that the SET_FILTER event is handled appropriately in all relevant parts of the codebase to avoid potential issues.

// Emitted by the preview at startup once it knows the initial set of globals+globalTypes
SET_GLOBALS = 'setGlobals',
// Tell the preview to update the value of a global
Expand Down Expand Up @@ -114,6 +116,7 @@ export const {
SELECT_STORY,
SET_CONFIG,
SET_CURRENT_STORY,
SET_FILTER,
SET_GLOBALS,
SET_INDEX,
SET_STORIES,
Expand Down
3 changes: 3 additions & 0 deletions code/core/src/manager-api/modules/stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import {
DOCS_PREPARED,
SET_CURRENT_STORY,
SET_CONFIG,
SET_FILTER,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Ensure the SET_FILTER event is handled correctly in all relevant parts of the codebase.

} from '@storybook/core/core-events';
import { logger } from '@storybook/core/client-logger';

Expand Down Expand Up @@ -662,6 +663,8 @@ export const init: ModuleFn<SubAPI, SubState> = ({
Object.entries(refs).forEach(([refId, { internal_index, ...ref }]) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: Verify that emitting the SET_FILTER event does not cause performance issues, especially with large story indexes.

fullAPI.setRef(refId, { ...ref, storyIndex: internal_index }, true);
});

provider.channel?.emit(SET_FILTER, { id });
},
};

Expand Down
40 changes: 40 additions & 0 deletions code/core/src/manager/components/sidebar/FilterToggle.stories.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { fn } from '@storybook/test';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Consider using a more descriptive name for the imported fn function to clarify its purpose.

import { FilterToggle } from './FilterToggle';

export default {
component: FilterToggle,
args: {
active: false,
onClick: fn(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check: Ensure that the fn function correctly simulates the onClick behavior expected in the actual application.

},
};

export const Errors = {
args: {
count: 2,
label: 'Error',
status: 'critical',
},
};

export const ErrorsActive = {
args: {
...Errors.args,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Verify that spreading Errors.args does not introduce unintended side effects, especially if Errors.args is modified in the future.

active: true,
},
};

export const Warning = {
args: {
count: 12,
label: 'Warning',
status: 'warning',
},
};

export const WarningActive = {
args: {
...Warning.args,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Similar to ErrorsActive, ensure that spreading Warning.args does not lead to unexpected behavior.

active: true,
},
};
59 changes: 59 additions & 0 deletions code/core/src/manager/components/sidebar/FilterToggle.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import { Badge as BaseBadge, IconButton } from '@storybook/components';
import { css, styled } from '@storybook/theming';
import React, { type ComponentProps } from 'react';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Consider importing React as a default import for consistency with other files in the codebase.


const Badge = styled(BaseBadge)(({ theme }) => ({
padding: '4px 8px',
fontSize: theme.typography.size.s1,
}));

const Button = styled(IconButton)(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: The nested hover styles could be simplified by using a single hover selector with conditional logic for different statuses.

({ theme }) => ({
fontSize: theme.typography.size.s2,
'&:hover [data-badge][data-status=warning], [data-badge=true][data-status=warning]': {
background: '#E3F3FF',
borderColor: 'rgba(2, 113, 182, 0.1)',
color: '#0271B6',
},
'&:hover [data-badge][data-status=critical], [data-badge=true][data-status=critical]': {
background: theme.background.negative,
boxShadow: `inset 0 0 0 1px rgba(182, 2, 2, 0.1)`,
color: theme.color.negativeText,
},
}),
({ active, theme }) =>
!active &&
css({
'&:hover': {
color: theme.base === 'light' ? theme.color.defaultText : theme.color.light,
},
})
);

const Label = styled.span(({ theme }) => ({
color: theme.base === 'light' ? theme.color.defaultText : theme.color.light,
}));

interface FilterToggleProps {
active: boolean;
count: number;
label: string;
status: ComponentProps<typeof Badge>['status'];
}

export const FilterToggle = ({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check: Ensure that the FilterToggle component is covered by unit tests to verify its behavior with different prop values.

active,
count,
label,
status,
...props
}: FilterToggleProps & Omit<ComponentProps<typeof Button>, 'status'>) => {
return (
<Button active={active} {...props}>
<Badge status={status} data-badge={active} data-status={status}>
{count}
</Badge>
<Label>{`${label}${count === 1 ? '' : 's'}`}</Label>
</Button>
);
};
103 changes: 45 additions & 58 deletions code/core/src/manager/components/sidebar/Sidebar.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { IndexHash, State } from '@storybook/core/manager-api';
import { ManagerContext, types } from '@storybook/core/manager-api';
import type { StoryObj, Meta } from '@storybook/react';
import { within, userEvent, expect, fn } from '@storybook/test';
import type { Addon_SidebarTopType } from '@storybook/core/types';
import type { Addon_SidebarTopType, API_StatusState } from '@storybook/core/types';
import { Button, IconButton } from '@storybook/core/components';
import { FaceHappyIcon } from '@storybook/icons';
import { Sidebar, DEFAULT_REF_ID } from './Sidebar';
Expand All @@ -26,6 +26,26 @@ const storyId = 'root-1-child-a2--grandchild-a1-1';
export const simpleData = { menu, index, storyId };
export const loadingData = { menu };

const managerContext: any = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: Centralizing the manager context state and API mock functions is a good practice for maintainability.

state: {
docsOptions: {
defaultName: 'Docs',
autodocs: 'tag',
docsMode: false,
},
},
api: {
emit: fn().mockName('api::emit'),
on: fn().mockName('api::on'),
off: fn().mockName('api::off'),
getShortcutKeys: fn(() => ({ search: ['control', 'shift', 's'] })).mockName(
'api::getShortcutKeys'
),
selectStory: fn().mockName('api::selectStory'),
experimental_setFilter: fn().mockName('api::experimental_setFilter'),
},
};

const meta = {
component: Sidebar,
title: 'Sidebar/Sidebar',
Expand All @@ -44,28 +64,7 @@ const meta = {
},
decorators: [
(storyFn) => (
<ManagerContext.Provider
value={
{
state: {
docsOptions: {
defaultName: 'Docs',
autodocs: 'tag',
docsMode: false,
},
},
api: {
emit: fn().mockName('api::emit'),
on: fn().mockName('api::on'),
off: fn().mockName('api::off'),
getShortcutKeys: fn(() => ({ search: ['control', 'shift', 's'] })).mockName(
'api::getShortcutKeys'
),
selectStory: fn().mockName('api::selectStory'),
},
} as any
}
>
<ManagerContext.Provider value={managerContext}>
<LayoutProvider>
<IconSymbols />
{storyFn()}
Expand Down Expand Up @@ -218,41 +217,29 @@ export const Searching: Story = {
};

export const Bottom: Story = {
args: {
bottom: [
{
id: '1',
type: types.experimental_SIDEBAR_BOTTOM,
render: () => (
<Button>
<FaceHappyIcon />
Custom addon A
</Button>
),
},
{
id: '2',
type: types.experimental_SIDEBAR_BOTTOM,
render: () => (
<Button>
{' '}
<FaceHappyIcon />
Custom addon B
</Button>
),
},
{
id: '3',
type: types.experimental_SIDEBAR_BOTTOM,
render: () => (
<IconButton>
{' '}
<FaceHappyIcon />
</IconButton>
),
},
],
},
decorators: [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check: Ensure the status states in the Bottom story decorator are comprehensive and cover all necessary scenarios.

(storyFn) => (
<ManagerContext.Provider
value={{
...managerContext,
state: {
...managerContext.state,
status: {
[storyId]: {
vitest: { status: 'warn', title: '', description: '' },
vta: { status: 'error', title: '', description: '' },
},
'root-1-child-a2--grandchild-a1-2': {
vitest: { status: 'warn', title: '', description: '' },
},
} satisfies API_StatusState,
},
}}
>
{storyFn()}
</ManagerContext.Provider>
),
],
};

/**
Expand Down
7 changes: 2 additions & 5 deletions code/core/src/manager/components/sidebar/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { SearchResults } from './SearchResults';
import type { CombinedDataset, Selection } from './types';
import { useLastViewed } from './useLastViewed';
import { MEDIA_DESKTOP_BREAKPOINT } from '../../constants';
import { SidebarBottom } from './SidebarBottom';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Ensure SidebarBottom component handles all necessary props and states previously managed by the bottom array.


export const DEFAULT_REF_ID = 'storybook_internal';

Expand Down Expand Up @@ -109,7 +110,6 @@ export interface SidebarProps extends API_LoadedRefData {
status: State['status'];
menu: any[];
extra: Addon_SidebarTopType[];
bottom?: Addon_SidebarBottomType[];
storyId?: string;
refId?: string;
menuHighlighted?: boolean;
Expand All @@ -128,7 +128,6 @@ export const Sidebar = React.memo(function Sidebar({
previewInitialized,
menu,
extra,
bottom = [],
menuHighlighted = false,
enableShortcuts = true,
refs = {},
Expand Down Expand Up @@ -194,9 +193,7 @@ export const Sidebar = React.memo(function Sidebar({
</ScrollArea>
{isLoading ? null : (
<Bottom className="sb-bar">
{bottom.map(({ id, render: Render }) => (
<Render key={id} />
))}
<SidebarBottom />
</Bottom>
Comment on lines 189 to 191
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Directly using SidebarBottom here assumes it covers all use cases previously handled by the bottom array.

)}
</Container>
Expand Down
42 changes: 42 additions & 0 deletions code/core/src/manager/components/sidebar/SidebarBottom.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { fn } from '@storybook/test';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Consider using a more descriptive name for the imported fn function to clarify its purpose in the context of the stories.


import { SidebarBottomBase } from './SidebarBottom';

export default {
component: SidebarBottomBase,
args: {
api: {
experimental_setFilter: fn(),
emit: fn(),
},
Comment on lines +8 to +11
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check: Ensure that the mocked experimental_setFilter and emit methods cover all necessary interactions for the SidebarBottomBase component.

},
};

export const Errors = {
args: {
status: {
one: { 'sidebar-bottom-filter': { status: 'error' } },
two: { 'sidebar-bottom-filter': { status: 'error' } },
Comment on lines +17 to +19
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check: Verify that the status keys (one, two, etc.) align with the actual keys used in the SidebarBottomBase component to avoid mismatches.

},
},
};

export const Warnings = {
args: {
status: {
one: { 'sidebar-bottom-filter': { status: 'warn' } },
two: { 'sidebar-bottom-filter': { status: 'warn' } },
},
},
};

export const Both = {
args: {
status: {
one: { 'sidebar-bottom-filter': { status: 'warn' } },
two: { 'sidebar-bottom-filter': { status: 'warn' } },
three: { 'sidebar-bottom-filter': { status: 'error' } },
four: { 'sidebar-bottom-filter': { status: 'error' } },
Comment on lines +35 to +39
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Consider adding more diverse status scenarios to thoroughly test the component's behavior under different conditions.

},
},
};
Loading