feat: add dark mode support, accordion UI, and current combination display

- Update Theme Studio sidebar to use DaisyUI theme-aware classes for dark mode
- Convert Customise accordion to native details/summary elements for proper interaction
- Add "Current combination" card showing active theme settings
- Add SVG recolorer for logo color customization
- Add image controller for serving uploaded images
- Implement header background image controls (zoom, position)
- Add toggle_customise event handler to preserve accordion state across re-renders

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2025-12-31 18:55:44 +00:00
parent 0dada968aa
commit 1ca703e548
20 changed files with 1477 additions and 318 deletions

View File

@@ -93,6 +93,21 @@ defmodule SimpleshopTheme.Theme.Presets do
}
}
@descriptions %{
gallery: "Elegant & editorial",
studio: "Clean & professional",
boutique: "Warm & sophisticated",
bold: "High contrast, strong",
playful: "Fun & approachable",
minimal: "Understated & modern",
night: "Dark & dramatic",
classic: "Traditional & refined",
impulse: "Light & airy"
}
# Core keys used to match presets (excludes branding-specific settings)
@core_keys ~w(mood typography shape density grid_columns header_layout accent_color)a
@doc """
Returns all available presets.
@@ -132,4 +147,72 @@ defmodule SimpleshopTheme.Theme.Presets do
def list_names do
Map.keys(@presets)
end
@doc """
Gets the description for a preset.
## Examples
iex> get_description(:gallery)
"Elegant & editorial"
"""
def get_description(preset_name) when is_atom(preset_name) do
Map.get(@descriptions, preset_name, "")
end
@doc """
Returns all presets with their descriptions.
## Examples
iex> all_with_descriptions()
[{:bold, "High contrast, strong"}, ...]
"""
def all_with_descriptions do
@presets
|> Map.keys()
|> Enum.sort()
|> Enum.map(fn name -> {name, Map.get(@descriptions, name, "")} end)
end
@doc """
Detects which preset matches the current theme settings, if any.
Only compares core theme keys, ignoring branding-specific settings.
## Examples
iex> detect_preset(%ThemeSettings{mood: "warm", typography: "editorial", ...})
:gallery
iex> detect_preset(%ThemeSettings{...customized...})
nil
"""
def detect_preset(theme_settings) do
current_core = extract_core_values(theme_settings)
Enum.find_value(@presets, fn {name, preset} ->
preset_core = Map.take(preset, @core_keys)
if maps_match?(current_core, preset_core) do
name
else
nil
end
end)
end
defp extract_core_values(theme_settings) do
theme_settings
|> Map.from_struct()
|> Map.take(@core_keys)
end
defp maps_match?(map1, map2) do
Enum.all?(@core_keys, fn key ->
Map.get(map1, key) == Map.get(map2, key)
end)
end
end