Skip to content

Commit 7143d74

Browse files
authored
feat: updates OpenInNewIconLink and adds LinksDemo component and upda… (#28)
…te routing in Home and App
2 parents 63a9bfd + f3c0e8b commit 7143d74

File tree

6 files changed

+58
-23
lines changed

6 files changed

+58
-23
lines changed

apps/react-kit-demo/src/app/Home.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ export default function Home() {
99
<Link to="/dialog">Dialog</Link> <br />
1010
<Link to="/circular-progress">Circular Progress</Link> <br />
1111
<Link to="/books">All Books</Link> <br />
12+
<Link to="/react-if">React If Demo</Link> <br />
13+
<Link to="/links">Links Demo</Link> <br />
1214
</ul>
1315
</div>
1416
);

apps/react-kit-demo/src/app/app.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { Link, Outlet } from 'react-router-dom';
2-
import React from 'react';
32

43
export default function App() {
54
return (
@@ -13,6 +12,7 @@ export default function App() {
1312
<Link to="/circular-progress">Circular Progress</Link> <br />
1413
<Link to="/books">All Books</Link> <br />
1514
<Link to="/react-if">React If Demo</Link> <br />
15+
<Link to="/links">Links Demo</Link> <br />
1616
</ul>
1717
</div>
1818

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { Divider } from "@mui/material";
2+
import { NextLink, OpenInNewIconLink } from "@react-kit/*";
3+
4+
5+
export default function LinksDemo() {
6+
return (
7+
<div>
8+
<div style={{ marginInline: '1rem', textAlign: 'center' }}>
9+
<h2>Links Demo</h2>
10+
<Divider sx={{ mb: 3 }} />
11+
MUI Link:
12+
<NextLink href={"/buttons-demo"}> Buttons Demo</NextLink>
13+
<br />
14+
Open In New Icon Link :
15+
<OpenInNewIconLink href={`https://www.google.com/`} target="_blank" linkText={'Open In New Tab'} />
16+
<br />
17+
</div>
18+
</div>
19+
);
20+
}

apps/react-kit-demo/src/routes/Routes.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import { createBrowserRouter } from 'react-router-dom';
22
import Home from '../app/Home';
3+
import AllBooks from '../app/all-books/AllBooks';
4+
import App from '../app/app';
35
import ButtonsDemo from '../app/buttons/ButtonsDemo';
4-
import SnackBarDemo from '../app/snack-bar/SnackBarDemo';
56
import DialogDemo from '../app/dialog/DialogDemo';
7+
import LinksDemo from '../app/links/LinksDemo';
68
import CenterCircularProgressDemo from '../app/progress-bar/CenterCircularProgressDemo';
7-
import AllBooks from '../app/all-books/AllBooks';
8-
import App from '../app/app';
99
import ReactIfDemo from '../app/react-if/ReactIfDemo';
10+
import SnackBarDemo from '../app/snack-bar/SnackBarDemo';
1011

1112
export const router = createBrowserRouter([
1213
{
@@ -45,6 +46,10 @@ export const router = createBrowserRouter([
4546
path: '/react-if',
4647
element: <ReactIfDemo />,
4748
},
49+
{
50+
path: '/links',
51+
element: <LinksDemo />,
52+
},
4853
],
4954
},
5055
]);

apps/react-kit-demo/src/styles.scss

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,3 @@
3434
font-size: 20px;
3535
display: block;
3636
}
37-
Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
import React from 'react';
2-
import { Icon } from '@mui/material';
31
import OpenInNewIcon from '@mui/icons-material/OpenInNew';
2+
import { Icon, Link as MuiLink } from '@mui/material';
3+
import React from 'react';
4+
import { Link } from 'react-router-dom';
45

56
interface OpenInNewIconLinkProps {
6-
href: string;
7-
linkText: string;
8-
target: string;
9-
children?: React.ReactNode;
7+
href: string;
8+
linkText: string;
9+
target: string;
10+
children?: React.ReactNode;
1011
}
1112

1213
/**
@@ -18,16 +19,24 @@ interface OpenInNewIconLinkProps {
1819
* @since 1.2.24
1920
*/
2021
export function OpenInNewIconLink(props: OpenInNewIconLinkProps) {
21-
return (
22-
<a
23-
href={props.href}
24-
target={'_blank'}
25-
rel="noreferrer"
26-
style={{ display: 'flex', alignItems: 'center' }}
27-
>
28-
{props.linkText}
29-
<Icon sx={{ fontSize: '1.1rem', mx: 0.75 }} component={OpenInNewIcon} />
30-
{props.children}
31-
</a>
32-
);
22+
return (
23+
<MuiLink
24+
component={Link}
25+
to={props.href}
26+
target={props.target || '_blank'}
27+
rel="noreferrer"
28+
className={'next-btn-link'}
29+
underline="hover">
30+
{props.linkText ?? props.children}
31+
<Icon
32+
sx={{
33+
fontSize: '1.1rem',
34+
mx: 0.75,
35+
verticalAlign: 'middle',
36+
display: 'inline-flex',
37+
}}
38+
component={OpenInNewIcon}
39+
/>
40+
</MuiLink>
41+
);
3342
}

0 commit comments

Comments
 (0)