2024-11-23 01:28:58 -05:00
|
|
|
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"
|
|
|
|
|
)
|
|
|
|
|
|
2024-11-23 16:32:15 -05:00
|
|
|
func (s FontAwesome) Icon(name string) templ.Component {
|
|
|
|
|
return renderIcon(s, name)
|
2024-11-23 01:28:58 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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>
|
|
|
|
|
}
|