-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
4599-feat(front): Add Copy Button to Floating Inputs (#4789)
Closes #4599 **Changes:** - Added copy button to floating inputs of Text, Number, Phone, Link and Email fields. --------- Co-authored-by: Félix Malfait <[email protected]> Co-authored-by: Lucas Bordeau <[email protected]> Co-authored-by: Weiko <[email protected]> Co-authored-by: Charles Bochet <[email protected]>
- Loading branch information
1 parent
a53ce1c
commit ce19582
Showing
12 changed files
with
137 additions
and
31 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
...es/twenty-front/src/modules/object-record/record-field/components/LightCopyIconButton.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,37 @@ | ||
import { useTheme } from '@emotion/react'; | ||
import styled from '@emotion/styled'; | ||
import { IconCopy } from 'twenty-ui'; | ||
|
||
import { useSnackBar } from '@/ui/feedback/snack-bar-manager/hooks/useSnackBar'; | ||
import { LightIconButton } from '@/ui/input/button/components/LightIconButton'; | ||
|
||
const StyledButtonContainer = styled.div` | ||
padding: 0 ${({ theme }) => theme.spacing(1)}; | ||
`; | ||
|
||
export type LightCopyIconButtonProps = { | ||
copyText: string; | ||
}; | ||
|
||
export const LightCopyIconButton = ({ copyText }: LightCopyIconButtonProps) => { | ||
const { enqueueSnackBar } = useSnackBar(); | ||
const theme = useTheme(); | ||
|
||
return ( | ||
<StyledButtonContainer> | ||
<LightIconButton | ||
className="copy-button" | ||
Icon={IconCopy} | ||
onClick={() => { | ||
enqueueSnackBar('Text copied to clipboard', { | ||
variant: 'success', | ||
icon: <IconCopy size={theme.icon.size.md} />, | ||
duration: 2000, | ||
}); | ||
navigator.clipboard.writeText(copyText); | ||
}} | ||
aria-label="Copy to Clipboard" | ||
/> | ||
</StyledButtonContainer> | ||
); | ||
}; |
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
5 changes: 3 additions & 2 deletions
5
packages/twenty-front/src/modules/ui/field/input/components/FieldTextAreaOverlay.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
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.