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

feat: Add copy to clipboard component #380

Merged
merged 1 commit into from
Jan 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pynecone/.templates/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"plotly.js": "2.6.4",
"prettier": "^2.8.1",
"react": "^17.0.2",
"react-copy-to-clipboard": "^5.1.0",
"react-dom": "^17.0.2",
"react-markdown": "^8.0.3",
"react-plotly.js": "^2.6.0",
Expand Down
1 change: 1 addition & 0 deletions pynecone/components/forms/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from .button import Button, ButtonGroup
from .checkbox import Checkbox, CheckboxGroup
from .copytoclipboard import CopyToClipboard
from .editable import Editable, EditableInput, EditablePreview, EditableTextarea
from .formcontrol import FormControl, FormErrorMessage, FormHelperText, FormLabel
from .iconbutton import IconButton
Expand Down
26 changes: 26 additions & 0 deletions pynecone/components/forms/copytoclipboard.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
"""A copy to clipboard component."""

from typing import Set

from pynecone.components import Component
from pynecone.var import Var


class CopyToClipboard(Component):
"""Component to copy text to clipboard."""

library = "react-copy-to-clipboard"

tag = "CopyToClipboard"

# The text to copy when clicked.
text: Var[str]

@classmethod
def get_controlled_triggers(cls) -> Set[str]:
"""Get the event triggers that pass the component's value to the handler.

Returns:
The controlled event triggers.
"""
return {"on_copy"}