-
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: switch template UI #9093
Merged
Merged
feat: switch template UI #9093
Changes from 19 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
a68fe98
create menu and menu item
nickoferrall a06fbfc
add menu item icon
nickoferrall 80e8b31
add retro drawer
nickoferrall 3b10b2d
implement RetroDrawerTemplateCard and get templates showing up
nickoferrall 4438b6f
filter templates on server by meeting type
nickoferrall 41e2c3b
fix mobile
nickoferrall c4bc28f
only show options in reflect phase
nickoferrall e148e2c
move meeting options to retroDrawer
nickoferrall 18b2458
add tooltip for disabled options menu item
nickoferrall 237b96c
handle mouse enter and leave
nickoferrall 7d093d9
reduce menu item padding
nickoferrall e2c44b5
clean up
nickoferrall f9b0b51
add twMerge to menu and menu item
nickoferrall 18d88bc
remove icon prop
nickoferrall 011b618
add radix tooltip
nickoferrall db1abe1
Merge branch 'master' into feat/9087/switch-template-ui
nickoferrall fa0d1ee
dont show options btn in demo
nickoferrall 7f50a58
clean up
nickoferrall 6f71f35
close drawer once reflections have been added
nickoferrall fcab9ce
update tooltip copy
nickoferrall b527743
Merge branch 'master' into feat/9087/switch-template-ui
nickoferrall f163370
add category to ActivityCardImage prop
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
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,62 @@ | ||
import React, {useState} from 'react' | ||
import IconLabel from './IconLabel' | ||
import {Menu} from '../ui/Menu/Menu' | ||
import {MenuItem} from '../ui/Menu/MenuItem' | ||
import SwapHorizIcon from '@mui/icons-material/SwapHoriz' | ||
import {OptionsButton} from './TeamPrompt/TeamPromptOptions' | ||
import {Tooltip} from '../ui/Tooltip/Tooltip' | ||
import {TooltipTrigger} from '../ui/Tooltip/TooltipTrigger' | ||
import {TooltipContent} from '../ui/Tooltip/TooltipContent' | ||
|
||
type Props = { | ||
setShowDrawer: (showDrawer: boolean) => void | ||
showDrawer: boolean | ||
hasReflections: boolean | ||
} | ||
|
||
const MeetingOptions = (props: Props) => { | ||
const {setShowDrawer, showDrawer, hasReflections} = props | ||
const [isOpen, setIsOpen] = useState(false) | ||
|
||
const handleClick = () => { | ||
if (hasReflections) return | ||
setShowDrawer(!showDrawer) | ||
} | ||
|
||
const handleMouseEnter = () => { | ||
if (hasReflections) { | ||
setIsOpen(true) | ||
} | ||
} | ||
|
||
const handleMouseLeave = () => { | ||
setIsOpen(false) | ||
} | ||
|
||
return ( | ||
<Menu | ||
trigger={ | ||
<OptionsButton> | ||
<IconLabel icon='tune' iconLarge /> | ||
<div className='text-slate-700'>Options</div> | ||
</OptionsButton> | ||
} | ||
> | ||
<Tooltip open={isOpen}> | ||
<div onMouseEnter={handleMouseEnter} onMouseLeave={handleMouseLeave}> | ||
<TooltipTrigger asChild> | ||
<MenuItem onClick={handleClick} isDisabled={hasReflections}> | ||
<div className='mr-3 flex text-slate-700'>{<SwapHorizIcon />}</div> | ||
Change template | ||
</MenuItem> | ||
</TooltipTrigger> | ||
</div> | ||
<TooltipContent> | ||
{'You can only change the template before reflections have been added.'} | ||
</TooltipContent> | ||
</Tooltip> | ||
</Menu> | ||
) | ||
} | ||
|
||
export default MeetingOptions |
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,108 @@ | ||
import {Close} from '@mui/icons-material' | ||
import graphql from 'babel-plugin-relay/macro' | ||
import React, {useEffect} from 'react' | ||
import {PreloadedQuery, usePreloadedQuery} from 'react-relay' | ||
import {Breakpoint, DiscussionThreadEnum} from '../types/constEnums' | ||
import ResponsiveDashSidebar from './ResponsiveDashSidebar' | ||
import MeetingOptions from './MeetingOptions' | ||
import RetroDrawerTemplateCard from './RetroDrawerTemplateCard' | ||
import {Drawer} from './TeamPrompt/TeamPromptDrawer' | ||
import {RetroDrawerQuery} from '../__generated__/RetroDrawerQuery.graphql' | ||
import useBreakpoint from '../hooks/useBreakpoint' | ||
|
||
interface Props { | ||
setShowDrawer: (showDrawer: boolean) => void | ||
showDrawer: boolean | ||
queryRef: PreloadedQuery<RetroDrawerQuery> | ||
} | ||
|
||
const RetroDrawer = (props: Props) => { | ||
const {queryRef, showDrawer, setShowDrawer} = props | ||
const {viewer} = usePreloadedQuery<RetroDrawerQuery>( | ||
graphql` | ||
query RetroDrawerQuery($first: Int!, $type: MeetingTypeEnum!, $meetingId: ID!) { | ||
viewer { | ||
meeting(meetingId: $meetingId) { | ||
... on RetrospectiveMeeting { | ||
reflectionGroups { | ||
id | ||
} | ||
localPhase { | ||
... on ReflectPhase { | ||
phaseType | ||
} | ||
} | ||
} | ||
} | ||
availableTemplates(first: $first, type: $type) | ||
@connection(key: "RetroDrawer_availableTemplates") { | ||
edges { | ||
node { | ||
...RetroDrawerTemplateCard_template | ||
id | ||
} | ||
} | ||
} | ||
} | ||
} | ||
`, | ||
queryRef | ||
) | ||
|
||
const templates = viewer.availableTemplates.edges | ||
const meeting = viewer.meeting | ||
const hasReflections = !!(meeting?.reflectionGroups && meeting.reflectionGroups.length > 0) | ||
const phaseType = meeting?.localPhase?.phaseType | ||
const isMobile = !useBreakpoint(Breakpoint.FUZZY_TABLET) | ||
const isDesktop = useBreakpoint(Breakpoint.SIDEBAR_LEFT) | ||
|
||
const toggleDrawer = () => { | ||
setShowDrawer(!showDrawer) | ||
} | ||
|
||
useEffect(() => { | ||
if (hasReflections && showDrawer) { | ||
setShowDrawer(false) | ||
} | ||
}, [hasReflections]) | ||
|
||
if (!phaseType || phaseType !== 'reflect') return null | ||
return ( | ||
<> | ||
<MeetingOptions | ||
hasReflections={hasReflections} | ||
showDrawer={showDrawer} | ||
setShowDrawer={setShowDrawer} | ||
/> | ||
<ResponsiveDashSidebar | ||
isOpen={showDrawer} | ||
isRightDrawer | ||
onToggle={toggleDrawer} | ||
sidebarWidth={DiscussionThreadEnum.WIDTH} | ||
> | ||
<Drawer | ||
className='overflow-scroll' | ||
isDesktop={isDesktop} | ||
isMobile={isMobile} | ||
isOpen={showDrawer} | ||
> | ||
<div className='py-4'> | ||
<div className='flex justify-between px-4'> | ||
<div className='pb-4 text-base font-semibold'>Templates</div> | ||
<div | ||
className='cursor-pointer text-slate-600 hover:opacity-50' | ||
onClick={toggleDrawer} | ||
> | ||
<Close /> | ||
</div> | ||
</div> | ||
{templates.map((template) => ( | ||
<RetroDrawerTemplateCard key={template.node.id} templateRef={template.node} /> | ||
))} | ||
</div> | ||
</Drawer> | ||
</ResponsiveDashSidebar> | ||
</> | ||
) | ||
} | ||
export default RetroDrawer |
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,28 @@ | ||
import React, {Suspense} from 'react' | ||
import useQueryLoaderNow from '../hooks/useQueryLoaderNow' | ||
import retroDrawerQuery, {RetroDrawerQuery} from '../__generated__/RetroDrawerQuery.graphql' | ||
import RetroDrawer from './RetroDrawer' | ||
|
||
type Props = { | ||
showDrawer: boolean | ||
setShowDrawer: (showDrawer: boolean) => void | ||
meetingId: string | ||
} | ||
|
||
const RetroDrawerRoot = (props: Props) => { | ||
const {showDrawer, setShowDrawer, meetingId} = props | ||
const queryRef = useQueryLoaderNow<RetroDrawerQuery>(retroDrawerQuery, { | ||
first: 200, | ||
type: 'retrospective', | ||
meetingId | ||
}) | ||
return ( | ||
<Suspense fallback={''}> | ||
{queryRef && ( | ||
<RetroDrawer showDrawer={showDrawer} setShowDrawer={setShowDrawer} queryRef={queryRef} /> | ||
)} | ||
</Suspense> | ||
) | ||
} | ||
|
||
export default RetroDrawerRoot |
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,51 @@ | ||
import {ActivityBadge} from './ActivityLibrary/ActivityBadge' | ||
import {ActivityLibraryCardDescription} from './ActivityLibrary/ActivityLibraryCardDescription' | ||
import graphql from 'babel-plugin-relay/macro' | ||
import React from 'react' | ||
import {useFragment} from 'react-relay' | ||
import {ActivityLibraryCard} from './ActivityLibrary/ActivityLibraryCard' | ||
import {ActivityCardImage} from './ActivityLibrary/ActivityCard' | ||
import {RetroDrawerTemplateCard_template$key} from '~/__generated__/RetroDrawerTemplateCard_template.graphql' | ||
import {CategoryID, CATEGORY_THEMES} from '././ActivityLibrary/Categories' | ||
|
||
interface Props { | ||
templateRef: RetroDrawerTemplateCard_template$key | ||
} | ||
|
||
const RetroDrawerTemplateCard = (props: Props) => { | ||
const {templateRef} = props | ||
const template = useFragment( | ||
graphql` | ||
fragment RetroDrawerTemplateCard_template on MeetingTemplate { | ||
...ActivityLibraryCardDescription_template | ||
name | ||
category | ||
illustrationUrl | ||
isFree | ||
} | ||
`, | ||
templateRef | ||
) | ||
|
||
return ( | ||
<div className='px-4 py-2'> | ||
<ActivityLibraryCard | ||
className='group aspect-[256/160] flex-1 hover:cursor-pointer' | ||
theme={CATEGORY_THEMES[template.category as CategoryID]} | ||
title={template.name} | ||
badge={ | ||
!template.isFree ? ( | ||
<ActivityBadge className='m-2 bg-gold-300 text-grape-700'>Premium</ActivityBadge> | ||
) : null | ||
} | ||
> | ||
<ActivityCardImage className='group-hover/card:hidden' src={template.illustrationUrl} /> | ||
<ActivityLibraryCardDescription | ||
className='hidden group-hover/card:flex' | ||
templateRef={template} | ||
/> | ||
</ActivityLibraryCard> | ||
</div> | ||
) | ||
} | ||
export default RetroDrawerTemplateCard |
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,29 @@ | ||
import * as DropdownMenu from '@radix-ui/react-dropdown-menu' | ||
import React from 'react' | ||
import {twMerge} from 'tailwind-merge' | ||
|
||
interface MenuProps { | ||
trigger: React.ReactNode | ||
className?: string | ||
children: React.ReactNode | ||
} | ||
|
||
export const Menu = React.forwardRef<HTMLDivElement, MenuProps>( | ||
({trigger, className, children}, ref) => { | ||
const contentClass = twMerge( | ||
'border-rad w-auto min-w-[200px] max-w-[400px] rounded-md bg-white shadow-lg outline-none', | ||
className | ||
) | ||
nickoferrall marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
return ( | ||
<DropdownMenu.Root> | ||
<DropdownMenu.Trigger asChild>{trigger}</DropdownMenu.Trigger> | ||
<DropdownMenu.Portal> | ||
<DropdownMenu.Content align='end' className={contentClass} sideOffset={10} ref={ref}> | ||
{children} | ||
</DropdownMenu.Content> | ||
</DropdownMenu.Portal> | ||
</DropdownMenu.Root> | ||
) | ||
} | ||
) |
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 * as DropdownMenu from '@radix-ui/react-dropdown-menu' | ||
import React from 'react' | ||
import {twMerge} from 'tailwind-merge' | ||
|
||
interface MenuItemProps { | ||
onClick: (event: Event) => void | ||
isDisabled?: boolean | ||
className?: string | ||
children: React.ReactNode | ||
} | ||
|
||
export const MenuItem = React.forwardRef<HTMLDivElement, MenuItemProps>( | ||
({onClick, isDisabled, className, children}, ref) => { | ||
const itemClass = twMerge( | ||
'flex w-full items-center rounded-md px-4 py-3 text-sm text-slate-700 outline-none hover:bg-slate-100 focus:bg-slate-100', | ||
isDisabled ? 'cursor-not-allowed opacity-50' : 'cursor-pointer', | ||
className | ||
) | ||
|
||
return ( | ||
<DropdownMenu.Item className={itemClass} onSelect={onClick} ref={ref}> | ||
{children} | ||
</DropdownMenu.Item> | ||
) | ||
} | ||
) |
Oops, something went wrong.
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 would rephrase this slightly to "You can only change the template if no reflections have been added." because it also works if you remove them again.