mirror of
https://github.com/axzilla/templui.git
synced 2025-02-23 11:44:02 +00:00
62 lines
1.4 KiB
Plaintext
62 lines
1.4 KiB
Plaintext
package modules
|
|
|
|
import (
|
|
"github.com/axzilla/templui/internals/ui/showcase"
|
|
"github.com/axzilla/templui/pkg/components"
|
|
)
|
|
|
|
type showcaseWrapperProps struct {
|
|
Content templ.Component
|
|
}
|
|
|
|
templ showcaseWrapper(p showcaseWrapperProps) {
|
|
<div class="flex justify-center items-center border rounded-md py-16 px-4">
|
|
@p.Content
|
|
</div>
|
|
}
|
|
|
|
type ExampleWrapperProps struct {
|
|
SectionName string
|
|
ShowcaseFile templ.Component
|
|
PreviewCodeFile string
|
|
ComponentCodeFile string
|
|
}
|
|
|
|
templ ExampleWrapper(p ExampleWrapperProps) {
|
|
<div>
|
|
<p class="mb-2 font-bold text-muted-foreground">{ p.SectionName }</p>
|
|
@components.Tabs(components.TabsProps{
|
|
Tabs: generateTabs(p), // Extrahiere Logik in separate Funktion
|
|
TabsContainerClass: "md:w-1/2",
|
|
ContentContainerClass: "w-full",
|
|
})
|
|
</div>
|
|
}
|
|
|
|
func generateTabs(p ExampleWrapperProps) []components.Tab {
|
|
tabs := []components.Tab{
|
|
{
|
|
ID: "preview",
|
|
Title: "Preview",
|
|
Content: showcaseWrapper(showcaseWrapperProps{
|
|
Content: p.ShowcaseFile,
|
|
}),
|
|
},
|
|
{
|
|
ID: "code",
|
|
Title: "Code",
|
|
Content: CodeSnippetFromEmbedded(p.PreviewCodeFile, "go", showcase.TemplFiles),
|
|
},
|
|
}
|
|
|
|
if p.ComponentCodeFile != "" {
|
|
tabs = append(tabs, components.Tab{
|
|
ID: "component",
|
|
Title: "Component",
|
|
Content: CodeSnippetFromEmbedded(p.ComponentCodeFile, "go", components.TemplFiles),
|
|
})
|
|
}
|
|
|
|
return tabs
|
|
}
|