Skip to content

Commit

Permalink
choices js styling
Browse files Browse the repository at this point in the history
  • Loading branch information
codecalm committed Feb 10, 2021
1 parent a83b4bc commit 92b349f
Show file tree
Hide file tree
Showing 10 changed files with 124 additions and 22 deletions.
2 changes: 0 additions & 2 deletions src/pages/_data/libs.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
"choices": "choices.js/public/assets/scripts/choices.js"
},
"css": {
"choices": "choices.js/public/assets/styles/choices.css",
"nouislider": "nouislider/distribute/nouislider.min.css",
"mapbox": "https://api.mapbox.com/mapbox-gl-js/v1.8.0/mapbox-gl.css"
}
}
2 changes: 1 addition & 1 deletion src/pages/_data/selects.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,4 @@ countries:

people:
value: 4
options: people
data: people
50 changes: 40 additions & 10 deletions src/pages/_includes/ui/select.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,33 @@

{% if id %}

{% assign key = include.key | default: 'people' %}
{% assign data = site.data.selects[key] %}
{% assign options = data.options %}

<select type="text" class="form-control{% if include.class %} {{ include.class }}{% endif %}"{% if placeholder %} placeholder="{{ placeholder }}"{% endif %} id="select-{{ id }}" value="{{ value }}">
{% for option in options %}
<option value="{{ option }}">{{ option }}</option>
{% endfor %}
<select type="text" class="form-select{% if include.class %} {{ include.class }}{% endif %}{% if include.state %} is-{{ include.state }}{% endif %}"{% if placeholder %} placeholder="{{ placeholder }}"{% endif %} id="select-{{ id }}" value="{{ value }}">
{% if include.values %}
{% assign values = include.values | split: ',' %}

{% for value in values %}
<option value="{{ value }}">{{ value }}</option>
{% endfor %}
{% else %}
{% assign key = include.key | default: 'people' %}
{% assign data = site.data.selects[key] %}
{% assign options = data.options %}

{% if data.data == 'people' %}
{% for person in site.data.people %}
<option value="{{ person.id }}">{{ person.full_name }}</option>
{% endfor %}

{% else %}
{% for option in options %}
{% if option.first %}
<option value="{{ option[0] }}">{{ option[1].name }}</option>
{% else %}
<option value="{{ option }}">{{ option }}</option>
{% endif %}
{% endfor %}
{% endif %}
{% endif %}
</select>


Expand All @@ -21,8 +40,19 @@
window.tabler_select = window.tabler_select || {};
{% endif %}

window.Choices && ({% if jekyll.environment == 'development' %}window.tabler_select["select-{{ id }}"] = {% endif %}new Choices(document.getElementById('select-{{ id }}'), {

var el;
window.Choices && ({% if jekyll.environment == 'development' %}window.tabler_select["select-{{ id }}"] = {% endif %}new Choices(el = document.getElementById('select-{{ id }}'), {
classNames: {
containerInner: el.className,
input: 'form-control',
inputCloned: 'form-control-sm',
listDropdown: 'dropdown-menu',
itemChoice: 'dropdown-item',
activeState: 'show',
selectedState: 'active',
},
shouldSort: false,
{% unless include.show-search %}searchEnabled: false,{% endunless %}
}));

});
Expand Down
2 changes: 1 addition & 1 deletion src/pages/form-elements.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Form elements
page-header: Form elements
menu: forms
libs: nouislider, autosize, tabler-flags, tabler-payments, litepicker
libs: nouislider, autosize, tabler-flags, tabler-payments, litepicker, choices
---

<div class="row row-cards">
Expand Down
4 changes: 3 additions & 1 deletion src/scss/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ $text-muted-light-opacity: .4 !default;
$text-muted-dark-opacity: .8 !default;

$border-opacity: .16 !default;
$border-dark-opacity: .24 !default;
$border-dark-opacity: .32 !default;

$light: #f4f6fa !default;
$dark: #232e3c !default;
Expand Down Expand Up @@ -361,6 +361,8 @@ $dropdown-spacer: 1px !default;
$dropdown-min-width: 11rem !default;
$dropdown-max-width: 25rem !default;

$dropdown-scrollable-height: 12rem !default;

$dropdown-link-active-color: $primary !default;
$dropdown-link-active-bg: $active-bg !default;

Expand Down
14 changes: 10 additions & 4 deletions src/scss/mixins/_mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,15 @@
@if ($is-dark) {
background: transparent;
} @else {
background: $gray-400;
background: $gray-600;
}
}

&::-webkit-scrollbar-track {
@if ($is-dark) {
background: transparent;
} @else {
background: $gray-300;
}
}

Expand All @@ -35,12 +43,10 @@
}

&:hover::-webkit-scrollbar-thumb {
background: $gray-500;

@if ($is-dark) {
background: mix($white, $dark, 20%);
} @else {
background: $gray-500;
background: $gray-600;
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/scss/tabler-vendors.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@

@import "vendor/apexcharts";
@import "vendor/nouislider";
@import "vendor/litepicker";
@import "vendor/litepicker";
@import "vendor/choices";
4 changes: 2 additions & 2 deletions src/scss/ui/_dropdowns.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.dropdown-menu {
box-shadow: $box-shadow;
user-select: none;
margin: 0;
margin: 0 !important;

&.card {
padding: 0;
Expand Down Expand Up @@ -39,7 +39,7 @@

.dropdown-menu-scrollable {
height: auto;
max-height: 12rem;
max-height: $dropdown-scrollable-height;
overflow-x: hidden;
}

Expand Down
63 changes: 63 additions & 0 deletions src/scss/vendor/_choices.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
@import "~choices.js/public/assets/styles/choices";

.choices {
margin: 0;
font-size: inherit;
position: relative;
cursor: pointer;

&:focus {
outline: none;
}

&:after {
content: none !important;
}

&.is-focused .form-select {
border-color: $form-select-focus-border-color;
box-shadow: $form-select-focus-box-shadow;
}

.dropdown-menu {
width: 100%;
height: auto;
max-height: $dropdown-scrollable-height;
overflow-x: hidden;

.dropdown-item {
padding-left: $input-padding-x;
padding-right: $input-padding-x;

&.active {
background: transparent;
color: inherit;
}

&.is-highlighted {
color: $dropdown-link-active-color;
background-color: $dropdown-link-active-bg;
}
}
}
}

.choices__placeholder {
color: $input-placeholder-color;
opacity: 1;
}

.choices__list--single {
padding: 0;
}

.choices__list--dropdown {

.is-focused &,
.is-open & {
}

.choices__item--selectable:after {
content: none;
}
}
2 changes: 2 additions & 0 deletions src/scss/vendor/_nouislider.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@import "~nouislider/distribute/nouislider";

.noUi-target {
border: 0;
box-shadow: none;
Expand Down

0 comments on commit 92b349f

Please sign in to comment.