2022-11-08 20:43:58 +05:30
|
|
|
// Copyright 2022 The Gitea Authors. All rights reserved.
|
2022-11-27 23:50:29 +05:30
|
|
|
// SPDX-License-Identifier: MIT
|
2022-11-08 20:43:58 +05:30
|
|
|
|
|
|
|
package html
|
|
|
|
|
|
|
|
// ParseSizeAndClass get size and class from string with default values
|
|
|
|
// If present, "others" expects the new size first and then the classes to use
|
2023-07-05 00:06:08 +05:30
|
|
|
func ParseSizeAndClass(defaultSize int, defaultClass string, others ...any) (int, string) {
|
2022-11-08 20:43:58 +05:30
|
|
|
if len(others) == 0 {
|
|
|
|
return defaultSize, defaultClass
|
|
|
|
}
|
|
|
|
|
|
|
|
size := defaultSize
|
|
|
|
_size, ok := others[0].(int)
|
|
|
|
if ok && _size != 0 {
|
|
|
|
size = _size
|
|
|
|
}
|
|
|
|
|
|
|
|
if len(others) == 1 {
|
|
|
|
return size, defaultClass
|
|
|
|
}
|
|
|
|
|
|
|
|
class := defaultClass
|
|
|
|
if _class, ok := others[1].(string); ok && _class != "" {
|
|
|
|
if defaultClass == "" {
|
|
|
|
class = _class
|
|
|
|
} else {
|
|
|
|
class = defaultClass + " " + _class
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return size, class
|
|
|
|
}
|