Giter VIP home page Giter VIP logo

Comments (8)

mdbassit avatar mdbassit commented on September 25, 2024

The color input fields shouldn't be styled by the color picker at all. But if you are talking about the input field inside the picker dialog, that's the intended behavior, you can of course customize the style with CSS.

from coloris.

melloware avatar melloware commented on September 25, 2024

@glewe can you post a screenshot of what you mean by "out of place" ?

from coloris.

glewe avatar glewe commented on September 25, 2024

Here is a normal input field (Bootstrap style)
input-normal
As soon as I link coloris to it it changes to this:
input-coloris

Is there any way to leave the original input field untouched?

from coloris.

mdbassit avatar mdbassit commented on September 25, 2024

The easiest way is to use a custom selector (set the el option to a class for example ) and set the wrap option to false. But the little color preview will not render.

Coloris({
  el: '.myclass',
  wrap: false
});

from coloris.

mdbassit avatar mdbassit commented on September 25, 2024

@glewe I just added Bootstrap 5 to a test page and the input field are rendered correctly without any issue. There is no overflowing preview thumbnail like in your screenshot. Could you maybe share a public page where I can see your issue in action?

from coloris.

glewe avatar glewe commented on September 25, 2024

Great. Thanks, that works. Code looks something like this now:

<div class="input-group mb-3">
  <span class="input-group-text"><i id="sample-txt_color" class="bi-square-fill" style="color: #F2EF3D"></i></span>
  <input id="txt_color" type="text" class="form-control" name="txt_color" value="#F2EF3D" maxlength="9">
</div>
<script>
  Coloris({
    el: "#txt_color",
    wrap: false,
    theme: "polaroid",
    themeMode: "dark",
    alpha: true,
    onChange: function (color) {
      $("#sample-txt_color").css("color", color);
    }
  });
</script>

from coloris.

glewe avatar glewe commented on September 25, 2024

Additional note:
I noticed that the onChange function does not work with multiple instances. I changed the code to this:

<div class="input-group mb-3">
  <span class="input-group-text"><i id="sample-txt_color" class="bi-square-fill" style="color: #608e20"></i></span>
  <input id="txt_color" type="text" class="form-control" name="txt_color" value="#608e20" maxlength="9" >
</div>
<script>
  Coloris({
    el: "#txt_color",
    wrap: false,
    theme: "polaroid",
    themeMode: "dark",
    alpha: true,
    format: "hex"
  });
  document.getElementById("txt_color").addEventListener("input", function() {
    document.getElementById("sample-txt_color").style.color = this.value;
  });
</script>

from coloris.

mdbassit avatar mdbassit commented on September 25, 2024

To support multiple instances, I'd recommend this method:

Coloris({
  el: "#txt_color",
  wrap: false,
  theme: "polaroid",
  themeMode: "dark",
  alpha: true,
  format: "hex",
  onChange: function (color, input) {
    var thumbnail = input.previousElementSibling; // This is the span.input-group-text

    if (thumbnail && thumbnail.firstElementChild) {
      thumbnail.firstElementChild.style.color = color;
    }
  }
});

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.