-
Notifications
You must be signed in to change notification settings - Fork 439
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
Showing
6 changed files
with
179 additions
and
8 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
src/components/[guild]/crm/CrmRoleAccessIndicator/CrmRoleAccessIndicator.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,30 @@ | ||
import { PopoverHeader } from "@chakra-ui/react" | ||
import { POPOVER_HEADER_STYLES } from "components/[guild]/Requirements/components/RequiementAccessIndicator" | ||
import { Check, X } from "phosphor-react" | ||
import { CrmRole } from "../useMembers" | ||
import CrmRoleAccessIndicatorUI from "./components/CrmRoleAccessIndicatorUI" | ||
|
||
type Props = { | ||
memberRole: CrmRole | ||
} | ||
|
||
const CrmRoleAccessIndicator = ({ memberRole }: Props) => { | ||
if (!memberRole) | ||
return ( | ||
<CrmRoleAccessIndicatorUI colorScheme={"gray"} icon={X}> | ||
<PopoverHeader {...POPOVER_HEADER_STYLES}>Role not satisfied</PopoverHeader> | ||
</CrmRoleAccessIndicatorUI> | ||
) | ||
|
||
return ( | ||
<CrmRoleAccessIndicatorUI | ||
colorScheme={"green"} | ||
icon={Check} | ||
amount={memberRole.amount} | ||
> | ||
<PopoverHeader {...POPOVER_HEADER_STYLES}>Role satisfied</PopoverHeader> | ||
</CrmRoleAccessIndicatorUI> | ||
) | ||
} | ||
|
||
export default CrmRoleAccessIndicator |
44 changes: 44 additions & 0 deletions
44
src/components/[guild]/crm/CrmRoleAccessIndicator/components/CrmRoleAccessIndicatorUI.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,44 @@ | ||
import { | ||
Center, | ||
Icon, | ||
Popover, | ||
PopoverArrow, | ||
PopoverContent, | ||
PopoverTrigger, | ||
Portal, | ||
Tag, | ||
Text, | ||
} from "@chakra-ui/react" | ||
import { FC, PropsWithChildren } from "react" | ||
|
||
type Props = { | ||
colorScheme: string | ||
icon: FC | ||
amount?: number | ||
} | ||
|
||
const CrmRoleAccessIndicatorUI = ({ | ||
colorScheme, | ||
icon, | ||
amount, | ||
children, | ||
}: PropsWithChildren<Props>) => ( | ||
<Center> | ||
<Popover placement="left" trigger="hover" closeDelay={100}> | ||
<PopoverTrigger> | ||
<Tag colorScheme={colorScheme} px="1.5"> | ||
<Icon as={icon} boxSize={3} /> | ||
{amount && <Text ml={1.5}>{amount.toFixed(2)}</Text>} | ||
</Tag> | ||
</PopoverTrigger> | ||
<Portal> | ||
<PopoverContent width="unset" maxW={{ base: "2xs", md: "xs" }}> | ||
{children} | ||
<PopoverArrow /> | ||
</PopoverContent> | ||
</Portal> | ||
</Popover> | ||
</Center> | ||
) | ||
|
||
export default CrmRoleAccessIndicatorUI |
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,3 @@ | ||
import CrmRoleAccessIndicator from "./CrmRoleAccessIndicator" | ||
|
||
export default CrmRoleAccessIndicator |
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