-
Notifications
You must be signed in to change notification settings - Fork 336
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: update dashboard nav item styles (#9795)
Co-authored-by: Terry Acker <[email protected]>
- Loading branch information
1 parent
095cf71
commit 71b17c2
Showing
23 changed files
with
637 additions
and
351 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
93 changes: 93 additions & 0 deletions
93
packages/client/components/DashNavList/DashNavListTeams.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 |
---|---|---|
@@ -0,0 +1,93 @@ | ||
import styled from '@emotion/styled' | ||
import graphql from 'babel-plugin-relay/macro' | ||
import React, {useState} from 'react' | ||
import {useFragment} from 'react-relay' | ||
import {DashNavListTeams_organization$key} from '../../__generated__/DashNavListTeams_organization.graphql' | ||
import {PALETTE} from '../../styles/paletteV3' | ||
import plural from '../../utils/plural' | ||
import LeftDashNavItem from '../Dashboard/LeftDashNavItem' | ||
import PublicTeamsModal from './PublicTeamsModal' | ||
|
||
const StyledLeftDashNavItem = styled(LeftDashNavItem)<{isPublicTeams?: boolean}>( | ||
({isPublicTeams}) => ({ | ||
color: isPublicTeams ? PALETTE.SLATE_600 : PALETTE.SLATE_700, | ||
borderRadius: 44, | ||
paddingLeft: 15 | ||
}) | ||
) | ||
|
||
type Props = { | ||
organizationRef: DashNavListTeams_organization$key | ||
onClick?: () => void | ||
} | ||
|
||
const DashNavListTeams = (props: Props) => { | ||
const {organizationRef, onClick} = props | ||
const organization = useFragment( | ||
graphql` | ||
fragment DashNavListTeams_organization on Organization { | ||
id | ||
name | ||
tier | ||
featureFlags { | ||
publicTeams | ||
} | ||
viewerTeams { | ||
...DashNavListTeam @relay(mask: false) | ||
} | ||
publicTeams { | ||
...PublicTeamsModal_team | ||
} | ||
} | ||
`, | ||
organizationRef | ||
) | ||
const [showModal, setShowModal] = useState(false) | ||
const {publicTeams, viewerTeams, featureFlags} = organization | ||
const publicTeamsEnabled = featureFlags?.publicTeams | ||
const publicTeamsCount = publicTeamsEnabled ? publicTeams.length : 0 | ||
|
||
const handleClose = () => { | ||
setShowModal(false) | ||
} | ||
|
||
const handleClick = () => { | ||
setShowModal(true) | ||
onClick && onClick() | ||
} | ||
|
||
const getIcon = (lockedAt: string | null, isPaid: boolean | null) => | ||
lockedAt || !isPaid ? 'warning' : 'group' | ||
|
||
return ( | ||
<div className='p-2'> | ||
{viewerTeams.map((team) => { | ||
return ( | ||
<StyledLeftDashNavItem | ||
key={team.id} | ||
icon={getIcon(team.organization.lockedAt, team.isPaid)} | ||
href={team.isViewerOnTeam ? `/team/${team.id}` : `/team/${team.id}/requestToJoin`} | ||
label={team.name} | ||
onClick={onClick} | ||
/> | ||
) | ||
})} | ||
{publicTeamsCount > 0 && ( | ||
<StyledLeftDashNavItem | ||
className='bg-white pl-11 lg:bg-slate-200' | ||
onClick={handleClick} | ||
isPublicTeams | ||
label={`View ${publicTeamsCount} ${plural(publicTeamsCount, 'Public Team', 'Public Teams')}`} | ||
/> | ||
)} | ||
<PublicTeamsModal | ||
orgName={organization.name} | ||
teamsRef={publicTeams} | ||
isOpen={showModal} | ||
onClose={handleClose} | ||
/> | ||
</div> | ||
) | ||
} | ||
|
||
export default DashNavListTeams |
Oops, something went wrong.