Skip to content

Commit

Permalink
improve index
Browse files Browse the repository at this point in the history
  • Loading branch information
mnajdova committed Aug 15, 2024
1 parent 0200896 commit ab06674
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 101 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,50 +3,47 @@ import Button from '@mui/material/Button';
import ButtonGroup from '@mui/material/ButtonGroup';
import Stack from '@mui/material/Stack';
import Tooltip from '@mui/material/Tooltip';
import Layout from './layout';

export default function DifferentChildren() {
const falsyCondition = 1 === 2;

return (
<Layout>
<Stack spacing={2}>
{/* It has one button with href which is rendered as anchor tag */}
<ButtonGroup variant="contained">
<Button href="##">Button 1</Button>
<Button>Button 2</Button>
<Button>Button 3</Button>
</ButtonGroup>
<Stack spacing={2}>
{/* It has one button with href which is rendered as anchor tag */}
<ButtonGroup variant="contained">
<Button href="##">Button 1</Button>
<Button>Button 2</Button>
<Button>Button 3</Button>
</ButtonGroup>

{/* With tooltip */}
<ButtonGroup>
<Tooltip title="tooltip">
<Button>Enabled</Button>
</Tooltip>
<Tooltip title="tooltip">
<span>
<Button disabled>Disabled</Button>
</span>
</Tooltip>
<Tooltip title="tooltip">
<span>
<Button disabled>Disabled</Button>
</span>
</Tooltip>
</ButtonGroup>
{/* With tooltip */}
<ButtonGroup>
<Tooltip title="tooltip">
<Button>Enabled</Button>
</Tooltip>
<Tooltip title="tooltip">
<span>
<Button disabled>Disabled</Button>
</span>
</Tooltip>
<Tooltip title="tooltip">
<span>
<Button disabled>Disabled</Button>
</span>
</Tooltip>
</ButtonGroup>

{/* Single button */}
<ButtonGroup>
<Button>Single Button</Button>
</ButtonGroup>
{/* Single button */}
<ButtonGroup>
<Button>Single Button</Button>
</ButtonGroup>

{/* Conditional elements */}
<ButtonGroup>
<Button>One</Button>
<Button>Two</Button>
{falsyCondition ? <Button>Three</Button> : undefined}
</ButtonGroup>
</Stack>
</Layout>
{/* Conditional elements */}
<ButtonGroup>
<Button>One</Button>
<Button>Two</Button>
{falsyCondition ? <Button>Three</Button> : undefined}
</ButtonGroup>
</Stack>
);
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
import * as React from 'react';
import Button from '@mui/material/Button';
import Layout from './layout';

export default function MultilineButton() {
return (
<Layout>
<Button variant="contained" style={{ width: 400 }}>
{[
'Contained buttons are rectangular-shaped buttons.',
'They may be used inline.',
'They lift and display ink reactions on press.',
].join(' ')}
</Button>
</Layout>
<Button variant="contained" style={{ width: 400 }}>
{[
'Contained buttons are rectangular-shaped buttons.',
'They may be used inline.',
'They lift and display ink reactions on press.',
].join(' ')}
</Button>
);
}
53 changes: 50 additions & 3 deletions apps/pigment-css-vite-app/src/pages/fixtures/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,53 @@
import * as React from 'react';
import Layout from './layout';
import { useLocation, matchRoutes, Link } from 'react-router-dom';
import routes from '~react-pages';
import IndexLayout from '../../Layout';

export default function Index() {
return <Layout />;
export default function Layout(props: { children?: React.ReactNode }) {
const location = useLocation();
const matchedRoute = React.useMemo(
() => matchRoutes(routes, location.pathname)?.[0],
[location.pathname],
);

const demo = new URLSearchParams(location.search).get('demo');
const childRoutes = (matchedRoute?.route.children ?? []).filter(
(item) => !!item.path && item.path !== 'index.test' && item.path !== 'layout',
);

return (
<IndexLayout>
{demo && <div id="root-demo">{childRoutes.find((item) => item.path === demo)?.element}</div>}
<div>
<h1>Fixtures Material UI + PIgment CSS</h1>
<nav id="tests">
<ul
sx={{
margin: 0,
marginBlock: '1rem',
padding: 0,
paddingLeft: '1.5rem',
display: 'flex',
flexDirection: 'column',
gap: '0.5rem',
}}
>
{childRoutes.map((item) => (
<li key={item.path}>
<Link
to={`/fixtures/?demo=${item.path}`}
sx={{
textDecoration: 'underline',
fontSize: '17px',
}}
>
{item.path}
</Link>
</li>
))}
</ul>
</nav>
</div>
</IndexLayout>
);
}
51 changes: 0 additions & 51 deletions apps/pigment-css-vite-app/src/pages/fixtures/layout.tsx

This file was deleted.

0 comments on commit ab06674

Please sign in to comment.