Skip to content

Commit

Permalink
Bumping compton and updating to the latest API changes
Browse files Browse the repository at this point in the history
  • Loading branch information
boggydigital committed Oct 23, 2024
1 parent 05583cb commit 8b7f901
Show file tree
Hide file tree
Showing 13 changed files with 43 additions and 63 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require (
github.com/boggydigital/atomus v0.1.9
github.com/boggydigital/backups v0.1.3
github.com/boggydigital/clo v1.0.4
github.com/boggydigital/compton v0.1.84
github.com/boggydigital/compton v0.1.85
github.com/boggydigital/coost v0.3.9
github.com/boggydigital/dolo v0.2.18
github.com/boggydigital/issa v0.1.12
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ github.com/boggydigital/compton v0.1.83 h1:NoNfJFRoruWNvxv+SKcseyKVPR+7x4g3v0bFK
github.com/boggydigital/compton v0.1.83/go.mod h1:dj/yZ2cCfts6+heUS60Favateu+gNTIsoxfX6yNZWLg=
github.com/boggydigital/compton v0.1.84 h1:jyxauYUyyoAE4Fi2M9RVhmaTyeE29G49a3p/rNV/zSQ=
github.com/boggydigital/compton v0.1.84/go.mod h1:dj/yZ2cCfts6+heUS60Favateu+gNTIsoxfX6yNZWLg=
github.com/boggydigital/compton v0.1.85 h1:xxGIpb6tlOuKVfOz48PN2MX32mGTiwIndxkSSe85q6M=
github.com/boggydigital/compton v0.1.85/go.mod h1:dj/yZ2cCfts6+heUS60Favateu+gNTIsoxfX6yNZWLg=
github.com/boggydigital/coost v0.3.9 h1:lMfR5PyexBDR4xDOQp0zWZWUk/Dqlrx7gw7i7XdsC4c=
github.com/boggydigital/coost v0.3.9/go.mod h1:w7ChGaah1DKsBIXb9ANdILg2pe2Jp7JkNpnK2R6rBec=
github.com/boggydigital/dolo v0.2.18 h1:aN/Bq55e0/9VgmVTNw0ru3aoS6lpZJI59ho5YQlFbDE=
Expand Down
24 changes: 11 additions & 13 deletions rest/compton_data/section_styles.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
package compton_data

import "github.com/arelate/vangogh/rest/compton_styles"

var SectionStyles = map[string][]byte{
PropertiesSection: nil,
ExternalLinksSection: nil,
DescriptionSection: compton_styles.DescriptionStyle,
ScreenshotsSection: compton_styles.ScreenshotsStyle,
VideosSection: compton_styles.VideosStyle,
ChangelogSection: compton_styles.ChangelogStyle,
SteamNewsSection: compton_styles.SteamNewsStyle,
SteamReviewsSection: compton_styles.SteamReviewsStyle,
SteamDeckSection: compton_styles.SteamDeckStyle,
DownloadsSection: compton_styles.DownloadsStyle,
var SectionStyles = map[string]string{
PropertiesSection: "",
ExternalLinksSection: "",
DescriptionSection: "style/description.css",
ScreenshotsSection: "style/screenshots.css",
VideosSection: "style/videos.css",
ChangelogSection: "style/changelog.css",
SteamNewsSection: "style/steam-news.css",
SteamReviewsSection: "style/steam-reviews.css",
SteamDeckSection: "style/steam-deck.css",
DownloadsSection: "style/downloads.css",
}
25 changes: 11 additions & 14 deletions rest/compton_elements/product_card/product_card.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package product_card

import (
"bytes"
"embed"
_ "embed"
"github.com/arelate/vangogh/rest/compton_atoms"
Expand All @@ -17,18 +18,18 @@ import (
)

const (
registrationName = "product-card"
pcFilename = "style/product-card.css"
)

var (
//go:embed "markup/product-card.html"
markupProductCard embed.FS
markupProductCard []byte
//go:embed "style/product-card.css"
styleProductCard embed.FS
)

type ProductCardElement struct {
compton.BaseElement
*compton.BaseElement
r compton.Registrar
poster compton.Element
osSymbols []compton.Element
Expand All @@ -38,11 +39,11 @@ type ProductCardElement struct {
}

func (pc *ProductCardElement) Write(w io.Writer) error {
file, err := pc.Markup.Open(pc.Filename)
bts, err := pc.BaseElement.MarkupProvider.GetMarkup()
if err != nil {
return err
}
return compton.WriteContents(file, w, pc.elementFragmentWriter)
return compton.WriteContents(bytes.NewReader(bts), w, pc.elementFragmentWriter)
}

func (pc *ProductCardElement) elementFragmentWriter(t string, w io.Writer) error {
Expand Down Expand Up @@ -106,14 +107,10 @@ func (pc *ProductCardElement) SetHydratedPoster(hydratedSrc, posterSrc string) *

func ProductCard(r compton.Registrar, id string, hydrated bool, rdx kevlar.ReadableRedux) *ProductCardElement {
pc := &ProductCardElement{
BaseElement: compton.BaseElement{
TagName: compton_atoms.ProductCard,
Markup: markupProductCard,
Filename: "markup/product-card.html",
},
r: r,
id: id,
rdx: rdx,
BaseElement: compton.NewElement(compton.BytesMarkup(compton_atoms.ProductCard, markupProductCard)),
r: r,
id: id,
rdx: rdx,
}

if viSrc, ok := rdx.GetLastVal(vangogh_local_data.VerticalImageProperty, id); ok {
Expand Down Expand Up @@ -147,7 +144,7 @@ func ProductCard(r compton.Registrar, id string, hydrated bool, rdx kevlar.Reada

pc.SetAttribute("data-id", id)

r.RegisterStyle("style/product-card.css", styleProductCard)
r.RegisterStyles(styleProductCard, pcFilename)

return pc
}
4 changes: 0 additions & 4 deletions rest/compton_elements/product_labels/product_labels.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
package product_labels

import (
_ "embed"
"fmt"
"github.com/arelate/vangogh/rest/compton_data"
"github.com/arelate/vangogh_local_data"
"github.com/boggydigital/compton"
"github.com/boggydigital/kevlar"
)

//go:embed "style/product-labels.css"
var StyleProductLabels []byte

func FormatLabels(id string, rdx kevlar.ReadableRedux, properties ...string) []compton.FormattedLabel {
owned := false
if op, ok := rdx.GetLastVal(vangogh_local_data.OwnedProperty, id); ok {
Expand Down
4 changes: 2 additions & 2 deletions rest/compton_fragments/app_page.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
)

func AppPage(current string) (p compton.PageElement, stack *compton.FlexItemsElement) {
p = compton.Page(current).
AppendStyle("style-app", compton_styles.AppStyle)
p = compton.Page(current)
p.RegisterStyles(compton_styles.VangoghStyles, "style/app.css")

stack = compton.FlexItems(p, direction.Column)
p.Append(stack)
Expand Down
5 changes: 3 additions & 2 deletions rest/compton_fragments/product_section.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package compton_fragments

import (
"github.com/arelate/vangogh/rest/compton_data"
"github.com/arelate/vangogh/rest/compton_styles"
"github.com/boggydigital/compton"
)

Expand All @@ -10,8 +11,8 @@ func ProductSection(section string) compton.PageElement {
title := compton_data.SectionTitles[section]
ifc := compton.IframeExpandContent(section, title)

if style, ok := compton_data.SectionStyles[section]; ok && style != nil {
ifc.AppendStyle("style-section", style)
if style, ok := compton_data.SectionStyles[section]; ok && style != "" {
ifc.RegisterStyles(compton_styles.VangoghStyles, style)
}

return ifc
Expand Down
3 changes: 2 additions & 1 deletion rest/compton_pages/product.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"github.com/arelate/vangogh/rest/compton_data"
"github.com/arelate/vangogh/rest/compton_elements/product_labels"
"github.com/arelate/vangogh/rest/compton_fragments"
"github.com/arelate/vangogh/rest/compton_styles"
"github.com/arelate/vangogh_local_data"
"github.com/boggydigital/compton"
"github.com/boggydigital/compton/consts/color"
Expand All @@ -20,7 +21,7 @@ func Product(id string, rdx kevlar.ReadableRedux, hasSections []string, extLinks
}

p, pageStack := compton_fragments.AppPage(title)
p.AppendStyle("style-product-labels", product_labels.StyleProductLabels)
p.RegisterStyles(compton_styles.VangoghStyles, "style/product-labels.css")

/* App navigation */

Expand Down
4 changes: 2 additions & 2 deletions rest/compton_pages/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package compton_pages

import (
"github.com/arelate/vangogh/rest/compton_data"
"github.com/arelate/vangogh/rest/compton_elements/product_labels"
"github.com/arelate/vangogh/rest/compton_fragments"
"github.com/arelate/vangogh/rest/compton_styles"
"github.com/boggydigital/compton"
"github.com/boggydigital/compton/consts/color"
"github.com/boggydigital/compton/consts/size"
Expand All @@ -19,7 +19,7 @@ func Search(query map[string][]string, ids []string, from, to int, rdx kevlar.Re

current := compton_data.AppNavSearch
p, pageStack := compton_fragments.AppPage(current)
p.AppendStyle("style-product-labels", product_labels.StyleProductLabels)
p.RegisterStyles(compton_styles.VangoghStyles, "style/product-labels.css")

/* Nav stack = App navigation + Search shortcuts */

Expand Down
2 changes: 1 addition & 1 deletion rest/compton_pages/tags_editor.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func TagsEditor(
tagsPropertyTitle := compton_data.PropertyTitles[tagsProperty]

p, pageStack := compton_fragments.AppPage("Edit " + tagsPropertyTitle)
p.AppendStyle("style-tag-editor", compton_styles.TagEditorsStyle)
p.RegisterStyles(compton_styles.VangoghStyles, "style/tag-editors.css")

/* App navigation */

Expand Down
4 changes: 2 additions & 2 deletions rest/compton_pages/updates.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package compton_pages

import (
"github.com/arelate/vangogh/rest/compton_data"
"github.com/arelate/vangogh/rest/compton_elements/product_labels"
"github.com/arelate/vangogh/rest/compton_fragments"
"github.com/arelate/vangogh/rest/compton_styles"
"github.com/boggydigital/compton"
"github.com/boggydigital/compton/consts/color"
"github.com/boggydigital/compton/consts/direction"
Expand All @@ -20,7 +20,7 @@ func Updates(sections []string,

current := compton_data.AppNavUpdates
p, pageStack := compton_fragments.AppPage(current)
p.AppendStyle("style-product-labels", product_labels.StyleProductLabels)
p.RegisterStyles(compton_styles.VangoghStyles, "style/product-labels.css")

/* Nav stack = App navigation + Updates sections shortcuts */

Expand Down
27 changes: 6 additions & 21 deletions rest/compton_styles/style.go
Original file line number Diff line number Diff line change
@@ -1,26 +1,11 @@
package compton_styles

import _ "embed"
import (
"embed"
_ "embed"
)

var (
//go:embed "style/app.css"
AppStyle []byte
//go:embed "style/screenshots.css"
ScreenshotsStyle []byte
//go:embed "style/videos.css"
VideosStyle []byte
//go:embed "style/description.css"
DescriptionStyle []byte
//go:embed "style/changelog.css"
ChangelogStyle []byte
//go:embed "style/steam-deck.css"
SteamDeckStyle []byte
//go:embed "style/steam-reviews.css"
SteamReviewsStyle []byte
//go:embed "style/steam-news.css"
SteamNewsStyle []byte
//go:embed "style/tag-editors.css"
TagEditorsStyle []byte
//go:embed "style/downloads.css"
DownloadsStyle []byte
//go:embed "style/*.css"
VangoghStyles embed.FS
)

0 comments on commit 8b7f901

Please sign in to comment.