Add OkThSlider component - #3048
atmgrifter00 with Copilot wants to merge 27 commits into
Conversation
Co-authored-by: atmgrifter00 <26874831+atmgrifter00@users.noreply.github.com>
|
@copilot can we include the |
Co-authored-by: atmgrifter00 <26874831+atmgrifter00@users.noreply.github.com>
|
Approved the workflow runs |
|
@copilot When pressing the slider it looks like this: I think we should adopt the same styling patterns seen in the switch control (see it's styling CSS file for reference: https://github.com/ni/nimble/blob/main/packages/nimble-components/src/switch/styles.ts. The color of the track for the slider should also match that of the switch. |
Co-authored-by: atmgrifter00 <26874831+atmgrifter00@users.noreply.github.com>
Co-authored-by: atmgrifter00 <26874831+atmgrifter00@users.noreply.github.com>
|
@copilot we also need to provide visual feedback for what the actual value is as you are changing it (perhaps tooltip next to the . We can provide this configuration via an attribute API. Additionally it would be nice to provide a fill effect on the slider from the minimum up to the current value. Let's start with using the $ni-nimble-fill-selected-color token for the fill color. |
Co-authored-by: atmgrifter00 <26874831+atmgrifter00@users.noreply.github.com>
Added |
|
@copilot A few things to fix: The thumb for the slider should not be showing the track behind it when in any mode (disabled or otherwise). The switch may have been able to get away with this because its track is the same size and color as the background of the thumb, but for the slider we can't do that, unless we can provide a mask image that removes the visuals behind the thumb. Let's also make the thumb size about 60% of its current size. We also should remove the visual box around the value. I would also like to see the min and max values to show up on the slider on hover. |
Co-authored-by: atmgrifter00 <26874831+atmgrifter00@users.noreply.github.com>
Aligned the vertical thumb with the fill boundary by correcting its transform, and changed the matrix/test value to 4 so the non-middle position is verified. Addressed in 5e25b2a. |
8383c47 to
e93ac86
Compare
| const internals = this as unknown as FoundationSliderInternals; | ||
| const calculateFoundationValue = internals.calculateNewValue; | ||
| internals.calculateNewValue = rawValue => calculateFoundationValue( | ||
| this.orientation === Orientation.vertical | ||
| ? this.trackMinHeight + this.trackHeight - rawValue | ||
| : rawValue |
There was a problem hiding this comment.
(non-blocking) gonna guess llm is fighting with custom element restrictions on what you can do in a constructor. resulting in these weird access patterns. The usual way to handle this is to do things that require messing with the DOM in connectedCallback instead as described in that spec note:
In general, work should be deferred to connectedCallback as much as possible—especially work involving fetching resources or rendering. However, note that connectedCallback can be called more than once, so any initialization work that is truly one-time will need a guard to prevent it from running twice.
There was a problem hiding this comment.
(non-blocking) Oh actually, think I'm wrong, it's the llm trying to get access to private methods in the base class:
If actually really needed, dunno if a sane workaround, may be better to make a small PR to foundation to mark them /** @internal */ public instead. Or just merge as-is. Up to you
| ${display('inline-block')} | ||
|
|
||
| :host { | ||
| width: 100%; |
There was a problem hiding this comment.
(non-blocking) Form style controls (as opposed to block level paragraph or inline text style controls) generally have some reasonable arbitrary width by default as opposed to filling 100% of the parent. Could consider menuMinWidth (which is already a bit abused for that) or a value that feels right
| width: 100%; | ||
| /* Three thumb widths allow three non-overlapping slider positions. */ | ||
| min-width: 42px; | ||
| height: 32px; |
There was a problem hiding this comment.
(non-blocking) This one we are more consistent on, controlHeight
| width: 32px; | ||
| min-width: 32px; | ||
| height: 100%; |
There was a problem hiding this comment.
(non-blocking) similar considerations as above
| @@ -22,6 +22,8 @@ | |||
| /**/Ts/** @jattasNI | |||
There was a problem hiding this comment.
Pretty much there. Question around accessing internal apis and gave some style feedback since was in the area but generally nimble owners won't be doing reviews of ok component content and focus on repo layout / infra.
Other repo layout considerations:
- (infra, please update) keeping status table up to date for
thcomponents, following ok ts / ok fv patterns: - (non-blocking) since you have wrappers, adding to the react example app:
| <Meta of={sliderStories} /> | ||
| <Title of={sliderStories} /> | ||
|
|
||
| A Nimble-styled TestHub slider based on the FAST Foundation slider. |
There was a problem hiding this comment.
(non-blocking) The llm inferred what TH stood for :P Dunno if you want the term TestHub here or have it use ThSlider instead (same in the change file description).
jattasNI
left a comment
There was a problem hiding this comment.
Structure looks fine, all comments are because I can't stop myself from applying a higher bar to reviews, you don't have to address any of them for the ok level of quality
| show-min-max="${x => x.showMinMax}" | ||
| ></${thSliderTag}> | ||
| `), | ||
| argTypes: { |
There was a problem hiding this comment.
It'd be great to add description for all of these. Many can probably be copied from other controls like nimble number field.
Especially important to note the behavior of value: it's the initial value not the current value.
| orientation === 'horizontal' ? `width: ${sliderSize};` : `height: ${sliderSize};` | ||
| ); | ||
|
|
||
| const component = ( |
There was a problem hiding this comment.
Would be good to include the min/max/value visibility as states too
| @@ -0,0 +1,7 @@ | |||
| { | |||
There was a problem hiding this comment.
Totally up to you whether these are in scope, but a few things I noticed that might be useful for others:
- label
- error state
- Angular wrappers
- Blazor wrappers
| expect(document.createElement(thSliderTag)).toBeInstanceOf(ThSlider); | ||
| }); | ||
|
|
||
| it('provides the FAST Foundation slider template', async () => { |
There was a problem hiding this comment.
Looks like we forked the template
| it('provides the FAST Foundation slider template', async () => { | |
| it('provides the expected slider template contents', async () => { |





Pull Request
🤨 Rationale
Add a Nimble-styled OK slider backed by the FAST Foundation slider.
👩💻 Implementation
ok-basic-sliderunderok-components/src/basic.🧪 Testing
✅ Checklist