Giter Club home page Giter Club logo

stimulus-clipboard's Introduction

Stimulus components

๐Ÿ‘‰ Introducing Stimulus components.

๐Ÿ“š Documentation

See Stimulus Components Website.

๐Ÿ‘ท Contributing

Do not hesitate to contribute to the controllers by adapting or adding features ! Bug reports or pull requests are welcome.

Don't forget to drop a ๐ŸŒŸ on GitHub to support the project.

๐Ÿ“ License

This project is released under the MIT license.

stimulus-clipboard's People

Contributors

guillaumebriday avatar jmsche avatar mkrauser avatar sho918 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

stimulus-clipboard's Issues

Use innerHTML instead of innertText on buttonTarget

Hey there,

In the controller, innerText is used to retrieve and put back the content of the buttonTarget in the connect and copied methods:

connect (): void {
    if (!this.hasButtonTarget) return

    this.originalText = this.buttonTarget.innerText
  }
copied (): void {
  ...
  this.timeout = setTimeout(() => {
      this.buttonTarget.innerText = this.originalText
    }, this.successDurationValue)
  }

Therefore if the content is, let's say, an icon, it doesn't work anymore. Wouldn't it be a nice additional feature to user innerHTML so that any kind of content would be put back in place once the successContent message has been displayed, like the suggestion below ? I can't see any side effect as it would work the same for simple text and only extend the component capabilities, but I might miss something...

connect (): void {
    if (!this.hasButtonTarget) return

    this.originalHTML= this.buttonTarget.innerHTML
  }
copied (): void {
  ...
  this.timeout = setTimeout(() => {
      this.buttonTarget.innerHTML = this.originalHTML
    }, this.successDurationValue)
  }

Thanks,

incompatible node version

hey ๐Ÿ‘‹๐Ÿป
thanks a lot for this lib!

I'm trying to upgrade to either 3.4 or 4.0 and I keep getting the same error:

error [email protected]: The engine "node" is incompatible with this module. Expected version "18". Got "20.2.0"
error Found incompatible module.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

checking the diff, I noticed you introduce a hardcoded node version in the requirements here. I'm not a JS developer but I wonder if it is possible to have a more relaxed node version pinning like >= 18 or something

Not working when in broadcast mode

The component is not working when Im broadcasting my server but when I'm in local(rails s) it is working, why? Is their anything I missed?

Allow content to be copied in values

Instead of requiring an HTMLInputElement, which has the display problem, what about allowing the content to be copied in the controller values?

Instead of

<div data-controller="clipboard" data-clipboard-success-content="Copied!">
  <input type="text" value="Click the button to copy me!" data-clipboard-target="source" />
<div data-controller="clipboard" 
data-clipboard-content="Click the button to copy me (this isn't visible, but it could be some long and garly url or uuid!)"
data-clipboard-success-content="Copied!">

I'm not sure if this is even possible, I'm not sure how 'select' and document.execCommand('copy') work.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.