feat: add 4 built-in gradients, searchable gradient picker, cleaner modal titles
All checks were successful
Lint & Test / test (push) Successful in 1m29s
All checks were successful
Lint & Test / test (push) Successful in 1m29s
- Add warm, cool, neon, pastel built-in gradients (promoted from frontend presets) - Change gradient seeding to add missing built-ins on every startup (not just first run) - Add searchable option to IconSelect component for filtering by name - Enable search on gradient, effect palette, and audio palette pickers - Simplify modal titles: "Add Gradient" / "Edit Gradient" instead of "Add Color Strip Source: Gradient" - Update INSTALLATION.md and .env.example
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
"""Gradient storage with built-in seeding.
|
||||
|
||||
Provides CRUD for gradient entities. On first run (empty/missing data),
|
||||
seeds 8 built-in gradients matching the legacy hardcoded palettes.
|
||||
Built-in gradients are read-only and cannot be deleted or modified.
|
||||
Provides CRUD for gradient entities. On startup, seeds any missing
|
||||
built-in gradients. Built-in gradients are read-only and cannot be
|
||||
deleted or modified.
|
||||
"""
|
||||
|
||||
import uuid
|
||||
@@ -36,6 +36,16 @@ _BUILTIN_DEFS = {
|
||||
(0.75, 255, 192, 64), (1.0, 255, 255, 192),
|
||||
],
|
||||
"ice": [(0, 0, 0, 64), (0.33, 0, 64, 192), (0.66, 128, 192, 255), (1.0, 240, 248, 255)],
|
||||
"warm": [(0, 255, 255, 80), (0.33, 255, 160, 0), (0.67, 255, 60, 0), (1.0, 160, 0, 0)],
|
||||
"cool": [(0, 0, 255, 200), (0.33, 0, 120, 255), (0.67, 60, 0, 255), (1.0, 120, 0, 180)],
|
||||
"neon": [
|
||||
(0, 255, 0, 200), (0.25, 0, 255, 255), (0.5, 0, 255, 50),
|
||||
(0.75, 255, 255, 0), (1.0, 255, 0, 100),
|
||||
],
|
||||
"pastel": [
|
||||
(0, 255, 180, 180), (0.2, 255, 220, 160), (0.4, 255, 255, 180),
|
||||
(0.6, 180, 255, 200), (0.8, 180, 200, 255), (1.0, 220, 180, 255),
|
||||
],
|
||||
}
|
||||
|
||||
|
||||
@@ -50,14 +60,16 @@ class GradientStore(BaseSqliteStore[Gradient]):
|
||||
|
||||
def __init__(self, db: Database):
|
||||
super().__init__(db, Gradient.from_dict)
|
||||
if not self._items:
|
||||
self._seed_builtins()
|
||||
self._seed_missing_builtins()
|
||||
|
||||
def _seed_builtins(self) -> None:
|
||||
"""Create the 8 built-in gradients on first run."""
|
||||
def _seed_missing_builtins(self) -> None:
|
||||
"""Seed any built-in gradients not yet in the store."""
|
||||
now = datetime.now(timezone.utc)
|
||||
added = 0
|
||||
for name, tuples in _BUILTIN_DEFS.items():
|
||||
gid = f"gr_builtin_{name}"
|
||||
if gid in self._items:
|
||||
continue
|
||||
gradient = Gradient(
|
||||
id=gid,
|
||||
name=name.capitalize(),
|
||||
@@ -69,7 +81,9 @@ class GradientStore(BaseSqliteStore[Gradient]):
|
||||
)
|
||||
self._items[gid] = gradient
|
||||
self._save_item(gid, gradient)
|
||||
logger.info(f"Seeded {len(_BUILTIN_DEFS)} built-in gradients")
|
||||
added += 1
|
||||
if added:
|
||||
logger.info(f"Seeded {added} new built-in gradients")
|
||||
|
||||
# Aliases
|
||||
get_all_gradients = BaseSqliteStore.get_all
|
||||
|
||||
Reference in New Issue
Block a user