Skip to content

Commit

Permalink
use IconButton component for copy (#52281)
Browse files Browse the repository at this point in the history
  • Loading branch information
hectorsector authored Sep 11, 2024
1 parent b49d31f commit 02473b8
Showing 1 changed file with 10 additions and 18 deletions.
28 changes: 10 additions & 18 deletions src/rest/components/RestCodeSamples.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { useState, useEffect, useRef, FormEvent } from 'react'
import { FormControl, Select, TabNav } from '@primer/react'
import { Tooltip } from '@primer/react/next'
import { FormControl, IconButton, Select, TabNav } from '@primer/react'
import { CheckIcon, CopyIcon } from '@primer/octicons-react'
import { announce } from '@primer/live-region-element'
import Cookies from 'src/frame/components/lib/cookies'
Expand Down Expand Up @@ -282,22 +281,15 @@ export function RestCodeSamples({ operation, slug, heading }: Props) {
</TabNav>
</div>
<div className="mr-2">
<Tooltip
className="mr-2"
direction="w"
text={isCopied ? t('button_text.copied') : t('button_text.copy_to_clipboard')}
>
<button
className="js-btn-copy btn-octicon"
aria-label={`${t('button_text.copy_to_clipboard')} ${selectedLanguage} request example`}
onClick={() => {
setCopied()
announce('Copied!')
}}
>
{isCopied ? <CheckIcon /> : <CopyIcon />}
</button>
</Tooltip>
<IconButton
icon={isCopied ? CheckIcon : CopyIcon}
className="js-btn-copy btn-octicon"
aria-label={`${t('button_text.copy_to_clipboard')} ${selectedLanguage} request example`}
onClick={() => {
setCopied()
announce('Copied!')
}}
></IconButton>
</div>
</div>

Expand Down

0 comments on commit 02473b8

Please sign in to comment.