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(theme-classic): clean up CSS of doc cards #6950

Merged
merged 13 commits into from
Mar 25, 2022
Merged

Conversation

lex111
Copy link
Contributor

@lex111 lex111 commented Mar 21, 2022

Motivation

Removing unnecessary CSS code and trying to use transform for hover state, because changing background only in dark mode breaks the consistency of the current visual design.

Have you read the Contributing Guidelines on pull requests?

Yes

Test Plan

Preview.

Related PRs

@lex111 lex111 added the pr: polish This PR adds a very minor behavior improvement that users will enjoy. label Mar 21, 2022
@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Mar 21, 2022
@lex111
Copy link
Contributor Author

lex111 commented Mar 21, 2022

And if I understand correctly, doc cards can not be without a link? So is that why this code can be removed also?

<div className={className}>{children}</div>

@netlify
Copy link

netlify bot commented Mar 21, 2022

[V2]

Name Link
🔨 Latest commit 7d20f5f
🔍 Latest deploy log https://app.netlify.com/sites/docusaurus-2/deploys/623da0ec6b4a1900089132d7
😎 Deploy Preview https://deploy-preview-6950--docusaurus-2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@github-actions
Copy link

github-actions bot commented Mar 21, 2022

⚡️ Lighthouse report for the changes in this PR:

Category Score
🟠 Performance 61
🟢 Accessibility 100
🟢 Best practices 92
🟢 SEO 100
🟢 PWA 90

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

@github-actions
Copy link

github-actions bot commented Mar 21, 2022

Size Change: -265 B (0%)

Total Size: 805 kB

Filename Size Change
website/build/assets/css/styles.********.css 105 kB +475 B (0%)
website/build/assets/js/main.********.js 612 kB -233 B (0%)
website/build/index.html 38.3 kB -507 B (-1%)
ℹ️ View Unchanged
Filename Size
website/.docusaurus/globalData.json 49.9 kB

compressed-size-action

@Josh-Cena
Copy link
Collaborator

doc cards can not be without a link?

It could actually happen, when findFirstCategoryLink returns undefined.

The only case in reality that I can think of right now is when a category contains only pure HTML items.

@lex111
Copy link
Contributor Author

lex111 commented Mar 21, 2022

How about hiding such categories without a link? Why would they show them in that case?

@Josh-Cena
Copy link
Collaborator

Yeah, it makes sense to hide them IMO🤷‍♂️Can't think of any other cases where a card doesn't have an href.

@Josh-Cena
Copy link
Collaborator

I like the border color change! However, I also find some value in the card slightly illuminating in dark mode...

@lex111
Copy link
Contributor Author

lex111 commented Mar 22, 2022

Alright, replaced with --ifm-color-primary.

@Josh-Cena
Copy link
Collaborator

Uh, miswording there. I meant that the background should probably be lightened a little bit like before when hovering, in addition to the highlighted border. But the current one looks fine as well.

@Josh-Cena Josh-Cena changed the title refactor: cleanup CSS of doc cards refactor(theme-classic): clean up CSS of doc cards Mar 22, 2022
@lex111
Copy link
Contributor Author

lex111 commented Mar 22, 2022

Background then needs to be changed on hover state for all color modes, but currently it is required only for dark one. However, this breaks the design consistency, so I decided to highlight border instead for all modes.

@Josh-Cena
Copy link
Collaborator

I think in light mode it thickens the box shadow instead. Since box shadow is usually substituted with lighter foreground in dark mode to signal elevation.

@lex111
Copy link
Contributor Author

lex111 commented Mar 22, 2022

Yes, so border seems like a reasonable alternative to background in that case.

@Josh-Cena
Copy link
Collaborator

Josh-Cena commented Mar 22, 2022

Yeah, still looks good to me. It might also be good for accessibility since the contrast seems more significant

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 👍

Requesting some minor changes

@lex111
Copy link
Contributor Author

lex111 commented Mar 24, 2022

Done, I also made a few minor semantic improvements.

@@ -81,7 +81,7 @@ function CardCategory({item}: {item: PropSidebarItemCategory}): JSX.Element {
{count: item.items.length},
)}
/>
);
) : null;
Copy link
Collaborator

Choose a reason for hiding this comment

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

same as before, I'd like any comp in DocCard to never render null as it's the responsibility of the list to filter or not items upfront

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's because the findFirstCategoryLink function can return undefined. But since we have a validation rule that prevents empty items in categories, we can assume that there will always be a link.

@@ -15,11 +15,20 @@ export default function DocCardList({
}: {
items: PropSidebarItem[];
}): JSX.Element {
const filteredItems = items.filter((item) => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

not sure this test is so great as it potentially not filter categories that have no link

the rule for filtering (not rendering) an item should be clear and in a single place (here)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Don't really understand, can you give concrete use case for testing?

@slorber
Copy link
Collaborator

slorber commented Mar 25, 2022

Understand better now, did some minor edits to make things clearer 👍 LGTM

function filterItems(items: PropSidebarItem[]): PropSidebarItem[] {
return items.filter((item) => {
if (item.type === 'category') {
return !!findFirstCategoryLink(item);
Copy link
Collaborator

Choose a reason for hiding this comment

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

That seems more expensive than before because we traverse the entire subtree twice. Is it worthwhile?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh, otherwise we render an empty article container😅 Well, fair then. A little nasty

Copy link
Collaborator

Choose a reason for hiding this comment

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

That seems more expensive than before

Agree but at the same time it's unlikely that the user build complex sidebar trees without any link, in most cases the link is found fast

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah, makes sense 👍

@Josh-Cena
Copy link
Collaborator

The web is down these days, CI just doesn't kick😕

@slorber slorber merged commit 78ecff9 into main Mar 25, 2022
@slorber slorber deleted the lex111/card-css-ref branch March 25, 2022 11:17
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: polish This PR adds a very minor behavior improvement that users will enjoy.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants