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] Improve Joy UI tutorial demo #34653

Merged
merged 2 commits into from Oct 7, 2022

Conversation

@oliviertassinari oliviertassinari added the docs Improvements or additions to the documentation label Oct 7, 2022
@mui-bot
Copy link

mui-bot commented Oct 7, 2022

No bundle size changes

Generated by 🚫 dangerJS against d4f3b0a

if (mode === 'light') {
setMode('dark');
} else {
setMode('light');
}
setMode(mode === 'light' ? 'dark' : 'light');
Copy link
Member Author

Choose a reason for hiding this comment

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

It seems mentally simpler to follow by calling setMode once rather than branching it entirely.

@@ -17,7 +17,7 @@ By the end, you should understand how to:

Here's what the final product looks like—click on the **< >** icon underneath the demo to see the full source code:

{{"demo": "LoginFinal.js", "hideToolbar": false, "bg": true}}
{{"demo": "LoginFinal.js"}}
Copy link
Member Author

Choose a reason for hiding this comment

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

I have removed hideToolbar": false because it's already the default. I have added a check to avoid this case going forward.

I have removed "bg": true so it looks the same when you export to codesandbox https://codesandbox.io/s/m1r0yt?file=/demo.tsx/import it in your codebase.

}}
>
{mode === 'light' ? 'Turn dark' : 'Turn light'}
</Button>
);
};
}
```

Finally, add your newly built `<ModeToggle />` button above `<Sheet />`:

```diff
Copy link
Member Author

Choose a reason for hiding this comment

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

The correct format of the git diff output is to prefix all the lines with one character:

  • , one space if nothing changed
  • - if something was removed
  • + if something was added

It looks strange otherwise.

@@ -3,6 +3,7 @@
/inbox* / 301
/trash / 301
/spam / 301
/sign-up / 301
Copy link
Member Author

Choose a reason for hiding this comment

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

@@ -6,7 +6,7 @@ import TextField from '@mui/joy/TextField';
import Button from '@mui/joy/Button';
import Link from '@mui/joy/Link';

const ModeToggle = () => {
function ModeToggle() {
Copy link
Member Author

Choose a reason for hiding this comment

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

I think the convention we use in the docs to create components. It's related to this PR https://github.com/mui/material-ui/pull/34644/files#diff-559bb65f49006b76c9495639f8c69571711721a76d0a19ae279ca4f93772e6ffR9

@@ -42,7 +38,7 @@ export default function App() {
<ModeToggle />
<Sheet
sx={{
maxWidth: 400,
width: 300,
Copy link
Member Author

Choose a reason for hiding this comment

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

So it looks better?

Before
Screenshot 2022-10-07 at 17 39 37

After
Screenshot 2022-10-07 at 17 39 29

After

>
Log in
</Button>
<Button sx={{ mt: 1 /* margin top */ }}>Log in</Button>
Copy link
Member Author

Choose a reason for hiding this comment

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

This takes a lot less vertical space

Comment on lines 163 to 164
src="https://images.unsplash.com/photo-1527549993586-dff825b37782?auto=forma&fit=cropt&h=80"
srcSet="https://images.unsplash.com/photo-1527549993586-dff825b37782?auto=format&h=160 2x"
Copy link
Member Author

Choose a reason for hiding this comment

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

@oliviertassinari oliviertassinari marked this pull request as ready for review October 7, 2022 15:46
Copy link
Member

@samuelsycamore samuelsycamore left a comment

Choose a reason for hiding this comment

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

Great improvements! 👍

@oliviertassinari oliviertassinari merged commit d3010f1 into mui:master Oct 7, 2022
@oliviertassinari oliviertassinari deleted the fix-404 branch October 8, 2022 09:49
alexfauquette pushed a commit to alexfauquette/material-ui that referenced this pull request Oct 14, 2022
daniel-rabe pushed a commit to daniel-rabe/material-ui that referenced this pull request Nov 29, 2022
feliperli pushed a commit to jesrodri/material-ui that referenced this pull request Dec 6, 2022
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants