Skip to content

docs: new APITable comp to render large tables #5891

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

Merged
merged 6 commits into from
Nov 10, 2021
Merged

Conversation

Josh-Cena
Copy link
Collaborator

@Josh-Cena Josh-Cena commented Nov 6, 2021

Motivation

When giving instructions on how to enable a particular option, it usually is quite awkward to give a link to the entire API table instead of pointing them to a specific row.

This PR introduces a new APITable on the website which allows us to direct to a specific row through anchor links. When visitors click on that link, the respective entry will also be highlighted.

Have you read the Contributing Guidelines on pull requests?

Yes

Test Plan

https://deploy-preview-5891--docusaurus-2.netlify.app/docs/api/plugins/@docusaurus/plugin-content-blog#archiveBasePath

Verified

This commit was signed with the committer’s verified signature.
Josh-Cena Joshua Chen
@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Nov 6, 2021

Verified

This commit was signed with the committer’s verified signature.
Josh-Cena Joshua Chen

Verified

This commit was signed with the committer’s verified signature.
Josh-Cena Joshua Chen
@github-actions
Copy link

github-actions bot commented Nov 6, 2021

Size Change: +431 B (0%)

Total Size: 882 kB

Filename Size Change
website/build/assets/css/styles.********.css 94.2 kB +244 B (0%)
website/build/assets/js/main.********.js 474 kB +190 B (0%)
ℹ️ View Unchanged
Filename Size Change
website/.docusaurus/globalData.json 38.2 kB -2 B (0%)
website/build/blog/2017/12/14/introducing-docusaurus/index.html 66.1 kB 0 B
website/build/blog/index.html 36.8 kB 0 B
website/build/docs/index.html 44 kB +1 B (0%)
website/build/docs/installation/index.html 51.5 kB -2 B (0%)
website/build/index.html 29.5 kB 0 B
website/build/tests/docs/index.html 25.2 kB 0 B
website/build/tests/docs/standalone/index.html 21.7 kB 0 B

compressed-size-action

@netlify
Copy link

netlify bot commented Nov 6, 2021

✔️ [V2]

🔨 Explore the source changes: 0ebe5dd

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

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

@github-actions
Copy link

github-actions bot commented Nov 6, 2021

⚡️ Lighthouse report for the changes in this PR:

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

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

Verified

This commit was signed with the committer’s verified signature.
Josh-Cena Joshua Chen
@Josh-Cena Josh-Cena added the pr: documentation This PR works on the website or other text documents in the repo. label Nov 7, 2021
@Josh-Cena
Copy link
Collaborator Author

box-shadow on the <tr> element is not rendered on Safari🌚 Not sure what we should do

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, LGTM and nice idea.

We can give it a try and improve later if bugs are found

const highlightedRow = useRef<HTMLTableRowElement>(null);
const rows = Children.map(
tbody.props.children,
(row: ReactElement<ComponentProps<'tr'>>) => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you extract an <APITableRow> component, and encapsulate the highlighting logic inside it?

Also use of useHistory rather than DOM APIs that do not trigger re-renders on route changes (in this case it might not produce any weird side effects but is still a bad practice to access window during render execution)

@Josh-Cena
Copy link
Collaborator Author

Josh-Cena commented Nov 10, 2021

My React has always been hacky especially for these comps that hook heavily into the context...🌚

@slorber
Copy link
Collaborator

slorber commented Nov 10, 2021

LGTM thanks 👍

It's a bit unnatural to use a conditional ref assignation and forwardRef (I would have used useEffect inside the row) but as it's local and may be more optimized, why not

@slorber slorber merged commit ecce576 into main Nov 10, 2021
@slorber slorber deleted the jc/website-apitable branch November 10, 2021 10:38
@Josh-Cena
Copy link
Collaborator Author

It's a bit unnatural to use a conditional ref assignation and forwardRef (I would have used useEffect inside the row)

I don't really know... I did intend to make one table responsible for only highlighting one row, hence only one ref being handled, but we can see if in the future we want to use query params and highlight multiple rows (like GitHub lines)

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: documentation This PR works on the website or other text documents in the repo.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants