26 lines
494 B
Go
26 lines
494 B
Go
|
package attribute
|
||
|
|
||
|
import "strconv"
|
||
|
import "gitlab.codemonkeysoftware.net/b/hatmill"
|
||
|
|
||
|
type StepValue *float32
|
||
|
|
||
|
func StepAny() StepValue {
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
func StepFloat(value float32) StepValue {
|
||
|
return &value
|
||
|
}
|
||
|
|
||
|
// Step indicates the minimum allowed change to a number input.
|
||
|
func Step(value StepValue) hatmill.Attrib {
|
||
|
var attr = hatmill.Attrib{Key: "step"}
|
||
|
if value == nil {
|
||
|
attr.Value = "any"
|
||
|
} else {
|
||
|
attr.Value = strconv.FormatFloat(float64(*value), 'G', -1, 32)
|
||
|
}
|
||
|
return attr
|
||
|
}
|