Slider Component
open class SliderComponent(store: Store<Int>?) : Component<Div> , FormProperties, SeverityProperties, OrientationProperty, TooltipProperties
Content copied to clipboard
This component creates a slider.
A slider should be used for getting an Int based result, where the exact value is not important as it's tedious to provide a specific value. On the other hand the slider gives a goods visual feedback to the user.
It handles:
the rendering of the slider (see
`render`method)the configuration (with sub-classes) and its DSL including special
`currentValue`event within`events`context.the state management via State
the styling via theme and ad hoc definitions offered within the slider DSL
Example usages:
// pass in a store for backup the value including predefined one
val valueStore = storeOf(42) // omitted in further snippets!
slider(value = valueStore) { } // no range -> lower=0, upper=100, step=1
// defining the range
slider(value = valueStore) {
range {
lower(-20) // could be negative
upper(40) // could also be negative, but must be greater than lower!
step(2) // must be positive!
}
}
// observe sliding movement explicitly:
val currentValueStore = storeOf(0) // store the current value
slider(value = valueStore) {
events {
// handle changing values also during sliding movement
currentValue handledBy currentValueStore.update
}
}
// render a vertical slider:
slider(value = valueStore) {
orientation { vertical } // ``horizontal`` is default
}
// change size
slider(value = valueStore) {
size { small } // ``normal`` (default) and ``large``
}
// style slider ad hoc:
slider(value = valueStore) {
track {
}
trackFilled { percent ->
// use percent value to change style according to the progress
}
thumb({ percent ->
// use percent value to change style according to the progress
}) { state ->
// use the whole state for creating custom content
// imagine a sticky info box with the current value appearing only
// if ``movementTracking`` is ``true``
}
}
// disable slider:
slider(value = valueStore) {
disabled(true) // could also be a ``Flow<Boolean>`` to make this dynamic.
// Be aware that the value is still changeable via the store!
}
See also
dev.fritz2.components.slider.StateStore
Parameters
store
an optional store for setting and accessing the value of the slider
Constructors
SliderComponent
Link copied to clipboard
an optional store for setting and accessing the value of the slider
Types
EventsContext
Link copied to clipboard
class EventsContext(element: Tag<HTMLElement>, value: Flow<Int>, currentValue: Flow<Int>) : EventContext<HTMLElement>
Content copied to clipboard
RangeContext
Link copied to clipboard
class RangeContext
Content copied to clipboard
Functions
range
Link copied to clipboard
severity
Link copied to clipboard
open override fun severity(value: SeverityProperties.SeverityContext.() -> Severity)
Content copied to clipboard
severityClassOf
Link copied to clipboard
open override fun severityClassOf(severityStyle: SeverityStyles): Flow<StyleClass>
Content copied to clipboard
tooltip
Link copied to clipboard
Properties
disabled
Link copied to clipboard
events
Link copied to clipboard
icon
Link copied to clipboard
orientation
Link copied to clipboard
open override val orientation: ComponentProperty<OrientationContext.() -> Orientation>
Content copied to clipboard
range
Link copied to clipboard
renderTooltip
Link copied to clipboard
open override val renderTooltip: ComponentProperty<Tag<HTMLElement>.() -> Unit>
Content copied to clipboard
severity
Link copied to clipboard
size
Link copied to clipboard
track
Link copied to clipboard
trackFilled
Link copied to clipboard
value
Link copied to clipboard