-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* copy all button * fix auto-scroll * styling adjustments * add css hashPrefix * update test snapshots
- Loading branch information
Showing
33 changed files
with
222 additions
and
59 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
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,48 @@ | ||
import React, { useRef, useState } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
|
||
import Button from '../Common/Button'; | ||
import Styles from './CopyAllButton.styles.scss'; | ||
import IconCopy from '../../icons/IconCopy'; | ||
import IconCheckMark from '../../icons/IconCheckMark'; | ||
|
||
const CopyAllButton = ({ text }) => { | ||
const [isCopied, setIsCopied] = useState(false); | ||
const timeoutRef = useRef(null); | ||
|
||
const copy = () => { | ||
navigator.clipboard.writeText(text); | ||
setIsCopied(true); | ||
|
||
if (timeoutRef.current) { | ||
clearTimeout(timeoutRef.current); | ||
} | ||
|
||
timeoutRef.current = setTimeout(() => { | ||
setIsCopied(false); | ||
}, 5000); | ||
}; | ||
|
||
return ( | ||
<Button | ||
className={Styles['copy-button']} | ||
onClick={copy} | ||
variant="text" | ||
> | ||
{isCopied ? | ||
<IconCheckMark className={Styles['copy-icon']} /> : | ||
<IconCopy className={Styles['copy-icon']} />} | ||
<span className={Styles['copy-text']}>{isCopied ? 'Copied!' : 'Copy All'}</span> | ||
</Button> | ||
); | ||
}; | ||
|
||
CopyAllButton.propTypes = { | ||
text: PropTypes.object, | ||
}; | ||
|
||
CopyAllButton.defaultProps = { | ||
text: 'testi testi', | ||
}; | ||
|
||
export default CopyAllButton; |
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,17 @@ | ||
@import "./../../styles/variables"; | ||
|
||
.copy-button { | ||
height: $filter-button-height; | ||
color: $brand-blue; | ||
font-size: $font-size-h6; | ||
|
||
.copy-text { | ||
padding-left: $size-xs; | ||
} | ||
|
||
.copy-icon { | ||
fill: $brand-blue; | ||
height: $size-s; | ||
width: $size-s; | ||
} | ||
} |
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 |
---|---|---|
|
@@ -12,5 +12,6 @@ | |
height: 100%; | ||
width: 100%; | ||
overflow: auto; | ||
overflow-x: hidden; | ||
outline: none; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
|
||
const IconCheckMark = ({ className }) => ( | ||
<svg | ||
className={className} | ||
height="24" | ||
viewBox="0 0 24 24" | ||
width="24" | ||
xmlns="http://www.w3.org/2000/svg" | ||
> | ||
<path | ||
clipRule="evenodd" | ||
d="M23.5789 2.30868C24.0956 2.75821 24.1435 3.53404 23.6857 4.04153L7.48717 22L0.313554 14.0321C-0.143724 13.5242 -0.0951526 12.7485 0.42204 12.2994C0.939233 11.8503 1.7292 11.898 2.18648 12.4059L7.48892 18.2954L21.8143 2.41361C22.2721 1.90612 23.0621 1.85914 23.5789 2.30868Z" | ||
fillRule="evenodd" | ||
/> | ||
</svg> | ||
); | ||
|
||
IconCheckMark.propTypes = { | ||
className: PropTypes.string, | ||
}; | ||
|
||
IconCheckMark.defaultProps = { | ||
className: '', | ||
}; | ||
|
||
export default IconCheckMark; |
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,28 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
|
||
const IconCopy = ({ className }) => ( | ||
<svg | ||
className={className} | ||
height="24" | ||
viewBox="0 0 24 24" | ||
width="24" | ||
xmlns="http://www.w3.org/2000/svg" | ||
> | ||
<path | ||
clipRule="evenodd" | ||
d="M14.5 0C15.3284 0 16 0.671573 16 1.5V4H22C23.1046 4 24 4.89543 24 6V22C24 23.1046 23.1046 24 22 24H10C8.89543 24 8 23.1046 8 22V20H1.5C0.671572 20 0 19.3284 0 18.5V5.34711C0 4.93755 0.167468 4.5458 0.463528 4.2628L4.4882 0.415691C4.76731 0.148892 5.13856 0 5.52467 0H14.5ZM22 6V22H10V11.2H14.9999C15.2652 11.2 15.5195 11.0946 15.707 10.9071C15.8946 10.7195 15.9999 10.4652 15.9999 10.2V6H22ZM13.9999 6H13.7252L10.3775 9.19997H13.9999V6Z" | ||
fillRule="evenodd" | ||
/> | ||
</svg> | ||
); | ||
|
||
IconCopy.propTypes = { | ||
className: PropTypes.string, | ||
}; | ||
|
||
IconCopy.defaultProps = { | ||
className: '', | ||
}; | ||
|
||
export default IconCopy; |
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.