artist-search-picker.templ (1164B)
1 package artistsearchpicker 2 3 import "fmt" 4 5 templ ArtistSearchPicker(params ArtistSearchPickerParams) { 6 if len(params.Artists) == 0 { 7 <fieldset class="picker-options" role="radiogroup" x-show="false"></fieldset> 8 } else { 9 <fieldset class="picker-options" role="radiogroup"> 10 <legend>select artist</legend> 11 <ul> 12 for _, artist := range params.Artists { 13 {{ 14 label := artist.Name 15 if artist.LatinName != nil && artist.Disambiguation != nil { 16 label = fmt.Sprintf("%s (%s, %s)", artist.Name, *artist.LatinName, *artist.Disambiguation) 17 } else if artist.LatinName != nil { 18 label = fmt.Sprintf("%s (%s)", artist.Name, *artist.LatinName) 19 } else if artist.Disambiguation != nil { 20 label = fmt.Sprintf("%s (%s)", artist.Name, *artist.Disambiguation) 21 } 22 }} 23 <li> 24 <label> 25 <input 26 type="radio" 27 value={ fmt.Sprintf("%d", artist.ID) } 28 data-name={ artist.Name } 29 required 30 @change="selected = true; artistId = $event.target.value; artistName = $event.target.dataset.name" 31 /> 32 { label } 33 </label> 34 </li> 35 } 36 </ul> 37 </fieldset> 38 } 39 }