Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@symbo.ls/image-color-picker

Package Overview
Dependencies
Maintainers
8
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@symbo.ls/image-color-picker - npm Package Compare versions

Comparing version 2.11.34 to 2.11.36

138

index.js
'use strict'
import { Flex, CommonField, Upload, ClickableItem, Img, WiderButton } from '@symbo.ls/ui'
import ColorThief from '@symbo.ls/colorthief'
import { rgbArrayToHex } from '@symbo.ls/scratch'
const colorThief = new ColorThief()
const applyColorThief = (el, s) => {
const { node } = el
const done = colorThief.getPalette(node, 5)
const arrs = done.map(v => '#' + rgbArrayToHex(v))
s.update(arrs)
}
const imgPicker = {
props: ({ state }) => ({
hide: !state.imageUrl,
position: 'absolute',
inset: '0 0 0 0',
width: 'I',
height: 'H',
borderRadius: 'A',
overflow: 'hidden',
zIndex: 2
}),
img: {
extend: Img,
props: ({ state }) => ({
src: state.imageUrl,
position: 'absolute',
inset: '0 0 0 0',
width: '100%'
}),
attr: {
crossOrigin: 'Anonymous'
},
on: {
load: (ev, el, s) => {
if (!s.imageUrl || s.imageUrl === s.__imageUrl) return
s.__imageUrl = s.imageUrl
applyColorThief(el, s)
}
}
},
buttons: {
props: {
position: 'absolute',
left: 'A1',
bottom: 'A1',
flexAlign: 'center flex-start',
gap: 'X2',
transition: 'B opacity'
},
childExtend: [WiderButton, ClickableItem],
delete: {
props: { icon: 'trash' },
on: {
click: (ev, el, s) => {
ev.preventDefault()
s.update({ imageUrl: null })
}
}
},
refresh: { props: { icon: 'sync' }
}
}
}
const upload = {
extend: [Upload, Flex, ClickableItem],
Icon: { },
P: { Span: null },
Input: {
on: {
change: (ev, el, s) => {
// var files = ev.target.files
// var file = files[0]
// if (files && file) {
// var reader = new window.FileReader()
// reader.onload = function (readerEvt) {
// var binaryString = readerEvt.target.result
// const base = window.btoa(binaryString)
// s.update({ imageUrl: base })
// const img = new Image(500, 500)
// img.src = `data:image/png;base64, ${base}`
// new ColorThief().getPalette(img)
// .then(palette => { console.log(palette) })
// .catch(err => { console.log(err) })
// }
// ColorThief.getPalette(img, 5)
// .then(palette => { console.log(palette) })
// .catch(err => { console.log(err) })
// reader.readAsBinaryString(file)
// }
}
}
}
}
export const ImageColorPicker = {
extend: [CommonField, Flex],
props: {
title: { text: 'Pick from the picture' },
element: {
position: 'relative',
upload: {
border: 'none',
background: 'gray1',
padding: 'Z2 A2 Z2 Z2',
gap: 'Z',
flow: 'row',
icon: { fontSize: 'H' },
p: {
text: 'Upload or drop the image'
}
}
}
},
title: {},
element: {
imgPicker,
upload
}
}

7

package.json
{
"name": "@symbo.ls/image-color-picker",
"author": "symbo.ls",
"version": "2.11.34",
"version": "2.11.36",
"repository": "https://github.com/symbo-ls/smbls",
"main": "index.js",
"gitHead": "a9875f5261165cbef5c9e6344f319636cb89c3f2"
"dependencies": {
"@symbo.ls/colorthief": "latest"
},
"gitHead": "e2746630554e446c0b8530701f389f986e2bdd45"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc