From f8b6792a71191efc09cb6306b410d7f677d15077 Mon Sep 17 00:00:00 2001 From: Michal Vanko Date: Thu, 9 Dec 2021 17:57:15 +0100 Subject: [PATCH] Fix see all posts and convert css to sprinkles --- src/components/blog/ArticleFooter.css.ts | 41 +++++++++++++++ src/components/blog/ArticleFooter.svelte | 34 +++++++++++++ src/components/blog/article-footer.svelte | 61 ----------------------- src/routes/blog/[slug].svelte | 35 ++----------- src/routes/blog/blog.css.ts | 21 ++++++++ src/routes/blog/index.css.ts | 20 ++++++++ src/routes/blog/index.json.ts | 2 +- src/routes/blog/index.svelte | 43 +++++----------- src/styles/sprinkles.css.ts | 3 +- src/styles/vars.css.ts | 9 +++- 10 files changed, 143 insertions(+), 126 deletions(-) create mode 100644 src/components/blog/ArticleFooter.css.ts create mode 100644 src/components/blog/ArticleFooter.svelte delete mode 100644 src/components/blog/article-footer.svelte create mode 100644 src/routes/blog/blog.css.ts create mode 100644 src/routes/blog/index.css.ts diff --git a/src/components/blog/ArticleFooter.css.ts b/src/components/blog/ArticleFooter.css.ts new file mode 100644 index 0000000..52f476f --- /dev/null +++ b/src/components/blog/ArticleFooter.css.ts @@ -0,0 +1,41 @@ +import { style } from '@vanilla-extract/css' +import { desaturate, transparentize } from 'polished' +import { colors } from '../../styles/vars.css' +import { sprinkles } from '../../styles/sprinkles.css' + +export const tagsListClass = sprinkles({ + listStyle: 'none', + margin: 'none', + padding: 'none', + display: 'inline', +}) + +export const tagsListLiClass = sprinkles({ + display: 'inline', + fontStyle: 'italic', +}) + +export const publishedClass = sprinkles({ + whiteSpace: 'nowrap', + fontStyle: 'italic', +}) + +export const publishedLabelClass = sprinkles({ + color: 'tintedText', +}) + +export const footerClass = style([ + sprinkles({ + display: 'flex', + fontSize: 'sm', + justifyContent: 'space-between', + paddingTop: '1x', + marginTop: '2x', + }), + { + borderTop: `1px solid ${transparentize( + 0.6, + desaturate(0.5, colors.tearkiss) + )}`, + }, +]) diff --git a/src/components/blog/ArticleFooter.svelte b/src/components/blog/ArticleFooter.svelte new file mode 100644 index 0000000..79b6251 --- /dev/null +++ b/src/components/blog/ArticleFooter.svelte @@ -0,0 +1,34 @@ + + + diff --git a/src/components/blog/article-footer.svelte b/src/components/blog/article-footer.svelte deleted file mode 100644 index 61759af..0000000 --- a/src/components/blog/article-footer.svelte +++ /dev/null @@ -1,61 +0,0 @@ - - - - - diff --git a/src/routes/blog/[slug].svelte b/src/routes/blog/[slug].svelte index f0319d5..deb45e0 100644 --- a/src/routes/blog/[slug].svelte +++ b/src/routes/blog/[slug].svelte @@ -26,7 +26,8 @@ @@ -37,37 +38,7 @@

{post.title}

-
+
{@html post.body}
- - diff --git a/src/routes/blog/blog.css.ts b/src/routes/blog/blog.css.ts new file mode 100644 index 0000000..b2ed3ad --- /dev/null +++ b/src/routes/blog/blog.css.ts @@ -0,0 +1,21 @@ +import { globalStyle, style } from '@vanilla-extract/css' +import { vars } from 'src/styles/vars.css' + +export const contentClass = style({}) + +globalStyle(`${contentClass} ul, ${contentClass} ol`, { + lineHeight: vars.lineHeight['2x'], +}) + +globalStyle(`${contentClass} li`, { + marginBottom: vars.space['2x'], +}) + +globalStyle(`${contentClass} img`, { + maxHeight: vars.height.image, +}) + +globalStyle(`${contentClass} img:only-child`, { + display: 'block', + margin: '0 auto', +}) diff --git a/src/routes/blog/index.css.ts b/src/routes/blog/index.css.ts new file mode 100644 index 0000000..05f8948 --- /dev/null +++ b/src/routes/blog/index.css.ts @@ -0,0 +1,20 @@ +import { globalStyle } from '@vanilla-extract/css' +import { vars } from '../../styles/vars.css' +import { sprinkles } from '../../styles/sprinkles.css' + +export const postListClass = sprinkles({ + padding: 'none', + lineHeight: '3x', + listStyle: 'none', +}) + +export const seeAllClass = sprinkles({ + textAlign: 'end', + width: 'parent', + maxWidth: 'max', + margin: 'auto', +}) + +globalStyle(`${postListClass} > li:not(:last-child)`, { + marginBottom: vars.space['4x'], +}) diff --git a/src/routes/blog/index.json.ts b/src/routes/blog/index.json.ts index b21c0b1..f2595a6 100644 --- a/src/routes/blog/index.json.ts +++ b/src/routes/blog/index.json.ts @@ -1,7 +1,7 @@ import { getBlogListing } from './_content' export async function get({ query }) { - const { tag } = query + const tag = query.get('tag') const filteredContents = await getBlogListing(tag) return { status: 200, diff --git a/src/routes/blog/index.svelte b/src/routes/blog/index.svelte index c53e3e3..dbe9ae9 100644 --- a/src/routes/blog/index.svelte +++ b/src/routes/blog/index.svelte @@ -1,14 +1,10 @@ @@ -34,18 +34,18 @@ {:else}

Recent - {#if query.tag} - {query.tag} + {#if tagQuery} + {tagQuery} {/if} posts

- {#if query.tag} -
- See all posts + {#if tagQuery} + {/if} {/if} -
    +
      {#each posts as post}