SliderComponent

open class SliderComponent(store: Store<Int>?) : Component<Div> , FormProperties, SeverityProperties, OrientationProperty, TooltipProperties

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
js
fun SliderComponent(store: Store<Int>? = null)
an optional store for setting and accessing the value of the slider

Types

Companion
Link copied to clipboard
js
object Companion
EventsContext
Link copied to clipboard
js
class EventsContext(element: Tag<HTMLElement>, value: Flow<Int>, currentValue: Flow<Int>) : EventContext<HTMLElement>
RangeContext
Link copied to clipboard
js
class RangeContext

Functions

enabled
Link copied to clipboard
js
open override fun enabled(value: Boolean)
open override fun enabled(value: Flow<Boolean>)
range
Link copied to clipboard
js
fun range(expr: SliderComponent.RangeContext.() -> Unit)
render
Link copied to clipboard
js
open override fun render(context: RenderContext, styling: BoxParams.() -> Unit, baseClass: StyleClass, id: String?, prefix: String): Div
Central method that should do the actual rendering of a component.
severity
Link copied to clipboard
js
open override fun severity(value: SeverityProperties.SeverityContext.() -> Severity)
Property to manage the severity value of the component.
severityClassOf
Link copied to clipboard
js
open override fun severityClassOf(severityStyle: SeverityStyles): Flow<StyleClass>
This function manages the task to map a value of the Severity enumeration to a corresponding style defined within the SeverityStyles interface.
thumb
Link copied to clipboard
js
fun thumb(styling: BoxParams.(Int) -> Unit = {}, content: Div.(State) -> Unit)
tooltip
Link copied to clipboard
js
open override fun tooltip(vararg text: String, build: TooltipComponent.() -> Unit)
open override fun tooltip(styling: BasicParams.() -> Unit, text: String?, baseClass: StyleClass, id: String, prefix: String, build: TooltipComponent.() -> Unit)

Properties

disabled
Link copied to clipboard
js
open override val disabled: DynamicComponentProperty<Boolean>
events
Link copied to clipboard
js
val events: ComponentProperty<SliderComponent.EventsContext.() -> Unit>
icon
Link copied to clipboard
js
val icon: ComponentProperty<Icons.() -> IconDefinition?>
orientation
Link copied to clipboard
js
open override val orientation: ComponentProperty<OrientationContext.() -> Orientation>
range
Link copied to clipboard
js
val range: ComponentProperty<Range>
renderTooltip
Link copied to clipboard
js
open override val renderTooltip: ComponentProperty<Tag<HTMLElement>.() -> Unit>
severity
Link copied to clipboard
js
open override val severity: NullableDynamicComponentProperty<Severity?>
size
Link copied to clipboard
js
val size: ComponentProperty<FormSizesStyles.() -> Style<BasicParams>>
track
Link copied to clipboard
js
val track: ComponentProperty<Style<BoxParams>>
trackFilled
Link copied to clipboard
js
val trackFilled: ComponentProperty<BoxParams.(Int) -> Unit>
value
Link copied to clipboard
js
val value: NullableDynamicComponentProperty<Int>