-
Notifications
You must be signed in to change notification settings - Fork 106
feat: Make it so PFE-Clipboard can copy arbitrary content #1795
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: Make it so PFE-Clipboard can copy arbitrary content #1795
Conversation
Need docs update and tests still
4e17be8 to
23a2c23
Compare
|
✔️ Deploy Preview for patternfly-elements ready! 🔨 Explore the source changes: 4e17be8 🔍 Inspect the deploy log: https://app.netlify.com/sites/patternfly-elements/deploys/616089f4f6f41c000714f318 😎 Browse the preview: https://deploy-preview-1795--patternfly-elements.netlify.app |
|
✔️ Deploy Preview for patternfly-elements ready! 🔨 Explore the source changes: d83a5c5 🔍 Inspect the deploy log: https://app.netlify.com/sites/patternfly-elements/deploys/618581127320370007f8ec2e 😎 Browse the preview: https://deploy-preview-1795--patternfly-elements.netlify.app/components/clipboard |
|
Are we interested in using the Clipboard API to copy multimedia objects in supporting browsers? |
…copy-arbitrary-things--new-tests feat: Update tests for pfe-clipboard
|
@bennypowers that'd be awesome! 🤔 Though I don't know that there's any use case for it yet. |
…ithub.com:patternfly/patternfly-elements into 1794-allow-pfe-clipboard-to-copy-arbitrary-things
|
EDIT The code is good to go as far as I'm concerned, but I it still needs docs. Wanted to bounce this issue off folks before I wrote the docs: I added a few disabled states for when:
The only other ways of checking to see if the element exists would be heavy... like a MutationObserver on the document 🤢 ... Do you all think this is good enough? Is there a 'cool kid' way to handle that 'not fool proof' concern that I'm missing? |
Discussed with Kyle Buchanan, Michael Clayton, and other CPFED folks, guarding against the HTML element that will have it's text copied isn't really worth it. There isn't a good way to know that it _should_ be disabled and then _should_ be enabled later. Better to leave it to the click event, and hopefully things were setup so it'll work when the user clicks on it
Discussed this with Kyle Buchanan, Michael Clayton, and other CPFED folks, and it feels like checking to see if an element exists isn't worth it. We can know if the property is set, but if an element exists is too hairy, and not a necessary thing to guard against. |
|
@heyMP Please ensure these colors are integrated or let me know if there is another issue where I can put this information. Light theme
Dark theme
|
|
@coreyvickery sounds good. @wesruv I'm going to add these styles to the icon quick if that's ok? |
Sounds great, thanks sir! |
|
@corey Here are the icon changes:
I also added a saturated theme where I used the following variables. I tried to semantically match them to their corresponding dark theme variables but they can be changed.
|
|
@heyMP Looks great. |
| // Attach variables to hover, focus states | ||
| // ignore disabled. | ||
| :host(:hover:not([disabled])), | ||
| :host(:focus:not([disabled])) { | ||
| .pfe-clipboard { | ||
| &__text { | ||
| color: pfe-local(Color--hover) !important; | ||
| } | ||
| &__icon { | ||
| // Customize icon color for pfe-icons | ||
| --pfe-icon--Color: #{pfe-local(icon--Color--hover)}; | ||
| svg { | ||
| // Customize icon color of fallback svg icon | ||
| fill: pfe-local(icon--Color--hover) !important; | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simplified our old focus,hover selectors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍🏼
| :host([on="dark"]) { | ||
| --pfe-clipboard--icon--Color: #{pfe-local(icon--Color--dark)}; | ||
| --pfe-clipboard--icon--Color--hover: #{pfe-local(icon--Color--hover--dark)}; | ||
| } | ||
|
|
||
| // Note: Hover states need to be defined after focus states | ||
| :host(:not([aria-disabled="true"]):hover), | ||
| :host(:not([aria-disabled="true"])) ::slotted(:hover) { | ||
| --pfe-clipboard--Color: #{pfe-local(Color--hover)}; | ||
| :host([on="saturated"]) { | ||
| --pfe-clipboard--icon--Color: #{pfe-local(icon--Color--saturated)}; | ||
| --pfe-clipboard--icon--Color--hover: #{pfe-local(icon--Color--hover--saturated)}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Explicitly adding theme context hooks for icon color. We don't have to include text color variables because that's automatically covered by broadcast variables.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍🏼
|
@wesruv I think almost ready. Sorry, this review took a while; but we have some really great improvements! I think we'll just need to add this new |
|
Removed those unnecessary removeEventListeners |
This reverts commit 8de71ec.
|
Hey, @wesruv. Would you be able to add the new "copy-from" attribute API to the docs? |
4fe2065 to
e2dfcdc
Compare
heyMP
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Need docs update and tests still, also think we can add a disabled state if it can't find what it should be copying.
For this proof o concept, see the comments I made below, and then check out the demo page here:
https://deploy-preview-1795--patternfly-elements.netlify.app/elements/pfe-clipboard/demo/
Related issues