1
0
mirror of https://github.com/H0llyW00dzZ/My-RESTAPIs-Boilerplate.git synced 2025-02-06 10:02:01 +00:00

Improve [Frontend] [HTMX-TEMPL] Tailwind CSS (#620)

This commit is contained in:
H0llyW00dzZ 2024-07-15 18:11:12 +07:00 committed by GitHub
parent 603f647ccc
commit e688c9f9c0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 15 additions and 41 deletions

View File

@ -24,13 +24,7 @@ var onceCSS = templ.NewOnceHandle()
templ cSS(cspRandom string) {
@onceCSS.Once() {
// Note: This safe & secure as well which it's already bound into CSP smiliar HTMX.
<script src="https://cdn.tailwindcss.com" nonce={ cspRandom }></script>
// Note: This seems risky due expose config in front, however this is Go, it's easy to secure, it's just that I'm lazy, due it only enable dark mode.
<script nonce={ cspRandom }>
tailwind.config = {
darkMode: 'selector',
}
</script>
<link rel="stylesheet" href="/styles/css/base-tailwind.css"/>
}
}

View File

@ -114,33 +114,7 @@ func cSS(cspRandom string) templ.Component {
}()
}
ctx = templ.InitializeContext(ctx)
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(" <script src=\"https://cdn.tailwindcss.com\" nonce=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var6 string
templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(cspRandom)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `frontend/htmx/site/head.templ`, Line: 27, Col: 61}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\"></script> <script nonce=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var7 string
templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(cspRandom)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `frontend/htmx/site/head.templ`, Line: 29, Col: 27}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("\">\r\n \t\t\t \ttailwind.config = {\r\n\t\t\t\tdarkMode: 'selector',\r\n \t\t\t}\r\n \t\t\t</script>")
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(" <link rel=\"stylesheet\" href=\"/styles/css/base-tailwind.css\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@ -169,12 +143,12 @@ func subHead() templ.Component {
}()
}
ctx = templ.InitializeContext(ctx)
templ_7745c5c3_Var8 := templ.GetChildren(ctx)
if templ_7745c5c3_Var8 == nil {
templ_7745c5c3_Var8 = templ.NopComponent
templ_7745c5c3_Var6 := templ.GetChildren(ctx)
if templ_7745c5c3_Var6 == nil {
templ_7745c5c3_Var6 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
templ_7745c5c3_Var9 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
templ_7745c5c3_Var7 := 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 {
@ -192,7 +166,7 @@ func subHead() templ.Component {
}
return templ_7745c5c3_Err
})
templ_7745c5c3_Err = onceIcon.Once().Render(templ.WithChildren(ctx, templ_7745c5c3_Var9), templ_7745c5c3_Buffer)
templ_7745c5c3_Err = onceIcon.Once().Render(templ.WithChildren(ctx, templ_7745c5c3_Var7), templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}

File diff suppressed because one or more lines are too long

View File

@ -1,9 +1,14 @@
/** @type {import('tailwindcss').Config} */
module.exports = {
content: [],
content: [
// Note: This should be correct. and now it fully rendered.
'frontend/htmx/error_page_handler/*.{templ,js}',
'frontend/htmx/site/*.{templ,js}',
'frontend/public/assets/js/*.{templ,js}',
],
theme: {
extend: {},
},
plugins: [],
darkMode: 'selector',
}