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

fix(v2): refactor icons in theme-classic, fix swizzle issue #3854

Merged
merged 3 commits into from
Dec 1, 2020

Conversation

Simek
Copy link
Contributor

@Simek Simek commented Dec 1, 2020

Motivation

Fixes #3830

This PR refactor all SVG usages in the theme-classic and introduces three new and swizzable icon components:

  • IconArrow,
  • IconEdit,
  • IconMenu.

I have tried to add define them in the icons folder but there were some wired import issues on build, maybe some one will be able to improve the directory structure in the future.

This refactor also fixes the swizzle problem, which occurs currently for DocPage and DocSidebar.

Have you read the Contributing Guidelines on pull requests?

Yes.

Test Plan

Local run of V2 Docusuaurs website with swizzled DocSidebar component.

Related PRs

@Simek Simek requested review from lex111 and slorber as code owners December 1, 2020 13:33
@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Dec 1, 2020
@netlify
Copy link

netlify bot commented Dec 1, 2020

Deploy preview for docusaurus-2 ready!

Built without sensitive environment variables with commit 6d7e32f

https://deploy-preview-3854--docusaurus-2.netlify.app

@github-actions
Copy link

github-actions bot commented Dec 1, 2020

⚡️ Lighthouse report for the changes in this PR:

Category Score
🟠 Performance 68
🟢 Accessibility 99
🟢 Best practices 100
🟢 SEO 100
🟢 PWA 95

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

@github-actions
Copy link

github-actions bot commented Dec 1, 2020

Size Change: +22 B (0%)

Total Size: 157 kB

ℹ️ View Unchanged
Filename Size Change
website/build/blog/2017/12/14/introducing-docusaurus/index.html 20.7 kB +1 B
website/build/docs/introduction/index.html 180 B 0 B
website/build/index.html 5.86 kB 0 B
website/build/main.********.js 113 kB +21 B (0%)
website/build/styles.********.css 17.6 kB 0 B

compressed-size-action

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.

thanks, that's a helpful refactor that we'd probably have to do to create the theme gallery anyway 👍

just I'd rather not hardcode a margin inside the SVG directly

style={{
marginRight: '0.3em',
verticalAlign: 'sub',
}}
Copy link
Collaborator

Choose a reason for hiding this comment

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

"external" styles should rather be passed as props and keep in the parent component.

Some refs:
https://visly.app/blogposts/layout-isolated-components
https://mxstbr.com/thoughts/margin

@Simek
Copy link
Contributor Author

Simek commented Dec 1, 2020

just I'd rather not hardcode a margin inside the SVG directly

It was how the inline SVG code looked like before refactor.

I will extract the inilne styles in the next commit.

@slorber
Copy link
Collaborator

slorber commented Dec 1, 2020

it was fine before because the svg was inlined, if we make a real comp we should only put "internal styles" in it, so that the component can be used safely in multiple different contexts.

@slorber
Copy link
Collaborator

slorber commented Dec 1, 2020

Thanks

Actually I meant the styles like margin should not be at all in the IconEdit comp, but in the comps using them (ie <IconEdit className={styles.docEditButton}/>)

But in this case, it would create some duplication as the comp is used in the same way from 2 places, so let's merge and see 🤷‍♂️

@slorber slorber merged commit 397fde0 into facebook:master Dec 1, 2020
@slorber slorber added the pr: bug fix This PR fixes a bug in a past release. label Dec 1, 2020
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: bug fix This PR fixes a bug in a past release.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

When DocSidebar is swizzled, arrow.svg is missing
3 participants