-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
UI: Simple tag filtering #29333
UI: Simple tag filtering #29333
Conversation
☁️ Nx Cloud ReportCI is running/has finished running commands for commit 816e595. As they complete they will appear below. Click to see the status, the terminal output, and the build insights. 📂 See all runs for this CI Pipeline Execution ✅ Successfully ran 1 targetSent with 💌 from NxCloud. |
d7baa28
to
e8a505c
Compare
3acf141
to
2b53b6e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤩 it's looking great!
I have a feeling that some users will want to filter by entry type (docs only or stories only). Do you reckon it could make sense, in a separate branch, to expose them as tags (type:story
and type:docs
) like you expose play-fn
?
import { TagsFilter } from './TagsFilter'; | ||
|
||
const meta = { | ||
component: TagsFilter, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I want our Storybooks to use auto-title as much as possible. I'll move the other stories over in a separate PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
9 file(s) reviewed, 16 comment(s)
Edit PR Review Bot Settings | Greptile
// we can filter out the primary story, but we still want to show autodocs | ||
(tags.includes('dev') || item.type === 'docs') && | ||
tags.filter((tag) => excludeTags[tag]).length === 0 | ||
tags.filter((tag) => staticExcludeTags[tag]).length === 0 | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: Consider extracting this logic into a separate function for better readability
const isDevelopment = global.CONFIG_TYPE === 'DEVELOPMENT'; | ||
const isRendererReact = global.STORYBOOK_RENDERER === 'react'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: Consider using environment variables or a configuration file for these global flags
<WithTooltip | ||
placement="bottom" | ||
trigger="click" | ||
onVisibleChange={setExpanded} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: The onVisibleChange prop is set to setExpanded, but expanded state is not used anywhere in the component. Consider removing this state if it's not needed.
toggleTag: fn(), | ||
api: { | ||
getDocsUrl: () => 'https://storybook.js.org/docs/', | ||
} as any, |
There was a problem hiding this comment.
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 specific type for the api object instead of 'any'
toggleTag, | ||
}: TagsFilterPanelProps) => { | ||
const theme = useTheme(); | ||
const userTags = allTags.filter((tag) => tag === 'play-fn' || !BUILT_IN_TAGS.has(tag)).toSorted(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: Consider using Array.prototype.sort() instead of .toSorted() for better browser compatibility
return { | ||
id, | ||
title: tag, | ||
right: <input type="checkbox" id={id} name={id} value={tag} checked={checked} />, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: Consider using a controlled component for the checkbox
// FIXME: This is the actual `index.json` index where the `index` below | ||
// is actually the stories hash. We should fix this up and make it consistent. | ||
// eslint-disable-next-line @typescript-eslint/naming-convention | ||
internal_index, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: Consider renaming 'internal_index' to a more descriptive name like 'indexJson' for clarity
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the docs updates!
e7ba7f5
to
7a90232
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM ✨
Closes #
QA
https://deploy-preview-234--storybook-frontpage.netlify.app/docs/8.4/writing-stories/tags#filtering-by-custom-tags
What I did
Design
Implementation
play-fn
built in tag (if any stories have play functions) but hides other "system" tagsFor later
story
anddocs
tags automaticallyChecklist for Contributors
Testing
The changes in this PR are covered in the following automated tests:
Manual testing
Documentation
🦋 Canary release
This pull request has been released as version
0.0.0-pr-29333-sha-c7603f3d
. Try it out in a new sandbox by runningnpx [email protected] sandbox
or in an existing project withnpx [email protected] upgrade
.More information
0.0.0-pr-29333-sha-c7603f3d
shilman/simple-tag-filter
c7603f3d
1728888615
)To request a new release of this pull request, mention the
@storybookjs/core
team.core team members can create a new canary release here or locally with
gh workflow run --repo storybookjs/storybook canary-release-pr.yml --field pr=29333
Greptile Summary
This PR introduces a simple tag filtering feature to the Storybook UI, enhancing the sidebar's functionality for filtering stories based on tags.
TagsFilter
andTagsFilterPanel
components in/code/core/src/manager/components/sidebar/
Sidebar
component to integrate tag filtering and remove 'Create New Story' buttonexperimental_setFilter
inTagsFilter.tsx
STATIC_FILTER
toTAG_FILTERS
incommon-manager.ts
for consistencyTagsFilter
andTagsFilterPanel
components to showcase different states