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

feat(theme-classic, plugin-docs): sidebar item level-specific className + allow customization #5642

Merged
merged 6 commits into from
Oct 7, 2021

Conversation

Josh-Cena
Copy link
Collaborator

Motivation

Resolve #5624.

Have you read the Contributing Guidelines on pull requests?

Yes

Test Plan

Dogfood

@Josh-Cena Josh-Cena changed the title feat(theme-classic, plugin-docs): allow customizing className for sidebar items + level-specific className feat(theme-classic, plugin-docs): sidebar item level-specific className + allow customization Oct 3, 2021
@netlify
Copy link

netlify bot commented Oct 3, 2021

✔️ [V2]
Built without sensitive environment variables

🔨 Explore the source changes: 5f25f31

🔍 Inspect the deploy log: https://app.netlify.com/sites/docusaurus-2/deploys/615a555f78e9b7000773731b

😎 Browse the preview: https://deploy-preview-5642--docusaurus-2.netlify.app

@github-actions
Copy link

github-actions bot commented Oct 3, 2021

⚡️ Lighthouse report for the changes in this PR:

Category Score
🟠 Performance 75
🟢 Accessibility 98
🟢 Best practices 100
🟢 SEO 100
🟢 PWA 95

Lighthouse ran on https://deploy-preview-5642--docusaurus-2.netlify.app/

@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Oct 3, 2021
@Josh-Cena
Copy link
Collaborator Author

I feel like the sidebar logic needs decent refactoring, currently 600 + 300 lines of code and adding one property requires patching ten files.

@lex111 lex111 added the pr: new feature This PR adds a new API or behavior. label Oct 3, 2021
Copy link
Collaborator

@slorber slorber left a comment

Choose a reason for hiding this comment

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

LGTM thanks 👍

throw new Error(
`Error loading ${JSON.stringify(item)}: "label" must be a string.`,
);
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

🤪 not urgent but we should probably make a Joi schema for all these older validations

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, that would be part of the "refactoring" :P

@@ -80,7 +80,7 @@ function DocSidebarDesktop({path, sidebar, onCollapse, isHidden}: Props) {
!isAnnouncementBarClosed && showAnnouncementBar,
})}>
<ul className={clsx(ThemeClassNames.docs.docSidebarMenu, 'menu__list')}>
<DocSidebarItems items={sidebar} activePath={path} />
<DocSidebarItems items={sidebar} activePath={path} level={1} />
Copy link
Collaborator

Choose a reason for hiding this comment

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

wonder if level 1 shouldn't be a default for convenience?
Also a new required prop on a theme component can be considered as a breaking change, but in practice it probably won't affect many people on upgrade

@slorber slorber merged commit eaacb0e into facebook:main Oct 7, 2021
@slorber
Copy link
Collaborator

slorber commented Oct 7, 2021

I feel like the sidebar logic needs decent refactoring, currently 600 + 300 lines of code and adding one property requires patching ten files.

Not sure what you mean by 600 + 300. What kind of refactoring do you have in mind?

@Josh-Cena Josh-Cena deleted the sidebar-classname branch October 7, 2021 15:09
@Josh-Cena
Copy link
Collaborator Author

Not sure what you mean by 600 + 300.

sidebars.ts: 583 lines
sidebarItemsGenerator: 315 lines

What kind of refactoring do you have in mind?

Splitting into more files; simplifying the autogeneration algorithm (which is also part of the TODO); use Joi, etc.

@slorber
Copy link
Collaborator

slorber commented Oct 7, 2021

As I'll start working on category index pages, if you want to submit a refactor it would be better to receive the PR for it soon ,or we'll do the refactorings afterward

@Josh-Cena
Copy link
Collaborator Author

I can do the refactor after that. Maybe also add "level: 1" as a default prop as you work on the category index?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Signed Facebook CLA pr: new feature This PR adds a new API or behavior.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow styling to target specific sidebar level
4 participants