-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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
Conversation
Signed-off-by: Marija Najdova <mnajdova@gmail.com>
…dova/material-ui into docs/build-hooks-interfaces
There was a problem hiding this 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 🎉
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great 🎂
There was a problem hiding this 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:
- [docs] Fix double API page redirection #36743 fixed double redirections
- [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.
* - [useBadge API](https://mui.com/base/api/use-badge/) | ||
* - [useBadge API](https://mui.com/base/react-badge/hooks-api/#use-badge) |
There was a problem hiding this comment.
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.
"/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", |
There was a problem hiding this comment.
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
"/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", |
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); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-
We have a problem with the page titles, this will be disorienting in Algolia and Google Search results:
-
https://deploy-preview-35938--material-ui.netlify.app/base/react-tabs/
"Unstyled React Tabs components - MUI Base" -
https://deploy-preview-35938--material-ui.netlify.app/base/react-tabs/components-api/
"Unstyled React Tabs components - MUI Base" -
https://deploy-preview-35938--material-ui.netlify.app/base/react-tabs/hooks-api/
"Unstyled React Tabs components - MUI Base"
|
||
return ( | ||
<AppWrapper emotionCache={emotionCache} pageProps={pageProps}> | ||
<Component {...pageProps} /> | ||
{getLayout(<Component {...pageProps} />)} |
There was a problem hiding this comment.
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 = () => { |
There was a problem hiding this comment.
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.
disableToc={disableToc} | ||
location={location} | ||
title={title} | ||
toc={activeToc} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- https://deploy-preview-35938--material-ui.netlify.app/base/react-tabs/components-api/#tabs-unstyled highlights the wrong header:
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. |
This PR converts the
MUI BaseBase UI's components pages to have tabs for the components & hooks apis. Changes done to make this possible:docs:api
cmd now generates the following pages: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 thecomponents/
folder.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