Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mnajdova committed Aug 15, 2024
1 parent fc5d041 commit 174a500
Show file tree
Hide file tree
Showing 5 changed files with 102 additions and 89 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,47 +3,50 @@ 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 (
<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>
<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>

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

export default function MultilineButton() {
return (
<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>
</Layout>
);
}
2 changes: 1 addition & 1 deletion apps/pigment-css-vite-app/src/pages/fixtures/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ async function main() {
// Move cursor offscreen to not trigger unwanted hover effects.
page.mouse.move(0, 0);

const testcase = await page.waitForSelector('#root');
const testcase = await page.waitForSelector('#root-demo');

return testcase;
}
Expand Down
50 changes: 3 additions & 47 deletions apps/pigment-css-vite-app/src/pages/fixtures/index.tsx
Original file line number Diff line number Diff line change
@@ -1,50 +1,6 @@
import * as React from 'react';
import { useLocation, matchRoutes, Link } from 'react-router-dom';
import routes from '~react-pages';
import Layout from '../../Layout';
import Layout from './layout';

export default function FixturesIndex() {
const location = useLocation();
const matchedRoute = React.useMemo(
() => matchRoutes(routes, location.pathname)?.[0],
[location.pathname],
);
const childRoutes = matchedRoute?.route.children ?? [];

return (
<Layout>
<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
.filter((item) => !!item.path && item.path !== 'index.test')
.map((item) => (
<li key={item.path}>
<Link
to={`/fixtures/${item.path}`}
sx={{
textDecoration: 'underline',
fontSize: '17px',
}}
>
{item.path}
</Link>
</li>
))}
</ul>
</nav>
</div>
</Layout>
);
export default function Index() {
return <Layout />;
}
51 changes: 51 additions & 0 deletions apps/pigment-css-vite-app/src/pages/fixtures/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import * as React from 'react';
import { useLocation, matchRoutes, Link } from 'react-router-dom';
import routes from '~react-pages';
import IndexLayout from '../../Layout';

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

return (
<IndexLayout>
{props.children && <div id="root-demo">{props.children}</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
.filter((item) => !!item.path && item.path !== 'index.test' && item.path !== 'layout')
.map((item) => (
<li key={item.path}>
<Link
to={`/fixtures/${item.path}`}
sx={{
textDecoration: 'underline',
fontSize: '17px',
}}
>
{item.path}
</Link>
</li>
))}
</ul>
</nav>
</div>
</IndexLayout>
);
}

0 comments on commit 174a500

Please sign in to comment.