Giter VIP home page Giter VIP logo

Comments (6)

MattOpen avatar MattOpen commented on July 21, 2024

I am also not a fan of "altering" existing dom elements.
For a quick solution, I have rewritten the wrapFields function:
(sure this is not the real solution, but it worked for me and I am willing to contribute a final solution)

`function wrapFields(selector) {
document.querySelectorAll(selector).forEach(function (field) {
var parentNode = field.parentNode;

  if (!parentNode.classList.contains('clr-field')) {
      var wrapper = field,
          classes = 'clr-field';
      wrapper.insertAdjacentHTML('beforebegin', "<button type=\"button\" aria-labelledby=\"clr-open-label\"></button>");
      parentNode.classList.add(classes);
      parentNode.style.color = field.value;


  //var wrapper = document.createElement('div');
  //var classes = 'clr-field';

  //if (settings.rtl || field.classList.contains('clr-rtl')) {
  //  classes += ' clr-rtl';
  //}

  //wrapper.innerHTML = "<button type=\"button\" aria-labelledby=\"clr-open-label\"></button>";
  //parentNode.insertBefore(wrapper, field);
  //wrapper.setAttribute('class', classes);
  //wrapper.style.color = field.value;
  //wrapper.appendChild(field);
}

});
}`

This is how the generated code looks like after:
image

I am working with bootstrap and floating label and this the result
image

from coloris.

mdbassit avatar mdbassit commented on July 21, 2024

@leonardfischer @MattOpen If you don't want to have your fields wrapped, you need to use a custom CSS class to initialize the color fields instead of the default [data-coloris] selector. As the doc states, the wrap option is ineffective on the default selector.

For my own uses, I need the color picker to keep this behavior, so I won't be accepting alterations to it.

from coloris.

MattOpen avatar MattOpen commented on July 21, 2024

Dear @mdbassit ,

I really love your work and you did a great job so far.

I have tried the solution with wrap: "false" and el: "#myid"
The color picker is rendered but the additional button showing the color is not rendered.
image

"For my own uses, I need the color picker to keep this behavior, so I won't be accepting alterations to it." thats also not my intention. I would like to enhance it, that you can use it with the additional div wrapped and others can use it without the additional div wrapped, but also showing the color in input.

it is unnecessary to fork the repo, only for this little enhancement. What do you think?

from coloris.

mdbassit avatar mdbassit commented on July 21, 2024

Thank you for your kind words !

I made this color picker mainly for my own use and decided to share it, modifying it to make it less convenient for me is not very reasonable. I'm afraid I have to insist on leaving it as is.

from coloris.

leonardfischer avatar leonardfischer commented on July 21, 2024

Hey @mdbassit that's fine by me - I already use the workaround :)

from coloris.

MattOpen avatar MattOpen commented on July 21, 2024

Dear @mdbassit ,
ok fine. I have forked your repo and made my necessary changes.
ColorisColorpicker

from coloris.

Related Issues (20)

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.