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-infra] Allows to use codeblock in the docs #37643

Merged
merged 19 commits into from
Jul 4, 2023

Conversation

alexfauquette
Copy link
Member

@alexfauquette alexfauquette commented Jun 19, 2023

Iteration over the #36766

Preview: https://deploy-preview-37643--material-ui.netlify.app/experiments/docs/installation/

Context

This PR solves the same issue as #36766 : Allowing to have tabs into code. But instead of using a component with some props, it's directly set into the markdown with a <codeblock /> wrapping multiple codes.

codeblocks with the same storageKey will save their value in the same place

<codeblock storageKey="package-manager">

```<language name> <tabname>
your code
```


```<language name> <tabname>
your code
```

</codeblock>

Which difference with initial PR

I did not keep the selected interface

image

The main reason was the management of the configuration, which does not feat well with their <codeblock> and it's very edge case to have those selects. So I assumed we will create a dedicated component for that based on <HighlightedCodeWithTabs/>

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Jun 19, 2023
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Jun 20, 2023
@siriwatknp
Copy link
Member

@alexfauquette Great improvements!

@alexfauquette alexfauquette marked this pull request as ready for review June 22, 2023 09:24
@zannager zannager added the scope: docs-infra Specific to the docs-infra product label Jun 22, 2023
Copy link
Member

@Janpot Janpot left a comment

Choose a reason for hiding this comment

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

Very nice!

Copy link
Member

@cherniavskii cherniavskii left a comment

Choose a reason for hiding this comment

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

A great addition to the docs! Thanks for working on this @alexfauquette @siriwatknp 🎉

}),
);

const STORAGE_KEY = 'package-manager';
Copy link
Member

Choose a reason for hiding this comment

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

Should be configurable?

Copy link
Member Author

Choose a reason for hiding this comment

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

Nice idea. Now it's feasible to do <codeblock storageKey="package-manager"> which will save the value in the key codeblock-package-manager. I'm adding codeblock- to avoid naming collisions.

docs/src/modules/components/HighlightedCodeWithTabs.tsx Outdated Show resolved Hide resolved
@@ -0,0 +1,144 @@
import * as React from 'react';
Copy link
Member

Choose a reason for hiding this comment

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

The selected state is acting weird after a few time switching between tabs:

Screen.Recording.2023-06-29.at.13.01.25.mov

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed
@siriwatknp I noticed, you used <Tab slot={{ root: StyledTab }} /> instead of doing StyledTab = styled(Tab)

Moving from the first to the second strategy fixed the bug. But I'm wondering if their is a reason to choose the first one?

Copy link
Member

@cherniavskii cherniavskii left a comment

Choose a reason for hiding this comment

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

Nice! 👍

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.

👍

docs/src/modules/components/HighlightedCodeWithTabs.tsx Outdated Show resolved Hide resolved
docs/src/modules/components/HighlightedCodeWithTabs.tsx Outdated Show resolved Hide resolved
docs/pages/experiments/docs/installation.md Show resolved Hide resolved
@oliviertassinari oliviertassinari added the new feature New feature or request label Jun 30, 2023
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Jul 4, 2023
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Jul 4, 2023
@alexfauquette alexfauquette merged commit 904d820 into mui:master Jul 4, 2023
21 checks passed
@alexfauquette
Copy link
Member Author

@samuelsycamore You can now update all the install script you want on core :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature New feature or request scope: docs-infra Specific to the docs-infra product
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants