-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: remove tasks Label and merge it with lib Chip (#907)
* feat: remove tasks Label and merge it with lib Chip * feat: update folder structure and move components to lib * fix: fix import errors * chore: replace dropdown with select Co-authored-by: Max Schäfer <[email protected]> * chore: go back to boringavatars * fix: fix next config --------- Co-authored-by: Max Schäfer <[email protected]>
- Loading branch information
1 parent
109acfc
commit bb8dd66
Showing
42 changed files
with
249 additions
and
204 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import Image from 'next/image' | ||
import { tx } from '../twind' | ||
|
||
export const avtarSizeList = ['tiny', 'small', 'medium', 'large'] as const | ||
export type AvatarSize = typeof avtarSizeList[number] | ||
export const avtarSizeMapping: Record<AvatarSize, number> = { | ||
tiny: 24, | ||
small: 32, | ||
medium: 48, | ||
large: 64 | ||
} | ||
|
||
export type AvatarProps = { | ||
avatarUrl: string, | ||
alt: string, | ||
size?: AvatarSize, | ||
className?: string | ||
} | ||
|
||
/** | ||
* A component for showing a profile picture | ||
*/ | ||
const Avatar = ({ avatarUrl, alt, size = 'medium', className = '' }: AvatarProps) => { | ||
// TODO remove later | ||
avatarUrl = 'https://source.boringavatars.com/marble/80' | ||
const usedSize = avtarSizeMapping[size] | ||
return ( | ||
// TODO transparent or white background later | ||
<div | ||
className={tx(`rounded-full bg-hw-primary-400 h-[${usedSize}px] w-[${usedSize}px] min-h-[${usedSize}px] min-w-[${usedSize}px]`, className)}> | ||
<Image | ||
className={tx('rounded-full border border-slate-200 group-hover:border-indigo-200 flex justify-evenly items-center', | ||
`h-[${usedSize}px] w-[${usedSize}px] min-h-[${usedSize}px] min-w-[${usedSize}px]` | ||
)} | ||
src={avatarUrl} | ||
alt={alt} | ||
width={usedSize} | ||
height={usedSize} | ||
/> | ||
</div> | ||
) | ||
} | ||
|
||
export { Avatar } |
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,44 @@ | ||
import { tw, tx } from '../twind' | ||
import type { AvatarProps, AvatarSize } from './Avatar' | ||
import { Avatar, avtarSizeMapping } from './Avatar' | ||
import { Span } from './Span' | ||
|
||
export type AvatarGroupProps = { | ||
avatars: Omit<AvatarProps, 'size'>[], | ||
maxShownProfiles?: number, | ||
size?: AvatarSize | ||
} | ||
|
||
/** | ||
* A component for showing a group of Avatar's | ||
*/ | ||
export const AvatarGroup = ({ | ||
avatars, | ||
maxShownProfiles = 5, | ||
size = 'tiny' | ||
}: AvatarGroupProps) => { | ||
const displayedProfiles = avatars.length < maxShownProfiles ? avatars : avatars.slice(0, maxShownProfiles) | ||
const diameter = avtarSizeMapping[size] | ||
const stackingOverlap = 0.5 // given as a percentage | ||
const notDisplayedProfiles = avatars.length - maxShownProfiles | ||
const avatarGroupWidth = diameter * (stackingOverlap * (displayedProfiles.length - 1) + 1) | ||
return ( | ||
<div className={tw(`h-[${diameter}px] flex flex-row relative`)}> | ||
<div className={tw(`w-[${avatarGroupWidth}px]`)}> | ||
{displayedProfiles.map((avatar, index) => ( | ||
<div key={index} className={tx(`absolute left-[${(index * diameter * stackingOverlap)}px] z-[${maxShownProfiles - index}]`)}> | ||
<Avatar avatarUrl={avatar.avatarUrl} alt={avatar.alt} size={size}/> | ||
</div> | ||
))} | ||
</div> | ||
{ | ||
notDisplayedProfiles > 0 && ( | ||
<div | ||
className={tx(`truncate ml-[${1 + diameter / 16}px] flex flex-row items-center text-[${diameter / 2}px]`)}> | ||
<Span>+ {notDisplayedProfiles}</Span> | ||
</div> | ||
) | ||
} | ||
</div> | ||
) | ||
} |
4 changes: 2 additions & 2 deletions
4
tasks/components/BreadCrumb.tsx → lib/components/BreadCrumb.tsx
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
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,21 @@ | ||
import type { Meta, StoryObj } from '@storybook/react' | ||
import { BreadCrumb } from '../../components/BreadCrumb' | ||
|
||
const meta = { | ||
title: 'Other/BreadCrumb', | ||
component: BreadCrumb, | ||
} satisfies Meta<typeof BreadCrumb> | ||
|
||
export default meta | ||
type Story = StoryObj<typeof meta>; | ||
|
||
export const BreadCrumbVariation: Story = { | ||
args: { | ||
crumbs: [ | ||
{ display: 'Organization', link: '' }, | ||
{ display: 'Ward', link: '' }, | ||
{ display: 'Bed', link: '' }, | ||
{ display: 'Patient', link: '' }, | ||
] | ||
}, | ||
} |
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,19 @@ | ||
import type { Meta, StoryObj } from '@storybook/react' | ||
import { Avatar } from '../../../components/Avatar' | ||
|
||
const meta = { | ||
title: 'Other/Avatar', | ||
component: Avatar, | ||
} satisfies Meta<typeof Avatar> | ||
|
||
export default meta | ||
type Story = StoryObj<typeof meta>; | ||
|
||
export const AvatarVariation: Story = { | ||
args: { | ||
alt: 'altText', | ||
avatarUrl: 'https://helpwave.de/favicon.ico', | ||
size: 'small', | ||
className: '' | ||
}, | ||
} |
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,26 @@ | ||
import type { Meta, StoryObj } from '@storybook/react' | ||
import { AvatarGroup } from '../../../components/AvatarGroup' | ||
|
||
const meta = { | ||
title: 'Other/Avatar', | ||
component: AvatarGroup, | ||
} satisfies Meta<typeof AvatarGroup> | ||
|
||
export default meta | ||
type Story = StoryObj<typeof meta>; | ||
|
||
export const AvatarGroupVariation: Story = { | ||
args: { | ||
avatars: [ | ||
{ alt: 'altText', avatarUrl: 'https://helpwave.de/favicon.ico' }, | ||
{ alt: 'altText', avatarUrl: 'https://helpwave.de/favicon.ico' }, | ||
{ alt: 'altText', avatarUrl: 'https://helpwave.de/favicon.ico' }, | ||
{ alt: 'altText', avatarUrl: 'https://helpwave.de/favicon.ico' }, | ||
{ alt: 'altText', avatarUrl: 'https://helpwave.de/favicon.ico' }, | ||
{ alt: 'altText', avatarUrl: 'https://helpwave.de/favicon.ico' }, | ||
{ alt: 'altText', avatarUrl: 'https://helpwave.de/favicon.ico' }, | ||
], | ||
maxShownProfiles: 5, | ||
size: 'tiny' | ||
}, | ||
} |
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 |
---|---|---|
@@ -1,27 +0,0 @@ | ||
import { tw, tx } from '@helpwave/common/twind' | ||
import Image from 'next/image' | ||
|
||
export type AvatarProps = { | ||
avatarUrl: string, | ||
alt: string, | ||
size?: 'tiny' | 'small' | 'medium' | 'large' | ||
} | ||
|
||
/** | ||
* A component for showing a profile picture | ||
*/ | ||
const Avatar = ({ avatarUrl, alt, size = 'medium' }: AvatarProps) => { | ||
avatarUrl = `https://source.boringavatars.com/marble/80/${alt}` | ||
return ( | ||
<div className={tw('rounded-full')}> | ||
<Image className={tx('rounded-full border border-slate-200 group-hover:border-indigo-200 flex justify-evenly items-center', { | ||
'h-6 w-6 min-h-[24px] min-w-[24px]': size === 'tiny', | ||
'h-8 w-8 min-h-[32px] min-w-[32px]': size === 'small', | ||
'h-12 w-12 min-h-[48px] min-w-[48px]': size === 'medium', | ||
'h-16 w-16 min-h-[64px] min-w-[64px]': size === 'large' | ||
})} src={avatarUrl} alt={alt} /> | ||
</div> | ||
) | ||
} | ||
|
||
export { Avatar } | ||
This file was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
Oops, something went wrong.