-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Initial layout setup * Ypp status widget * Further work on YppDashboardTier.tsx * Configure tiers * Add tooltips * Add close button * Add copy logic * Redirect user on sign up click * Remap routes on studio to go into dashboard only * Add missing assets * Correct payments link * Adjust sync details information to follow BE data * Modify eslint config * Fix linter * Overall fixes * Css fixes * BenefitCard layout rework * Add off sync and tooltips
- Loading branch information
Showing
32 changed files
with
1,041 additions
and
634 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
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,59 @@ | ||
import styled from '@emotion/styled' | ||
import { useRef, useState } from 'react' | ||
|
||
import { Text } from '@/components/Text' | ||
import { Button, ButtonProps } from '@/components/_buttons/Button' | ||
import { Popover, PopoverImperativeHandle } from '@/components/_overlays/Popover' | ||
import { useClipboard } from '@/hooks/useClipboard' | ||
import { cVar, sizes } from '@/styles' | ||
|
||
export type CopyButtonProps = { | ||
textToCopy: string | ||
copySuccessText?: string | ||
className?: string | ||
onClick?: () => void | ||
} & Omit<ButtonProps, 'to' | 'onClick'> | ||
export const CopyButton = ({ | ||
textToCopy, | ||
copySuccessText = 'Copied', | ||
className, | ||
onClick, | ||
...buttonProps | ||
}: CopyButtonProps) => { | ||
const { copyToClipboard } = useClipboard() | ||
const popoverRef = useRef<PopoverImperativeHandle>(null) | ||
const [copyButtonClicked, setCopyButtonClicked] = useState(false) | ||
const handleCopy = () => { | ||
if (!textToCopy || copyButtonClicked) { | ||
return | ||
} | ||
copyToClipboard(textToCopy) | ||
setCopyButtonClicked(true) | ||
onClick?.() | ||
popoverRef.current?.show() | ||
setTimeout(() => { | ||
setCopyButtonClicked(false) | ||
popoverRef.current?.hide() | ||
}, 3_000) | ||
} | ||
|
||
return ( | ||
<span className={className}> | ||
<Popover placement="top" ref={popoverRef} trigger={<div />}> | ||
<PopoverContent> | ||
<Text variant="t100" as="p"> | ||
{copySuccessText} | ||
</Text> | ||
</PopoverContent> | ||
</Popover> | ||
|
||
<Button {...buttonProps} onClick={handleCopy} /> | ||
</span> | ||
) | ||
} | ||
|
||
const PopoverContent = styled.div` | ||
background-color: ${cVar('colorBackgroundElevated')}; | ||
border-radius: ${cVar('radiusSmall')}; | ||
padding: ${sizes(2)}; | ||
` |
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
Oops, something went wrong.