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

@@ -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 Subsubheadline from './Subsubheadline.svelte';
import Subsubheadline from './Subsubheadline.astro';
---
<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>
<a
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'
}`}
>

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 Headline from '../components/Headline.astro';
---
<Layout title="Homepage">
<h1>Homepage</h1>
<Headline>Homepage</Headline>
</Layout>