2019-04-23 14:15:17 +00:00
|
|
|
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 {
|
2019-08-31 15:05:43 +00:00
|
|
|
attr.Value = String("any")
|
2019-04-23 14:15:17 +00:00
|
|
|
} else {
|
2019-08-31 15:05:43 +00:00
|
|
|
attr.Value = String(strconv.FormatFloat(float64(*value), 'G', -1, 32))
|
2019-04-23 14:15:17 +00:00
|
|
|
}
|
|
|
|
return attr
|
|
|
|
}
|