Skip to content

Commit

Permalink
Finish formatting JS file + clean up Sass variables modifications
Browse files Browse the repository at this point in the history
  • Loading branch information
julien-deramond committed Feb 24, 2022
1 parent 1dca654 commit bbe452a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 28 deletions.
44 changes: 22 additions & 22 deletions js/src/quantity-selector.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,25 @@ class QuantitySelector extends BaseComponent {
return NAME
}

// Public
ValueOnLoad(element) {
const counterInput = element.querySelector(SELECTOR_COUNTER_INPUT)
const btnUp = element.querySelector(SELECTOR_STEP_UP_BUTTON)
const btnDown = element.querySelector(SELECTOR_STEP_DOWN_BUTTON)

const min = counterInput.getAttribute('min')
const max = counterInput.getAttribute('max')
const step = Number(counterInput.getAttribute('step'))

if (Number(counterInput.value) - step < min) {
btnDown.setAttribute('disabled', '')
}

if (Number(counterInput.value) + step > max) {
btnUp.setAttribute('disabled', '')
}
}

// Static
static StepUp(event) {
event.preventDefault()
Expand Down Expand Up @@ -65,25 +84,6 @@ class QuantitySelector extends BaseComponent {
}
}

// Public
ValueOnLoad(element) {
const counterInput = element.querySelector(SELECTOR_COUNTER_INPUT)
const BTN_UP = element.querySelector(SELECTOR_STEP_UP_BUTTON)
const BTN_DOWN = element.querySelector(SELECTOR_STEP_DOWN_BUTTON)

const MIN = counterInput.getAttribute('min')
const MAX = counterInput.getAttribute('max')
const STEP = Number(counterInput.getAttribute('step'))

if (Number(counterInput.value) - STEP < MIN) {
BTN_DOWN.setAttribute('disabled', '')
}

if (Number(counterInput.value) + STEP > MAX) {
BTN_UP.setAttribute('disabled', '')
}
}

static StepDown(event) {
event.preventDefault()
const parent = event.target.closest(SELECTOR_INPUT_GROUP)
Expand Down Expand Up @@ -119,16 +119,16 @@ class QuantitySelector extends BaseComponent {

const min = counterInput.getAttribute('min')
const max = counterInput.getAttribute('max')
const STEP = Number(counterInput.getAttribute('step'))
const step = Number(counterInput.getAttribute('step'))

btnUp.removeAttribute('disabled', '')
btnDown.removeAttribute('disabled', '')

if (Number(counterInput.value) - STEP < min) {
if (Number(counterInput.value) - step < min) {
btnDown.setAttribute('disabled', '')
}

if (Number(counterInput.value) + STEP > max) {
if (Number(counterInput.value) + step > max) {
btnUp.setAttribute('disabled', '')
}
}
Expand Down
10 changes: 4 additions & 6 deletions scss/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -936,14 +936,14 @@ $form-label-disabled-color: $gray-500 !default; // Boosted mod
// scss-docs-start form-input-variables
$input-padding-y: $input-btn-padding-y !default;
$input-padding-x: $spacer * .5 !default;
$input-padding-y-sm: divide($input-padding-y, 2) !default;
$input-padding-x-sm: divide($input-padding-y, 2) !default;
$input-font-family: $input-btn-font-family !default;
$input-font-size: $input-btn-font-size !default;
$input-font-weight: $font-weight-bold !default;
$input-line-height: $input-btn-line-height !default;

// Boosted mod: no input-sm
$input-padding-y-sm: divide($input-padding-y, 2) !default; // Boosted mod
$input-padding-x-sm: divide($input-padding-y, 2) !default; // Boosted mod
// Boosted mod: no $input-font-size-sm

$input-padding-y-lg: $input-btn-padding-y-lg !default;
$input-padding-x-lg: $input-btn-padding-x-lg !default;
Expand Down Expand Up @@ -975,15 +975,13 @@ $input-plaintext-color: $body-color !default;
// Boosted mod: no $input-height-inner-*

$input-height: 2.5rem !default;
// Boosted mod: no input-sm
// Boosted mod: no $input-height-sm
$input-height-lg: 3.125rem !default;
$input-line-height-lg: $h5-line-height !default; // Boosted mod

$input-transition: border-color $transition-duration $transition-timing, $transition-focus !default;

$form-color-width: 3rem !default;
// End mod

// scss-docs-end form-input-variables

// scss-docs-start form-check-variables
Expand Down

0 comments on commit bbe452a

Please sign in to comment.