New position prop to Header

This commit is contained in:
prototypa
2023-01-22 03:30:52 -05:00
parent 068531d355
commit 1ddaf803e9
3 changed files with 25 additions and 4 deletions

View File

@ -27,9 +27,17 @@ export interface Props {
isSticky?: boolean; isSticky?: boolean;
showToggleTheme?: boolean; showToggleTheme?: boolean;
showRssFeed?: boolean; showRssFeed?: boolean;
position?: string;
} }
const { links = [], actions = [], isSticky = false, showToggleTheme = false, showRssFeed = false } = Astro.props; const {
links = [],
actions = [],
isSticky = false,
showToggleTheme = false,
showRssFeed = false,
position = 'center',
} = Astro.props;
--- ---
<header <header
@ -40,7 +48,7 @@ const { links = [], actions = [], isSticky = false, showToggleTheme = false, sho
id="header" id="header"
> >
<div class="py-3 px-3 md:py-3.5 md:px-4 mx-auto w-full md:flex md:justify-between max-w-screen-xl"> <div class="py-3 px-3 md:py-3.5 md:px-4 mx-auto w-full md:flex md:justify-between max-w-screen-xl">
<div class="flex justify-between"> <div class:list={[{"mr-auto": position === "right"}, "flex justify-between"]}>
<a class="flex items-center" href={getHomePermalink()}> <a class="flex items-center" href={getHomePermalink()}>
<Logo /> <Logo />
</a> </a>
@ -50,7 +58,7 @@ const { links = [], actions = [], isSticky = false, showToggleTheme = false, sho
</div> </div>
</div> </div>
<nav <nav
class="items-center w-full md:w-auto hidden md:flex dark:text-slate-200 h-[calc(100vh-72px)] md:h-auto overflow-y-auto md:overflow-visible" class="items-center w-full md:w-auto hidden md:flex dark:text-slate-200 h-[calc(100vh-72px)] md:h-auto overflow-y-auto md:overflow-visible md:mx-5"
aria-label="Main navigation" aria-label="Main navigation"
> >
<ul class="flex flex-col pt-8 md:pt-0 md:flex-row md:self-center w-full md:w-auto text-xl md:text-base"> <ul class="flex flex-col pt-8 md:pt-0 md:flex-row md:self-center w-full md:w-auto text-xl md:text-base">
@ -88,7 +96,7 @@ const { links = [], actions = [], isSticky = false, showToggleTheme = false, sho
} }
</ul> </ul>
</nav> </nav>
<div class="md:self-center flex items-center md:mb-0"> <div class:list={[{ 'ml-auto': position === 'left' }, 'md:self-center flex items-center md:mb-0']}>
<div class="hidden items-center md:flex"> <div class="hidden items-center md:flex">
{showToggleTheme && <ToggleTheme iconClass="w-5 h-5" />} {showToggleTheme && <ToggleTheme iconClass="w-5 h-5" />}

View File

@ -30,6 +30,7 @@ const meta = {
href: '#', href: '#',
}, },
]} ]}
isSticky
/> />
</Fragment> </Fragment>

View File

@ -1,15 +1,27 @@
--- ---
import Layout from '~/layouts/PageLayout.astro'; import Layout from '~/layouts/PageLayout.astro';
import Header from '~/components/widgets/Header.astro';
import Hero from '~/components/widgets/Hero.astro'; import Hero from '~/components/widgets/Hero.astro';
import CallToAction from '~/components/widgets/CallToAction.astro'; import CallToAction from '~/components/widgets/CallToAction.astro';
import { headerData } from '~/data';
const meta = { const meta = {
title: "Startup Landing Page", title: "Startup Landing Page",
}; };
--- ---
<Layout {meta}> <Layout {meta}>
<Fragment slot="header">
<Header
{...headerData}
showRssFeed
showToggleTheme
position="left"
/>
</Fragment>
<!-- Hero2 Widget ******************* --> <!-- Hero2 Widget ******************* -->
<Hero <Hero