refactor: move Svelte components to Astro

This commit is contained in:
Stefan Imhoff
2023-02-27 17:28:09 +01:00
parent 6c15bb55cf
commit c3998b9239
13 changed files with 89 additions and 52 deletions

View File

@@ -1,8 +1,6 @@
Backlink
Imhoff
Secuela
astro astro
astrojs astrojs
Backlink
bezier bezier
bitstream bitstream
clickarea clickarea
@@ -10,6 +8,7 @@ crossorigin
cssnano cssnano
evenodd evenodd
favicons favicons
Imhoff
linejoin linejoin
lucida lucida
menlo menlo
@@ -21,7 +20,13 @@ noreferrer
onclick onclick
rgba rgba
secuela secuela
Secuela
shibui shibui
sketchnotes
Sketchnotes
stefanimhoff stefanimhoff
subnavigation
Subnavigation
Subsubheadline
tailwindcss tailwindcss
typeof typeof

View File

@@ -0,0 +1,20 @@
---
interface Props {
as?: string;
children?: any;
class?: string;
}
const { as = 'h2', class: className, ...props } = Astro.props;
const Element = as;
---
<Element
class:list={[
'text-5 font-black tracking-tight mbe-10 mbs-16 first-of-type:mbs-0 dark:font-extrabold',
className,
]}
{...props}
>
<slot />
</Element>

View File

@@ -1,12 +0,0 @@
<script lang="ts">
export let as = 'h2';
</script>
<svelte:element
this={as}
class={`text-5 font-black tracking-tight mbe-10 mbs-16 first-of-type:mbs-0 dark:font-extrabold ${
$$props.class || ''
}`}
>
<slot />
</svelte:element>

View File

@@ -1,10 +0,0 @@
<script lang="ts">
export let as = 'h1';
</script>
<svelte:element
this={as}
class={`text-7 font-black tracking-tight mbe-13 dark:font-extrabold ${$$props.class || ''}`}
>
<slot />
</svelte:element>

View File

@@ -1,7 +1,7 @@
--- ---
import { Sprite } from 'astro-icon'; import { Sprite } from 'astro-icon';
import Subsubheadline from './Subsubheadline.svelte'; import Subsubheadline from './Subsubheadline.astro';
--- ---
<div class="grow mbe-5 sm:mbe-0"> <div class="grow mbe-5 sm:mbe-0">

View File

@@ -0,0 +1,20 @@
---
interface Props {
as?: string;
children?: any;
class?: string;
}
const { as = 'h3', class: className, ...props } = Astro.props;
const Element = as;
---
<Element
class:list={[
'text-4 font-black tracking-tight mbe-8 mbs-14 first-of-type:mbs-0 dark:font-extrabold',
className,
]}
{...props}
>
<slot />
</Element>

View File

@@ -1,12 +0,0 @@
<script lang="ts">
export let as = 'h3';
</script>
<svelte:element
this={as}
class={`text-4 font-black tracking-tight mbe-8 mbs-14 first-of-type:mbs-0 dark:font-extrabold ${
$$props.class || ''
}`}
>
<slot />
</svelte:element>

View File

@@ -27,7 +27,7 @@ const currentPath = new URL(Astro.request.url).pathname;
<li> <li>
<a <a
href={url} href={url}
class={`text-3 font-light decoration-4 underline-offset-auto hover:underline hover:decoration-shibui-900/20 dark:hover:decoration-shibui-100/20 ${ class={`font-light decoration-4 underline-offset-auto hover:underline hover:decoration-shibui-900/20 dark:hover:decoration-shibui-100/20 ${
currentPath === url && 'underline !decoration-accent decoration-4' currentPath === url && 'underline !decoration-accent decoration-4'
}`} }`}
> >

View File

@@ -0,0 +1,20 @@
---
interface Props {
as?: string;
children?: any;
class?: string;
}
const { as = 'h4', class: className, ...props } = Astro.props;
const Element = as;
---
<Element
class:list={[
'text-3 font-black tracking-tight mbe-5 mbs-14 first-of-type:mbs-0 dark:font-extrabold',
className,
]}
{...props}
>
<slot />
</Element>

View File

@@ -1,12 +0,0 @@
<script lang="ts">
export let as = 'h4';
</script>
<svelte:element
this={as}
class={`text-3 font-black tracking-tight mbe-5 mbs-14 first-of-type:mbs-0 dark:font-extrabold ${
$$props.class || ''
}`}
>
<slot />
</svelte:element>

View File

@@ -0,0 +1,17 @@
---
interface Props {
as?: string;
children?: any;
class?: string;
}
const { as = 'h1', class: className, ...props } = Astro.props;
const Element = as;
---
<Element
class:list={['text-7 font-black tracking-tight mbe-13 dark:font-extrabold', className]}
{...props}
>
<slot />
</Element>

View File

@@ -1,7 +1,8 @@
--- ---
import Layout from '../layouts/Layout.astro'; import Layout from '../layouts/Layout.astro';
import Headline from '../components/Headline.astro';
--- ---
<Layout title="Homepage"> <Layout title="Homepage">
<h1>Homepage</h1> <Headline>Homepage</Headline>
</Layout> </Layout>