Skip to content

Commit

Permalink
Add new color picker component using coloris.js library (#1575)
Browse files Browse the repository at this point in the history
  • Loading branch information
codecalm committed May 16, 2023
1 parent 0f129b1 commit be14607
Show file tree
Hide file tree
Showing 13 changed files with 251 additions and 82 deletions.
5 changes: 5 additions & 0 deletions .changeset/thin-eagles-mix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@tabler/core": patch
---

Add new color picker component using `coloris.js` library
2 changes: 1 addition & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ gulp.task('copy-libs', (cb) => {
files.forEach((file) => {
if (!file.match(/^https?/)) {
let dirname = path.dirname(file).replace('@', '')
let cmd = `mkdir -p "${distDir}/libs/${dirname}" && cp -r node_modules/${dirname}/* ${distDir}/libs/${dirname}`
let cmd = `mkdir -p "${distDir}/libs/${dirname}" && cp -r node_modules/${path.dirname(file)}/* ${distDir}/libs/${dirname}`

cp.exec(cmd)
}
Expand Down
11 changes: 8 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@
]
},
"devDependencies": {
"@melloware/coloris": "^0.19.1",
"@babel/core": "^7.21.8",
"@babel/preset-env": "^7.21.5",
"@changesets/cli": "^2.26.1",
Expand Down Expand Up @@ -179,13 +180,13 @@
"rollup-plugin-babel": "^4.4.0",
"rollup-plugin-cleanup": "^3.2.1",
"sass": "^1.62.1",
"star-rating.js": "^4.3.0",
"tinymce": "^6.4.2",
"tom-select": "^2.2.2",
"vinyl-buffer": "^1.0.1",
"vinyl-source-stream": "^2.0.0",
"yaml": "^2.2.2",
"yargs": "^17.7.2",
"star-rating.js": "^4.3.0"
"yargs": "^17.7.2"
},
"dependencies": {
"@popperjs/core": "^2.11.7",
Expand All @@ -206,11 +207,15 @@
"litepicker": "^2.0.12",
"nouislider": "^15.7.0",
"plyr": "^3.7.8",
"star-rating.js": "^4.3.0",
"tinymce": "^6.4.2",
"tom-select": "^2.2.2",
"star-rating.js": "^4.3.0"
"@melloware/coloris": "^0.19.1"
},
"peerDependenciesMeta": {
"@melloware/coloris": {
"optional": true
},
"apexcharts": {
"optional": true
},
Expand Down
7 changes: 7 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions src/pages/_data/libs.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,18 @@
"jsvectormap-world": "jsvectormap/dist/maps/world.js",
"jsvectormap-world-merc": "jsvectormap/dist/maps/world-merc.js",
"fslightbox": "fslightbox/index.js",
"tinymce" :"tinymce/tinymce.min.js",
"tinymce": "tinymce/tinymce.min.js",
"plyr": "plyr/dist/plyr.min.js",
"dropzone": "dropzone/dist/dropzone-min.js",
"star-rating.js": "star-rating.js/dist/star-rating.min.js"
"star-rating.js": "star-rating.js/dist/star-rating.min.js",
"coloris.js": "@melloware/coloris/dist/umd/coloris.min.js"
},
"css": {
"mapbox": "https://api.mapbox.com/mapbox-gl-js/v1.8.0/mapbox-gl.css",
"dropzone": "dropzone/dist/dropzone.css",
"plyr": "plyr/dist/plyr.css",
"star-rating.js": "star-rating.js/dist/star-rating.min.css"
"star-rating.js": "star-rating.js/dist/star-rating.min.css",
"coloris.js": "@melloware/coloris/dist/coloris.min.css"
},
"js-copy": {
"tinymce" :"tinymce/*"
Expand Down
147 changes: 74 additions & 73 deletions src/pages/_data/menu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,33 @@ base:
accordion:
title: Accordion
url: accordion.html
authentication:
title: Authentication
children:
sign-in:
title: Sign in
url: sign-in.html
sign-in-link:
title: Sign in link
url: sign-in-link.html
sign-in-illustration:
title: Sign in with illustration
url: sign-in-illustration.html
sign-in-cover:
title: Sign in with cover
url: sign-in-cover.html
sign-up:
title: Sign up
url: sign-up.html
forgot-password:
title: Forgot password
url: forgot-password.html
terms-of-service:
title: Terms of service
url: terms-of-service.html
auth-lock:
title: Lock screen
url: auth-lock.html
blank:
title: Blank page
url: blank.html
Expand All @@ -35,9 +62,20 @@ base:
masonry:
url: cards-masonry.html
title: Cards Masonry
carousel:
title: Carousel
url: carousel.html
badge: New
charts:
url: charts.html
title: Charts
colors:
url: colors.html
title: Colors
colorpicker:
url: colorpicker.html
title: Color picker
badge: New
datagrid:
url: datagrid.html
title: Data grid
Expand All @@ -49,25 +87,55 @@ base:
dropdowns:
url: dropdowns.html
title: Dropdowns
dropzone:
title: Dropzone
url: dropzone.html
badge: New
error:
title: Error pages
children:
404:
url: error-404.html
title: 404 page
500:
url: error-500.html
title: 500 page
maintenance:
url: error-maintenance.html
title: Maintenance page
plyr:
title: Inline player
badge: New
url: inline-player.html
lightbox:
title: Lightbox
url: lightbox.html
badge: New
lists:
title: Lists
url: lists.html
modals:
url: modals.html
title: Modals
title: Modal
maps:
url: maps.html
title: Maps
title: Map
map-fullsize:
url: map-fullsize.html
title: Map fullsize
maps-vector:
url: maps-vector.html
title: Vector maps
title: Map vector
badge: New
markdown:
title: Markdown
url: markdown.html
navigation:
url: navigation.html
title: Navigation
charts:
url: charts.html
title: Charts
offcanvas:
title: Offcanvas
url: offcanvas.html
pagination:
url: pagination.html
title: Pagination
Expand All @@ -89,80 +157,13 @@ base:
tables:
url: tables.html
title: Tables
carousel:
title: Carousel
url: carousel.html
badge: New
lists:
title: Lists
url: lists.html
typography:
title: Typography
url: typography.html
offcanvas:
title: Offcanvas
url: offcanvas.html
markdown:
title: Markdown
url: markdown.html
dropzone:
title: Dropzone
url: dropzone.html
badge: New
lightbox:
title: Lightbox
url: lightbox.html
badge: New
tinymce:
title: TinyMCE
url: tinymce.html
badge: New
plyr:
title: Inline player
badge: New
url: inline-player.html

authentication:
title: Authentication
children:
sign-in:
title: Sign in
url: sign-in.html
sign-in-link:
title: Sign in link
url: sign-in-link.html
sign-in-illustration:
title: Sign in with illustration
url: sign-in-illustration.html
sign-in-cover:
title: Sign in with cover
url: sign-in-cover.html
sign-up:
title: Sign up
url: sign-up.html
forgot-password:
title: Forgot password
url: forgot-password.html
terms-of-service:
title: Terms of service
url: terms-of-service.html
auth-lock:
title: Lock screen
url: auth-lock.html

error:
title: Error pages
icon: file-minus
children:
404:
url: error-404.html
title: 404 page
500:
url: error-500.html
title: 500 page
maintenance:
url: error-maintenance.html
title: Maintenance page

forms:
url: form-elements.html
Expand Down
39 changes: 39 additions & 0 deletions src/pages/_includes/ui/colorpicker.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{% assign id = include.id | default: 'default' %}
{% assign alpha = include.alpha | default: false %}
{% assign format = include.format | default: false %}

<input type="text" class="form-control d-block{% if include.class %} {{ include.class }}{% endif %}" id="colorpicker-{{ id }}" value="{{ include.value }}" />

{% capture_global scripts %}
<script>
// @formatter:off
document.addEventListener("DOMContentLoaded", function () {
{% if jekyll.environment == 'development' %}
window.tabler_colorpicker = window.tabler_colorpicker || {};
{% endif %}

window.Coloris && ({% if jekyll.environment == 'development' %}window.tabler_colorpicker["colorpicker-{{ id }}"] = {% endif %}Coloris({
el: "#colorpicker-{{ id }}",
selectInput: false,
alpha: {% if alpha %}true{% else %}false{% endif %},
{% if format %}format: "{{ format }}",{% endif %}
{% if include['swatches-only'] %}swatchesOnly: true,{% endif %}
swatches: [
"#206bc4",
"#45aaf2",
"#6574cd",
"#a55eea",
"#f66d9b",
"#fa4654",
"#fd9644",
"#f1c40f",
"#7bd235",
"#5eba00",
"#2bcbba",
"#17a2b8",
],
}))
})
// @formatter:on
</script>
{% endcapture_global %}
4 changes: 4 additions & 0 deletions src/pages/_plugins/jekyll-filters.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ def timestamp_to_date(timestamp)
def htmlbeautifier(output)
HtmlBeautifier.beautify output
end

def hex_to_rgb(hex)
hex.match(/^#(..)(..)(..)$/).captures.map(&:hex)
end
end
end

Expand Down
21 changes: 21 additions & 0 deletions src/pages/colorpicker.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
title: Color picker
page-header: Color picker
menu: base.colorpicker
libs: coloris.js
---

{% assign colors = "#206bc4,#45aaf2,#6574cd,#a55eea,#f66d9b,#fa4654,#fd9644,#f1c40f,#7bd235,#5eba00,#2bcbba,#17a2b8" | split: "," %}

<div class="card">
<div class="card-body">
<h3 class="card-title">Basic</h3>
<div class="row g-3">
{% for color in colors %}
<div class="col-2">
<div>{% include ui/colorpicker.html value=color id=forloop.index format="hex" %}</div>
</div>
{% endfor %}
</div>
</div>
</div>
12 changes: 10 additions & 2 deletions src/scss/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,14 @@ $shadows: (

$box-shadow-inset: 0 0 transparent !default;

// Focus
$focus-ring-width: 0.25rem !default;
$focus-ring-opacity: 0.25 !default;
$focus-ring-color: rgba(var(--#{$prefix}primary-rgb), $focus-ring-opacity) !default;
$focus-ring-blur: 0 !default;
$focus-ring-border-color: rgba(var(--#{$prefix}primary-rgb), 50%) !default;
$focus-ring-box-shadow: 0 0 $focus-ring-blur $focus-ring-width $focus-ring-color !default;

// Transitions
$transition-time: 0.3s !default;

Expand Down Expand Up @@ -529,8 +537,8 @@ $input-height: null !default;
$input-height-sm: null !default;
$input-height-lg: null !default;
$input-border-radius: var(--#{$prefix}border-radius) !default;
$input-color: inherit !default;
$input-focus-color: inherit !default;
$input-color: var(--#{$prefix}body-color) !default;
$input-focus-color: var(--#{$prefix}body-color) !default;

// Buttons
$btn-disabled-opacity: 0.4 !default;
Expand Down
Loading

0 comments on commit be14607

Please sign in to comment.