Files
sonr/pkg/webapp/components/ui/icon.templ
T

40 lines
957 B
Templ

package ui
import "fmt"
type FontAwesome string
type IconFunc func(name string) templ.Component
const (
FaSolid FontAwesome = "fa-solid"
FaRegular FontAwesome = "fa-regular"
FaLight FontAwesome = "fa-light"
FaThin FontAwesome = "fa-thin"
FaDuotone FontAwesome = "fa-duotone fa-solid"
FaSharpSolid FontAwesome = "fa-sharp fa-solid"
FaSharpRegular FontAwesome = "fa-sharp fa-regular"
FaSharpLight FontAwesome = "fa-sharp fa-light"
FaSharpThin FontAwesome = "fa-sharp fa-thin"
FaSharpDuotone FontAwesome = "fa-sharp-duotone fa-solid"
FaBrands FontAwesome = "fa-brands"
)
func (s FontAwesome) Icon(name string) templ.Component {
return renderIcon(s, name)
}
func renderIcon(s FontAwesome, name string) templ.Component {
return faIcon(formatIconClass(s, name))
}
func formatIconClass(s FontAwesome, name string) string {
return fmt.Sprintf("%s %s", string(s), name)
}
templ faIcon(class string) {
<i class={ class }></i>
}