generated from gravity-ui/package-example
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add copy button for view layouts (#59)
- Loading branch information
1 parent
8f7c4c6
commit c31fcbf
Showing
19 changed files
with
117 additions
and
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
@import '../../styles/variables.scss'; | ||
|
||
.#{$ns}copy-button { | ||
display: none; | ||
margin: 2px 0 0 5px; | ||
} |
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 {ClipboardButton} from '@gravity-ui/uikit'; | ||
|
||
import {FormValue, Spec, isNumberSpec, isStringSpec} from '../../../core'; | ||
import {block} from '../../utils'; | ||
|
||
import './CopyButton.scss'; | ||
|
||
const b = block('copy-button'); | ||
|
||
export interface CopyButtonProps { | ||
spec: Spec; | ||
value: FormValue; | ||
} | ||
|
||
/** | ||
* | ||
* Use the with-copy-button scss mixin for visible on hover | ||
*/ | ||
|
||
export const CopyButton: React.FC<CopyButtonProps> = ({spec, value}) => { | ||
if ((isStringSpec(spec) || isNumberSpec(spec)) && spec.viewSpec.copy) { | ||
return <ClipboardButton className={b()} text={`${value}`} size={14} />; | ||
} | ||
|
||
return null; | ||
}; |
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 @@ | ||
export * from './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
25 changes: 16 additions & 9 deletions
25
src/lib/kit/components/ViewLayouts/ViewTableCell/ViewTableCell.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 |
---|---|---|
@@ -1,19 +1,26 @@ | ||
@import '../../../styles/variables.scss'; | ||
@import '../../../styles/mixins.scss'; | ||
|
||
.#{$ns}view-table-cell { | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
|
||
& > .#{$ns}view-row:last-child { | ||
margin-bottom: 0; | ||
} | ||
|
||
& > .#{$ns}view-transparent { | ||
margin-bottom: 6px; | ||
&__inner { | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
|
||
&:last-child { | ||
& > .#{$ns}view-row:last-child { | ||
margin-bottom: 0; | ||
} | ||
|
||
& > .#{$ns}view-transparent { | ||
margin-bottom: 6px; | ||
|
||
&:last-child { | ||
margin-bottom: 0; | ||
} | ||
} | ||
} | ||
|
||
@include with-copy-button(); | ||
} |
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
4 changes: 4 additions & 0 deletions
4
src/lib/kit/components/ViewLayouts/ViewTransparent/ViewTransparent.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 |
---|---|---|
@@ -1,9 +1,13 @@ | ||
@import '../../../styles/variables.scss'; | ||
@import '../../../styles/mixins.scss'; | ||
|
||
.#{$ns}view-transparent { | ||
display: flex; | ||
margin-bottom: 20px; | ||
|
||
&:last-child { | ||
margin-bottom: 0; | ||
} | ||
|
||
@include with-copy-button(); | ||
} |
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,7 @@ | ||
@import './variables.scss'; | ||
|
||
@mixin with-copy-button() { | ||
&:hover > .#{$ns}copy-button { | ||
display: block; | ||
} | ||
} |
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