1
0
mirror of https://github.com/axzilla/templui.git synced 2025-02-22 02:53:09 +00:00

fix: bring back theme preview functionality with new component structure

This commit is contained in:
axzilla 2024-12-07 11:54:36 +07:00
parent 5151e3c070
commit a987cac2fa
4 changed files with 139 additions and 65 deletions

View File

@ -1981,11 +1981,31 @@ body {
height: 0.375rem; height: 0.375rem;
} }
.before\:h-2::before {
content: var(--tw-content);
height: 0.5rem;
}
.before\:h-2\.5::before {
content: var(--tw-content);
height: 0.625rem;
}
.before\:w-1\.5::before { .before\:w-1\.5::before {
content: var(--tw-content); content: var(--tw-content);
width: 0.375rem; width: 0.375rem;
} }
.before\:w-2::before {
content: var(--tw-content);
width: 0.5rem;
}
.before\:w-2\.5::before {
content: var(--tw-content);
width: 0.625rem;
}
.before\:-translate-x-1\/2::before { .before\:-translate-x-1\/2::before {
content: var(--tw-content); content: var(--tw-content);
--tw-translate-x: -50%; --tw-translate-x: -50%;

View File

@ -63,103 +63,138 @@ templ ThemePreview() {
} }
@components.CardContent() { @components.CardContent() {
<form class="space-y-4"> <form class="space-y-4">
<div class="space-y-2"> @components.FormItem(components.FormItemProps{}) {
<label for="username" class="text-sm font-medium">Username</label> @components.Label(components.LabelProps{For: "username", Text: "Username"})
@components.Input(components.InputProps{ @components.Input(components.InputProps{
ID: "username", ID: "username",
Name: "username", Name: "username",
Type: components.InputTypeText, Type: components.InputTypeText,
Placeholder: "Enter your username", Placeholder: "Enter your username",
}) })
</div> }
<div class="space-y-2"> @components.FormItem(components.FormItemProps{}) {
<label for="email" class="text-sm font-medium">Email</label> @components.Label(components.LabelProps{For: "email", Text: "Email"})
@components.Input(components.InputProps{ @components.Input(components.InputProps{
ID: "email", ID: "email",
Name: "email", Name: "email",
Type: components.InputTypeEmail, Type: components.InputTypeEmail,
Placeholder: "Enter your email", Placeholder: "Enter your email",
}) })
</div> }
<div class="space-y-2"> @components.FormItem(components.FormItemProps{}) {
<label for="password" class="text-sm font-medium">Password</label> @components.Label(components.LabelProps{For: "password", Text: "Password"})
@components.Input(components.InputProps{ @components.Input(components.InputProps{
ID: "password", ID: "password",
Name: "password", Name: "password",
Type: components.InputTypePassword, Type: components.InputTypePassword,
Placeholder: "Enter your password", Placeholder: "Enter your password",
}) })
</div> }
<div class="space-y-2"> @components.FormItem(components.FormItemProps{}) {
<label for="birthdate" class="text-sm font-medium">Date of Birth</label> @components.Label(components.LabelProps{For: "birthdate", Text: "Birth Date"})
@components.Datepicker(components.DatepickerProps{ @components.Datepicker(components.DatepickerProps{
ID: "birthdate", ID: "birthdate",
Name: "birthdate", Name: "birthdate",
Placeholder: "Select your birth date", Placeholder: "Select your birth date",
}) })
</div> }
<div class="space-y-2"> @components.FormItem(components.FormItemProps{}) {
<label class="text-sm font-medium">Preferred Contact Method</label> @components.Label(components.LabelProps{For: "contact-method", Text: "Contact Method"})
@components.Radio(components.RadioProps{ @components.FormItemFlex(components.FormItemProps{}) {
Value: "email", @components.Radio(components.RadioProps{
ID: "contact-email", Value: "email",
Name: "contact-method", ID: "contact-email",
// Label: templ.Raw("Email"), Name: "contact-method",
}) })
@components.Radio(components.RadioProps{ @components.Label(components.LabelProps{
Value: "phone", For: "contact-email",
ID: "contact-phone", Text: "Email",
Name: "contact-method", })
// Label: templ.Raw("Phone"), }
}) @components.FormItemFlex(components.FormItemProps{}) {
@components.Radio(components.RadioProps{ @components.Radio(components.RadioProps{
Value: "mail", Value: "phone",
ID: "contact-mail", ID: "contact-phone",
Name: "contact-method", Name: "contact-method",
// Label: templ.Raw("Physical Mail"), })
Attributes: templ.Attributes{"disabled": "true"}, @components.Label(components.LabelProps{
}) For: "contact-phone",
</div> Text: "Phone",
<div class="space-y-4"> })
<label class="text-sm font-medium">Preferences</label> }
<div class="space-y-2"> @components.FormItemFlex(components.FormItemProps{}) {
@components.Radio(components.RadioProps{
Value: "mail",
ID: "contact-mail",
Name: "contact-method",
Attributes: templ.Attributes{"disabled": "true"},
})
@components.Label(components.LabelProps{
For: "contact-mail",
Text: "Physical Mail",
})
}
}
@components.FormItem(components.FormItemProps{}) {
@components.Label(components.LabelProps{Text: "Preferences"})
@components.FormItemFlex(components.FormItemProps{}) {
@components.Toggle(components.ToggleProps{ @components.Toggle(components.ToggleProps{
ID: "marketing", ID: "marketing",
Name: "marketing", Name: "marketing",
// LabelRight: "Receive marketing emails",
}) })
</div> @components.Label(components.LabelProps{
<div class="space-y-2"> For: "marketing",
Text: "Receive marketing emails",
})
}
@components.FormItemFlex(components.FormItemProps{}) {
@components.Toggle(components.ToggleProps{ @components.Toggle(components.ToggleProps{
ID: "notifications", ID: "notifications",
Name: "notifications", Name: "notifications",
// LabelRight: "Enable notifications",
Attributes: templ.Attributes{"checked": "true"}, Attributes: templ.Attributes{"checked": "true"},
}) })
</div> @components.Label(components.LabelProps{
<div class="space-y-2"> For: "notifications",
Text: "Enable notifications",
})
}
@components.FormItemFlex(components.FormItemProps{}) {
@components.Toggle(components.ToggleProps{ @components.Toggle(components.ToggleProps{
ID: "beta", ID: "beta",
Name: "beta", Name: "beta",
// LabelRight: "Join beta program",
Attributes: templ.Attributes{"disabled": "true"}, Attributes: templ.Attributes{"disabled": "true"},
}) })
</div> @components.Label(components.LabelProps{
</div> For: "beta",
<div class="space-y-2"> Text: "Join beta program",
@components.Checkbox(components.CheckboxProps{ })
ID: "terms", }
Name: "terms", }
Value: "accepted", @components.FormItem(components.FormItemProps{}) {
}) @components.Label(components.LabelProps{Text: "Terms and Conditions"})
</div> @components.FormItemFlex(components.FormItemProps{}) {
<div class="space-y-2"> @components.Checkbox(components.CheckboxProps{
@components.Checkbox(components.CheckboxProps{ ID: "terms",
ID: "newsletter", Name: "terms",
Name: "newsletter", Value: "accepted",
Value: "subscribed", })
}) @components.Label(components.LabelProps{
</div> For: "terms",
Text: "I accept the terms and conditions",
})
}
@components.FormItemFlex(components.FormItemProps{}) {
@components.Checkbox(components.CheckboxProps{
ID: "newsletter",
Name: "newsletter",
Value: "subscribed",
})
@components.Label(components.LabelProps{
For: "newsletter",
Text: "Subscribe to newsletter",
})
}
}
</form> </form>
} }
@components.CardFooter() { @components.CardFooter() {

View File

@ -15,7 +15,6 @@ templ InputForm() {
Name: "email", Name: "email",
Placeholder: "m@example.com", Placeholder: "m@example.com",
HasError: true, HasError: true,
Disabled: true,
}) })
@components.FormDescription(components.FormDescriptionProps{}) { @components.FormDescription(components.FormDescriptionProps{}) {
Enter your email address for notifications. Enter your email address for notifications.

View File

@ -1587,11 +1587,31 @@ body {
height: 0.375rem; height: 0.375rem;
} }
.before\:h-2::before {
content: var(--tw-content);
height: 0.5rem;
}
.before\:h-2\.5::before {
content: var(--tw-content);
height: 0.625rem;
}
.before\:w-1\.5::before { .before\:w-1\.5::before {
content: var(--tw-content); content: var(--tw-content);
width: 0.375rem; width: 0.375rem;
} }
.before\:w-2::before {
content: var(--tw-content);
width: 0.5rem;
}
.before\:w-2\.5::before {
content: var(--tw-content);
width: 0.625rem;
}
.before\:-translate-x-1\/2::before { .before\:-translate-x-1\/2::before {
content: var(--tw-content); content: var(--tw-content);
--tw-translate-x: -50%; --tw-translate-x: -50%;