From 9bbc71cd33809e1bfa03861cf964172c757bb0ea Mon Sep 17 00:00:00 2001 From: nemanjam Date: Sat, 15 Jun 2024 19:30:04 +0200 Subject: [PATCH] PostCard new design, desktop --- docs/my-old-code/PostCard.astro | 77 +++++++++++++++++++++++++++++++++ src/components/PostCard.astro | 54 ++++++++++++++++------- src/components/PostMeta.astro | 1 - src/styles/themes.css | 4 +- src/styles/variables.css | 2 +- 5 files changed, 118 insertions(+), 20 deletions(-) create mode 100644 docs/my-old-code/PostCard.astro diff --git a/docs/my-old-code/PostCard.astro b/docs/my-old-code/PostCard.astro new file mode 100644 index 0000000..4c0f8d5 --- /dev/null +++ b/docs/my-old-code/PostCard.astro @@ -0,0 +1,77 @@ +--- +import { Image } from 'astro:assets'; + +import Link from '@/components/Link.astro'; +import PostMeta from '@/components/PostMeta.astro'; +import TagList from '@/components/TagList.astro'; +import { ROUTES } from '@/constants/routes'; +import { cn } from '@/utils/styles'; + +import type { Post } from '@/types/post'; + +export interface Props { + post: Post; +} + +const { post } = Astro.props; +const { data, slug, readingTime } = post; + +const { + draft, + publishDate, + title, + heroImage, + heroAlt, + // category, + tags = [], + description, +} = data; + +const postMetaProps = { readingTime, publishDate }; +--- + +{/* Text in right column determines height, 2 lines title + 2 lines description. */} +{/* Image determines max-height. For cases when image isn't 16/9 so it's cropped. */} +{/* Image for 2 + 2 lines text has 168px naturaly, limit to 172, h-44 = 176 */} + +
+ {/* left column */} + { + heroImage && ( +
+ {heroAlt} +
+ ) + } + + {/* right column */} +
+ + + {/* title */} +

+ + {title} + {draft && (draft)} + +

+ + {description &&

{description}

} + + +
+
diff --git a/src/components/PostCard.astro b/src/components/PostCard.astro index 4c0f8d5..587826e 100644 --- a/src/components/PostCard.astro +++ b/src/components/PostCard.astro @@ -1,10 +1,12 @@ --- +import { Icon } from 'astro-icon/components'; import { Image } from 'astro:assets'; +import { getCategoryProps } from '@/modules/post'; import Link from '@/components/Link.astro'; -import PostMeta from '@/components/PostMeta.astro'; import TagList from '@/components/TagList.astro'; import { ROUTES } from '@/constants/routes'; +import { formatDate, formatDateIso } from '@/utils/datetime'; import { cn } from '@/utils/styles'; import type { Post } from '@/types/post'; @@ -16,18 +18,9 @@ export interface Props { const { post } = Astro.props; const { data, slug, readingTime } = post; -const { - draft, - publishDate, - title, - heroImage, - heroAlt, - // category, - tags = [], - description, -} = data; +const { draft, publishDate, title, heroImage, heroAlt, category, tags = [], description } = data; -const postMetaProps = { readingTime, publishDate }; +const { icon: categoryIcon } = getCategoryProps(category); --- {/* Text in right column determines height, 2 lines title + 2 lines description. */} @@ -51,7 +44,7 @@ const postMetaProps = { readingTime, publishDate }; widths={[320, 540]} sizes="(max-width: 475px) 320px, 540px" itemprop="image" - class="w-full h-40 md:h-full md:max-h-[172px] object-cover rounded-box" + class="w-full h-40 md:h-full md:max-h-52 object-cover rounded-box" transition:name={`hero-${heroImage.src}`} /> @@ -60,7 +53,25 @@ const postMetaProps = { readingTime, publishDate }; {/* right column */}
- + {/* category and publishDate row*/} +
+ + + + {category} + + + + + + + +
{/* title */}

@@ -70,8 +81,19 @@ const postMetaProps = { readingTime, publishDate };

- {description &&

{description}

} + {description &&

{description}

} - + {/* reading time and read more link */} +
+ + + {`${Math.round(readingTime)} minutes`} + + + + Read more + + +
diff --git a/src/components/PostMeta.astro b/src/components/PostMeta.astro index de79320..b8c874e 100644 --- a/src/components/PostMeta.astro +++ b/src/components/PostMeta.astro @@ -2,7 +2,6 @@ import { Icon } from 'astro-icon/components'; import Link from '@/components/Link.astro'; -import { CATEGORIES } from '@/constants/collections'; import { ROUTES } from '@/constants/routes'; import { formatDate, formatDateIso } from '@/utils/datetime'; import { cn } from '@/utils/styles'; diff --git a/src/styles/themes.css b/src/styles/themes.css index ed90858..2b586f2 100644 --- a/src/styles/themes.css +++ b/src/styles/themes.css @@ -19,8 +19,8 @@ --th-primary: var(--var-color-blue-500); --th-primary-content: var(--var-color-white); - --th-primary-base-200: var(--var-color-blue-200); - --th-primary-base-300: var(--var-color-blue-300); + --th-primary-base-200: var(--var-color-blue-100); + --th-primary-base-300: var(--var-color-blue-200); --th-secondary: var(--var-color-orange); --th-secondary-content: var(--var-color-white); diff --git a/src/styles/variables.css b/src/styles/variables.css index 081785d..27f3843 100644 --- a/src/styles/variables.css +++ b/src/styles/variables.css @@ -16,8 +16,8 @@ --var-color-blue-500: theme('colors.blue.500'); --var-color-blue-600: theme('colors.blue.600'); --var-color-blue-700: theme('colors.blue.700'); + --var-color-blue-100: theme('colors.blue.100'); --var-color-blue-200: theme('colors.blue.200'); - --var-color-blue-300: theme('colors.blue.300'); --var-color-purple-700: theme('colors.purple.700'); --var-color-purple-500: theme('colors.purple.500'); --var-color-orange: theme('colors.orange.400');