diff --git a/css/portfolio.css b/css/portfolio.css index 860612b..79cd808 100644 --- a/css/portfolio.css +++ b/css/portfolio.css @@ -1,27 +1,31 @@ -.portfolio { - padding-top: 2rem; +#portfolio-grid { + display: grid; + grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); + grid-auto-flow: dense; + gap: 0.5rem; - & > header { - justify-content: center; - align-items: center; - display: flex; - flex-direction: column; - - & > p { - margin: 0; - } - - & > * { - text-align: center; - max-width: 40rem; - } + & > * { + overflow: hidden; + border-radius: var(--small-border-radius); } - & > div:nth-child(2) { - display: flex; - align-items: center; - gap: 1rem; - justify-content: center; - padding: 3rem; + & img { + display: block; + width: 100%; + height: 100%; + object-fit: cover; } -} \ No newline at end of file + + & > :nth-child(7n) { + grid-column: span 2; + grid-row: span 2; + } + + & > :nth-child(11n+5) { + grid-column: span 2; + } + + & > :nth-child(13n+9) { + grid-row: span 2; + } +} diff --git a/html/layout.templ b/html/layout.templ index 1744f29..d0a5f8a 100644 --- a/html/layout.templ +++ b/html/layout.templ @@ -190,19 +190,32 @@ templ GreenLink(activePage, targetPage, title string) { >{ title } } -templ wyrobyHeader(activePage string) { +templ subnavHeader(title, description string) { } + +templ wyrobyHeader(activePage string) { + @subnavHeader("Nasze słodkości", "Poznaj nasze tradycyjne receptury przekute w nowoczesne formy. Każdy wypiek to historia pasji, a każde lody to powiew naturalnej świeżości") { + @GreenLink(activePage, "wyroby", "Ciasta") + @GreenLink(activePage, "wyroby_deserki", "Deserki") + @GreenLink(activePage, "wyroby_torty", "Torty") + @GreenLink(activePage, "wyroby_slodkie_stoly", "Słodkie stoły") + @GreenLink(activePage, "wyroby_lody", "Lody") + } +} + +templ portfolioHeader(activePage string) { + @subnavHeader("Nasze Słodkie Realizacje", "Galeria pasji uwieczniona w kremie i dekoracjach. Zobacz wybrane projekty, które uświetniły wyjątkowe chwile naszych klientów – od bajkowych tortów dla dzieci po eleganckie torty weselne.") { + @GreenLink(activePage, "portfolio_ciasta", "Ciasta") + @GreenLink(activePage, "portfolio_deserki", "Deserki") + @GreenLink(activePage, "portfolio_torty", "Torty") + @GreenLink(activePage, "portfolio_slodkie_stoly", "Słodkie stoły") + @GreenLink(activePage, "portfolio_lody", "Lody") + } +} diff --git a/html/layout_templ.go b/html/layout_templ.go index 76206bf..d474979 100644 --- a/html/layout_templ.go +++ b/html/layout_templ.go @@ -197,7 +197,7 @@ func GreenLink(activePage, targetPage, title string) templ.Component { }) } -func wyrobyHeader(activePage string) templ.Component { +func subnavHeader(title, description string) templ.Component { return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { @@ -218,31 +218,199 @@ func wyrobyHeader(activePage string) templ.Component { templ_7745c5c3_Var8 = templ.NopComponent } ctx = templ.ClearChildren(ctx) - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 14, "

Nasze słodkości

Poznaj nasze tradycyjne receptury przekute w nowoczesne formy. Każdy wypiek to historia pasji, a każde lody to powiew naturalnej świeżości

") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + return nil + }) +} + +func wyrobyHeader(activePage string) templ.Component { + return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { + templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context + if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { + return templ_7745c5c3_CtxErr + } + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) + if !templ_7745c5c3_IsBuffer { + defer func() { + templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) + if templ_7745c5c3_Err == nil { + templ_7745c5c3_Err = templ_7745c5c3_BufErr + } + }() + } + ctx = templ.InitializeContext(ctx) + templ_7745c5c3_Var11 := templ.GetChildren(ctx) + if templ_7745c5c3_Var11 == nil { + templ_7745c5c3_Var11 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + templ_7745c5c3_Var12 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { + templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) + if !templ_7745c5c3_IsBuffer { + defer func() { + templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) + if templ_7745c5c3_Err == nil { + templ_7745c5c3_Err = templ_7745c5c3_BufErr + } + }() + } + ctx = templ.InitializeContext(ctx) + templ_7745c5c3_Err = GreenLink(activePage, "wyroby", "Ciasta").Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 18, " ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = GreenLink(activePage, "wyroby_deserki", "Deserki").Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 19, " ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = GreenLink(activePage, "wyroby_torty", "Torty").Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 20, " ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = GreenLink(activePage, "wyroby_slodkie_stoly", "Słodkie stoły").Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 21, " ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = GreenLink(activePage, "wyroby_lody", "Lody").Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + return nil + }) + templ_7745c5c3_Err = subnavHeader("Nasze słodkości", "Poznaj nasze tradycyjne receptury przekute w nowoczesne formy. Każdy wypiek to historia pasji, a każde lody to powiew naturalnej świeżości").Render(templ.WithChildren(ctx, templ_7745c5c3_Var12), templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + return nil + }) +} + +func portfolioHeader(activePage string) templ.Component { + return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { + templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context + if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { + return templ_7745c5c3_CtxErr + } + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) + if !templ_7745c5c3_IsBuffer { + defer func() { + templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) + if templ_7745c5c3_Err == nil { + templ_7745c5c3_Err = templ_7745c5c3_BufErr + } + }() + } + ctx = templ.InitializeContext(ctx) + templ_7745c5c3_Var13 := templ.GetChildren(ctx) + if templ_7745c5c3_Var13 == nil { + templ_7745c5c3_Var13 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + templ_7745c5c3_Var14 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { + templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) + if !templ_7745c5c3_IsBuffer { + defer func() { + templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) + if templ_7745c5c3_Err == nil { + templ_7745c5c3_Err = templ_7745c5c3_BufErr + } + }() + } + ctx = templ.InitializeContext(ctx) + templ_7745c5c3_Err = GreenLink(activePage, "portfolio_ciasta", "Ciasta").Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 22, " ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = GreenLink(activePage, "portfolio_deserki", "Deserki").Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 23, " ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = GreenLink(activePage, "portfolio_torty", "Torty").Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 24, " ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = GreenLink(activePage, "portfolio_slodkie_stoly", "Słodkie stoły").Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 25, " ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = GreenLink(activePage, "portfolio_lody", "Lody").Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + return nil + }) + templ_7745c5c3_Err = subnavHeader("Nasze Słodkie Realizacje", "Galeria pasji uwieczniona w kremie i dekoracjach. Zobacz wybrane projekty, które uświetniły wyjątkowe chwile naszych klientów – od bajkowych tortów dla dzieci po eleganckie torty weselne.").Render(templ.WithChildren(ctx, templ_7745c5c3_Var14), templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } diff --git a/html/portfolio.templ b/html/portfolio.templ index 1c4ab88..6c86016 100644 --- a/html/portfolio.templ +++ b/html/portfolio.templ @@ -1,18 +1,14 @@ package html -templ Portfolio() { +templ Portfolio(images []string) { @layout("portfolio") {
-
-
-

Nasze Słodkie Realizacje

-

Galeria pasji uwieczniona w kremie i dekoracjach. Zobacz wybrane projekty, które uświetniły wyjątkowe chwile naszych klientów – od bajkowych tortów dla dzieci po eleganckie torty weselne.

-
-
- Ciasta - Torty - Slodkie stoły - Lody + @portfolioHeader("portfolio") +
+
+ for _, img := range images { + @AvifImage("portfolio/"+img, "portfolio") + }
diff --git a/html/portfolio_templ.go b/html/portfolio_templ.go index b043a92..aeaaecb 100644 --- a/html/portfolio_templ.go +++ b/html/portfolio_templ.go @@ -8,7 +8,7 @@ package html import "github.com/a-h/templ" import templruntime "github.com/a-h/templ/runtime" -func Portfolio() templ.Component { +func Portfolio(images []string) templ.Component { return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { @@ -41,7 +41,25 @@ func Portfolio() templ.Component { }() } ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "

Nasze Słodkie Realizacje

Galeria pasji uwieczniona w kremie i dekoracjach. Zobacz wybrane projekty, które uświetniły wyjątkowe chwile naszych klientów – od bajkowych tortów dla dzieci po eleganckie torty weselne.

Ciasta Torty Slodkie stoły Lody
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = portfolioHeader("portfolio").Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, "
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + for _, img := range images { + templ_7745c5c3_Err = AvifImage("portfolio/"+img, "portfolio").Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 3, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } diff --git a/main.go b/main.go index 5150a24..9b0b069 100644 --- a/main.go +++ b/main.go @@ -7,9 +7,11 @@ import ( "log" "net/http" "os" + "path/filepath" "piekarnikgosi/data" "piekarnikgosi/html" "piekarnikgosi/utils" + "sort" ) type ComponentRenderer interface { @@ -29,11 +31,26 @@ func saveFile(name string, comp ComponentRenderer) { } } +func portfolioImages() []string { + entries, err := os.ReadDir("img/portfolio") + if err != nil { + log.Fatal(err) + } + var names []string + for _, e := range entries { + if filepath.Ext(e.Name()) == ".avif" { + names = append(names, e.Name()) + } + } + sort.Strings(names) + return names +} + func generateHTML() { log.Println("generating html") saveFile(`index`, html.Index()) saveFile(`kawiarnia`, html.Kawiarnia()) - saveFile(`portfolio`, html.Portfolio()) + saveFile(`portfolio`, html.Portfolio(portfolioImages())) saveFile(`wyroby`, html.Wyroby(data.Cakes, "wyroby")) saveFile(`wyroby_deserki`, html.Wyroby(data.Desserts, "wyroby_deserki")) saveFile(`wyroby_torty`, html.WyrobyTorty())