mirror of
https://github.com/sonr-io/sonr.git
synced 2026-08-02 17:31:39 +00:00
157 lines
4.7 KiB
Templ
157 lines
4.7 KiB
Templ
package styles
|
|
|
|
import "strings"
|
|
|
|
type Icon interface {
|
|
Render() templ.Component
|
|
}
|
|
|
|
type Variant interface {
|
|
Attributes() templ.Attributes
|
|
}
|
|
|
|
templ Spacer() {
|
|
<br/>
|
|
}
|
|
|
|
templ Rows() {
|
|
<div class="flex flex-row w-full gap-2 md:gap-4">
|
|
{ children... }
|
|
</div>
|
|
}
|
|
|
|
templ Columns() {
|
|
<div class="flex flex-col h-full w-full gap-3 md:gap-6 md:flex-row">
|
|
{ children... }
|
|
</div>
|
|
}
|
|
|
|
templ Layout(title string, remote bool) {
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
@Styles()
|
|
@Htmx()
|
|
@Alpine()
|
|
<meta charset="UTF-8"/>
|
|
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
|
<title>{ title }</title>
|
|
<!-- Sets the status bar style to transparent -->
|
|
<meta name="apple-mobile-web-app-capable" content="yes"/>
|
|
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent"/>
|
|
<link rel="icon" type="image/png" href="https://cdn.sonr.id/favicon.png"/>
|
|
</head>
|
|
<body class="flex items-center justify-center h-full bg-neutral-50 lg:p-24 md:16 p-4">
|
|
<main class="flex-row items-center justify-center mx-auto w-fit max-w-screen-sm gap-y-3">
|
|
{ children... }
|
|
</main>
|
|
</body>
|
|
</html>
|
|
}
|
|
|
|
templ LayoutNoBody(title string, remote bool) {
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
@Styles()
|
|
@Htmx()
|
|
@Alpine()
|
|
<meta charset="UTF-8"/>
|
|
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
|
<title>{ title }</title>
|
|
<link rel="icon" type="image/png" href="https://cdn.sonr.id/favicon.png"/>
|
|
<!-- Sets the status bar style to transparent -->
|
|
<meta name="apple-mobile-web-app-capable" content="yes"/>
|
|
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent"/>
|
|
</head>
|
|
<main class="grow">
|
|
<body class="font-inter antialiased bg-white text-zinc-900 tracking-tight">
|
|
<div class="flex flex-col min-h-screen overflow-hidden supports-[overflow:clip]:overflow-clip">
|
|
{ children... }
|
|
</div>
|
|
</body>
|
|
</main>
|
|
</html>
|
|
}
|
|
|
|
templ OpenModal(title, description string) {
|
|
<div
|
|
x-data="{ modalOpen: true }"
|
|
@keydown.escape="modalOpen=false"
|
|
:class="{ 'z-40': modalOpen }"
|
|
class="relative w-auto h-auto"
|
|
>
|
|
<template x-teleport="body">
|
|
<div x-show="modalOpen" class="fixed top-0 left-0 z-[99] flex items-center justify-center w-screen h-screen" x-cloak>
|
|
<div
|
|
x-show="modalOpen"
|
|
x-transition:enter="ease-out duration-300"
|
|
x-transition:enter-start="opacity-0"
|
|
x-transition:enter-end="opacity-100"
|
|
x-transition:leave="ease-in duration-300"
|
|
x-transition:leave-start="opacity-100"
|
|
x-transition:leave-end="opacity-0"
|
|
@click="modalOpen=false"
|
|
class="absolute inset-0 w-full h-full bg-zinc-900 bg-opacity-90 backdrop-blur-sm"
|
|
></div>
|
|
<div
|
|
x-show="modalOpen"
|
|
x-trap.inert.noscroll="modalOpen"
|
|
x-transition:enter="ease-out duration-300"
|
|
x-transition:enter-start="opacity-0 scale-90"
|
|
x-transition:enter-end="opacity-100 scale-100"
|
|
x-transition:leave="ease-in duration-200"
|
|
x-transition:leave-start="opacity-100 scale-100"
|
|
x-transition:leave-end="opacity-0 scale-90"
|
|
class="relative w-full py-6 bg-white shadow-md px-7 bg-opacity-90 drop-shadow-md backdrop-blur-sm sm:max-w-lg sm:rounded-lg"
|
|
>
|
|
<div class="flex items-center justify-between pb-3">
|
|
<h3 class="text-lg font-semibold">{ title }</h3>
|
|
<button @click="modalOpen=false" class="absolute top-0 right-0 flex items-center justify-center w-8 h-8 mt-5 mr-5 text-zinc-600 rounded-full hover:text-zinc-800 hover:bg-zinc-50">
|
|
<svg class="w-5 h-5" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M6 18L18 6M6 6l12 12"></path></svg>
|
|
</button>
|
|
</div>
|
|
<div class="relative w-auto pb-8">
|
|
<p>{ description }</p>
|
|
</div>
|
|
{ children... }
|
|
</div>
|
|
</div>
|
|
</template>
|
|
</div>
|
|
}
|
|
|
|
func clsxMerge(variants ...Variant) templ.Attributes {
|
|
combinedAttrs := templ.Attributes{}
|
|
var classElements []string
|
|
|
|
for _, variant := range variants {
|
|
attrs := variant.Attributes()
|
|
if class, ok := attrs["class"].(string); ok {
|
|
classElements = append(classElements, strings.Fields(class)...)
|
|
}
|
|
for key, value := range attrs {
|
|
if key != "class" {
|
|
combinedAttrs[key] = value
|
|
}
|
|
}
|
|
}
|
|
|
|
if len(classElements) > 0 {
|
|
combinedAttrs["class"] = strings.Join(classElements, " ")
|
|
}
|
|
return combinedAttrs
|
|
}
|
|
|
|
func clsxBuilder(classes ...string) templ.Attributes {
|
|
if len(classes) == 0 {
|
|
return templ.Attributes{}
|
|
}
|
|
class := strings.Join(classes, " ")
|
|
return templ.Attributes{
|
|
"class": class,
|
|
}
|
|
}
|