-
Notifications
You must be signed in to change notification settings - Fork 9
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
7 changed files
with
432 additions
and
253 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/*** UNDER NO CIRCUMSTANCES DO NOT EDIT THIS FILE. THIS FILE IS COPIED ***/ | ||
/*** FROM OSS UI. ANY CHANGES TO BE MADE IN KUBEVIOUS OSS UI. ***/ | ||
/*** SOURCE: ../ui/src/src/components/CopyClipboard/index.js ***/ | ||
|
||
import React, { useState } from 'react'; | ||
import { faClone as farClone } from '@fortawesome/free-regular-svg-icons'; | ||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; | ||
|
||
import './styles.scss' | ||
|
||
const CopyClipboard = ({ text }) => { | ||
const [copied, setCopied] = useState(false) | ||
|
||
const copyText = () => { | ||
const textField = document.createElement('textarea') | ||
textField.value = text | ||
document.body.appendChild(textField) | ||
textField.select() | ||
document.execCommand('copy') | ||
setCopied(true) | ||
textField.remove() | ||
|
||
setTimeout(() => { | ||
setCopied(false) | ||
}, 3000) | ||
} | ||
|
||
return ( | ||
<div className="icon-wrapper"> | ||
{copied && <div className="copied-container"> | ||
Copied to clipboard | ||
<div className="caret" /> | ||
</div>} | ||
|
||
<FontAwesomeIcon className="copy-icon" icon={farClone} onClick={() => copyText()} | ||
title="Copy to clipboard" /> | ||
</div> | ||
) | ||
} | ||
|
||
export default CopyClipboard |
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 @@ | ||
/*** UNDER NO CIRCUMSTANCES DO NOT EDIT THIS FILE. THIS FILE IS COPIED ***/ | ||
/*** FROM OSS UI. ANY CHANGES TO BE MADE IN KUBEVIOUS OSS UI. ***/ | ||
/*** SOURCE: ../ui/src/src/components/CopyClipboard/styles.scss ***/ | ||
|
||
.icon-wrapper { | ||
margin-left: 10px; | ||
color: #999999; | ||
position: relative; | ||
|
||
.copy-icon { | ||
color: #999999; | ||
position: absolute; | ||
font-size: 16px; | ||
z-index: 10; | ||
|
||
&:hover { | ||
color: white; | ||
cursor: pointer; | ||
} | ||
} | ||
|
||
.copied-container { | ||
position: absolute; | ||
top: -35px; | ||
left: -70px; | ||
width: 160px; | ||
display: flex; | ||
justify-content: center; | ||
background: #4ECD77; | ||
border-radius: 3px; | ||
color: white; | ||
z-index: 1001; | ||
font-size: 14px; | ||
|
||
.caret { | ||
width: 10px; | ||
height: 10px; | ||
position: absolute; | ||
background: #4ECD77; | ||
bottom: -5px; | ||
transform: rotate(45deg); | ||
} | ||
} | ||
} |
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