-
Notifications
You must be signed in to change notification settings - Fork 331
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: update activity library card UI #9168
Merged
Merged
Changes from 11 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
40ce8ff
show title and type below activity card
nickoferrall 9e6b112
make activity library card dynamic
nickoferrall 5bb30a5
add retro background swirls
nickoferrall 8799073
add background images for all meeting types
nickoferrall 040fc96
fix custom card size
nickoferrall a490939
truncate text if there is no space
nickoferrall a324d07
clean up
nickoferrall b5ebf09
use grape 100
nickoferrall dad04a9
add premortem and postmortem imgs
nickoferrall 0d4b81c
remove bg from categories themes
nickoferrall 572679a
move background img to div
nickoferrall c3e957f
Merge branch 'master' into feat/9112/update-activity-library-card
nickoferrall File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
77 changes: 43 additions & 34 deletions
77
packages/client/components/ActivityLibrary/ActivityCard.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,68 +1,77 @@ | ||
import clsx from 'clsx' | ||
import React, {ComponentPropsWithoutRef, PropsWithChildren} from 'react' | ||
import React, {PropsWithChildren} from 'react' | ||
import {upperFirst} from '../../utils/upperFirst' | ||
import {MeetingTypeEnum} from '../../__generated__/NewMeetingQuery.graphql' | ||
import {backgroundImgMap, CategoryID, MEETING_TYPE_TO_CATEGORY} from './Categories' | ||
import {twMerge} from 'tailwind-merge' | ||
|
||
export interface CardTheme { | ||
primary: string | ||
secondary: string | ||
} | ||
|
||
export const ActivityCardImage = ( | ||
props: PropsWithChildren<React.ImgHTMLAttributes<HTMLImageElement>> | ||
) => { | ||
const {className, src} = props | ||
|
||
return ( | ||
<div | ||
className={clsx( | ||
'my-1 flex flex-1 items-center justify-center overflow-hidden px-4', | ||
className | ||
)} | ||
> | ||
<img className={'h-full w-full object-contain'} src={src} /> | ||
</div> | ||
) | ||
type ActivityCardImageProps = { | ||
className?: string | ||
src: string | ||
category: CategoryID | ||
} | ||
|
||
const ActivityCardTitle = (props: ComponentPropsWithoutRef<'div'>) => { | ||
const {children, className, ...rest} = props | ||
export const ActivityCardImage = (props: PropsWithChildren<ActivityCardImageProps>) => { | ||
const {className, src, category} = props | ||
const backgroundSrc = backgroundImgMap[category] | ||
|
||
return ( | ||
<div | ||
className={clsx( | ||
'px-2 py-1 text-sm font-semibold leading-5 text-slate-800 sm:text-base', | ||
className={twMerge( | ||
'relative flex h-full w-full items-center justify-center overflow-hidden', | ||
className | ||
)} | ||
{...rest} | ||
style={{backgroundImage: `url(${backgroundSrc})`, backgroundSize: 'cover'}} | ||
> | ||
{children} | ||
<img | ||
className='absolute top-0 left-0 z-10 h-full w-full object-contain p-10' | ||
src={src} | ||
alt='Card Illustration' | ||
/> | ||
</div> | ||
) | ||
} | ||
|
||
export interface ActivityCardProps { | ||
className?: string | ||
theme: CardTheme | ||
titleAs?: React.ElementType | ||
title?: string | ||
badge?: React.ReactNode | ||
children?: React.ReactNode | ||
type?: MeetingTypeEnum | ||
} | ||
|
||
export const ActivityCard = (props: ActivityCardProps) => { | ||
const {className, theme, title, titleAs, badge, children} = props | ||
const Title = titleAs ?? ActivityCardTitle | ||
const {className, theme, title, children, type, badge} = props | ||
const category = type && MEETING_TYPE_TO_CATEGORY[type] | ||
|
||
return ( | ||
<div className={clsx('flex flex-col overflow-hidden rounded-lg', theme.secondary, className)}> | ||
<div className='flex flex-shrink-0'> | ||
<Title>{title}</Title> | ||
<div className={clsx('ml-auto h-8 w-8 flex-shrink-0 rounded-bl-full', theme.primary)} /> | ||
</div> | ||
{children} | ||
<div className='flex flex-shrink-0 group-hover/card:hidden'> | ||
<div className={clsx('mt-auto h-8 w-8 flex-shrink-0 rounded-tr-full', theme.primary)} /> | ||
<div className='ml-auto'>{badge}</div> | ||
<div className='flex w-full flex-col'> | ||
<div | ||
className={twMerge( | ||
'relative flex h-full min-w-0 flex-col overflow-hidden rounded-lg', | ||
`bg-${theme.secondary}`, | ||
className | ||
)} | ||
> | ||
<div className='flex-1'> | ||
{children} | ||
<div className='absolute bottom-0 right-0'>{badge}</div> | ||
</div> | ||
</div> | ||
{title && category && ( | ||
<div className='mt-2 px-2 pb-2'> | ||
<div className='truncate pb-1 text-lg leading-5 text-slate-800'>{title}</div> | ||
<div className={clsx('font-semibold italic', `text-${theme.primary}`)}> | ||
{upperFirst(category)} | ||
</div> | ||
</div> | ||
)} | ||
</div> | ||
) | ||
} |
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
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 I think the images would be more versatile if these wouldn't have rounded corners