-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cluster): update creation flow general step (#1349)
- Loading branch information
1 parent
1dcb85b
commit 46fdcaf
Showing
7 changed files
with
239 additions
and
82 deletions.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
...es/clusters/src/lib/ui/page-clusters-create/step-general/copy-button/copy-button.spec.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,10 @@ | ||
import { renderWithProviders } from '@qovery/shared/util-tests' | ||
import CopyButton from './copy-button' | ||
|
||
describe('CopyButton', () => { | ||
test('should render CopyButton component', () => { | ||
const { getByText } = renderWithProviders(<CopyButton content="Hello, world!" />) | ||
const copyButton = getByText('Copy') | ||
expect(copyButton).toBeInTheDocument() | ||
}) | ||
}) |
36 changes: 36 additions & 0 deletions
36
libs/pages/clusters/src/lib/ui/page-clusters-create/step-general/copy-button/copy-button.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,36 @@ | ||
import { type IconName } from '@fortawesome/fontawesome-common-types' | ||
import { useState } from 'react' | ||
import { Button, Icon } from '@qovery/shared/ui' | ||
import { useCopyToClipboard } from '@qovery/shared/util-hooks' | ||
|
||
export interface CopyButtonProps { | ||
content: string | ||
} | ||
|
||
export function CopyButton({ content }: CopyButtonProps) { | ||
const [icon, setIcon] = useState<IconName>('copy') | ||
const [, copyToClipboard] = useCopyToClipboard() | ||
|
||
const onClickCopyToClipboard = (content: string) => { | ||
copyToClipboard(content) | ||
setIcon('check') | ||
setTimeout(() => { | ||
setIcon('copy') | ||
}, 1000) | ||
} | ||
|
||
return ( | ||
<Button | ||
type="button" | ||
color="neutral" | ||
variant="surface" | ||
onClick={() => onClickCopyToClipboard(content)} | ||
className="cursor-pointer font-medium gap-2 font-sans" | ||
> | ||
Copy | ||
<Icon iconName={icon} className="text-xs" /> | ||
</Button> | ||
) | ||
} | ||
|
||
export default CopyButton |
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.