Scoop API

scoop:scoop.ui.style:0.1.0

src/theme/shape_builder.scoop

Selected production source · src/theme/shape_builder.scoop

1package scoop.ui.style
3/** Constructs a complete description and applies configuration once. */
4public fun shapeTheme(
5 tokens: ThemeTokens,
6 surfaces: SurfaceParts,
7 checkbox: CheckboxPart,
8 radio: RadioPart,
9 scrollbar: ScrollbarPart,
10 configure: ShapeThemeBuilder.() -> Unit = {}
11): ShapeTheme =
12 configureShapeTheme(
13 ShapeTheme(
14 tokens = tokens,
15 surfaces = surfaces,
16 checkbox = checkbox,
17 radio = radio,
18 scrollbar = scrollbar
19 ),
20 configure
21 )
23internal fun configureShapeTheme(
24 initial: ShapeTheme,
25 configure: ShapeThemeBuilder.() -> Unit
26): ShapeTheme {
27 val builder = ShapeThemeBuilder(initial)
28 builder.configure()
29 return builder.snapshot()
32/** Mutable configuration initialized from a complete immutable value. */
33public class ShapeThemeBuilder internal constructor(initial: ShapeTheme) {
34 public var tokens: ThemeTokens = initial.tokens
35 public var surfaces: SurfaceParts = initial.surfaces
36 public var checkbox: CheckboxPart = initial.checkbox
37 public var radio: RadioPart = initial.radio
38 public var scrollbar: ScrollbarPart = initial.scrollbar
40 public fun tokens(configure: ThemeTokensBuilder.() -> Unit): Unit {
41 tokens = tokens.copy(configure)
42 }
44 public fun surfaces(configure: SurfacePartsBuilder.() -> Unit): Unit {
45 surfaces = surfaces.copy(configure)
46 }
48 public fun checkbox(configure: CheckboxPartBuilder.() -> Unit): Unit {
49 checkbox = checkbox.copy(configure)
50 }
52 public fun radio(configure: RadioPartBuilder.() -> Unit): Unit {
53 radio = radio.copy(configure)
54 }
56 public fun scrollbar(configure: ScrollbarPartBuilder.() -> Unit): Unit {
57 scrollbar = scrollbar.copy(configure)
58 }
60 internal fun snapshot(): ShapeTheme =
61 ShapeTheme(
62 tokens = tokens,
63 surfaces = surfaces,
64 checkbox = checkbox,
65 radio = radio,
66 scrollbar = scrollbar
67 )