Skip to content

Commit 1874773

Browse files
authored
[docs][joy] Build TS versions for Link component demos (#36366)
1 parent 03b616a commit 1874773

File tree

3 files changed

+158
-0
lines changed

3 files changed

+158
-0
lines changed
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
import * as React from 'react';
2+
import { keyframes } from '@mui/system';
3+
import Box from '@mui/joy/Box';
4+
import Link from '@mui/joy/Link';
5+
import Chip from '@mui/joy/Chip';
6+
7+
const circulate = keyframes({
8+
'0%': {
9+
transform: 'rotate(0deg)',
10+
},
11+
'100%': {
12+
transform: 'rotate(360deg)',
13+
},
14+
});
15+
16+
export default function DecoratorExamples() {
17+
return (
18+
<Box
19+
sx={{ display: 'flex', flexDirection: 'column', alignItems: 'center', gap: 4 }}
20+
>
21+
<Link
22+
href="#common-examples"
23+
disabled
24+
startDecorator={
25+
<Box
26+
sx={{
27+
'--loader-thickness': '4px',
28+
borderRadius: '50%',
29+
border: 'var(--loader-thickness) solid',
30+
borderColor: 'primary.softBg',
31+
width: 'var(--Icon-fontSize)',
32+
height: 'var(--Icon-fontSize)',
33+
boxSizing: 'border-box',
34+
position: 'relative',
35+
}}
36+
>
37+
<Box
38+
sx={{
39+
position: 'absolute',
40+
top: 'calc(-1 * var(--loader-thickness))',
41+
left: 'calc(-1 * var(--loader-thickness))',
42+
width: 'inherit',
43+
height: 'inherit',
44+
borderRadius: 'inherit',
45+
border: 'inherit',
46+
boxSizing: 'inherit',
47+
borderColor: (theme) =>
48+
`${theme.vars.palette.primary.softColor} transparent transparent`,
49+
animation: `${circulate} 1s ease infinite`,
50+
}}
51+
/>
52+
</Box>
53+
}
54+
>
55+
Processing...
56+
</Link>
57+
58+
<Link
59+
href="#common-examples"
60+
underline="none"
61+
variant="soft"
62+
color="success"
63+
endDecorator={
64+
<Chip color="success" size="sm" sx={{ borderRadius: '3px', mr: '2px' }}>
65+
HIRING!
66+
</Chip>
67+
}
68+
sx={{ '--Link-gap': '0.5rem', pr: 0, pl: 1 }}
69+
>
70+
Careers
71+
</Link>
72+
</Box>
73+
);
74+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import * as React from 'react';
2+
import Box from '@mui/joy/Box';
3+
import Link from '@mui/joy/Link';
4+
import Typography from '@mui/joy/Typography';
5+
import Launch from '@mui/icons-material/Launch';
6+
import LinkIcon from '@mui/icons-material/Link';
7+
8+
export default function LinkAndTypography() {
9+
return (
10+
<Box sx={{ maxWidth: 360 }}>
11+
<Typography
12+
id="heading-demo"
13+
level="h2"
14+
fontSize="lg"
15+
endDecorator={
16+
<Link
17+
variant="outlined"
18+
aria-labelledby="heading-demo"
19+
href="#heading-demo"
20+
fontSize="md"
21+
borderRadius="sm"
22+
>
23+
<LinkIcon />
24+
</Link>
25+
}
26+
mb={1}
27+
sx={{ scrollMarginTop: 100 }}
28+
>
29+
Heading
30+
</Typography>
31+
<Typography>
32+
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
33+
tempor incididunt ut labore et dolore{' '}
34+
<Link href="#heading-demo" endDecorator={<Launch />}>
35+
Magna Aliqua
36+
</Link>
37+
. Maecenas sed enim ut sem viverra aliquet eget.
38+
</Typography>
39+
</Box>
40+
);
41+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import * as React from 'react';
2+
import Avatar from '@mui/joy/Avatar';
3+
import Box from '@mui/joy/Box';
4+
import Card from '@mui/joy/Card';
5+
import Link from '@mui/joy/Link';
6+
import Typography from '@mui/joy/Typography';
7+
import CenterFocusWeak from '@mui/icons-material/CenterFocusWeak';
8+
9+
export default function Links() {
10+
return (
11+
<Card
12+
sx={{
13+
bgcolor: 'background.body',
14+
'&:hover, &:focus-within': {
15+
bgcolor: 'background.level2',
16+
},
17+
boxShadow: 'inset 0 1px 0 0 rgb(255 255 255 / 5%)',
18+
}}
19+
>
20+
<Box sx={{ display: 'flex', gap: 2, mb: 2 }}>
21+
<Avatar size="lg" src="/static/images/avatar/1.jpg" />
22+
<div>
23+
{/* This could be a heading (eg. h2) depends on your use case. */}
24+
<Typography component="div">
25+
<Link
26+
overlay
27+
href="#with-card"
28+
textColor="inherit"
29+
underline="none"
30+
fontWeight="md"
31+
>
32+
Joy UI
33+
</Link>
34+
</Typography>
35+
<Typography level="body2">Components that spark joy!</Typography>
36+
</div>
37+
</Box>
38+
<Typography level="body2" display="flex" alignItems="center" gap={0.5}>
39+
Click the <CenterFocusWeak /> and <kbd>TAB</kbd> to test the focus
40+
</Typography>
41+
</Card>
42+
);
43+
}

0 commit comments

Comments
 (0)