Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement copy button #880

Merged
merged 9 commits into from
Apr 10, 2021
Merged

Implement copy button #880

merged 9 commits into from
Apr 10, 2021

Conversation

aushaag
Copy link
Contributor

@aushaag aushaag commented Apr 9, 2021

Create new copy button in the symbol output (disabled by default). When users click the copy button, copy the labels of the selected symbols to the clipboard:

image

Disable CopyButton by default, and give users the option to enable it in Settings/Navigation/ShowCopyButton:

image

aushaag added 6 commits April 9, 2021 16:43
…of the translations

Since there are button settings in the "Navigation" section of buttons, it seems clearer to rename "Navigation" in the settings list to "Navigation and Buttons". There are many languages I have not added this to yet, but I can complete the translations soon.
Add new setting for showing/hiding the copy button in the output. Also add dividers between options to match other settings.
Implement copy button functionality. When copy button is clicked, output labels of currently selected symbols to clipboard
Create CopyButton component that follows BackspaceButton as template.
Add CopyButton to SymbolOutput to the left of backspace and clear. CopyButton is only displayed when enabled in navigationSettings (copyShowActive). CopyButton is also only displayed when at least one symbol has been selected (symbols.length > 0).
Add text to display for the setting that enables/disables showing the CopyButton. Note: these messages need translations!
Copy link
Collaborator

@martinbedouret martinbedouret left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aushaag Terrific job!! Congrats!
My only comment is that you don't need to worry about the translation files. You only need to add any new string to be translated into the cboard\src\translations\src\cboard.json file. before the production release, an automation script will take care of the translations.

src/components/Board/Output/Output.container.js Outdated Show resolved Hide resolved
@martinbedouret martinbedouret added this to the 1.10.0 milestone Apr 9, 2021
aushaag added 3 commits April 10, 2021 00:41
Curly brackets are unnecessary
These are the descriptions next to the toggle to enable/disable the copy button in the output panel
I believe this will be overridden by the translation script anyway, but I realized there was a typo and "Display" should be "Navigation".
@martinbedouret martinbedouret linked an issue Apr 10, 2021 that may be closed by this pull request
@martinbedouret martinbedouret merged commit fbafc49 into cboard-org:master Apr 10, 2021
Copy link
Collaborator

@sylvansson sylvansson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the great first contribution @aushaag :-)

@@ -179,6 +181,14 @@ export class OutputContainer extends Component {
this.clearOutput();
};

handleCopyClick = () => {
const { intl, showNotification } = this.props;
let labels = [];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this was merged already, but I have a very small comment.

It would be simpler to assign the value when declaring the variable, and it's usually preferable to use forEach over map when we don't care about the function's return value.

const labels = this.props.output.map(symbol => symbol.label);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense. Just submitted a request for this update, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make current phrase shareable
3 participants