Unify code and styles for tiles

This commit is contained in:
Konrad Szwarc 2022-12-08 17:27:46 +01:00
parent 5e2bc16693
commit cea074b00c
6 changed files with 32 additions and 31 deletions

View file

@ -24,7 +24,6 @@
"@astrojs/image": "0.12.0",
"@iconify-icon/react": "1.0.2",
"@tippyjs/react": "4.2.6",
"clsx": "1.2.1",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-use": "17.4.0"

View file

@ -8,25 +8,27 @@ export interface Props {
value: Book;
}
const { value } = Astro.props;
const {
value: { author, cover, title, url },
} = Astro.props;
---
<a href={value.url} class="flex w-full flex-col gap-3 transition duration-300 hover:translate-y-2">
<a href={url} class="flex w-full flex-col gap-3 transition duration-300 hover:translate-y-2">
<Image
class="rounded-lg shadow-md aspect-[3/4] object-cover"
format="webp"
fit={'cover'}
aspectRatio={3 / 4}
quality={100}
src={value.cover}
alt={value.title}
src={cover}
alt={title}
/>
<div class="w-full gap-1">
<Typography class="leading-5, hover:text-gray-900" variant="tile-title">
{value.title}
<Typography variant="tile-title">
{title}
</Typography>
<Typography variant="tile-subtitle">
{value.author}
{author}
</Typography>
</div>
</a>

View file

@ -8,25 +8,27 @@ export interface Props {
value: Media;
}
const { value } = Astro.props;
const {
value: { image, title, type, url },
} = Astro.props;
---
<a href={value.url} class="flex w-full flex-col gap-3 transition duration-300 hover:translate-y-2">
<a href={url} class="flex w-full flex-col gap-3 transition duration-300 hover:translate-y-2">
<Image
class="rounded-lg shadow-md aspect-square object-cover"
fit="cover"
format="webp"
aspectRatio={1}
quality={100}
src={value.image}
alt={value.title}
src={image}
alt={title}
/>
<div class="gap-1">
<Typography class="leading-5 hover:text-gray-900" variant="tile-title">
{value.title}
<Typography variant="tile-title">
{title}
</Typography>
<Typography variant="tile-subtitle">
{value.type}
{type}
</Typography>
</div>
</a>

View file

@ -8,22 +8,22 @@ export interface Props {
value: Person;
}
const { value } = Astro.props;
const {
value: { image, name, url },
} = Astro.props;
---
<a href={value.url} class="flex w-full flex-col gap-3 transition duration-300 hover:translate-y-2">
<a href={url} class="flex w-full flex-col gap-3 transition duration-300 hover:translate-y-2">
<Image
class="rounded-lg shadow-md transition duration-300 aspect-square object-cover"
format="webp"
fit="cover"
quality={100}
aspectRatio={1}
src={value.image}
alt={value.name}
src={image}
alt={name}
/>
<div class="gap-1">
<Typography class="leading-5 hover:text-gray-900" variant="tile-title">
{value.name}
<Typography variant="tile-title">
{name}
</Typography>
</div>
</a>

View file

@ -24,7 +24,7 @@ const variantToElement = {
paragraph: 'p',
} as const;
const variantToClassName = {
const variantToClassName /* tw */ = {
'main-title': 'text-3xl sm:text-4xl font-extrabold text-gray-900 dark:text-gray-100',
'main-subtitle': 'text-md sm:text-lg font-medium text-gray-700 dark:text-gray-100',
'section-title': 'text-3xl font-extrabold text-gray-900 dark:text-gray-100',
@ -34,7 +34,7 @@ const variantToClassName = {
'item-subtitle': 'text-md font-medium text-gray-700 dark:text-gray-100',
'tile-title': 'text-sm font-medium text-gray-700 dark:text-gray-200',
'tile-subtitle': 'text-sm font-normal text-gray-500 dark:text-gray-300',
paragraph: 'text-sm sm:text-base leading-relaxed font-normal text-gray-500 dark:text-gray-300',
paragraph: 'text-sm leading-relaxed font-normal text-gray-500 sm:text-base sm:leading-relaxed dark:text-gray-300',
};
export interface Props extends Omit<astroHTML.JSX.HTMLAttributes, 'slot'> {

View file

@ -25,9 +25,7 @@ const thumbnail = `https://img.youtube.com/vi/${id}/0.jpg`;
src={thumbnail}
alt={title}
/>
<div class="gap-1">
<Typography class="leading-5 hover:text-gray-900" variant="tile-title">
<Typography variant="tile-title">
{title}
</Typography>
</div>
</a>