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

[docs][base] Show components & hooks API on the components page #35938

Merged
merged 101 commits into from Mar 31, 2023

Conversation

mnajdova
Copy link
Member

@mnajdova mnajdova commented Jan 24, 2023

This PR converts the MUI Base Base UI's components pages to have tabs for the components & hooks apis. Changes done to make this possible:

  • The docs:api cmd now generates the following pages:
    • /react-componentName/index.js - the initial page for the component (demos)
    • /react-componentName/[docsTab]/index.js - the page for the tabs APIs (components & hooks)
  • The new pages use the getLayout method, that allows us to define the app frame once, so that the transition between the tabs (and pages for that matter) is smoother. The files are generated based on the md files and currently run only for the base docs, more specifically for the pages inside the components/ folder.
  • The JSDocs of the components & hooks are also updated to point to the new API locations.
  • the scripts are updated to not generate the old API pages, and they have been removed

Preview

Demos page: https://deploy-preview-35938--material-ui.netlify.app/base/react-tabs/
Components API: https://deploy-preview-35938--material-ui.netlify.app/base/react-tabs/components-api
Hooks API: https://deploy-preview-35938--material-ui.netlify.app/base/react-tabs/hooks-api

Community feedback: #36204

@mnajdova mnajdova added docs Improvements or additions to the documentation proof of concept Studying and/or experimenting with a to be validated approach labels Jan 24, 2023
Copy link
Contributor

@danilo-leal danilo-leal left a comment

Choose a reason for hiding this comment

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

Looks great to me ⎯ excellent work 🎉

@flaviendelangle
Copy link
Member

image

Should we remove the Default column when it's fully empty ?

@mnajdova
Copy link
Member Author

Should we remove the Default column when it's fully empty?

That makes sense 👍, I will create a separate PR for this, as it would affect other API pages too, just to make sure I won't create regressions.

Copy link
Member

@flaviendelangle flaviendelangle left a comment

Choose a reason for hiding this comment

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

Looks great 🎂

@mnajdova mnajdova added the package: base-ui Specific to @mui/base label Mar 29, 2023
@mnajdova mnajdova merged commit dea13c8 into mui:master Mar 31, 2023
8 checks passed
Copy link
Member

@oliviertassinari oliviertassinari left a comment

Choose a reason for hiding this comment

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

Alright, we are getting there :)!

I did a deep dive into the changes with the thing that I could find, in addition to the inline comments:

  1. [docs] Fix double API page redirection #36743 fixed double redirections
  2. [docs] Improve side nav scroll into view #36732 is a fun one I took care of, this isn't directly related to these changes.

I think that it could be interesting to explore how we can have generic tab support in the docs infra, like https://stripe.com/docs/quotes/create?testing-method=without-code. Right now, it feels like it's not something MUI X or Toolpad could use.


In terms of UX, now that I can fully play with it, I'm personally in the camp of one page per exported module to consume the content is better/simpler to use. As we are making each of these pages more comprehensive (= unreadable toc, and = more scroll to), I think that this reinforces this feeling. However, the new UI to access the reference is better.

I think that as a next step, it would be great to move https://deploy-preview-35938--material-ui.netlify.app/material-ui/react-button/#api to the top of the page so it can be easily accessed (e.g. https://vuetifyjs.com/en/components/expansion-panels/#api) and to wait to see how developers are enjoying the different UX. Maybe try to move Joy UI as well, if we see that Algolia & Google search & the other user journey with Base UI works OK. But I think that it would make more impact to invest time in fixing #34085 considering the volume of requests we have about it and that it's not too big of a task.

docs/data/base/pagesApi.js Show resolved Hide resolved
docs/data/base/pages.ts Show resolved Hide resolved
* - [useBadge API](https://mui.com/base/api/use-badge/)
* - [useBadge API](https://mui.com/base/react-badge/hooks-api/#use-badge)
Copy link
Member

Choose a reason for hiding this comment

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

If we ever need to revert this change, we will need to get innovative with anchor redirections. anchors are never sent from the client to the server.

Comment on lines +242 to +269
"/base/react-badge/components-api": "BadgeUnstyled",
"/base/react-button/components-api": "ButtonUnstyled",
"/base/react-click-away-listener/components-api": "ClickAwayListener",
"/base/react-focus-trap/components-api": "FocusTrap",
"/base/react-form-control/components-api": "FormControlUnstyled",
"/base/react-input/components-api": "InputUnstyled",
"/base/react-menu/components-api": "MenuUnstyled",
"/base/react-modal/components-api": "ModalUnstyled",
"/base/react-no-ssr/components-api": "NoSsr",
"/base/react-select/components-api": "SelectUnstyled",
"/base/react-popper/components-api": "PopperUnstyled",
"/base/react-portal/components-api": "Portal",
"/base/react-slider/components-api": "SliderUnstyled",
"/base/react-snackbar/components-api": "SnackbarUnstyled",
"/base/react-switch/components-api": "SwitchUnstyled",
"/base/react-tabs/components-api": "TabsUnstyled",
"/base/react-table-pagination/components-api": "TablePaginationUnstyled",
"/base/react-textarea-autosize/components-api": "TextareaAutosize",
"/base/react-badge/hooks-api": "useBadge",
"/base/react-button/hooks-api": "useButton",
"/base/react-form-control/hooks-api": "useFormControlUnstyledContext",
"/base/react-input/hooks-api": "useInput",
"/base/react-menu/hooks-api": "useMenuItem",
"/base/react-select/hooks-api": "useSelect",
"/base/react-slider/hooks-api": "useSlider",
"/base/react-snackbar/hooks-api": "useSnackbar",
"/base/react-switch/hooks-api": "useSwitch",
"/base/react-tabs/hooks-api": "useTabsList",
Copy link
Member

Choose a reason for hiding this comment

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

  • API module names shouldn't be translated
Suggested change
"/base/react-badge/components-api": "BadgeUnstyled",
"/base/react-button/components-api": "ButtonUnstyled",
"/base/react-click-away-listener/components-api": "ClickAwayListener",
"/base/react-focus-trap/components-api": "FocusTrap",
"/base/react-form-control/components-api": "FormControlUnstyled",
"/base/react-input/components-api": "InputUnstyled",
"/base/react-menu/components-api": "MenuUnstyled",
"/base/react-modal/components-api": "ModalUnstyled",
"/base/react-no-ssr/components-api": "NoSsr",
"/base/react-select/components-api": "SelectUnstyled",
"/base/react-popper/components-api": "PopperUnstyled",
"/base/react-portal/components-api": "Portal",
"/base/react-slider/components-api": "SliderUnstyled",
"/base/react-snackbar/components-api": "SnackbarUnstyled",
"/base/react-switch/components-api": "SwitchUnstyled",
"/base/react-tabs/components-api": "TabsUnstyled",
"/base/react-table-pagination/components-api": "TablePaginationUnstyled",
"/base/react-textarea-autosize/components-api": "TextareaAutosize",
"/base/react-badge/hooks-api": "useBadge",
"/base/react-button/hooks-api": "useButton",
"/base/react-form-control/hooks-api": "useFormControlUnstyledContext",
"/base/react-input/hooks-api": "useInput",
"/base/react-menu/hooks-api": "useMenuItem",
"/base/react-select/hooks-api": "useSelect",
"/base/react-slider/hooks-api": "useSlider",
"/base/react-snackbar/hooks-api": "useSnackbar",
"/base/react-switch/hooks-api": "useSwitch",
"/base/react-tabs/hooks-api": "useTabsList",

Comment on lines 47 to 52
export function pageToTitleI18n(page: Page, t: Translate): string | null {
const path = page.subheader || page.pathname;
return t(`pages.${path}`, { ignoreWarning: true }) || pageToTitle(page);
return page.query
? pageToTitle(page)
: t(`pages.${path}`, { ignoreWarning: true }) || pageToTitle(page);
}
Copy link
Member

Choose a reason for hiding this comment

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


return (
<AppWrapper emotionCache={emotionCache} pageProps={pageProps}>
<Component {...pageProps} />
{getLayout(<Component {...pageProps} />)}
Copy link
Member

Choose a reason for hiding this comment

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

This makes the page transition feel a lot better 👌. I think to deploy everywhere: https://www.notion.so/mui-org/Fix-page-transition-slowness-212d920a9ab245f08ac3a2aea874f1bc.

It would solve the "Out of scope" part of #36732. I'm so excited about this fix! cc @siriwatknp @mnajdova

};
};

export const getStaticProps = () => {
Copy link
Member

Choose a reason for hiding this comment

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

In the past, we struggled to make the translation work with this approach: vercel/next.js#15315 (comment), it was not possible.

I'm curious to see which translation approach React takes in reactjs/react.dev#4135.

docs/src/modules/components/AppLayoutDocs.js Show resolved Hide resolved
disableToc={disableToc}
location={location}
title={title}
toc={activeToc}
Copy link
Member

Choose a reason for hiding this comment

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

docs/data/base/pagesApi.js Show resolved Hide resolved
@oliviertassinari
Copy link
Member

oliviertassinari commented Apr 7, 2023

  1. Open https://mui.com/material-ui/react-tabs/#api
  2. Click on

Screenshot 2023-04-07 at 19 00 58

  1. Click on it, it's a 404 (https://mui.com/base/api/tabs-list-unstyled/)

I think that we should fix the redirection that leads to a 404, and then, update all the links in the markdown so there are no redirections.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Improvements or additions to the documentation package: base-ui Specific to @mui/base scope: docs-infra Specific to the docs-infra product
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants