Create sidebar component (#32)

This commit is contained in:
Rafał Pryma 2022-10-10 18:39:46 +02:00 committed by GitHub
parent 5b4ca5eb8a
commit a713bb5400
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 41 additions and 1 deletions

View file

@ -0,0 +1,24 @@
---
import type { Icon as IconName } from '@/types/icon';
import Icon from './icon';
export interface Props extends astroHTML.JSX.ButtonHTMLAttributes {
icon: IconName;
active?: boolean;
}
const { props } = Astro;
---
<button
type="button"
class:list={[
`inline-flex justify-center items-center h-10 w-10 rounded-lg transition hover:bg-primary-600`,
props.active && 'bg-primary-600',
props.class,
]}
>
<Icon client:load name={props.icon} size={20} color={props.active ? 'white' : 'gray'} />
<slot />
</button>

View file

@ -4,4 +4,6 @@ export interface Props extends astroHTML.JSX.HTMLAttributes {}
const { props } = Astro; const { props } = Astro;
--- ---
<nav class:list={['w-14 min-w-[56px] h-72 rounded-lg bg-white shadow-md', props.class]}></nav> <nav class:list={['flex flex-col w-max p-2 rounded-lg gap-2 bg-white shadow-md', props.class]}>
<slot />
</nav>

View file

@ -0,0 +1,5 @@
---
import SidebarItem from '@/atoms/sidebar-item.astro';
---
<SidebarItem icon="fa6-brands:accusoft" />

View file

@ -0,0 +1,9 @@
---
import SidebarItem from '@/atoms/sidebar-item.astro';
import Sidebar from '@/organisms/sidebar.astro';
---
<Sidebar>
<SidebarItem icon="fa6-brands:accusoft" />
<SidebarItem icon="fa6-brands:accusoft" active={true} />
</Sidebar>