diff --git a/ui/app/components/stepper-input.js b/ui/app/components/stepper-input.js index eeef1c3bb..09db48532 100644 --- a/ui/app/components/stepper-input.js +++ b/ui/app/components/stepper-input.js @@ -2,13 +2,14 @@ import Component from '@ember/component'; import { action } from '@ember/object'; import { debounce } from '@ember/runloop'; import { oneWay } from '@ember/object/computed'; -import { classNames } from '@ember-decorators/component'; +import { classNames, classNameBindings } from '@ember-decorators/component'; import classic from 'ember-classic-decorator'; const ESC = 27; @classic @classNames('stepper-input') +@classNameBindings('class') export default class StepperInput extends Component { min = 0; max = 10; @@ -21,13 +22,6 @@ export default class StepperInput extends Component { // On onChange which is debounced. @oneWay('value') internalValue; - // text change: debounce set value if value changed - // debouncing here means when the text input blurs to click a button - // things don't get weird and send two change events - // text focus ESC: revert value - // - // Also add the xsmall button to the existing button story - @action increment() { if (this.internalValue < this.max) { diff --git a/ui/app/styles/components.scss b/ui/app/styles/components.scss index 1bfd76d9b..6f70cceef 100644 --- a/ui/app/styles/components.scss +++ b/ui/app/styles/components.scss @@ -27,6 +27,7 @@ @import './components/search-box'; @import './components/simple-list'; @import './components/status-text'; +@import './components/stepper-input'; @import './components/timeline'; @import './components/toggle'; @import './components/toolbar'; diff --git a/ui/app/styles/components/stepper-input.scss b/ui/app/styles/components/stepper-input.scss new file mode 100644 index 000000000..3d48f91ea --- /dev/null +++ b/ui/app/styles/components/stepper-input.scss @@ -0,0 +1,78 @@ +.stepper-input { + display: inline-flex; + font-weight: $weight-bold; + box-shadow: $button-box-shadow-standard; + border: 1px solid transparent; + text-decoration: none; + line-height: 1; + border-radius: $radius; + padding-left: 0.75em; + whitespace: nowrap; + height: 2.25em; + + .stepper-input-label { + display: flex; + align-self: center; + padding-right: 0.75em; + } + + .stepper-input-input { + display: flex; + text-align: center; + font-weight: bold; + -moz-appearance: textfield; + width: 3em; + + &::-webkit-outer-spin-button, + &::-webkit-inner-spin-button { + -webkit-appearance: none; + margin: 0; + } + + &:focus { + outline: none; + box-shadow: inset 0 0 0 1px $grey-light; + } + } + + .stepper-input-input, + .stepper-input-stepper { + border: none; + border-left: 1px solid; + } + + .stepper-input-stepper { + box-shadow: none; + display: flex; + height: 100%; + border-radius: 0; + + &:last-child { + border-top-right-radius: $radius; + border-bottom-right-radius: $radius; + } + } + + @each $name, $pair in $colors { + $color: nth($pair, 1); + $color-invert: nth($pair, 2); + + &.is-#{$name} { + border-color: darken($color, 10%); + background: $color; + color: $color-invert; + + .stepper-input-input, + .stepper-input-stepper { + border-left-color: darken($color, 5%); + } + + .stepper-input-stepper.is-#{$name} { + &:focus { + outline: none; + box-shadow: inset 0 0 0 1px rgba($white, 0.4); + } + } + } + } +} diff --git a/ui/app/templates/components/stepper-input.hbs b/ui/app/templates/components/stepper-input.hbs index 708276d45..346316426 100644 --- a/ui/app/templates/components/stepper-input.hbs +++ b/ui/app/templates/components/stepper-input.hbs @@ -1,21 +1,22 @@ - +
External Value: {{value}}
`, @@ -22,6 +42,7 @@ export let Standard = () => { min: 0, max: 10, value: 5, + variant: variantKnob(), }, }; };