feat(ui): add heading component
This commit is contained in:
parent
e858b080a7
commit
c76e15ff2f
25
src/components/ui/Heading.astro
Normal file
25
src/components/ui/Heading.astro
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
---
|
||||||
|
interface Props {
|
||||||
|
level?: 1 | 2 | 3 | 4 | 5 | 6;
|
||||||
|
classes?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
const { level = 2, classes = '', ...rest } = Astro.props as Props;
|
||||||
|
|
||||||
|
const HeadingTag = `h${level}` as `h${1 | 2 | 3 | 4 | 5 | 6}`;
|
||||||
|
|
||||||
|
const headingStyles = {
|
||||||
|
h1: 'text-4xl md:text-5xl lg:text-7xl font-bold',
|
||||||
|
h2: 'text-3xl md:text-4xl lg:text-5xl font-bold',
|
||||||
|
h3: 'text-2xl font-semibold',
|
||||||
|
h4: 'text-xl font-semibold',
|
||||||
|
h5: 'text-lg font-semibold',
|
||||||
|
h6: 'text-base font-semibold',
|
||||||
|
};
|
||||||
|
|
||||||
|
const classList = `${headingStyles[HeadingTag]} ${classes}`;
|
||||||
|
---
|
||||||
|
|
||||||
|
<HeadingTag class={classList.trim()} {...rest}>
|
||||||
|
<slot />
|
||||||
|
</HeadingTag>
|
||||||
1
src/env.d.ts
vendored
1
src/env.d.ts
vendored
@ -1 +1,2 @@
|
|||||||
|
/// <reference path="../.astro/types.d.ts" />
|
||||||
/// <reference types="astro/client" />
|
/// <reference types="astro/client" />
|
||||||
|
|||||||
@ -1,7 +1,10 @@
|
|||||||
---
|
---
|
||||||
import BaseLayout from '@/layouts/BaseLayout.astro';
|
import BaseLayout from '@/layouts/BaseLayout.astro';
|
||||||
|
import Heading from '@/components/ui/Heading.astro';
|
||||||
---
|
---
|
||||||
|
|
||||||
<BaseLayout title="Astro Deploy">
|
<BaseLayout title="Astro Deploy">
|
||||||
<div class="flex items-center justify-center px-4 pt-48 dark:text-white">Hello World</div>
|
<div class="flex items-center justify-center px-4 pt-48 dark:text-white">
|
||||||
|
<Heading level={1} classes="text-zinc-900 dark:text-zinc-200">Hello World</Heading>
|
||||||
|
</div>
|
||||||
</BaseLayout>
|
</BaseLayout>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user