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

copy code example to clipboard #37

Merged
merged 3 commits into from
Oct 16, 2018
Merged

Conversation

dsntzn
Copy link

@dsntzn dsntzn commented Oct 10, 2018

Copy to clipboard button for code example

);
}
}

const StyledCopyButton = styled.button`

Choose a reason for hiding this comment

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

A tento copy button by nemohol byt rovnaky ako code-toggle?

Copy link
Author

Choose a reason for hiding this comment

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

mohol ale bohužiaľ nie sú na rovnakej vetve tak ho nemôžem použiť. Budem to musieť potom prerobiť na ten button. či mám to nejak cherry picknúť a použiť to aj tu? alebo rovno na vetve s buttonom robiť copy button?

Choose a reason for hiding this comment

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

Tak skusme dotlacit tlacidlo, potom to mergneme do tohoto :) Moze byt? Ci by si radsej toto uzatvoril takto a potom neskor to zosuladil.

Copy link
Author

Choose a reason for hiding this comment

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

asi to bude vpohode ak spravíme najprv button a potom mergneme

<StyledCopyButton onClick={e => this.handleCopyCode(e, '#code-block')}>
{this.state.copyButtonText}
</StyledCopyButton>
<CodeBlock id="code-block" language={this.state.codePreviewType}>

Choose a reason for hiding this comment

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

Tu nemoze byt idcko, lebo ak budem mat viac <Preview /> na stranke, idecka budu kolidovat.

Choose a reason for hiding this comment

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

Pozil by som namiesot idecka ref.

Copy link
Author

Choose a reason for hiding this comment

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

ano aj ja by som požil ref ale nejak mi to nechcelo fungovať. skúsim sa na to pozrieť bližšie. možno si lepšie naštudovať ref. 👍

newClass = 'error';
}

button.classList.add(newClass);

Choose a reason for hiding this comment

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

Toto by sa malo v react idelane riesit cez state a zmenu propu toho kompenentu. Nemanipulovat s classname, to by mal byt implementacny detail.

document.execCommand('copy');
// selection.removeAllRanges();
} catch (e) {
newText = 'Error! Press Ctrl + C';

Choose a reason for hiding this comment

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

Paci sa mi takyto handling, ked exec nie je podporovany :)

{
copyButtonText: newText
},
() => {

Choose a reason for hiding this comment

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

Toto je super, takto sa mozes spolahnut ze druhy set state sa urcite zavola po prvom.

Copy link
Author

Choose a reason for hiding this comment

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

Tak tak, aby nenastalo že bude človek klikať a ostane mu tam zlý state

@adammockor
Copy link

Inak pekne naimplementovane!

@dsntzn
Copy link
Author

dsntzn commented Oct 11, 2018

nahodil som verziu kde sa používajú propsy a bohužiaľ som musel použiť ReactDom.findDOMNode kvôli tomu selectovaniu. Inak sa nedalo. ešte som pridal aj error classu pre button nech sa tiež vysvieti na červeno ak je error

@dsntzn
Copy link
Author

dsntzn commented Oct 15, 2018

Videl som že si mergol Button tak som vyriešil konflikty tuto a už je to podľa Buttonu spravené ten copy button.

@adammockor adammockor merged commit d553aa8 into master Oct 16, 2018
@adammockor adammockor deleted the feature/copy-to-clipboard branch November 27, 2018 14:08
adammockor pushed a commit that referenced this pull request Oct 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants