From dd6d18626f90a6d956ac4e7c75b007285da40a23 Mon Sep 17 00:00:00 2001 From: Erik Harper Date: Wed, 20 May 2020 11:48:15 -0700 Subject: [PATCH 01/52] Adding hasHistogram prop for use in css later --- src/components/calcite-slider/calcite-slider.tsx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/components/calcite-slider/calcite-slider.tsx b/src/components/calcite-slider/calcite-slider.tsx index 3096ef4a1aa..7d354f99f0b 100644 --- a/src/components/calcite-slider/calcite-slider.tsx +++ b/src/components/calcite-slider/calcite-slider.tsx @@ -10,6 +10,7 @@ import { h, State, VNode, + Watch, } from "@stencil/core"; import { guid } from "../../utils/guid"; import { getKey } from "../../utils/key"; @@ -68,6 +69,11 @@ export class CalciteSlider { @Prop() precise?: boolean; /** Display a histogram above the slider */ @Prop() histogram?: DataSeries; + @Watch("histogram") histogramWatcher(newHistogram) { + this.hasHistogram = newHistogram ? true : false; + } + /** Indicates if a histogram is present */ + @Prop({ reflect: true, mutable: true }) hasHistogram: boolean = false; //-------------------------------------------------------------------------- // // Lifecycle @@ -80,6 +86,9 @@ export class CalciteSlider { if (this.snap) { this.value = this.getClosestStep(this.value); } + if (this.histogram) { + this.hasHistogram = true; + } this.calciteSliderUpdate.emit(); } From 0a978e836803fc0f0287f3e75bc2290a4d2deafc Mon Sep 17 00:00:00 2001 From: Erik Harper Date: Wed, 20 May 2020 15:15:56 -0700 Subject: [PATCH 02/52] refactor: replacing borders with box-shadow and increasing the hitbox of the value/maxValue handle with the :after trick. This commit breaks the minValue handle, but we'll fix that in the next commit --- .../calcite-slider/calcite-slider.scss | 65 ++++++++++--------- 1 file changed, 34 insertions(+), 31 deletions(-) diff --git a/src/components/calcite-slider/calcite-slider.scss b/src/components/calcite-slider/calcite-slider.scss index 0aa119fd9cb..83d868a67dc 100644 --- a/src/components/calcite-slider/calcite-slider.scss +++ b/src/components/calcite-slider/calcite-slider.scss @@ -43,40 +43,49 @@ $tick-height: 4px; margin-bottom: $thumb-size + $thumb-padding; } -// focus styles -.thumb { - @include focus-style-base(); - &:focus { - @include focus-style-outset(); - } -} - .thumb { position: absolute; - height: $thumb-size; - width: $thumb-size; - margin: -15px; + top: -5px; box-sizing: border-box; border: none; background: transparent; cursor: pointer; font-family: inherit; z-index: 2; -} + outline: none; -.handle { - position: absolute; - top: 0; - left: 0; - height: $handle-size; - width: $handle-size; - margin: $thumb-padding; - box-sizing: border-box; - border-radius: 100%; - background-color: var(--calcite-ui-foreground-1); - border: 2px solid var(--calcite-ui-text-3); - transition: border 0.25s ease, background-color 0.25s ease, - box-shadow 0.25s ease; + .handle { + @include focus-style-base(); + position: absolute; + top: 6px; + height: $handle-size; + width: $handle-size; + box-sizing: border-box; + border-radius: 100%; + background-color: var(--calcite-ui-foreground-1); + box-shadow: 0 0 0 2px var(--calcite-ui-text-3) inset; + transition: border 0.25s ease, background-color 0.25s ease, + box-shadow 0.25s ease; + &:after { + content: ""; + position: absolute; + top: -6px; + left: -6px; + width: 26px; + height: 26px; + } + } + + &:hover { + .handle { + box-shadow: 0 0 0 3px var(--calcite-ui-blue-1) inset; + } + } + + &:focus .handle { + @include focus-style-outset(); + outline-offset: 6px; + } } .handle__label { @@ -92,12 +101,6 @@ $tick-height: 4px; text-align: center; } -.thumb:hover .handle { - border-width: 3px; - border-color: var(--calcite-ui-blue-1); - @include shadow(1, "hover"); -} - .thumb:focus, .thumb--active { z-index: 3; From 61156752ad75e7626a97f6baffe3479d46097f1a Mon Sep 17 00:00:00 2001 From: Erik Harper Date: Wed, 20 May 2020 15:41:35 -0700 Subject: [PATCH 03/52] fixing the minValue handle position post-refactor --- src/components/calcite-slider/calcite-slider.scss | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/components/calcite-slider/calcite-slider.scss b/src/components/calcite-slider/calcite-slider.scss index 83d868a67dc..3b830e1561d 100644 --- a/src/components/calcite-slider/calcite-slider.scss +++ b/src/components/calcite-slider/calcite-slider.scss @@ -46,7 +46,6 @@ $tick-height: 4px; .thumb { position: absolute; top: -5px; - box-sizing: border-box; border: none; background: transparent; cursor: pointer; @@ -75,6 +74,9 @@ $tick-height: 4px; height: 26px; } } + &.thumb--min .handle { + left: -7px; + } &:hover { .handle { From 414c1791d2a50341ce49846e5a8891737cb45742 Mon Sep 17 00:00:00 2001 From: Erik Harper Date: Thu, 21 May 2020 14:45:30 -0700 Subject: [PATCH 04/52] fix: handles not perfectly centered at both ends of the track --- src/components/calcite-slider/calcite-slider.scss | 5 +++-- src/demos/calcite-slider.html | 5 ++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/components/calcite-slider/calcite-slider.scss b/src/components/calcite-slider/calcite-slider.scss index 3b830e1561d..7d4fe0f61f7 100644 --- a/src/components/calcite-slider/calcite-slider.scss +++ b/src/components/calcite-slider/calcite-slider.scss @@ -45,18 +45,19 @@ $tick-height: 4px; .thumb { position: absolute; - top: -5px; border: none; background: transparent; cursor: pointer; font-family: inherit; z-index: 2; outline: none; + padding: 0; .handle { @include focus-style-base(); position: absolute; - top: 6px; + top: -8px; + left: -7px; height: $handle-size; width: $handle-size; box-sizing: border-box; diff --git a/src/demos/calcite-slider.html b/src/demos/calcite-slider.html index 2ff9fb90187..33f0fe5bc4b 100644 --- a/src/demos/calcite-slider.html +++ b/src/demos/calcite-slider.html @@ -27,7 +27,10 @@

Calcite Slider

Single Value

- +
+ + +

Disabled

From fae8d404ea268891fc1c22204c78a6a03c54134d Mon Sep 17 00:00:00 2001 From: Erik Harper Date: Fri, 22 May 2020 09:03:29 -0700 Subject: [PATCH 05/52] Attempt at using getBoundingClientRect to change positioning --- .../calcite-slider/calcite-slider.scss | 12 +++-- .../calcite-slider/calcite-slider.tsx | 52 ++++++++++++++++++- src/demos/calcite-slider.html | 8 ++- 3 files changed, 61 insertions(+), 11 deletions(-) diff --git a/src/components/calcite-slider/calcite-slider.scss b/src/components/calcite-slider/calcite-slider.scss index 7d4fe0f61f7..d9de2d49bba 100644 --- a/src/components/calcite-slider/calcite-slider.scss +++ b/src/components/calcite-slider/calcite-slider.scss @@ -93,15 +93,17 @@ $tick-height: 4px; .handle__label { position: absolute; - left: 0; - bottom: $thumb-size; - width: $thumb-size; - height: 0.75em; + bottom: 14px; @include font-size(-3); font-weight: 500; line-height: 1; color: var(--calcite-ui-text-3); - text-align: center; + &--visible { + left: 0; + } + &--obscured { + right: -7px; + } } .thumb:focus, diff --git a/src/components/calcite-slider/calcite-slider.tsx b/src/components/calcite-slider/calcite-slider.tsx index 7d354f99f0b..dcfd083ba02 100644 --- a/src/components/calcite-slider/calcite-slider.tsx +++ b/src/components/calcite-slider/calcite-slider.tsx @@ -100,6 +100,10 @@ export class CalciteSlider { const left = `${this.getUnitInterval(min) * 100}%`; const right = `${100 - this.getUnitInterval(max) * 100}%`; + console.clear(); + const isLabelOutOfViewport = this.handleLabelOutOfViewport(); + console.log(`render ${isLabelOutOfViewport}`); + return ( {this.renderGraph()} @@ -196,7 +200,14 @@ export class CalciteSlider { > {this.labelHandles ? ( - ); } diff --git a/src/demos/calcite-slider.html b/src/demos/calcite-slider.html index 91d626a89ca..f53ad08a1ad 100644 --- a/src/demos/calcite-slider.html +++ b/src/demos/calcite-slider.html @@ -43,10 +43,22 @@

Precise Labeled Handle

Ticks

- + + +

Ticks with Labeled Handle

+ + +

Ticks with Precise Handle

+ + +

Ticks with Precise Labeled Handle

+

Labeled Ticks

- + + +

Labeled Ticks with Labeled Handle

+

Labeled Ticks with Precise Handle

@@ -63,26 +75,38 @@

Disabled

Histogram

-

Histogram Labeled Handle

+

Histogram with Labeled Handle

-

Histogram Precise Handle

+

Histogram with Precise Handle

-

Histogram Precise Labeled Handle

+

Histogram with Precise Labeled Handle

-

Histogram Ticks

+

Histogram with Ticks

-

Histogram Labeled Ticks

+

Histogram with Ticks and Labeled Handle

+ + +

Histogram with Ticks and Precise Handle

+ + +

Histogram with Ticks and Labeled Precise Handle

+ + +

Histogram with Labeled Ticks

-

Histogram Labeled Ticks with Precise Handle

+

Histogram with Labeled Ticks and Labeled Handle

+ + +

Histogram with Labeled Ticks and Precise Handle

-

Histogram Labeled Ticks with Precise Labeled Handle

+

Histogram with Labeled Ticks and Precise Labeled Handle

@@ -112,20 +136,30 @@

Ticks

+

Ticks with Labeled Handles

+ +

Ticks with Precise Handles

+

Ticks with Precise Labeled Handles

+ + +

Labeled Ticks

+

Labeled Ticks with Labeled Handles

+ +

Labeled Ticks with Precise Handles

Labeled Ticks with Precise Labeled Handles

-
@@ -134,38 +168,52 @@

Histogram

-

Histogram Labeled Handles

+

Histogram with Labeled Handles

-

Histogram Precise Handles

+

Histogram with Precise Handles

-

Histogram Precise Labeled Handles

+

Histogram with Precise Labeled Handles

-

Histogram Ticks

+

Histogram with Ticks

-

Histogram Ticks with Precise Handles

+

Histogram with Ticks and Labeled Handles

+ + +

Histogram with Ticks and Precise Handles

-

Histogram Labeled Ticks

+

Histogram with Ticks and Precise Labeled Handles

+ + + +

Histogram with Labeled Ticks

-

Histogram Labeled Ticks with Precise Handles

+

Histogram with Labeled Ticks and Labeled Handles

+ + + +

Histogram with Labeled Ticks and Precise Handles

-

Histogram Labeled Ticks with Precise Labeled Handles

+

Histogram with Labeled Ticks and Precise Labeled Handles

From 29b0c920318390a57b08b86a46d2b22470ccfe81 Mon Sep 17 00:00:00 2001 From: Erik Harper Date: Thu, 4 Jun 2020 16:09:17 -0700 Subject: [PATCH 29/52] fix: moving all histogram labels and precise handles below track --- .../calcite-slider/calcite-slider.scss | 32 ++++++++++++++ .../calcite-slider/calcite-slider.tsx | 43 ++++++++++++++++--- src/demos/calcite-slider.html | 2 +- 3 files changed, 69 insertions(+), 8 deletions(-) diff --git a/src/components/calcite-slider/calcite-slider.scss b/src/components/calcite-slider/calcite-slider.scss index 9ac76df2dd1..939a06f85ca 100644 --- a/src/components/calcite-slider/calcite-slider.scss +++ b/src/components/calcite-slider/calcite-slider.scss @@ -143,6 +143,14 @@ $tick-height: 4px; } } } +:host([has-histogram][precise]) { + .thumb { + transform: translate(7px, -2px); + } + .thumb--min { + transform: translate(-50%, -2px); + } +} :host([precise][ticks]) { .thumb { transform: translate(7px, -20px); @@ -151,6 +159,14 @@ $tick-height: 4px; transform: translate(-7px, -3px); } } +:host([has-histogram][precise][ticks]) { + .thumb { + transform: translate(7px, -3px); + } + .thumb--min { + transform: translate(-50%, -3px); + } +} :host([precise][label-handles]) { .thumb { transform: translate(50%, -39px); @@ -159,6 +175,14 @@ $tick-height: 4px; transform: translate(-50%, -2px); } } +:host([has-histogram][precise][label-handles]) { + .thumb { + transform: translate(7px, -2px); + } + .thumb--min { + transform: translate(-50%, -2px); + } +} :host([precise][ticks][label-handles]) { .thumb { transform: translate(50%, -38px); @@ -167,6 +191,14 @@ $tick-height: 4px; transform: translate(-50%, -3px); } } +:host([has-histogram][precise][ticks][label-handles]) { + .thumb { + transform: translate(50%, -3px); + } + .thumb--min { + transform: translate(-50%, -3px); + } +} :host([has-histogram][precise][label-handles][is-range]) { .thumb { transform: translate(50%, -2px); diff --git a/src/components/calcite-slider/calcite-slider.tsx b/src/components/calcite-slider/calcite-slider.tsx index fa62629d589..d7502a42a73 100644 --- a/src/components/calcite-slider/calcite-slider.tsx +++ b/src/components/calcite-slider/calcite-slider.tsx @@ -239,6 +239,34 @@ export class CalciteSlider { ); + const histogramPreciseHandle = ( + + ); + const labeledPreciseHandle = (
-
+
+

Scale s

- Stencil + Stencil + React Ember - Angular + Angular +
@@ -166,100 +184,142 @@

Scale s

Stencil React - Ember - Angular + Ember + + Angular +

Scale m (default)

- Stencil + Stencil + React Ember Angular
- Stencil - React - Ember - Angular + Stencil + + React + + Ember + + Angular +

Scale l

- Stencil - React - Ember - Angular + Stencil + + React + Ember + Angular + -
+
- Stencil - React - Ember - Angular + + Stencil + + React + Ember + + Angular +

Uses value as label if missing

- - - + + + -
+
- - - + + + + + +

None checked

- - - + + + -
+
- - - + + + + + +

Only one checked value (first wins, first two checked)

- - - + + + + + -
+
- - - + + + + +

Only one checked value (first wins, second two checked)

- - - + + + + + + -
+
- - - + + + + +

Only one checked value (first wins, first and last checked)

- - - + + + + + + -
+
- - - + + +

Only one checked value (first wins, all checked)

- - - + + + + + + -
+
- - - + + + + +
diff --git a/src/demos/calcite-slider.html b/src/demos/calcite-slider.html index c842de458d6..6b4945e1917 100644 --- a/src/demos/calcite-slider.html +++ b/src/demos/calcite-slider.html @@ -7,11 +7,25 @@ Calcite Slider