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] Add CodeSandbox/Stackblitz to the rest of the templates #43708

Merged
merged 41 commits into from
Oct 21, 2024

Conversation

siriwatknp
Copy link
Member

@siriwatknp siriwatknp commented Sep 11, 2024

Preview:

Follow up PR from #43604

  • Mostly deleting duplicated theme files in each template (switch to use the shared theme)
    🫣 image
  • Fixed minor CSS after switching to shared TemplateFrame
  • Refactor theme.palette.* to use theme.vars.palette.*

@siriwatknp siriwatknp added the scope: docs-infra Specific to the docs-infra product label Sep 11, 2024
@siriwatknp siriwatknp changed the title [docs-infra] Apply new structure to the rest of the templates [docs-infra] Add CodeSandbox/Stackblitz to the rest of the templates Sep 11, 2024
@siriwatknp siriwatknp marked this pull request as draft September 11, 2024 10:58
@siriwatknp siriwatknp removed the request for review from zanivan September 11, 2024 10:58
@zanivan
Copy link
Contributor

zanivan commented Sep 11, 2024

@siriwatknp, these are the issues I found during my initial review. I won't dive too deep into visual tweaks for the templates, like the box-shadow on the marketing page appbar, since that's not the focus of this PR. I've kept the feedback primarily focused on layout and interaction issues based on TemplateFrame:

  • There's an issue on the mobile layout of the Marketing-page, Sign-in, and Checkout templates:
    Screenshot 2024-09-11 at 08 55 53Screenshot 2024-09-11 at 08 56 13Screenshot 2024-09-11 at 08 58 59Screenshot 2024-09-11 at 08 57 54

  • The AppBar on Blog template is not centralized: Screenshot 2024-09-11 at 09 01 26

  • The drawer in the Blog/Marketing page template is placed behind the TemplateFrame: Screenshot 2024-09-11 at 09 00 37

  • The same issue happens in the mobile drawer of Checkout template: Screenshot 2024-09-11 at 08 58 16Screenshot 2024-09-11 at 08 58 10

  • There's a vertical scroll in the Checkout template:

Screen.Recording.2024-09-11.at.08.57.18.mov
  • There's an arrow icon behind the color mode select (same as in this comment): Screenshot 2024-09-11 at 08 58 59

@siriwatknp
Copy link
Member Author

Updates:

  1. Make the theme selector smaller in mobile viewport
image
  1. Addressed all of the comments

@siriwatknp siriwatknp marked this pull request as ready for review September 12, 2024 03:49
@DiegoAndai
Copy link
Member

Question

Mostly deleting duplicated theme files in each template (switch to use the shared theme)

I thought the idea was to have duplicate theme files so each template would have all the code. This way users can clone one template without having to navigate to the shared theme. Is this no longer the case? @zanivan

Some issues found

1. Checkout mobile dark mode
Screenshot 2024-09-12 at 09 45 13

2. Blog images not showing up
Screenshot 2024-09-12 at 09 44 06

3. Stackblitx only: Sessions graph width not working as expected

Screen.Recording.2024-09-12.at.09.42.37.mov

@zanivan
Copy link
Contributor

zanivan commented Sep 12, 2024

I thought the idea was to have duplicate theme files so each template would have all the code. This way users can clone one template without having to navigate to the shared theme. Is this no longer the case? @zanivan

This was the idea, as the only way users could get the templates before was by copying the folder from the project. However, integrating with CodeSandbox/StackBlitz solves this issue, since @siriwatknp packaged the shared theme within the template files when opened on either platform

@zanivan
Copy link
Contributor

zanivan commented Sep 12, 2024

Some bugs/issues I noticed while reviewing it again:

  • The TemplateFrame toolbar sometimes gets stuck when scrolling the dashboard template: Screenshot 2024-09-12 at 10 41 10

  • The AppBar from Blog and Marketing-page templates is not centralized: Screenshot 2024-09-12 at 10 44 22

  • There's an issue in all templates in both StackBlitz and CodeSandbox regarding the dark/light theme:

Screenshot 2024-09-12 at 10 42 02 Screenshot 2024-09-12 at 10 43 52 Screenshot 2024-09-12 at 10 44 49 Screenshot 2024-09-12 at 10 44 59

Just a disclaimer, there are other small UI improvements since we changed the way the TemplateFrame works, and some other adjustments, that can be addressed in a future PR.

@DiegoAndai
Copy link
Member

DiegoAndai commented Sep 12, 2024

This was the idea, as the only way users could get the templates before was by copying the folder from the project. However, integrating with CodeSandbox/StackBlitz solves this issue, since @siriwatknp packaged the shared theme within the template files when opened on either platform

This makes sense. I'll leave it up to you to decide. I think we could be a bit more cautious: We have this new and improved way to use the templates with the sandboxes, and we should promote it, but it might not be best to "remove" the old way right away. There's no rush; we can wait and see how users react to this new system, and if it sticks, we can remove the old one (duplicated themes).

If you decide to remove the duplicated files, then let's also remove the copying mechanism and CI check, which were added here: #43220

@zanivan
Copy link
Contributor

zanivan commented Sep 12, 2024

We have this new and improved way to use the templates with the sandboxes, and we should promote it, but it might not be best to "remove" the old way right away. There's no rush; we can wait and see how users react to this new system, and if it sticks, we can remove the old one (duplicated themes).

No strong opinion on this. Maybe we can wait until the feature to copy the theme to the clipboard is ready before removing the theme folders from the templates

@siriwatknp
Copy link
Member Author

siriwatknp commented Sep 13, 2024

I think we could be a bit more cautious: We have this new and improved way to use the templates with the sandboxes, and we should promote it, but it might not be best to "remove" the old way right away

Thanks for pointing out. Let me clarify the removal of the duplicate theme. Using the shared-theme import has more benefits in several ways:

  • Better DX, updating the shared theme immediately update all the templates, no longer need to run the script every time you change the code. Also, when new template is added, you don't need to remember to update the script.
  • Reduced complexity, no script, no CI check. Faster feedback loop, if you forget to run the script, you need to wait for more 15-20 minutes until the CIs are green.
  • Almost 20k lines are removed, the repo size is already huge (> 120MB). If we could optimize it, we should do it.
  • The duplicated theme is not required to make the CodeSandbox/Stackblitz works.

With all the above reasons, I don't see why we should keep the duplicated theme.

@siriwatknp
Copy link
Member Author

siriwatknp commented Sep 13, 2024

  • There's an issue in all templates in both StackBlitz and CodeSandbox regarding the dark/light theme:

This is a regression from #43632 due to <StyledEngineProvider injectFirst>. I'm investigating.

@siriwatknp
Copy link
Member Author

siriwatknp commented Oct 10, 2024

There's a bug with Dashboard background color:

Found the root cause, will open a separate PR but it's not related to this PR.

There's a bug with the theme Select where an icon appears behind the light/dark color mode toggle:

I could not see it in Chrome (in any templates), what's your browser and which template?

In almost all templates, when in mobile breakpoint, we end up losing the color mode toggle. Since users will likely see this in a split view, we need to have it there somehow—maybe we could draw some inspiration from the previous layouts that we had before adding the TemplateFrame, and bring it to CodeSandbox/Stackblitz UIs

Added the toggle to Dashboard, Marketing, and Blog mobile viewport (only show when open with Sandboxes)

Images aren't loading, probably because we use static images from the docs. Do you have any suggestions about how we might solve this?

I fixed it by using a new process.env.TEMPLATE_IMAGE_URL. In dev, it will use the / path but when deployed it will use the deployed url.

Sign-in, Sign-up and Sign-in-side color mode toggle could be improved, there are some bugs when clicking on it, as well as layout shift and overlapping.

Improved, can you check it again. For "there are some bugs when clicking on it", I think it comes from the custom styles from the theme, can you try to fix it?

@zanivan
Copy link
Contributor

zanivan commented Oct 10, 2024

@siriwatknp I tried to update the branch from upstream to get the changes from the light/dark background color PR #44059 to review the PR again, but noticed that doing this it also committed 170a9c9. Is this right?

@zanivan
Copy link
Contributor

zanivan commented Oct 10, 2024

I could not see it in Chrome (in any templates), what's your browser and which template?

It's happening on Sign-in, Sign-up and Sign-in-side. I've tested on Arc (chrome), Firefox and Safari, and it happens in all of these browsers.

For "there are some bugs when clicking on it", I think it comes from the custom styles from the theme, can you try to fix it?

Will work on it 👍

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Oct 10, 2024
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Oct 14, 2024
@siriwatknp
Copy link
Member Author

There's a bug with the theme Select where an icon appears behind the light/dark color mode toggle

@zanivan found the issue, it's fixed in the latest change.

@zanivan
Copy link
Contributor

zanivan commented Oct 14, 2024

Awesome—I think we're almost there! I just have some small remarks:

  1. On the custom theme, by default, we're only using the icons rounded, so we need to replace these in the StackBlitz/CodeSandbox (let me know if you want me to make this one):
import DarkModeIcon from '@mui/icons-material/DarkModeOutlined';
import LightModeIcon from '@mui/icons-material/LightModeOutlined';
  1. I don't know if it's expected, so correct me if I'm wrong, but images aren't loading on both StackBlitz/CodeSandbox;
  2. On the checkout template, we could add a little extra space atop, so we wouldn't have this overlapping components: Screenshot 2024-10-14 at 08 42 21

@siriwatknp
Copy link
Member Author

@zanivan All fixed. There is one caveat for the images, when you open with CodeSandbox, the image will use https://mui.com as a host.

Copy link
Contributor

@zanivan zanivan left a comment

Choose a reason for hiding this comment

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

I think everything design-wise for adding StackBlitz and CodeSandbox is covered—nice work, @siriwatknp! It might be good to get an engineering review before merging, though @DiegoAndai @aarongarciah


Side note: There are some design issues with the templates, but they aren’t directly related to the CodeSandbox/StackBlitz addition. I think it makes sense to address these in follow-up PRs.

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.

Very cool, I love to see this.

@@ -4,7 +4,7 @@

<!-- #default-branch-switch -->

1. Copy the files into your project, or one of the [example projects](https://github.com/mui/material-ui/tree/master/examples).
1. Copy these folders (`blog` and `shared-theme`) into your project, or one of the [example projects](https://github.com/mui/material-ui/tree/master/examples).
Copy link
Member

Choose a reason for hiding this comment

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

Off-topic

We could provide a CLI script that does this. Related to #39588

Copy link
Contributor

Choose a reason for hiding this comment

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

I really dig this! I created a shaping page kind of related to this https://www.notion.so/mui-org/material-ui-Installation-CLI-e32438c1880c466c8b7075d289e825c4 I think it'd be really nice to have the templates as starting point for new projects.

@@ -1,11 +1,14 @@
import * as React from 'react';
import AppTheme from 'docs/src/modules/components/AppTheme';
Copy link
Member

Choose a reason for hiding this comment

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

Could we rename this? We have two AppTheme in the React tree, and this component has nothing to do with theming.

Copy link
Member

@oliviertassinari oliviertassinari Oct 16, 2024

Choose a reason for hiding this comment

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

Actually, seeing:

<AppTheme title="Onepirate theme - MUI" description="A onepirate theme">

  • Could we also add a title to those template pages? This could be a better DX.
  • I believe we should also remove those description. What's the point, the page is <meta name="robots" content="noindex,nofollow" />, it's absurd.

Copy link
Member Author

Choose a reason for hiding this comment

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

Could we rename this? We have two AppTheme in the React tree, and this component has nothing to do with theming.

Thanks for the feedback but I would do it in a separate PR.

Copy link
Member

@oliviertassinari oliviertassinari Oct 17, 2024

Choose a reason for hiding this comment

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

It makes sense, it's already off in HEAD, not specific to this PR, so best to split the effort in smaller chunks 👍

@oliviertassinari oliviertassinari added docs Improvements or additions to the documentation package: material-ui Specific to @mui/material enhancement This is not a bug, nor a new feature and removed scope: docs-infra Specific to the docs-infra product labels Oct 16, 2024
@oliviertassinari oliviertassinari changed the title [docs-infra] Add CodeSandbox/Stackblitz to the rest of the templates [docs] Add CodeSandbox/Stackblitz to the rest of the templates Oct 16, 2024
Copy link
Member

@DiegoAndai DiegoAndai left a comment

Choose a reason for hiding this comment

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

LGTM, one small nit.

@@ -395,5 +395,9 @@ export const shape = {
};

// @ts-ignore
Copy link
Member

Choose a reason for hiding this comment

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

Nit: is this still required?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, it's still required.

@DiegoAndai
Copy link
Member

@zanivan lets remember to tweet about this when it releases 🙏🏼

@siriwatknp siriwatknp merged commit 91d0d91 into mui:master Oct 21, 2024
26 checks passed
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 enhancement This is not a bug, nor a new feature package: material-ui Specific to @mui/material
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

5 participants