mirror of
https://github.com/sonr-io/sonr.git
synced 2026-08-03 09:51:39 +00:00
54 lines
1.1 KiB
Templ
54 lines
1.1 KiB
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 Icon(s FontAwesome) IconFunc {
|
||
|
|
return func(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>
|
||
|
|
}
|
||
|
|
|
||
|
|
templ RegularIcon() {
|
||
|
|
}
|
||
|
|
|
||
|
|
templ LightIcon() {
|
||
|
|
}
|
||
|
|
|
||
|
|
templ ThinIcon() {
|
||
|
|
}
|
||
|
|
|
||
|
|
templ BrandsIcon() {
|
||
|
|
}
|