Skip to content

Commit

Permalink
feat: missiles tab added
Browse files Browse the repository at this point in the history
  • Loading branch information
dd84ai committed Mar 31, 2024
1 parent 84b7692 commit 1cad5f2
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 5 deletions.
14 changes: 10 additions & 4 deletions darkstat/front/guns.templ
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,31 @@ import (
func GunDetailedUrl(gun configs_export.Gun, mode GunTabMode) string {
if mode == GunsShowBases {
return "guns/guns_base_" + strings.ToLower(gun.Nickname)
} else {
} else if mode == GunsShowDamageBonuses {
return "guns/guns_bonuses_" + strings.ToLower(gun.Nickname)
} else if mode == GunsMissiles {
return "guns/missiles_" + strings.ToLower(gun.Nickname)
}
panic("unsupported choice in GunDetailedUrl")
}

type GunTabMode int64

const (
GunsShowBases GunTabMode = iota
GunsShowDamageBonuses
GunsMissiles
)

// https://www.cssscript.com/minimalist-table-sortable/#:~:text=Description%3A-,sorttable.,clicking%20on%20the%20table%20headers
// https://www.cssscript.com/fast-html-table-sorting/
templ GunsT(guns []configs_export.Gun, mode GunTabMode) {
if mode == GunsShowBases {
@TabMenu(urls.Guns)
} else {
} else if mode == GunsShowDamageBonuses {
@TabMenu(urls.GunModifiers)
} else if mode == GunsMissiles {
@TabMenu(urls.Missiles)
}
@TabContent() {
<div class="splitter">
Expand Down Expand Up @@ -111,8 +117,8 @@ templ GunsT(guns []configs_export.Gun, mode GunTabMode) {
</table>
</div>
<div id="table-bottom">
if mode == GunsShowBases {
@GoodAtBaseSharedT(ShowPricePerVolume(true))
if mode == GunsShowBases || mode == GunsMissiles {
@GoodAtBaseSharedT(ShowPricePerVolume(false))
} else {
@GunShowModifiersShared()
}
Expand Down
1 change: 1 addition & 0 deletions darkstat/front/shared.templ
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ templ TabMenu(url utils_types.FilePath) {
<button hx-get={ types.GetCtx(ctx).SiteRoot + urls.Commodities.ToString() } class={ templ.KV("selected", urls.Commodities == url) } role="tab" aria-selected="false" aria-controls="tab-content">Commodities</button>
<button hx-get={ types.GetCtx(ctx).SiteRoot + urls.Guns.ToString() } class={ templ.KV("selected", urls.Guns == url) } role="tab" aria-selected="false" aria-controls="tab-content">Guns</button>
<button hx-get={ types.GetCtx(ctx).SiteRoot + urls.GunModifiers.ToString() } class={ templ.KV("selected", urls.GunModifiers == url) } role="tab" aria-selected="false" aria-controls="tab-content">Gun Modifiers</button>
<button hx-get={ types.GetCtx(ctx).SiteRoot + urls.Missiles.ToString() } class={ templ.KV("selected", urls.Missiles == url) } role="tab" aria-selected="false" aria-controls="tab-content">Missiles</button>
</div>
}
<hr/>
Expand Down
1 change: 1 addition & 0 deletions darkstat/front/urls/urls.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ const (
Commodities utils_types.FilePath = "commodities.html"
Guns utils_types.FilePath = "guns.html"
GunModifiers utils_types.FilePath = "gun_modifiers.html"
Missiles utils_types.FilePath = "missiles.html"
)
13 changes: 13 additions & 0 deletions darkstat/linker/linker.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,10 @@ func (l *Linker) Link() *builder.Builder {
urls.GunModifiers,
front.GunsT(data.Guns, front.GunsShowDamageBonuses),
),
builder.NewComponent(
urls.Missiles,
front.GunsT(data.Missiles, front.GunsMissiles),
),
)

for _, base := range data.Bases {
Expand Down Expand Up @@ -194,5 +198,14 @@ func (l *Linker) Link() *builder.Builder {
)
}

for _, missile := range data.Missiles {
build.RegComps(
builder.NewComponent(
utils_types.FilePath(front.GunDetailedUrl(missile, front.GunsMissiles)),
front.GoodAtBaseInfoT(missile.Bases, front.ShowPricePerVolume(false)),
),
)
}

return build
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.21.1

require (
github.com/a-h/templ v0.2.543
github.com/darklab8/fl-configs v0.21.1
github.com/darklab8/fl-configs v0.22.0
github.com/darklab8/go-typelog v0.6.0
github.com/darklab8/go-utils v0.12.0
github.com/yosssi/gohtml v0.0.0-20201013000340-ee4748c638f4
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ github.com/darklab8/fl-configs v0.21.0 h1:B31NaDIZ/ApRX6JboCmD+m99NSH73YMMsv6yn3
github.com/darklab8/fl-configs v0.21.0/go.mod h1:8zaCaFL21TvawP65KB9NOJ+nEpaMDQYsnoOi77RiSVY=
github.com/darklab8/fl-configs v0.21.1 h1:dBIVOJocWL9JefjU616cY4KdpxyCgEBuvpETf7PrIVA=
github.com/darklab8/fl-configs v0.21.1/go.mod h1:8zaCaFL21TvawP65KB9NOJ+nEpaMDQYsnoOi77RiSVY=
github.com/darklab8/fl-configs v0.22.0 h1:f3klPld5n0qLS7wn3x3uqEvrgf348pgHnuOnpqgRlVQ=
github.com/darklab8/fl-configs v0.22.0/go.mod h1:8zaCaFL21TvawP65KB9NOJ+nEpaMDQYsnoOi77RiSVY=
github.com/darklab8/go-typelog v0.6.0 h1:Ci8imc7ScXiy5e1qMgf46NyJjrqNLPoIE1gbVe7bxl4=
github.com/darklab8/go-typelog v0.6.0/go.mod h1:AwwOf3dkp/tpevHFNbkB+PbwlDrUUgO1CVFkEnj+q5w=
github.com/darklab8/go-utils v0.12.0 h1:LxsG3yVNf9W4xyV+tHPOaZB2ewItgM/1BzOXyKFvofs=
Expand Down

0 comments on commit 1cad5f2

Please sign in to comment.