How to use @pluginjs/color - 10 common examples

To help you get started, we’ve selected a few @pluginjs/color examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pluginjs / pluginjs / modules / color-selector / src / components / hex.js View on Github external
constructor(instance, element) {
    this.instance = instance
    this.element = element
    this.classes = this.instance.classes
    this.opac = 100
    this.color = null

    this.COLOR = new Color()
    this.mode = this.COLOR.toHEX()
    this.HSL = this.COLOR.toHSL().toUpperCase()
    this.HEX = this.COLOR.toHEX().toUpperCase()
    this.RGB = this.COLOR.toRGB().toUpperCase()

    this.classify = this.HEX

    this.data = [
      { label: this.HEX, value: 'HEX' },
      { label: this.HSL, value: 'HSL' },
      { label: this.RGB, value: 'RGB' }
    ]
    // this.bind()

    this.init()
  }
github pluginjs / pluginjs / modules / color-picker / src / main2.js View on Github external
initialize() {
    // take element defalut value
    this.elementColor = this.element.value

    // init Color
    this.asColor = Color.of(this.options.defaultColor, this.options.color)

    // init frame
    this.initFrame()

    // set theme
    if (this.options.theme) {
      addClass(this.getThemeClass(), this.$wrap)
    }

    // init collection
    if (this.hasModule('collection')) {
      this.initCollection()
    }

    // init solid
    if (this.hasModule('solid')) {
github pluginjs / pluginjs / modules / color-picker / src / main.js View on Github external
this.setupI18n()
    // class
    this.setupClasses()
    compose(
      attr({ placeholder: this.options.placeholder }),
      addClass(this.classes.INPUT, 'pj-input')
    )(this.element)

    // init global vars
    this.$body = query('body')

    this.color = this.options.defaultColor || '#000'
    this.oldColor = null

    this.module = this.options.module
    this.COLOR = Color.of(this.options.defaultColor, this.options.color)

    this.setupStates()
    this.initialize()
  }
github pluginjs / pluginjs / modules / color-selector / src / modules / solid.js View on Github external
constructor(instance, element) {
    this.instance = instance
    this.element = element
    this.classes = this.instance.classes
    this.color = Color.of(
      this.instance.options.defaultColor,
      this.instance.options.color
    )

    this.init()
  }
github pluginjs / pluginjs / modules / color-picker / src / components / hex.js View on Github external
constructor(instance, element) {
    this.instance = instance
    this.element = element
    this.classes = this.instance.classes
    this.opac = 100
    this.color = null

    this.COLOR = new Color()
    this.mode = this.COLOR.toHEX()
    this.HSL = this.COLOR.toHSL().toUpperCase()
    this.HEX = this.COLOR.toHEX().toUpperCase()
    this.RGB = this.COLOR.toRGB().toUpperCase()

    this.classify = this.HEX

    this.data = [
      { label: this.HEX, value: 'HEX' },
      { label: this.HSL, value: 'HSL' },
      { label: this.RGB, value: 'RGB' }
    ]
    this.init()
  }
github pluginjs / pluginjs / modules / gradient / src / colorStop.js View on Github external
constructor(color, position, gradient) {
    this.color = Color.of(color, gradient.options.color)
    this.position = GradientString.parsePosition(position)
    this.id = ++gradient.privateStopIdCount
    this.gradient = gradient
  }
github pluginjs / pluginjs / modules / color-picker / src / main.js View on Github external
e => {
          if (new Color().matchString(e.target.value)) {
            this.set(e.target.value)
          }
        },
        this.element
github pluginjs / pluginjs / modules / color-selector / src / main.js View on Github external
e => {
        if (
          new Color().matchString(e.target.value) ||
          new Gradient().matchString(e.target.value)
        ) {
          this.set(this.options.parse.call(this, e.target.value))
        }
      },
      this.element
github pluginjs / pluginjs / modules / color-picker / src / components / saturation.js View on Github external
const top = (1 - color.value.v) * this.maxLengthY - this.size
    const hue = color.value.h

    this.hue = color.value.h

    setStyle(
      {
        top: `${top}px`,
        left: `${left}px`
      },
      this.$pointer
    )

    setStyle(
      {
        backgroundColor: Converter.HSLtoHEX({
          h: hue,
          s: 1,
          l: 0.5
        })
      },
      this.element
    )
  }
github pluginjs / pluginjs / modules / color-selector / src / components / saturation.js View on Github external
const top = (1 - color.value.v) * this.maxLengthY - this.size
    const hue = color.value.h

    this.hue = color.value.h

    setStyle(
      {
        top: `${top}px`,
        left: `${left}px`
      },
      this.$pointer
    )

    setStyle(
      {
        backgroundColor: Converter.HSLtoHEX({
          h: hue,
          s: 1,
          l: 0.5
        })
      },
      this.element
    )
  }

@pluginjs/color

A flexible modern color js plugin.

GPL-3.0
Latest version published 2 years ago

Package Health Score

46 / 100
Full package analysis

Similar packages