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

V4.1: Custom range control #23380

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 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
14 changes: 14 additions & 0 deletions docs/4.0/components/forms.md
Original file line number Diff line number Diff line change
Expand Up @@ -989,6 +989,20 @@ Custom `<select>` menus need only a custom class, `.custom-select` to trigger th
</select>
{% endexample %}

### Range control

Custom `<input type="range">` controls need only a custom class, `.custom-range` to trigger the custom styles.

{% example html %}
<input type="range" class="custom-range">
{% endexample %}

Additionally you can add steps by defining `min` and `max` attributes.

{% example html %}
<input type="range" class="custom-range" min="0" max="5">
{% endexample %}

### File browser

The file input is the most gnarly of the bunch and require additional JavaScript if you'd like to hook them up with functional *Choose file...* and selected file name text.
Expand Down
102 changes: 102 additions & 0 deletions scss/_custom-forms.scss
Original file line number Diff line number Diff line change
Expand Up @@ -253,3 +253,105 @@
}
}
}

// Range
//
// Replace the browser default range with a custom one.
.custom-range {
width: 100%;
padding-left: 0;
background-color: transparent;
-webkit-appearance: none;

&:focus {
outline: none;

&::-webkit-slider-thumb, &::-moz-range-thumb, &::-ms-thumb {
box-shadow: $custom-control-indicator-focus-box-shadow;
}
}

&::-moz-focus-inner, &:-moz-focusring {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we have one rule per line so try updating your patch.

border: 0;
outline: none;
}

&:active {

&::-webkit-slider-thumb, &::-moz-range-thumb, &::-ms-thumb {
background-color: $custom-control-indicator-active-bg;
}
}

// webkit styling
&::-webkit-slider-thumb {
width: $custom-control-indicator-size;
height: $custom-control-indicator-size;
margin-top: -($custom-control-indicator-size * .25);
background-color: $custom-control-indicator-checked-bg;
border: 0;
border-radius: $custom-control-indicator-size;
-webkit-appearance: none;
}

&::-webkit-slider-runnable-track {
width: 100%;
height: $custom-control-indicator-size * .5;
color: transparent;
cursor: pointer;
background-color: $custom-control-indicator-bg;
border-color: transparent;
border-radius: $custom-control-indicator-size;
}

// firefox styling
&::-moz-range-thumb {
width: $custom-control-indicator-size;
height: $custom-control-indicator-size;
background-color: $custom-control-indicator-checked-bg;
border: 0;
border-radius: $custom-control-indicator-size;
-webkit-appearance: none;
}

&::-moz-range-track {
width: 100%;
height: $custom-control-indicator-size * .5;
color: transparent;
cursor: pointer;
background-color: $custom-control-indicator-bg;
border-color: transparent;
border-radius: $custom-control-indicator-size;
}

// IE styling
&::-ms-thumb {
width: $custom-control-indicator-size;
height: $custom-control-indicator-size;
background-color: $custom-control-indicator-checked-bg;
border: 0;
border-radius: $custom-control-indicator-size;
-webkit-appearance: none;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this should be unprefixed and let autoprefixer do its thing. The same goes for other prefixes.

}

&::-ms-track {
width: 100%;
height: $custom-control-indicator-size * .5;
color: transparent;
cursor: pointer;
background-color: transparent;
border-color: transparent;
border-width: ($custom-control-indicator-size * .5);
}

&::-ms-fill-lower {
background-color: $custom-control-indicator-bg;
border-radius: $custom-control-indicator-size;
}

&::-ms-fill-upper {
margin-right: 15px;
background-color: $custom-control-indicator-bg;
border-radius: $custom-control-indicator-size;
}
}