Skip to content
Snippets Groups Projects
Commit 63bf5b01 authored by tovo's avatar tovo
Browse files

format code

parent 19019f6f
No related branches found
No related tags found
No related merge requests found
......@@ -3,80 +3,60 @@ import { IGatsbyImageData } from "gatsby-plugin-image";
import Card from "./Card";
interface CardProps {
title?: string;
content?: string;
image?: string | IGatsbyImageData;
to?: string;
anime?: boolean;
layout?: "top" | "left";
className?: string;
title?: string;
content?: string;
image?: string | IGatsbyImageData;
to?: string;
anime?: boolean;
layout?: "top" | "left";
className?: string;
}
interface Props {
cards?: CardProps[];
layout?: 'row' | 'col' | 'grid';
className?: string;
anime?: boolean;
cards?: CardProps[];
layout?: "row" | "col" | "grid";
className?: string;
anime?: boolean;
}
const oCardProps = {
'row': {
layout: 'left',
className: ''
},
'col': {
layout: 'top',
className: ''
},
'grid': {
layout: 'top',
className: 'max-w-full'
}
}
row: {
layout: "left",
className: "",
},
col: {
layout: "top",
className: "",
},
grid: {
layout: "top",
className: "max-w-full",
},
};
const CardList = (props: Props) => {
const {
cards = [],
layout = 'row',
className = '',
anime = true
} = props;
const oListClassName = {
'row': `space-y-10 w-full ${className}`,
'col': `flex space-x-12 flex-nowrap justify-center ${className}`,
'grid': `grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-12 ${className}`
}
const tmpProps = oCardProps[layout];
const listCards = cards.map((card, index) => {
let cardProps = {
...card,
...tmpProps,
anime
};
const { cards = [], layout = "row", className = "", anime = true } = props;
return (
<Card
key={index}
{...(cardProps as CardProps)}
/>
)
})
const oListClassName = {
row: `space-y-10 w-full ${className}`,
col: `flex space-x-12 flex-nowrap justify-center ${className}`,
grid: `grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-12 ${className}`,
};
return (
<div
className={oListClassName[layout]}
>
{listCards}
</div>
)
};
const tmpProps = oCardProps[layout];
const listCards = cards.map((card, index) => {
let cardProps = {
...card,
...tmpProps,
anime,
};
return <Card key={index} {...(cardProps as CardProps)} />;
});
return <div className={oListClassName[layout]}>{listCards}</div>;
};
export default CardList;
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment