Skip to content

Commit

Permalink
[docs] Link Material UI from the landing page
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviertassinari committed Jul 17, 2023
1 parent 0591739 commit 8362869
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 31 deletions.
56 changes: 28 additions & 28 deletions docs/src/components/home/GetStartedButtons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,25 @@ import Button from '@mui/material/Button';
import KeyboardArrowRightRounded from '@mui/icons-material/KeyboardArrowRightRounded';
import ContentCopyRounded from '@mui/icons-material/ContentCopyRounded';
import CheckRounded from '@mui/icons-material/CheckRounded';
import ROUTES from 'docs/src/route';
import Link from 'docs/src/modules/components/Link';

interface GetStartedButtonsProps extends BoxProps {
callToAction?: string;
installation?: string;
to?: string;
to: string;
}

export default function GetStartedButtons(props: GetStartedButtonsProps) {
const [copied, setCopied] = React.useState(false);
const {
installation = 'npm install @mui/material @emotion/react @emotion/styled',
to = ROUTES.documentation,
...other
} = props;
const { installation, callToAction = 'Get started', to, ...other } = props;

const handleCopy = () => {
setCopied(true);
copy(installation).then(() => {
copy(installation as any).then(() => {
setTimeout(() => setCopied(false), 2000);
});
};

return (
<Box
{...other}
Expand All @@ -51,27 +49,29 @@ export default function GetStartedButtons(props: GetStartedButtonsProps) {
mb: { xs: 2, md: 0 },
}}
>
Get started
</Button>
<Button
size="large"
// @ts-expect-error
variant="code"
endIcon={copied ? <CheckRounded color="primary" /> : <ContentCopyRounded />}
onClick={handleCopy}
sx={{
maxWidth: '324px',
display: 'inline-block',
justifyContent: 'start',
overflowX: 'hidden',
whiteSpace: 'nowrap',
textOverflow: 'ellipsis',
position: 'relative',
pr: 5,
}}
>
{installation}
{callToAction}
</Button>
{installation ? (
<Button
size="large"
// @ts-expect-error
variant="code"
endIcon={copied ? <CheckRounded color="primary" /> : <ContentCopyRounded />}
onClick={handleCopy}
sx={{
maxWidth: '324px',
display: 'inline-block',
justifyContent: 'start',
overflowX: 'hidden',
whiteSpace: 'nowrap',
textOverflow: 'ellipsis',
position: 'relative',
pr: 5,
}}
>
{installation}
</Button>
) : null}
</Box>
);
}
2 changes: 1 addition & 1 deletion docs/src/components/home/Hero.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export default function Hero() {
with Material UI, our fully-loaded component library, or bring your own design system to
our production-ready components.
</Typography>
<GetStartedButtons />
<GetStartedButtons callToAction="Discover Material UI" to="/material-ui/" />
</Box>
}
rightSx={{
Expand Down
2 changes: 1 addition & 1 deletion docs/src/components/home/StartToday.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default function StartToday() {
}
description="Find out why MUI's tools are trusted by thousands of open-source developers and teams around the world."
/>
<GetStartedButtons />
<GetStartedButtons callToAction="Discover Material UI" to="/material-ui/" />
</Grid>
<Grid item xs={12} sm={6} md={6} container spacing={2}>
<Grid item xs={12} md={6}>
Expand Down
5 changes: 4 additions & 1 deletion docs/src/components/productMaterial/MaterialHero.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,10 @@ export default function MaterialHero() {
Material UI is beautiful by design and features a suite of customization options that
make it easy to implement your own custom design system.
</Typography>
<GetStartedButtons />
<GetStartedButtons
to="/material-ui/getting-started/"
installation="npm install @mui/material @emotion/react @emotion/styled"
/>
</Box>
}
rightSx={{
Expand Down

0 comments on commit 8362869

Please sign in to comment.