Collapse focus/hover/normal ternaries into Style.controlFill helpers
TextField, NumberField, Dropdown, SearchableDropdown, and Toggle all painted their background, border color, and border width with the same three-line ternary ladder (`_focused ? focusFill : _hot ? hoverFill : normalFill`). Five components × three properties × three branches is a lot of room for one of them to drift from the others when a new state ever gets added. Add controlFill / controlBorder / controlBorderWidth on Style and rewrite each call site as a single binding. No visual change.
This commit is contained in:
+3
-13
@@ -49,19 +49,9 @@ TextField {
|
||||
bottomPadding: verticalPadding
|
||||
|
||||
background: Rectangle {
|
||||
color: root._focused
|
||||
? Style.focusFillFor(root.foreground, root.accent)
|
||||
: (root._hot
|
||||
? Style.hoverFillFor(root.foreground, root.accent)
|
||||
: Style.normalFillFor(root.foreground, root.accent))
|
||||
border.color: root._focused
|
||||
? Style.focusBorderFor(root.foreground, root.accent)
|
||||
: (root._hot
|
||||
? Style.hoverBorderFor(root.foreground, root.accent)
|
||||
: Style.normalBorderFor(root.foreground, root.accent))
|
||||
border.width: root._focused
|
||||
? Style.focusBorderWidth
|
||||
: (root._hot ? Style.hoverBorderWidth : Style.normalBorderWidth)
|
||||
color: Style.controlFill(root._focused, root._hot, root.foreground, root.accent)
|
||||
border.color: Style.controlBorder(root._focused, root._hot, root.foreground, root.accent)
|
||||
border.width: Style.controlBorderWidth(root._focused, root._hot)
|
||||
radius: Style.cornerRadius
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user