Skip to content

Commit

Permalink
Add Astro ListItem Component (#2193)
Browse files Browse the repository at this point in the history
  • Loading branch information
smmr-dn authored Sep 6, 2024
1 parent ba4f897 commit 476ccb9
Show file tree
Hide file tree
Showing 2 changed files with 589 additions and 777 deletions.
69 changes: 69 additions & 0 deletions apps/css-workshop/src/components/ListItem.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
---
type Props = {
isActive?: boolean;
size?: string;
disabled?: boolean;
startIconProps?: astroHTML.JSX.HTMLAttributes;
endIconProps?: astroHTML.JSX.HTMLAttributes;
contentProps?: astroHTML.JSX.HTMLAttributes;
actionable?: boolean;
description?: string;
} & astroHTML.JSX.HTMLAttributes;
const {
class: className,
isActive,
size,
disabled,
startIconProps,
endIconProps,
actionable,
contentProps,
description,
...props
} = Astro.props;
---

<li
class:list={[
'iui-list-item',
{ 'iui-active': isActive },
{ 'iui-disabled': disabled },
{ 'iui-large': size === 'large' },
className,
]}
data-iui-actionable={actionable ? 'true' : undefined}
{...props}
>
{
Astro.slots.has('start-icon') && (
<span
class:list={['iui-list-item-icon', startIconProps?.class]}
{...startIconProps}
aria-hidden='true'
>
<slot name='start-icon' />
</span>
)
}
{
Astro.slots.has('default') && (
<span class:list={['iui-list-item-content', contentProps?.class]} {...contentProps}>
<slot />
{description && <div class='iui-list-item-description'>{description}</div>}
</span>
)
}

{
Astro.slots.has('end-icon') && (
<span
class:list={['iui-list-item-icon', endIconProps?.class]}
{...endIconProps}
aria-hidden='true'
>
<slot name='end-icon' />
</span>
)
}
</li>
Loading

0 comments on commit 476ccb9

Please sign in to comment.