Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Stylelint and a reasonable configuration, and bring SASS/SCSS up-to-spec #595

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .stylelintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": ["stylelint-config-standard-scss"],
"rules": {
"scss/at-import-partial-extension": null,
"scss/dollar-variable-colon-space-after": null,
"scss/dollar-variable-empty-line-before": null,
"no-invalid-position-at-import-rule": null
}
}
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@
"rollup-plugin-insert": "^1.3.2",
"rollup-plugin-terser": "^7.0.2",
"sass": "^1.49.9",
"stylelint": "^15.6.2",
"stylelint-config-standard": "^33.0.0",
"stylelint-config-standard-scss": "^9.0.0",
"syn": "^0.15.0",
"tslib": "^2.4.0",
"typescript": "^4.8.3"
Expand All @@ -95,6 +98,7 @@
"test": "karma start",
"test:one": "karma start --test_one",
"test:typescript": "tsc -p .config --noemit",
"sass-lint": "stylelint -q src/scss",
"start": "grunt serve",
"pretest": "grunt build",
"prepare": "husky install"
Expand Down
2 changes: 0 additions & 2 deletions src/scss/-tom-select.bootstrap4.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


@import "../../node_modules/bootstrap/scss/functions";
@import "../../node_modules/bootstrap/scss/variables";
@import "../../node_modules/bootstrap/scss/mixins";
Expand Down
12 changes: 7 additions & 5 deletions src/scss/_dropdown.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@
left: 0;
width: 100%;
z-index: 10;

border: $select-dropdown-border;
background: $select-color-dropdown;
margin: 0.25rem 0 0 0;
margin: 0.25rem 0 0;
border-top: 0 none;
box-sizing: border-box;
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
box-shadow: 0 1px 3px rgba(0 0 0 / 10%);
border-radius: 0 0 $select-border-radius $select-border-radius;


[data-selectable] {
cursor: pointer;
overflow: hidden;

.highlight {
background: $select-color-highlight;
border-radius: 1px;
Expand Down Expand Up @@ -55,6 +55,7 @@
.active {
background-color: $select-color-dropdown-item-active;
color: $select-color-dropdown-item-active-text;

&.create {
color: $select-color-dropdown-item-create-active-text;
}
Expand All @@ -71,7 +72,7 @@
margin: $select-padding-dropdown-item-y $select-padding-dropdown-item-x;


&:after {
&::after {
content: " ";
display: block;
width: $select-spinner-size * .8;
Expand All @@ -82,10 +83,12 @@
border-color: $select-spinner-border-color transparent $select-spinner-border-color transparent;
animation: lds-dual-ring 1.2s linear infinite;
}

@keyframes lds-dual-ring {
0% {
transform: rotate(0deg);
}

100% {
transform: rotate(360deg);
}
Expand All @@ -97,6 +100,5 @@
overflow-y: auto;
overflow-x: hidden;
max-height: $select-max-height-dropdown;
overflow-scrolling: touch;
scroll-behavior: smooth;
}
8 changes: 4 additions & 4 deletions src/scss/_items.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@


.#{$select-ns}-control {

border: $select-border;
padding: $select-padding-y $select-padding-x;
width: 100%;
Expand All @@ -18,6 +17,7 @@
$padding-x: $select-padding-x;
$padding-top: calc( #{$select-padding-y} - #{$select-padding-item-y} - #{$select-width-item-border});
$padding-bottom: calc( #{$select-padding-y} - #{$select-padding-item-y} - #{$select-margin-item-y} - #{$select-width-item-border});

padding: $padding-top $padding-x $padding-bottom;
}

Expand Down Expand Up @@ -56,9 +56,9 @@

.#{$select-ns}-wrapper.multi.disabled & > div {
&, &.active {
color: lighten(desaturate($select-color-item-text, 100%), $select-lighten-disabled-item-text);
background: lighten(desaturate($select-color-item, 100%), $select-lighten-disabled-item);
border: $select-width-item-border solid lighten(desaturate($select-color-item-border, 100%), $select-lighten-disabled-item-border);
color: color.adjust(color.adjust($select-color-item-text, $saturation: -100%), $lightness: $select-lighten-disabled-item-text);
background: color.adjust(color.adjust($select-color-item, $saturation: -100%), $lightness: $select-lighten-disabled-item);
border: $select-width-item-border solid color.adjust(color.adjust($select-color-item-border, $saturation: -100%), $lightness: $select-lighten-disabled-item-border);
}
}

Expand Down
92 changes: 52 additions & 40 deletions src/scss/tom-select.bootstrap4.scss
Original file line number Diff line number Diff line change
@@ -1,34 +1,36 @@
/**
* Tom Select bootstrap 4
*/
@use "sass:color";
@use "sass:map";

//Import Boostrap 4 functions and variables
// Import Boostrap 4 functions and variables

$state-valid: map-get($form-validation-states,'valid') !default;
$state-invalid: map-get($form-validation-states,'invalid') !default;
$state-valid: map.get($form-validation-states,'valid') !default;
$state-invalid: map.get($form-validation-states,'invalid') !default;

$enable-shadows: true !default;
$select-font-family: inherit !default;
$select-font-size: inherit !default;
$select-line-height: $input-btn-line-height !default; //formerly line-height-computed
$select-line-height: $input-btn-line-height !default; // formerly line-height-computed

$select-color-text: gray("800") !default; //$gray-800
$select-color-highlight: rgba(255,237,40,0.4) !default;
$select-color-text: gray("800") !default; // $gray-800
$select-color-highlight: rgb(255 237 40 / 40%) !default;
$select-color-input: $input-bg !default;
$select-color-input-full: $input-bg !default;
$select-color-input-error: map-get($state-invalid,'color') !default;
$select-color-input-error-focus: darken($select-color-input-error, 10%) !default;
$select-color-input-error: map.get($state-invalid,'color') !default;
$select-color-input-error-focus: color.adjust($select-color-input-error, $lightness: -10%) !default;
$select-color-disabled: $input-disabled-bg !default;
$select-color-item: #efefef !default;
$select-color-item-border: $border-color !default;
$select-color-item-active: $component-active-bg !default;
$select-color-item-active-text: #fff !default;
$select-color-item-active-border: rgba(0,0,0,0) !default;
$select-color-item-active-border: rgb(0 0 0 / 0%) !default;
$select-color-optgroup: $dropdown-bg !default;
$select-color-optgroup-text: $dropdown-header-color !default;
$select-color-optgroup-border: $dropdown-divider-bg !default;
$select-color-dropdown: $dropdown-bg !default;
$select-color-dropdown-border-top: mix($input-border-color, $input-bg, 0.8) !default;
$select-color-dropdown-border-top: color.mix($input-border-color, $input-bg, 80%) !default;
$select-color-dropdown-item-active: $dropdown-link-hover-bg !default;
$select-color-dropdown-item-active-text: $dropdown-link-hover-color !default;
$select-color-dropdown-item-create-active-text: $dropdown-link-hover-color !default;
Expand All @@ -37,7 +39,7 @@ $select-opacity-disabled: 0.5 !default;
$select-border: 1px solid $input-border-color !default;
$select-border-radius: $input-border-radius !default;

$select-width-item-border: 0px !default;
$select-width-item-border: 0 !default;
$select-padding-x: $input-btn-padding-x !default;
$select-padding-y: $input-btn-padding-y !default;
$select-padding-dropdown-item-x: $input-btn-padding-x !default;
Expand All @@ -53,7 +55,7 @@ $select-arrow-offset: calc(#{$select-padding-x} + 5px) !default;


@import "tom-select";
@include ts-caret();
@include ts-caret;

.#{$select-ns}-wrapper.form-control,
.#{$select-ns}-wrapper.form-select{
Expand All @@ -66,28 +68,34 @@ $select-arrow-offset: calc(#{$select-padding-x} + 5px) !default;
padding: 0;
z-index: $zindex-dropdown;
background: $select-color-dropdown;
border: 1px solid $dropdown-border-color; //$dropdown-fallback-border
border: 1px solid $dropdown-border-color; // $dropdown-fallback-border
border-radius: $border-radius;
box-shadow: 0 6px 12px rgba(0,0,0,.175);
box-shadow: 0 6px 12px rgb(0 0 0 / 17.5%);
}

.#{$select-ns}-dropdown {
.optgroup-header {
font-size: $font-size-sm;
line-height: $line-height-base;
}
.optgroup:first-child:before {
display: none;
}
.optgroup:before {
content: ' ';
display: block;
height: 0;
margin: $dropdown-divider-margin-y 0;
overflow: hidden;
border-top: 1px solid $dropdown-divider-bg;
margin-left: $select-padding-dropdown-item-x * -1;
margin-right: $select-padding-dropdown-item-x * -1;

.optgroup {
&:first-child {
&::before {
display: none;
}
}

&::before {
content: ' ';
display: block;
height: 0;
margin: $dropdown-divider-margin-y 0;
overflow: hidden;
border-top: 1px solid $dropdown-divider-bg;
margin-left: $select-padding-dropdown-item-x * -1;
margin-right: $select-padding-dropdown-item-x * -1;
}
}

.create {
Expand All @@ -100,15 +108,17 @@ $select-arrow-offset: calc(#{$select-padding-x} + 5px) !default;
}

.#{$select-ns}-control {
min-height: $input-height;
@include box-shadow($input-box-shadow);
@include transition($input-transition);

min-height: $input-height;
display:flex;
align-items: center;

.focus & {
border-color: $input-focus-border-color;
outline: 0;

@if $enable-shadows {
box-shadow: $input-box-shadow, $input-focus-box-shadow;
} @else {
Expand All @@ -128,8 +138,8 @@ $select-arrow-offset: calc(#{$select-padding-x} + 5px) !default;
}

.is-valid .#{$select-ns}-control{
$_color: map-get($state-valid,'color');
//$_icon: map-get($state-valid,'icon');
// $_icon: map.get($state-valid, 'icon');
$_color: map.get($state-valid, 'color'); /* stylelint-disable-line scss/dollar-variable-pattern */

border-color: $_color;

Expand All @@ -140,16 +150,14 @@ $select-arrow-offset: calc(#{$select-padding-x} + 5px) !default;
}

.#{$select-ns}-wrapper {

.input-group-sm > &,
&.form-control-sm{

.#{$select-ns}-control{
min-height: $input-height-sm;
padding: 0 .75rem;
//padding: $input-padding-y-sm $input-padding-x-sm;
.#{$select-ns}-control {
@include border-radius($input-border-radius-sm);
@include font-size($input-font-size-sm);

min-height: $input-height-sm;
padding: 0 .75rem; // padding: $input-padding-y-sm $input-padding-x-sm;
}

&.has-items .#{$select-ns}-control{
Expand All @@ -166,17 +174,20 @@ $select-arrow-offset: calc(#{$select-padding-x} + 5px) !default;
// padding-top = ($input-height-sm - border-width - item-height) / 2;
// item-height = ($select-line-height * $input-font-size-sm) + ($select-padding-item-y * 2)
$border-and-padding: add($input-border-width,$select-padding-item-y) * 2;
$ts-select-padding-sm: calc( (#{$input-height-sm} - (#{$select-line-height} * #{$input-font-size-sm}) - #{$border-and-padding})/2);
$ts-select-padding-sm: calc((#{$input-height-sm} - (#{$select-line-height} * #{$input-font-size-sm}) - #{$border-and-padding}) / 2);

padding-top: $ts-select-padding-sm !important;
}
}


&.multi {
&.has-items .#{$select-ns}-control {
padding-left: calc(#{$select-padding-x} - #{$select-padding-item-x});
--ts-pr-min: calc(#{$select-padding-x} - #{$select-padding-item-x});

padding-left: calc(#{$select-padding-x} - #{$select-padding-item-x});
}

.#{$select-ns}-control > div {
border-radius: calc(#{$select-border-radius} - 1px);
}
Expand All @@ -185,9 +196,10 @@ $select-arrow-offset: calc(#{$select-padding-x} + 5px) !default;
.input-group-lg > & >,
&.form-control-lg{
.#{$select-ns}-control{
min-height: $input-height-lg;
@include border-radius($input-border-radius-lg);
@include font-size($input-font-size-lg);

min-height: $input-height-lg;
}
}
}
Expand All @@ -197,12 +209,12 @@ $select-arrow-offset: calc(#{$select-padding-x} + 5px) !default;
height: auto;
border: none;
background: none;
//box-shadow: none;
border-radius: 0;

// box-shadow: none;
}

.input-group{

& > .#{$select-ns}-wrapper{
flex-grow: 1;
}
Expand Down
Loading