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): ability to use <DocCardList> without items prop, on any doc page #8008

Merged
merged 3 commits into from
Aug 26, 2022

Conversation

slorber
Copy link
Collaborator

@slorber slorber commented Aug 25, 2022

Motivation

It's annoying to have to write:

import DocCardList from '@theme/DocCardList';
import {useCurrentSidebarCategory} from '@docusaurus/theme-common';

<DocCardList items={useCurrentSidebarCategory().items}/>

when it could just be:

import DocCardList from '@theme/DocCardList';

<DocCardList />

Also it should be possible to use it on regular docs too, not just category index pages:

CleanShot 2022-08-25 at 17 51 00@2x

items prop is kept for retro compatibility but undocumented. Maybe we'll want to remove it later unless someone comes up with a use-case for it

Test Plan

unit tests + dogfood in our doc

retrocompatible: old docs version still use the items prop + hook

Test links

Deploy preview:

@slorber slorber added pr: new feature This PR adds a new API or behavior. to backport This PR is planned to be backported to a stable version of Docusaurus labels Aug 25, 2022
@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Aug 25, 2022
@netlify
Copy link

netlify bot commented Aug 25, 2022

[V2]

Name Link
🔨 Latest commit 7aed44e
🔍 Latest deploy log https://app.netlify.com/sites/docusaurus-2/deploys/63079ea29c2de9000713bdf9
😎 Deploy Preview https://deploy-preview-8008--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 Aug 25, 2022

⚡️ Lighthouse report for the deploy preview of this PR

URL Performance Accessibility Best Practices SEO PWA Report
/ 🟢 90 🟢 98 🟢 100 🟢 100 🟠 80 Report
/docs/installation 🟠 75 🟢 100 🟢 100 🟢 100 🟢 90 Report

@github-actions
Copy link

github-actions bot commented Aug 25, 2022

Size Change: +100 B (0%)

Total Size: 814 kB

Filename Size Change
website/build/assets/js/main.********.js 610 kB +100 B (0%)
ℹ️ View Unchanged
Filename Size
website/.docusaurus/globalData.json 52.5 kB
website/build/assets/css/styles.********.css 111 kB
website/build/index.html 40.9 kB

compressed-size-action

@slorber slorber changed the title feat(theme): ability to use <DocCardList> propless, on any doc page feat(theme): ability to use <DocCardList> without items prop, on any doc page Aug 25, 2022
@Josh-Cena
Copy link
Collaborator

This is very nice. I would definitely keep supporting items—from a design perspective, I always prefer using props to context where possible since that makes the dependency explicit. Keeping it means the component may be used as a pure design system component instead of being coupled to any context.

@slorber
Copy link
Collaborator Author

slorber commented Aug 26, 2022

This is very nice. I would definitely keep supporting items—from a design perspective, I always prefer using props to context where possible since that makes the dependency explicit. Keeping it means the component may be used as a pure design system component instead of being coupled to any context.

yes I'm fine to keep it! although not sure in which case you'd want to use it, curious to know ;)

@slorber slorber merged commit c811d62 into main Aug 26, 2022
@slorber slorber deleted the slorber/simpler-doc-card-list branch August 26, 2022 15:43
@Josh-Cena
Copy link
Collaborator

Maybe for example, filtering some items or pushing more items?

slorber added a commit that referenced this pull request Sep 1, 2022
slorber added a commit that referenced this pull request Sep 1, 2022
@slorber slorber added backported This PR has been backported to a stable version of Docusaurus and removed to backport This PR is planned to be backported to a stable version of Docusaurus labels Sep 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backported This PR has been backported to a stable version of Docusaurus 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.

3 participants