Skip to content

Commit

Permalink
Merge pull request #26 from iib0011/examples
Browse files Browse the repository at this point in the history
Examples
  • Loading branch information
iib0011 authored Feb 27, 2025
2 parents a03df0a + a713690 commit f855d33
Show file tree
Hide file tree
Showing 12 changed files with 364 additions and 330 deletions.
151 changes: 77 additions & 74 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions src/components/ToolHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function ToolLinks() {

return (
<Grid container spacing={2} mt={1}>
<Grid item md={12} lg={4}>
<Grid item md={12} lg={6}>
<StyledButton
sx={{ backgroundColor: 'white' }}
fullWidth
Expand All @@ -36,16 +36,16 @@ function ToolLinks() {
Use This Tool
</StyledButton>
</Grid>
<Grid item md={12} lg={4}>
<Grid item md={12} lg={6}>
<StyledButton fullWidth variant="outlined" href="#examples">
See Examples
</StyledButton>
</Grid>
<Grid item md={12} lg={4}>
<StyledButton fullWidth variant="outlined" href="#tour">
Learn How to Use
</StyledButton>
</Grid>
{/*<Grid item md={12} lg={4}>*/}
{/* <StyledButton fullWidth variant="outlined" href="#tour">*/}
{/* Learn How to Use*/}
{/* </StyledButton>*/}
{/*</Grid>*/}
</Grid>
);
}
Expand Down
32 changes: 22 additions & 10 deletions src/components/examples/ExampleCard.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { ExampleCardProps } from './Examples';
import {
Box,
Card,
Expand All @@ -9,26 +8,42 @@ import {
useTheme
} from '@mui/material';
import ArrowDownwardIcon from '@mui/icons-material/ArrowDownward';
import RequiredOptions from './RequiredOptions';
import ExampleOptions from './ExampleOptions';
import { GetGroupsType } from '@components/options/ToolOptions';

export default function ExampleCard({
export interface ExampleCardProps<T> {
title: string;
description: string;
sampleText: string;
sampleResult: string;
sampleOptions: T;
changeInputResult: (newOptions: T) => void;
getGroups: GetGroupsType<T>;
}

export default function ExampleCard<T>({
title,
description,
sampleText,
sampleResult,
requiredOptions,
changeInputResult
}: ExampleCardProps) {
sampleOptions,
changeInputResult,
getGroups
}: ExampleCardProps<T>) {
const theme = useTheme();
return (
<Card
raised
onClick={() => {
changeInputResult(sampleOptions);
}}
sx={{
bgcolor: theme.palette.background.default,
height: '100%',
overflow: 'hidden',
borderRadius: 2,
transition: 'background-color 0.3s ease',
cursor: 'pointer',
'&:hover': {
boxShadow: '12px 9px 11px 2px #b8b9be, -6px -6px 12px #fff'
}
Expand All @@ -46,7 +61,6 @@ export default function ExampleCard({
</Typography>

<Box
onClick={() => changeInputResult(sampleText, sampleResult)}
sx={{
display: 'flex',
zIndex: '2',
Expand All @@ -55,7 +69,6 @@ export default function ExampleCard({
bgcolor: 'transparent',
padding: '5px 10px',
borderRadius: '5px',
cursor: 'pointer',
boxShadow: 'inset 2px 2px 5px #b8b9be, inset -3px -3px 7px #fff;'
}}
>
Expand All @@ -77,7 +90,6 @@ export default function ExampleCard({

<ArrowDownwardIcon />
<Box
onClick={() => changeInputResult(sampleText, sampleResult)}
sx={{
display: 'flex',
zIndex: '2',
Expand Down Expand Up @@ -106,7 +118,7 @@ export default function ExampleCard({
/>
</Box>

<RequiredOptions options={requiredOptions} />
<ExampleOptions options={sampleOptions} getGroups={getGroups} />
</Stack>
</CardContent>
</Card>
Expand Down
19 changes: 19 additions & 0 deletions src/components/examples/ExampleOptions.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import ToolOptionGroups from '@components/options/ToolOptionGroups';
import { GetGroupsType } from '@components/options/ToolOptions';
import React from 'react';

export default function ExampleOptions<T>({
options,
getGroups
}: {
options: T;
getGroups: GetGroupsType<T>;
}) {
return (
<ToolOptionGroups
// @ts-ignore
groups={getGroups({ values: options })}
vertical
/>
);
}
59 changes: 0 additions & 59 deletions src/components/examples/Examples.tsx

This file was deleted.

Loading

0 comments on commit f855d33

Please sign in to comment.