init: first init
This commit is contained in:
130
web/components/navigation/navigation.templ
Normal file
130
web/components/navigation/navigation.templ
Normal file
@@ -0,0 +1,130 @@
|
||||
package navigation
|
||||
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
// CHANGE TO WHATEVER DIRECTORY HAS YOUR TEMPLUI UTILS FOLDER
|
||||
"blog/web/utils"
|
||||
)
|
||||
|
||||
type Variant string
|
||||
type Size string
|
||||
|
||||
const(
|
||||
VariantDefault Variant = "default"
|
||||
VariantOutline Variant = "outline"
|
||||
VariantSecondary Variant = "secondary"
|
||||
VariantGhost Variant = "ghost"
|
||||
)
|
||||
|
||||
const(
|
||||
SizeDefault Size = "default"
|
||||
SizeSm Size = "sm"
|
||||
SizeLg Size = "lg"
|
||||
SizeIcon Size = "icon"
|
||||
)
|
||||
|
||||
type Props struct {
|
||||
ID string
|
||||
Class string
|
||||
Columns int
|
||||
Attributes templ.Attributes
|
||||
Variant Variant
|
||||
Size Size
|
||||
}
|
||||
|
||||
templ Navigation(props ...Props) {
|
||||
{{ var p Props }}
|
||||
{{ var cols string }}
|
||||
if len(props) > 0 {
|
||||
{{ p = props[0] }}
|
||||
}
|
||||
|
||||
if p.Columns == 0 {
|
||||
{{ cols = "grid-cols-1"}}
|
||||
} else {
|
||||
{{ cols = fmt.Sprintf("grid-cols-%d", p.Columns) }}
|
||||
}
|
||||
|
||||
<header
|
||||
class={
|
||||
utils.TwMerge(
|
||||
"w-full bg-card border-b border-b-secondary h-16 grid 2 text-lg items-center px-4 ",
|
||||
cols,
|
||||
),
|
||||
}
|
||||
|
||||
{ p.Attributes... }
|
||||
>
|
||||
{ children... }
|
||||
</header>
|
||||
}
|
||||
|
||||
func (p Props) variantClasses() string {
|
||||
switch p.Variant {
|
||||
case VariantGhost:
|
||||
return "hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent"
|
||||
case VariantOutline:
|
||||
return "border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50"
|
||||
case VariantSecondary:
|
||||
return "bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80"
|
||||
default:
|
||||
return "bg-primary text-primary-foreground shadow-xs hover:bg-primary/90"
|
||||
}
|
||||
}
|
||||
|
||||
func (b Props) sizeClasses() string {
|
||||
switch b.Size {
|
||||
case SizeSm:
|
||||
return "h-8 rounded-full aspect-square gap-1.5 px-3 has-[>svg]:px-2.5"
|
||||
case SizeLg:
|
||||
return "h-10 rounded-full aspect-square px-6 has-[>svg]:px-4"
|
||||
case SizeIcon:
|
||||
return "size-9"
|
||||
default: // SizeDefault
|
||||
return "h-9 px-4 py-2 has-[>svg]:px-3"
|
||||
}
|
||||
}
|
||||
|
||||
// Theme change script
|
||||
templ Script() {
|
||||
<script>
|
||||
function ThemeToggle() {
|
||||
return {
|
||||
darkMode: false,
|
||||
|
||||
init() {
|
||||
// Check localStorage for "darkMode" first, then use system preference
|
||||
const stored = localStorage.getItem("darkMode")
|
||||
if (stored !== null) {
|
||||
this.darkMode = stored === "true"
|
||||
} else {
|
||||
this.darkMode = window.matchMedia('(prefers-color-scheme: dark)').matches
|
||||
}
|
||||
|
||||
// Apply theme immediately
|
||||
this.updateTheme()
|
||||
|
||||
// Watch for changes
|
||||
this.$watch("darkMode", () => {
|
||||
this.updateTheme()
|
||||
localStorage.setItem('darkMode', this.darkMode)
|
||||
})
|
||||
},
|
||||
|
||||
toggle() {
|
||||
this.darkMode = !this.darkMode
|
||||
},
|
||||
|
||||
updateTheme() {
|
||||
if (this.darkMode) {
|
||||
document.body.classList.add("dark")
|
||||
} else {
|
||||
document.body.classList.remove("dark")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
}
|
||||
|
||||
176
web/components/navigation/navigation_templ.go
Normal file
176
web/components/navigation/navigation_templ.go
Normal file
@@ -0,0 +1,176 @@
|
||||
// Code generated by templ - DO NOT EDIT.
|
||||
|
||||
// templ: version: v0.3.977
|
||||
package navigation
|
||||
|
||||
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
||||
|
||||
import "github.com/a-h/templ"
|
||||
import templruntime "github.com/a-h/templ/runtime"
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
// CHANGE TO WHATEVER DIRECTORY HAS YOUR TEMPLUI UTILS FOLDER
|
||||
"blog/web/utils"
|
||||
)
|
||||
|
||||
type Variant string
|
||||
type Size string
|
||||
|
||||
const (
|
||||
VariantDefault Variant = "default"
|
||||
VariantOutline Variant = "outline"
|
||||
VariantSecondary Variant = "secondary"
|
||||
VariantGhost Variant = "ghost"
|
||||
)
|
||||
|
||||
const (
|
||||
SizeDefault Size = "default"
|
||||
SizeSm Size = "sm"
|
||||
SizeLg Size = "lg"
|
||||
SizeIcon Size = "icon"
|
||||
)
|
||||
|
||||
type Props struct {
|
||||
ID string
|
||||
Class string
|
||||
Columns int
|
||||
Attributes templ.Attributes
|
||||
Variant Variant
|
||||
Size Size
|
||||
}
|
||||
|
||||
func Navigation(props ...Props) 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_Var1 := templ.GetChildren(ctx)
|
||||
if templ_7745c5c3_Var1 == nil {
|
||||
templ_7745c5c3_Var1 = templ.NopComponent
|
||||
}
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
var p Props
|
||||
var cols string
|
||||
if len(props) > 0 {
|
||||
p = props[0]
|
||||
}
|
||||
if p.Columns == 0 {
|
||||
cols = "grid-cols-1"
|
||||
} else {
|
||||
cols = fmt.Sprintf("grid-cols-%d", p.Columns)
|
||||
}
|
||||
var templ_7745c5c3_Var2 = []any{utils.TwMerge(
|
||||
"w-full bg-card border-b border-b-secondary h-16 grid 2 text-lg items-center px-4 ",
|
||||
cols,
|
||||
),
|
||||
}
|
||||
templ_7745c5c3_Err = templ.RenderCSSItems(ctx, templ_7745c5c3_Buffer, templ_7745c5c3_Var2...)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "<header class=\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var3 string
|
||||
templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(templ.CSSClasses(templ_7745c5c3_Var2).String())
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `web/components/navigation/navigation.templ`, Line: 1, Col: 0}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3))
|
||||
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
|
||||
}
|
||||
templ_7745c5c3_Err = templ.RenderAttributes(ctx, templ_7745c5c3_Buffer, p.Attributes)
|
||||
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
|
||||
}
|
||||
templ_7745c5c3_Err = templ_7745c5c3_Var1.Render(ctx, templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 4, "</header>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
func (p Props) variantClasses() string {
|
||||
switch p.Variant {
|
||||
case VariantGhost:
|
||||
return "hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent"
|
||||
case VariantOutline:
|
||||
return "border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50"
|
||||
case VariantSecondary:
|
||||
return "bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80"
|
||||
default:
|
||||
return "bg-primary text-primary-foreground shadow-xs hover:bg-primary/90"
|
||||
}
|
||||
}
|
||||
|
||||
func (b Props) sizeClasses() string {
|
||||
switch b.Size {
|
||||
case SizeSm:
|
||||
return "h-8 rounded-full aspect-square gap-1.5 px-3 has-[>svg]:px-2.5"
|
||||
case SizeLg:
|
||||
return "h-10 rounded-full aspect-square px-6 has-[>svg]:px-4"
|
||||
case SizeIcon:
|
||||
return "size-9"
|
||||
default: // SizeDefault
|
||||
return "h-9 px-4 py-2 has-[>svg]:px-3"
|
||||
}
|
||||
}
|
||||
|
||||
// Theme change script
|
||||
func Script() 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_Var4 := templ.GetChildren(ctx)
|
||||
if templ_7745c5c3_Var4 == nil {
|
||||
templ_7745c5c3_Var4 = templ.NopComponent
|
||||
}
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 5, "<script>\n function ThemeToggle() {\n return {\n darkMode: false,\n \n init() {\n // Check localStorage for \"darkMode\" first, then use system preference\n const stored = localStorage.getItem(\"darkMode\")\n if (stored !== null) {\n this.darkMode = stored === \"true\"\n } else {\n this.darkMode = window.matchMedia('(prefers-color-scheme: dark)').matches\n }\n\n // Apply theme immediately\n this.updateTheme()\n\n // Watch for changes\n this.$watch(\"darkMode\", () => {\n this.updateTheme()\n localStorage.setItem('darkMode', this.darkMode) \n })\n },\n\n toggle() {\n this.darkMode = !this.darkMode\n },\n\n updateTheme() {\n if (this.darkMode) {\n document.body.classList.add(\"dark\")\n } else {\n document.body.classList.remove(\"dark\")\n }\n }\n }\n }\n </script>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
var _ = templruntime.GeneratedTemplate
|
||||
195
web/static/css/input.css
Normal file
195
web/static/css/input.css
Normal file
@@ -0,0 +1,195 @@
|
||||
@import "tailwindcss";
|
||||
|
||||
@custom-variant dark (&:where(.dark, .dark *));
|
||||
|
||||
@theme inline {
|
||||
--breakpoint-3xl: 1600px;
|
||||
--breakpoint-4xl: 2000px;
|
||||
--radius-sm: calc(var(--radius) - 4px);
|
||||
--radius-md: calc(var(--radius) - 2px);
|
||||
--radius-lg: var(--radius);
|
||||
--radius-xl: calc(var(--radius) + 4px);
|
||||
--color-background: var(--background);
|
||||
--color-foreground: var(--foreground);
|
||||
--color-card: var(--card);
|
||||
--color-card-foreground: var(--card-foreground);
|
||||
--color-popover: var(--popover);
|
||||
--color-popover-foreground: var(--popover-foreground);
|
||||
--color-primary: var(--primary);
|
||||
--color-primary-foreground: var(--primary-foreground);
|
||||
--color-secondary: var(--secondary);
|
||||
--color-secondary-foreground: var(--secondary-foreground);
|
||||
--color-muted: var(--muted);
|
||||
--color-muted-foreground: var(--muted-foreground);
|
||||
--color-accent: var(--accent);
|
||||
--color-accent-foreground: var(--accent-foreground);
|
||||
--color-destructive: var(--destructive);
|
||||
--color-destructive-foreground: var(--destructive-foreground);
|
||||
--color-border: var(--border);
|
||||
--color-input: var(--input);
|
||||
--color-ring: var(--ring);
|
||||
--color-chart-1: var(--chart-1);
|
||||
--color-chart-2: var(--chart-2);
|
||||
--color-chart-3: var(--chart-3);
|
||||
--color-chart-4: var(--chart-4);
|
||||
--color-chart-5: var(--chart-5);
|
||||
--color-sidebar: var(--sidebar);
|
||||
--color-sidebar-foreground: var(--sidebar-foreground);
|
||||
--color-sidebar-primary: var(--sidebar-primary);
|
||||
--color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
|
||||
--color-sidebar-accent: var(--sidebar-accent);
|
||||
--color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
|
||||
--color-sidebar-border: var(--sidebar-border);
|
||||
--color-sidebar-ring: var(--sidebar-ring);
|
||||
--font-sans: var(--font-sans);
|
||||
--font-mono: var(--font-mono);
|
||||
--font-serif: var(--font-serif);
|
||||
--font-lato: var(--font-lato);
|
||||
--shadow-2xs: var(--shadow-2xs);
|
||||
--shadow-xs: var(--shadow-xs);
|
||||
--shadow-sm: var(--shadow-sm);
|
||||
--shadow: var(--shadow);
|
||||
--shadow-md: var(--shadow-md);
|
||||
--shadow-lg: var(--shadow-lg);
|
||||
--shadow-xl: var(--shadow-xl);
|
||||
--shadow-2xl: var(--shadow-2xl);
|
||||
--tracking-tighter: calc(var(--tracking-normal) - 0.05em);
|
||||
--tracking-tight: calc(var(--tracking-normal) - 0.025em);
|
||||
--tracking-normal: var(--tracking-normal);
|
||||
--tracking-wide: calc(var(--tracking-normal) + 0.025em);
|
||||
--tracking-wider: calc(var(--tracking-normal) + 0.05em);
|
||||
--tracking-widest: calc(var(--tracking-normal) + 0.1em);
|
||||
}
|
||||
|
||||
:root {
|
||||
--radius: 0.75rem;
|
||||
--background: oklch(0.9755 0.0067 97.3510);
|
||||
--foreground: oklch(0.2178 0 0);
|
||||
--card: oklch(1.0000 0 0);
|
||||
--card-foreground: oklch(0.2178 0 0);
|
||||
--popover: oklch(1.0000 0 0);
|
||||
--popover-foreground: oklch(0.2178 0 0);
|
||||
--primary: oklch(0.7414 0.0738 84.5946);
|
||||
--primary-foreground: oklch(1.0000 0 0);
|
||||
--secondary: oklch(0.9096 0.0167 91.5611);
|
||||
--secondary-foreground: oklch(0.2178 0 0);
|
||||
--muted: oklch(0.9459 0.0165 91.5544);
|
||||
--muted-foreground: oklch(0.5022 0.0278 85.7741);
|
||||
--accent: oklch(0.7414 0.0738 84.5946);
|
||||
--accent-foreground: oklch(1.0000 0 0);
|
||||
--destructive: oklch(0.5680 0.2002 26.4057);
|
||||
--destructive-foreground: oklch(1.0000 0 0);
|
||||
--border: oklch(0.8986 0.0258 97.1423);
|
||||
--input: oklch(0.8986 0.0258 97.1423);
|
||||
--ring: oklch(0.7414 0.0738 84.5946);
|
||||
--chart-1: oklch(0.7414 0.0738 84.5946);
|
||||
--chart-2: oklch(0.3738 0.0116 258.3660);
|
||||
--chart-3: oklch(0.9096 0.0167 91.5611);
|
||||
--chart-4: oklch(0.5933 0.0472 87.9063);
|
||||
--chart-5: oklch(0.2958 0.0084 255.5667);
|
||||
--sidebar: oklch(0.9459 0.0165 91.5544);
|
||||
--sidebar-foreground: oklch(0.2178 0 0);
|
||||
--sidebar-primary: oklch(0.7414 0.0738 84.5946);
|
||||
--sidebar-primary-foreground: oklch(1.0000 0 0);
|
||||
--sidebar-accent: oklch(0.8986 0.0258 97.1423);
|
||||
--sidebar-accent-foreground: oklch(0.2178 0 0);
|
||||
--sidebar-border: oklch(0.8986 0.0258 97.1423);
|
||||
--sidebar-ring: oklch(0.7414 0.0738 84.5946);
|
||||
--font-sans: Inter, -apple-system, sans-serif;
|
||||
--font-serif: Georgia, serif;
|
||||
--font-lato: Lato, sans-serif;
|
||||
--font-mono: JetBrains Mono, monospace;
|
||||
--shadow-x: 0px;
|
||||
--shadow-y: 8px;
|
||||
--shadow-blur: 15px;
|
||||
--shadow-spread: 0px;
|
||||
--shadow-opacity: 0.05;
|
||||
--shadow-color: #000000;
|
||||
--shadow-2xs: 0px 8px 15px 0px hsl(0 0% 0% / 0.03);
|
||||
--shadow-xs: 0px 8px 15px 0px hsl(0 0% 0% / 0.03);
|
||||
--shadow-sm: 0px 8px 15px 0px hsl(0 0% 0% / 0.05), 0px 1px 2px -1px hsl(0 0% 0% / 0.05);
|
||||
--shadow: 0px 8px 15px 0px hsl(0 0% 0% / 0.05), 0px 1px 2px -1px hsl(0 0% 0% / 0.05);
|
||||
--shadow-md: 0px 8px 15px 0px hsl(0 0% 0% / 0.05), 0px 2px 4px -1px hsl(0 0% 0% / 0.05);
|
||||
--shadow-lg: 0px 8px 15px 0px hsl(0 0% 0% / 0.05), 0px 4px 6px -1px hsl(0 0% 0% / 0.05);
|
||||
--shadow-xl: 0px 8px 15px 0px hsl(0 0% 0% / 0.05), 0px 8px 10px -1px hsl(0 0% 0% / 0.05);
|
||||
--shadow-2xl: 0px 8px 15px 0px hsl(0 0% 0% / 0.13);
|
||||
--tracking-normal: -0.02em;
|
||||
--spacing: 0.25rem;
|
||||
}
|
||||
|
||||
.dark {
|
||||
--background: oklch(0.1904 0.0040 106.7692);
|
||||
--foreground: oklch(0.9755 0.0067 97.3510);
|
||||
--card: oklch(0.2343 0.0038 106.6863);
|
||||
--card-foreground: oklch(0.9755 0.0067 97.3510);
|
||||
--popover: oklch(0.2343 0.0038 106.6863);
|
||||
--popover-foreground: oklch(0.9755 0.0067 97.3510);
|
||||
--primary: oklch(0.8039 0.0702 84.7579);
|
||||
--primary-foreground: oklch(0.1904 0.0040 106.7692);
|
||||
--secondary: oklch(0.2901 0.0061 78.2320);
|
||||
--secondary-foreground: oklch(0.9755 0.0067 97.3510);
|
||||
--muted: oklch(0.2596 0.0037 106.6523);
|
||||
--muted-foreground: oklch(0.7006 0.0154 84.5911);
|
||||
--accent: oklch(0.8039 0.0702 84.7579);
|
||||
--accent-foreground: oklch(0.1904 0.0040 106.7692);
|
||||
--destructive: oklch(0.6368 0.2078 25.3313);
|
||||
--destructive-foreground: oklch(0.9755 0.0067 97.3510);
|
||||
--border: oklch(0.2901 0.0061 78.2320);
|
||||
--input: oklch(0.2901 0.0061 78.2320);
|
||||
--ring: oklch(0.8039 0.0702 84.7579);
|
||||
--chart-1: oklch(0.8039 0.0702 84.7579);
|
||||
--chart-2: oklch(0.5498 0.0111 252.8780);
|
||||
--chart-3: oklch(0.3142 0.0060 78.2414);
|
||||
--chart-4: oklch(0.6926 0.0459 87.9527);
|
||||
--chart-5: oklch(0.2170 0.0038 106.7146);
|
||||
--sidebar: oklch(0.1904 0.0040 106.7692);
|
||||
--sidebar-foreground: oklch(0.9755 0.0067 97.3510);
|
||||
--sidebar-primary: oklch(0.8039 0.0702 84.7579);
|
||||
--sidebar-primary-foreground: oklch(0.1904 0.0040 106.7692);
|
||||
--sidebar-accent: oklch(0.2901 0.0061 78.2320);
|
||||
--sidebar-accent-foreground: oklch(0.9755 0.0067 97.3510);
|
||||
--sidebar-border: oklch(0.2901 0.0061 78.2320);
|
||||
--sidebar-ring: oklch(0.8039 0.0702 84.7579);
|
||||
--font-sans: Inter, -apple-system, sans-serif;
|
||||
--font-serif: Georgia, serif;
|
||||
--font-mono: JetBrains Mono, monospace;
|
||||
--shadow-x: 0px;
|
||||
--shadow-y: 10px;
|
||||
--shadow-blur: 25px;
|
||||
--shadow-spread: 0px;
|
||||
--shadow-opacity: 0.4;
|
||||
--shadow-color: #000000;
|
||||
--shadow-2xs: 0px 10px 25px 0px hsl(0 0% 0% / 0.20);
|
||||
--shadow-xs: 0px 10px 25px 0px hsl(0 0% 0% / 0.20);
|
||||
--shadow-sm: 0px 10px 25px 0px hsl(0 0% 0% / 0.40), 0px 1px 2px -1px hsl(0 0% 0% / 0.40);
|
||||
--shadow: 0px 10px 25px 0px hsl(0 0% 0% / 0.40), 0px 1px 2px -1px hsl(0 0% 0% / 0.40);
|
||||
--shadow-md: 0px 10px 25px 0px hsl(0 0% 0% / 0.40), 0px 2px 4px -1px hsl(0 0% 0% / 0.40);
|
||||
--shadow-lg: 0px 10px 25px 0px hsl(0 0% 0% / 0.40), 0px 4px 6px -1px hsl(0 0% 0% / 0.40);
|
||||
--shadow-xl: 0px 10px 25px 0px hsl(0 0% 0% / 0.40), 0px 8px 10px -1px hsl(0 0% 0% / 0.40);
|
||||
--shadow-2xl: 0px 10px 25px 0px hsl(0 0% 0% / 1.00);
|
||||
}
|
||||
|
||||
@layer base {
|
||||
* {
|
||||
@apply border-border;
|
||||
scrollbar-width: thin;
|
||||
scrollbar-color: var(--color-muted-foreground) transparent;
|
||||
}
|
||||
*::-webkit-scrollbar {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
}
|
||||
*::-webkit-scrollbar-thumb {
|
||||
background: var(--color-muted-foreground);
|
||||
border-radius: 4px;
|
||||
}
|
||||
*::-webkit-scrollbar-thumb:hover {
|
||||
background: var(--color-foreground);
|
||||
}
|
||||
body {
|
||||
@apply bg-background text-foreground;
|
||||
letter-spacing: var(--tracking-normal);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
74
web/utils/templui.go
Normal file
74
web/utils/templui.go
Normal file
@@ -0,0 +1,74 @@
|
||||
// templui util templui.go - version: v1.5.0 installed by templui v1.5.0
|
||||
package utils
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"crypto/rand"
|
||||
|
||||
"github.com/a-h/templ"
|
||||
|
||||
twmerge "github.com/Oudwins/tailwind-merge-go"
|
||||
)
|
||||
|
||||
// TwMerge combines Tailwind classes and resolves conflicts.
|
||||
// Example: "bg-red-500 hover:bg-blue-500", "bg-green-500" → "hover:bg-blue-500 bg-green-500"
|
||||
func TwMerge(classes ...string) string {
|
||||
return twmerge.Merge(classes...)
|
||||
}
|
||||
|
||||
// TwIf returns value if condition is true, otherwise an empty value of type T.
|
||||
// Example: true, "bg-red-500" → "bg-red-500"
|
||||
func If[T comparable](condition bool, value T) T {
|
||||
var empty T
|
||||
if condition {
|
||||
return value
|
||||
}
|
||||
return empty
|
||||
}
|
||||
|
||||
// TwIfElse returns trueValue if condition is true, otherwise falseValue.
|
||||
// Example: true, "bg-red-500", "bg-gray-300" → "bg-red-500"
|
||||
func IfElse[T any](condition bool, trueValue T, falseValue T) T {
|
||||
if condition {
|
||||
return trueValue
|
||||
}
|
||||
return falseValue
|
||||
}
|
||||
|
||||
// MergeAttributes combines multiple Attributes into one.
|
||||
// Example: MergeAttributes(attr1, attr2) → combined attributes
|
||||
func MergeAttributes(attrs ...templ.Attributes) templ.Attributes {
|
||||
merged := templ.Attributes{}
|
||||
for _, attr := range attrs {
|
||||
for k, v := range attr {
|
||||
merged[k] = v
|
||||
}
|
||||
}
|
||||
return merged
|
||||
}
|
||||
|
||||
// RandomID generates a random ID string.
|
||||
// Example: RandomID() → "id-1a2b3c"
|
||||
func RandomID() string {
|
||||
return fmt.Sprintf("id-%s", rand.Text())
|
||||
}
|
||||
|
||||
// ScriptVersion is a timestamp generated at app start for cache busting.
|
||||
// Used in Script() templates to append ?v=<timestamp> to script URLs.
|
||||
var ScriptVersion = fmt.Sprintf("%d", time.Now().Unix())
|
||||
|
||||
// ScriptURL generates cache-busted script URLs.
|
||||
// Override this to use custom cache busting (CDN, content hashing, etc.)
|
||||
//
|
||||
// Example override in your app:
|
||||
//
|
||||
// func init() {
|
||||
// utils.ScriptURL = func(path string) string {
|
||||
// return myAssetManifest.GetURL(path)
|
||||
// }
|
||||
// }
|
||||
var ScriptURL = func(path string) string {
|
||||
return path + "?v=" + ScriptVersion
|
||||
}
|
||||
Reference in New Issue
Block a user