forked from mbk-lab/rui_orig
2
0
Fork 0

Added Name and Args function to SizeFunc interface

This commit is contained in:
Alexei Anoshenko 2022-09-07 15:05:53 +03:00
parent ed03368f5d
commit ed4d2b6ffa
2 changed files with 17 additions and 2 deletions

View File

@ -11,6 +11,10 @@ import (
// "min", "max", "clamp", "sum", "sub", "mul", and "div" functions are available.
type SizeFunc interface {
fmt.Stringer
// Name() returns the function name: "min", "max", "clamp", "sum", "sub", "mul", or "div"
Name() string
// Args() returns a list of function arguments
Args() []any
cssString(session Session) string
writeCSS(topFunc string, buffer *strings.Builder, session Session)
writeString(topFunc string, buffer *strings.Builder)
@ -159,6 +163,16 @@ func (data *sizeFuncData) String() string {
return buffer.String()
}
func (data *sizeFuncData) Name() string {
return data.tag
}
func (data *sizeFuncData) Args() []any {
args := make([]any, len(data.args))
copy(args, data.args)
return args
}
func (data *sizeFuncData) writeString(topFunc string, buffer *strings.Builder) {
buffer.WriteString(data.tag)
buffer.WriteRune('(')

View File

@ -582,7 +582,8 @@ func writePropertyValue(buffer *strings.Builder, tag string, value any, indent s
} else {
for _, ch := range text {
if (ch >= '0' && ch <= '9') || (ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z') ||
ch == '+' || ch == '-' || ch == '@' || ch == '/' || ch == '_' || ch == ':' {
ch == '+' || ch == '-' || ch == '@' || ch == '/' || ch == '_' || ch == ':' ||
ch == '#' || ch == '%' || ch == 'π' || ch == '°' {
} else {
simple = false
break
@ -667,7 +668,7 @@ func writePropertyValue(buffer *strings.Builder, tag string, value any, indent s
value.writeString(buffer, indent+"\t")
case fmt.Stringer:
buffer.WriteString(value.String())
writeString(value.String())
case []ViewShadow:
switch len(value) {