-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fb9ad9f
commit d87fe56
Showing
9 changed files
with
240 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
import { Fragment, useState } from 'react'; | ||
|
||
import { ListItemBase, ListItemAction } from './'; | ||
|
||
const meta = { | ||
title: 'List/ListItemAction', | ||
component: ListItemAction, | ||
tags: ['autodocs'], | ||
parameters: {}, | ||
args: {}, | ||
} satisfies Meta<typeof ListItem>; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof meta>; | ||
|
||
export const Icon: Story = { | ||
args: { | ||
linkIcon: 'chevron-right', | ||
}, | ||
}; | ||
|
||
export const TextAndIcon: Story = { | ||
args: { | ||
linkText: '2 dager siden', | ||
linkIcon: 'chevron-right', | ||
}, | ||
}; | ||
|
||
export const BadgeAndIcon: Story = { | ||
args: { | ||
badge: { | ||
label: 'Admin', | ||
}, | ||
linkIcon: 'chevron-down', | ||
}, | ||
}; | ||
|
||
export const ContextMenu: Story = { | ||
args: { | ||
menu: { | ||
items: [ | ||
{ | ||
label: 'Slett alle', | ||
}, | ||
], | ||
}, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import type { ReactNode } from 'react'; | ||
import { Badge, type BadgeProps } from '../Badge'; | ||
import { ContextMenu, type ContextMenuProps } from '../ContextMenu'; | ||
import { Icon, type IconName } from '../Icon'; | ||
import styles from './listItemAction.module.css'; | ||
|
||
interface ListItemActionProps { | ||
badge?: BadgeProps; | ||
menu?: ContextMenuProps; | ||
linkText?: string; | ||
linkIcon?: IconName; | ||
children?: ReactNode; | ||
} | ||
|
||
export const ListItemAction = ({ linkText, linkIcon, menu, badge, children }: ListItemActionProps) => { | ||
return ( | ||
<div className={styles.action}> | ||
{children ? ( | ||
children | ||
) : ( | ||
<> | ||
{badge && <Badge {...badge} />} | ||
{menu && <ContextMenu {...menu} />} | ||
{linkText && <span className={styles.linkText}>{linkText}</span>} | ||
{linkIcon && <Icon name={linkIcon} className={styles.linkIcon} />} | ||
</> | ||
)} | ||
</div> | ||
); | ||
}; |
Oops, something went wrong.