-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9487 from hicommonwealth/kaleemNeslit.9244.copy_w…
…allet_address Kaleem neslit.9244.copy wallet address
- Loading branch information
Showing
5 changed files
with
103 additions
and
3 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
18 changes: 18 additions & 0 deletions
18
...pts/views/components/component_kit/new_designs/CWSingleSelectItem/CWSingleSelectItem.scss
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,18 @@ | ||
@import '../../../../../../styles/shared.scss'; | ||
.CWSingleSelectItem { | ||
display: flex; | ||
width: 97%; | ||
justify-content: space-between; | ||
align-items: center; | ||
padding-right: 4px; | ||
cursor: pointer; | ||
|
||
.inner-container { | ||
display: flex; | ||
|
||
.check-icon { | ||
fill: $green-600; | ||
margin-right: 8px; | ||
} | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
...ipts/views/components/component_kit/new_designs/CWSingleSelectItem/CWSingleSelectItem.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,55 @@ | ||
import { CopySimple } from '@phosphor-icons/react'; | ||
import { formatAddressShort } from 'client/scripts/helpers'; | ||
import React from 'react'; | ||
import { SingleValueProps } from 'react-select'; | ||
import { CWIcon } from '../../cw_icons/cw_icon'; | ||
import './CWSingleSelectItem.scss'; | ||
type CustomSingleValueProps = { | ||
showCopyIcon?: boolean; | ||
// eslint-disable-next-line prettier/prettier | ||
saveToClipboard?: ( | ||
id: string, | ||
successNotification?: boolean, | ||
) => Promise<void>; | ||
}; | ||
|
||
type OptionProps = { | ||
value: string; | ||
label: string; | ||
}; | ||
|
||
export const CWSingleSelectItem = ( | ||
props: SingleValueProps<OptionProps> & CustomSingleValueProps, | ||
) => { | ||
const { data, showCopyIcon = false, saveToClipboard } = props; | ||
|
||
const handleClickToCopy = async (event: React.MouseEvent) => { | ||
event.stopPropagation(); | ||
if (saveToClipboard) { | ||
await saveToClipboard(data.value, true); | ||
} | ||
}; | ||
|
||
return ( | ||
<div className="CWSingleSelectItem"> | ||
{showCopyIcon && ( | ||
<div className="inner-container"> | ||
<CWIcon | ||
className="check-icon" | ||
iconSize="small" | ||
iconName="checkCircleFilled" | ||
/> | ||
{formatAddressShort(data.label, 6)} | ||
</div> | ||
)} | ||
{showCopyIcon && ( | ||
<CopySimple | ||
size={20} | ||
onMouseDown={(event) => { | ||
void handleClickToCopy(event); | ||
}} | ||
/> | ||
)} | ||
</div> | ||
); | ||
}; |
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