Skip to content
This repository has been archived by the owner on Mar 4, 2020. It is now read-only.

feat(CopyToClipboard): add prototype #1860

Merged
merged 43 commits into from
Sep 5, 2019
Merged

Conversation

lucivpav
Copy link
Contributor

@lucivpav lucivpav commented Aug 28, 2019

Props

  • value - the value to be copied
  • copyPrompt - text describing what is going to be copied
  • timeout - how long to show copied prompt, in milliseconds
  • attached - displays copied prompt as a popup vs renders the message in the middle of parent element
  • pointing - whether the popup is pointing

Examples

image

image

image

image

Issues

When clicking the not attached version, use has no way to interact with elements other than the message.

@codecov
Copy link

codecov bot commented Aug 28, 2019

Codecov Report

Merging #1860 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@          Coverage Diff           @@
##           master   #1860   +/-   ##
======================================
  Coverage    69.9%   69.9%           
======================================
  Files         888     888           
  Lines        7775    7775           
  Branches     2244    2271   +27     
======================================
  Hits         5435    5435           
  Misses       2330    2330           
  Partials       10      10

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ac76e84...6b70ac1. Read the comment docs.

@vercel vercel bot temporarily deployed to staging August 30, 2019 09:01 Inactive
})}
/>
{hideContent && (
<Portal
Copy link
Member

Choose a reason for hiding this comment

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

Let's extract this to a separate component like CopyButtonNotification. We can reuse our createComponent() to host styles.

const CopyButtonNotification = createComponent({
  displayName: 'CopyButtonNotification',
  render: () => {
    return (
      <Portal>
        <div className={classes.root}>
          <div className={classes.content}>{children}</div>
        </div>
       </Portal>
    )
  },
})

Copy link
Contributor

Choose a reason for hiding this comment

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

Agree with createComponent, also consolidating styles in the provider or theme would be nice.

Would it be possible to create a "Notification" component instead so that you can use without the button? (which I believe Shift's example might be showing as well)

Copy link
Member

Choose a reason for hiding this comment

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

Would it be possible to create a "Notification" component instead so that you can use without the button?

I think so 👍

const { attached, pointing, copyPrompt } = this.props
const hideContent = this.state.copied && !attached
const copiedStr = 'Copied to clipboard'
const copiedText = hideContent ? (
Copy link
Member

Choose a reason for hiding this comment

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

I am not fully understand this logic, can you please clarify?

I expect something like this:

{attached && copied && <CopyButtonNotification>{notice}</CopyButtonNotification>}
{!attached && <Tooltip>{copied ? notice : usualMessage}</CopyButtonNotification>}

Copy link
Contributor Author

@lucivpav lucivpav Aug 30, 2019

Choose a reason for hiding this comment

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

We don't want to show the window-centered message when we are in attached mode. In attached mode, we just change the content of the Tooltip.

And to make the centered message more visible, I'm setting Text's size to larger.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hideContent implies that we should hide the Tooltip's content, as instead we are displaying the centered message.

...(hideContent && hiddenPopupContentVariables),
},
}}
on={['hover', 'context']}
Copy link
Contributor

Choose a reason for hiding this comment

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

I tried the prototype - it shows the message correctly after click, but then when I move my cursor outside of the button and return back to it, it shows the message again - I believe it's because of 'hover'. I think it should be on={[]}. Not sure if Toolbar would behave better or worse

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is intentional. Upon clicking the button, the components gets into a copied state. During the duration of this state, I'm showing 'Copied to clipboard' message. Would you prefer to show the original "Copy commit ID" message instead?

Copy link
Contributor

Choose a reason for hiding this comment

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

the message should be visible also when you do not hover/focus on the button.

Copy link
Contributor Author

@lucivpav lucivpav Sep 3, 2019

Choose a reason for hiding this comment

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

It is now visible also when the button is not hovered/focused

@vercel vercel bot temporarily deployed to staging September 4, 2019 15:30 Inactive
@lucivpav lucivpav merged commit c826c3a into master Sep 5, 2019
@delete-merged-branch delete-merged-branch bot deleted the feat/copy-to-clipboard branch September 5, 2019 13:49
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants