Skip to content

Commit

Permalink
refactor: start using props in components
Browse files Browse the repository at this point in the history
  • Loading branch information
believer committed Sep 11, 2024
1 parent c1814f7 commit bfb75bb
Show file tree
Hide file tree
Showing 16 changed files with 776 additions and 406 deletions.
11 changes: 8 additions & 3 deletions components/descriptionList.templ
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,14 @@ templ DescriptionList() {
</dl>
}

templ DescriptionListItem(detail string, isTabular bool) {
@descriptionDetail(detail)
@descriptionTerm(isTabular) {
type DescriptionListItemProps struct {
Detail string
IsTabular bool
}

templ DescriptionListItem(props DescriptionListItemProps) {
@descriptionDetail(props.Detail)
@descriptionTerm(props.IsTabular) {
{ children... }
}
}
11 changes: 8 additions & 3 deletions components/descriptionList_templ.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions components/dropdown.templ
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package components

import "strconv"

type DropdownProps struct {
Route string
Options []int
Value string
}

templ Dropdown(props DropdownProps) {
<select class="appearance-none border border-neutral-300 dark:border-neutral-700 rounded text-xs px-2 py-1 bg-transparent focus:outline-dashed focus:outline-offset-2 focus:outline-neutral-300 dark:focus:outline-neutral-700" hx-target="closest section" hx-get={ props.Route } name="year" value={ props.Value } hx-swap="outerHTML">
for _, option := range props.Options {
<option
value={ strconv.Itoa(option) }
if props.Value == strconv.Itoa(option) {
selected
}
>{ strconv.Itoa(option) }</option>
}
</select>
}
117 changes: 117 additions & 0 deletions components/dropdown_templ.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 0 additions & 24 deletions components/graphWithYear.templ

This file was deleted.

144 changes: 0 additions & 144 deletions components/graphWithYear_templ.go

This file was deleted.

Loading

0 comments on commit bfb75bb

Please sign in to comment.