-
-
Notifications
You must be signed in to change notification settings - Fork 230
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
Improve range-field #1016
Improve range-field #1016
Conversation
Adds some JS (2.04 KB), SCSS (6.87 KB), and changed Twig to improve the functionality and styling of the range-field.
I haven't tested it but on first review this looks good! This is so the vendor and the admin are kept separated. Cheers |
There, added |
That should be enough |
@OleVik can you re-merge? compiled css is conflicting.. cheers. |
That should do it, I think. |
I'm having a little problem with this: First i set
Then I reloaded the page and tested. First it didn't quite render the same as your screenshots. When i tried to change the range with the numeric input, i got errors, and updating the slider caused the same thing: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ole, please see my comments in the conversation. I can't get this to work. not sure if i'm doing something wrong or if the range field expects something i'm not using. It should not need an ID for example.
This is "simply" because |
Replaces dots with underscores for id-attributes within the field.
Looks good, are those appends still accessible as number-type inputs? One previous problem was that there was no granular control of the selected number. |
its just a text input you can put after.. the counter/numeric is still a number field, just right aligned so it's more flush with the append (if provided) |
Looking forward to using it and releasing new versions of plugins without the custom form. 1.3.0 looks to be just around the corner. |
Adds rangetouch.js (2.04 KB minified, pure JS), some SCSS (6.87 KB compiled minified, source), and changed Twig to improve the functionality and styling of the range-field. Notes:
As remarked in #995, there is near-universal support for the input-types (input-range, input-number), but on native touch-devices behavior does not always meet expectations. This is helped by Rangetouch.js, which is added as a dependency in package.json.
Most of the weight of the CSS (5.20 KB) is a generated
box-shadow
-property which enables the filled/unfilled appearance of the slider. CSS is vendor-prefixed for cross-browser compatibility. The entirety of SCSS is inthemes/grav/scss/template/modules/_input-range.scss
, imported at the end ofthemes/grav/scss/preset.scss
. This was the simplest way of inheriting the theme's default variables for colors, but I'd happily restructure it for better organization. SCSS variables are prefixed withrangefield-
and styles nested in arangefield
-class to avoid future conflicts.Width is the same as the
colorpicker
-field (230px), and number-input width is set to hold up to four integers. This ensures that the input-tags remain on the same line even on smaller resolutions. Thumb size is 2.125em x 2.125em, and slider size is 1.35em. If changed, note that the latter is sensitive to the former to match heights - depending on base font-size slider should be 34 to 36 percentage smaller than thumb.The range- and number-fields are synced with a small piece of
oninput
, using declaredid
-attributes where available or generated as a fallback. Added thestep
-attribute, and number-field value fallbacks. Attributesmin
,max
,step
are not supported on mobile for number-input, but they work on range-input.Built files with default
gulp
task, let me know if I should do it some other way. Preview of field:Chrome:
![range_chrome](https://cloud.githubusercontent.com/assets/974717/23831910/9a07ace2-072a-11e7-821e-64d33fd9c319.png)
Firefox (by default their number-input steps are visible):
![range_firefox](https://cloud.githubusercontent.com/assets/974717/23831912/9fcd9006-072a-11e7-9b58-ac057d4db645.png)
Edge:
![range_edge](https://cloud.githubusercontent.com/assets/974717/23831913/a47b4db4-072a-11e7-9eb9-744d05bf3cde.png)