Skip to content

Commit d4e5ffd

Browse files
committed
add fronted
1 parent 6481ebe commit d4e5ffd

File tree

6 files changed

+126
-84
lines changed

6 files changed

+126
-84
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ site
66
*templ.go
77
output.css
88
tailwindcss
9+
tmp/

blueprint-ui/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Simple Makefile for a Go project
22

33
# Build the application
4-
all: build
4+
all: run
55
templ-install:
66
@if ! command -v templ > /dev/null; then \
77
read -p "Go's 'templ' is not installed on your machine. Do you want to install it? [Y/n] " choice; \

blueprint-ui/cmd/web/components/FeatureBlockCheckbox.templ

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7,29 +7,28 @@ type FeatureBlockCheckboxProps struct {
77
}
88

99
templ FeatureBlockCheckbox(props FeatureBlockProps) {
10-
<div class="bg-white shadow sm:rounded-lg">
11-
<div class="px-4 py-5 sm:p-6">
12-
<h3 class="text-base font-semibold leading-6 text-gray-900">
13-
{ props.Title }
14-
</h3>
15-
<div class="mt-2 max-w-xl text-sm text-gray-500 space-y-1">
16-
for _, feature := range props.FeatureOptions {
17-
<div>
18-
<label class="flex items-start">
19-
<input
20-
type="checkbox"
21-
name={ props.GroupName }
22-
value={ feature.Key }
23-
class="mr-2 mt-1"
24-
hx-post="/update_structure"
25-
hx-target="#results"
26-
/>
27-
// x-model={ props.ModelString }
28-
{ feature.Value }
29-
</label>
30-
</div>
31-
}
32-
</div>
33-
</div>
34-
</div>
10+
<div class="w-full">
11+
<div class="px-4 py-5">
12+
<h3 class="text-base font-semibold leading-6 text-gray-900">
13+
{ props.Title }
14+
</h3>
15+
<div class="mt-2 max-w-xl text-sm text-gray-500 space-y-1">
16+
for _, feature := range props.FeatureOptions {
17+
<div>
18+
<label class="flex items-start">
19+
<input
20+
type="checkbox"
21+
name={ props.GroupName }
22+
value={ feature.Key }
23+
class="mr-2 mt-1"
24+
hx-post="/update_structure"
25+
hx-target="#results"
26+
/>
27+
{ feature.Value }
28+
</label>
29+
</div>
30+
}
31+
</div>
32+
</div>
33+
</div>
3534
}

blueprint-ui/cmd/web/components/featureblock.templ

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,30 +7,29 @@ type FeatureBlockProps struct {
77
}
88

99
templ FeatureBlock(props FeatureBlockProps) {
10-
<div class="bg-white shadow sm:rounded-lg w-full">
11-
<div class="px-4 py-5 sm:p-6">
12-
<h3 class="text-base font-semibold leading-6 text-gray-900">
13-
{ props.Title }
14-
</h3>
15-
<div class="mt-2 max-w-xl text-sm text-gray-500 space-y-1">
16-
for i, feature := range props.FeatureOptions {
17-
<div>
18-
<label class="flex items-center">
19-
<input
20-
type="radio"
21-
name={ props.GroupName }
22-
value={ feature.Key }
23-
class="mr-2"
24-
checked?={ i == 0 }
25-
hx-post="/update_structure"
26-
hx-target="#results"
27-
/>
28-
// x-model={ props.ModelString }
29-
{ feature.Value }
30-
</label>
31-
</div>
32-
}
33-
</div>
34-
</div>
35-
</div>
10+
<div class="w-full">
11+
<div class="px-4 py-5">
12+
<h3 class="text-base font-semibold leading-6 text-gray-900">
13+
{ props.Title }
14+
</h3>
15+
<div class="mt-2 max-w-xl text-sm text-gray-500 space-y-1">
16+
for i, feature := range props.FeatureOptions {
17+
<div>
18+
<label class="flex items-center">
19+
<input
20+
type="radio"
21+
name={ props.GroupName }
22+
value={ feature.Key }
23+
class="mr-2"
24+
checked?={ i == 0 }
25+
hx-post="/update_structure"
26+
hx-target="#results"
27+
/>
28+
{ feature.Value }
29+
</label>
30+
</div>
31+
}
32+
</div>
33+
</div>
34+
</div>
3635
}

blueprint-ui/cmd/web/components/form.templ

Lines changed: 70 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,21 @@ var git = []FeatureTuple{
5353
{"skip", "Skip"},
5454
}
5555

56+
var frontend = []FeatureTuple{
57+
{"htmx", "HTMX"},
58+
{"react", "React"},
59+
}
60+
61+
var frontendAdvanced = []FeatureTuple{
62+
{"tailwind", "Tailwind CSS"},
63+
}
64+
65+
var advanced = []FeatureTuple{
66+
{"githubaction", "CI/CD workflow setup using Github Actions."},
67+
{"websocket", "Adds a Websocket endpoint."},
68+
{"docker", "Docker configuration for go project."},
69+
}
70+
5671
var options = OptionsStruct{
5772
ProjectName: "my_project",
5873
SelectedBackend: "standard-library",
@@ -83,40 +98,64 @@ templ Form() {
8398
</div>
8499
</div>
85100
<div class="space-y-6">
86-
<div class="flex justify-between px-4">
87-
<div class="w-1/4">
88-
@FeatureBlock(FeatureBlockProps{
89-
Title: "Backend",
90-
FeatureOptions: backend,
91-
GroupName: "backend",
92-
})
101+
// First row with Backend, Database, and Git
102+
<div class="bg-white shadow sm:rounded-lg">
103+
<div class="flex justify-center gap-32 px-4">
104+
<div class="w-1/4">
105+
@FeatureBlock(FeatureBlockProps{
106+
Title: "Backend",
107+
FeatureOptions: backend,
108+
GroupName: "backend",
109+
})
110+
</div>
111+
<div class="w-1/4">
112+
@FeatureBlock(FeatureBlockProps{
113+
Title: "Database",
114+
FeatureOptions: databases,
115+
GroupName: "database",
116+
})
117+
</div>
118+
<div class="w-1/4">
119+
@FeatureBlock(FeatureBlockProps{
120+
Title: "Git",
121+
FeatureOptions: git,
122+
GroupName: "git",
123+
})
124+
</div>
93125
</div>
94-
<div class="w-1/4">
95-
@FeatureBlock(FeatureBlockProps{
96-
Title: "Database",
97-
FeatureOptions: databases,
98-
GroupName: "database",
99-
})
100-
</div>
101-
<div class="w-1/4">
102-
@FeatureBlock(FeatureBlockProps{
103-
Title: "Git",
104-
FeatureOptions: git,
105-
GroupName: "git",
106-
})
126+
</div>
127+
128+
// Second row with Frontend and Frontend Advanced
129+
<div class="bg-white shadow sm:rounded-lg">
130+
<div class="flex justify-center gap-32 px-4">
131+
<div class="w-1/4">
132+
@FeatureBlock(FeatureBlockProps{
133+
Title: "Frontend",
134+
FeatureOptions: frontend,
135+
GroupName: "frontend",
136+
})
137+
</div>
138+
<div class="w-1/4">
139+
@FeatureBlockCheckbox(FeatureBlockProps{
140+
Title: "Frontend Advanced",
141+
FeatureOptions: frontendAdvanced,
142+
GroupName: "frontedAdvancedOptions",
143+
})
144+
</div>
107145
</div>
108146
</div>
109-
<div class="max-w-4xl mx-auto px-4">
110-
@FeatureBlockCheckbox(FeatureBlockProps{
111-
Title: "Advanced",
112-
FeatureOptions: []FeatureTuple{
113-
{"htmx", "HTMX support using Templ."},
114-
{"githubaction", "CI/CD workflow setup using Github Actions."},
115-
{"websocket", "Adds a Websocket endpoint."},
116-
{"tailwind", "Adds Tailwind config and allows for using the Tailwind CLI to compile css based on classes used."},
117-
},
118-
GroupName: "advancedOptions",
119-
})
147+
148+
// Third row with Advanced
149+
<div class="bg-white shadow sm:rounded-lg">
150+
<div class="flex justify-center px-4">
151+
<div class="w-1/4">
152+
@FeatureBlockCheckbox(FeatureBlockProps{
153+
Title: "Advanced",
154+
FeatureOptions: advanced,
155+
GroupName: "advancedOptions",
156+
})
157+
</div>
158+
</div>
120159
</div>
121160
</div>
122161
</form>

blueprint-ui/cmd/web/update_structure.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,9 @@ func UpdateStructureHandler(w http.ResponseWriter, r *http.Request) {
4040
}
4141
commandStr := components.GetCommandString(options)
4242

43-
components.FolderStructure(options, commandStr).Render(r.Context(), w)
43+
err = components.FolderStructure(options, commandStr).Render(r.Context(), w)
44+
if err != nil {
45+
http.Error(w, "Internal Server Error", http.StatusInternalServerError)
46+
return
47+
}
4448
}

0 commit comments

Comments
 (0)