1
0
mirror of https://github.com/tabler/tabler.git synced 2026-08-07 03:42:27 +04:00
Files
tabler/shared/ui/ThemeSettings.astro
codecalm f27c70ad38 Fix Prettier formatting regression and Astro type-check errors
`Render Modal as real markup` (#2742) reformatted ~140 files back to
tabs/semicolons, breaking the Prettier config added by the Astro
quality gates (#2749). Re-run prettier --write to restore it, and fix
the type errors it had been masking: HTMLElement casts and `this`
typing in ChangePasswordModalContent/ConfirmDeleteModalContent
scripts, plain-JS syntax in the inline-injected progress.astro script,
narrowed prop unions in Button/Check/Spinner, nullable icon svg casts
in Icons/Rating, and a duplicate firstLetters/invalid `placeholder`
attribute in Select.astro. Also fix shared/vitest.config.mts's stale
`astro/lib/**/*.test.ts` include glob left over from the shared source
restructure, which made `pnpm test` report zero test files.
2026-08-03 01:26:19 +02:00

130 lines
4.9 KiB
Plaintext

---
// Offcanvas behavior script lives in BaseLayout (after global scripts).
import FormHint from './FormHint.astro'
import Icon from './Icon.astro'
import FormGroup from './FormGroup.astro'
import { site } from '@shared/lib/site'
const defaults = {
'theme': 'light',
'theme-base': 'gray',
'theme-font': 'sans-serif',
'theme-primary': 'blue',
'theme-radius': '1',
}
---
<!-- BEGIN THEME SETTINGS -->
<div class="settings">
<a href="#" class="btn btn-floating btn-icon btn-primary" data-bs-toggle="offcanvas" data-bs-target="#offcanvas-settings" aria-controls="offcanvas-settings" aria-label="Theme Settings">
<Icon name="brush" />
</a>
<form class="offcanvas offcanvas-start offcanvas-narrow" tabindex="-1" id="offcanvas-settings" role="dialog" aria-modal="true" aria-labelledby="offcanvas-settings-title">
<div class="offcanvas-header">
<h2 class="offcanvas-title" id="offcanvas-settings-title">Theme Settings</h2>
<button type="button" class="btn-close" data-bs-dismiss="offcanvas" aria-label="Close"></button>
</div>
<div class="offcanvas-body d-flex flex-column">
<div>
<FormGroup label="Color mode" class="mb-4">
<FormHint as="p">Choose the color mode for your app.</FormHint>
{
['light', 'dark', 'auto'].map((mode) => (
<label class="form-check">
<div class="form-selectgroup-item">
<input type="radio" name="theme" value={mode} class="form-check-input" checked={mode === defaults.theme} />
<div class="form-check-label">{mode.charAt(0).toUpperCase() + mode.slice(1)}</div>
</div>
</label>
))
}
</FormGroup>
<FormGroup label="Color scheme" class="mb-4">
<FormHint as="p">The perfect color mode for your app.</FormHint>
<div class="row g-2">
{
site.themeColors.map((color) => (
<div class="col-auto">
<label class="form-colorinput">
<input name="theme-primary" type="radio" value={color} class="form-colorinput-input" />
<span class={`form-colorinput-color bg-${color}`} />
</label>
</div>
))
}
<div class="col-auto">
<label class="form-colorinput">
<input name="theme-primary" type="radio" value="inverted" class="form-colorinput-input" />
<span class="form-colorinput-color bg-inverted"></span>
</label>
</div>
</div>
</FormGroup>
<FormGroup label="Font family" class="mb-4">
<FormHint as="p">Choose the font family that fits your app.</FormHint>
<div>
{
site.themeFonts.map((font) => (
<label class="form-check">
<div class="form-selectgroup-item">
<input type="radio" name="theme-font" value={font} class="form-check-input" checked={font === defaults['theme-font']} />
<div class="form-check-label">{font.charAt(0).toUpperCase() + font.slice(1)}</div>
</div>
</label>
))
}
</div>
</FormGroup>
<FormGroup label="Theme base" class="mb-4">
<FormHint as="p">Choose the gray shade for your app.</FormHint>
<div>
{
site.themeBases.map((base) => (
<label class="form-check">
<div class="form-selectgroup-item">
<input type="radio" name="theme-base" value={base} class="form-check-input" checked={base === defaults['theme-base']} />
<div class="form-check-label">{base.charAt(0).toUpperCase() + base.slice(1)}</div>
</div>
</label>
))
}
</div>
</FormGroup>
<FormGroup label="Corner Radius" class="mb-4">
<FormHint as="p">Choose the border radius factor for your app.</FormHint>
<div>
{
site.themeRadiuses.map((radius) => (
<label class="form-check">
<div class="form-selectgroup-item">
<input type="radio" name="theme-radius" value={radius} class="form-check-input" checked={radius === defaults['theme-radius']} />
<div class="form-check-label">{radius}</div>
</div>
</label>
))
}
</div>
</FormGroup>
</div>
<div class="mt-auto space-y">
<button type="button" class="btn w-100" id="reset-changes">
<Icon name="rotate" />
Reset changes
</button>
<a href="#" class="btn btn-primary w-100" data-bs-dismiss="offcanvas"> Save </a>
</div>
</div>
</form>
</div>
<!-- END THEME SETTINGS -->