mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-06 10:30:31 +08:00
- Add dark_color_scheme_id to Theme model - Update theme editor interface to allow selecting both light and dark schemes - Update color scheme selector to support setting default light/dark schemes - Fix user preferences to use theme's dark scheme instead of site setting <img width="1095" height="823" alt="Screenshot 2025-07-30 at 3 48 57 pm" src="https://github.com/user-attachments/assets/cdc32e9e-b2ac-41fc-b533-047bbd09406a" /> <img width="1020" height="736" alt="Screenshot 2025-07-30 at 3 49 08 pm" src="https://github.com/user-attachments/assets/63e8473f-d2a7-4fc5-81b7-4dad0d0fcace" />
35 lines
1.2 KiB
Ruby
35 lines
1.2 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
theme_exists = Theme.exists?
|
|
|
|
SystemThemesManager.sync!
|
|
|
|
# we can not guess what to do if customization already started, so skip it
|
|
if !theme_exists
|
|
STDERR.puts "> Seeding theme and color schemes"
|
|
|
|
color_schemes = [
|
|
{ name: I18n.t("color_schemes.dark"), base_scheme_id: "Dark" },
|
|
{ name: I18n.t("color_schemes.wcag"), base_scheme_id: "WCAG" },
|
|
{ name: I18n.t("color_schemes.wcag_dark"), base_scheme_id: "WCAG Dark" },
|
|
{ name: I18n.t("color_schemes.dracula"), base_scheme_id: "Dracula" },
|
|
{ name: I18n.t("color_schemes.solarized_light"), base_scheme_id: "Solarized Light" },
|
|
{ name: I18n.t("color_schemes.solarized_dark"), base_scheme_id: "Solarized Dark" },
|
|
]
|
|
|
|
color_schemes.each do |cs|
|
|
scheme = ColorScheme.find_by(base_scheme_id: cs[:base_scheme_id])
|
|
scheme ||=
|
|
ColorScheme.create_from_base(
|
|
name: cs[:name],
|
|
via_wizard: true,
|
|
base_scheme_id: cs[:base_scheme_id],
|
|
user_selectable: true,
|
|
)
|
|
end
|
|
|
|
Theme.foundation_theme.set_default!
|
|
|
|
dark_scheme_id = ColorScheme.where(base_scheme_id: "Dark").pick(:id)
|
|
Theme.foundation_theme.update!(dark_color_scheme_id: dark_scheme_id) if dark_scheme_id.present?
|
|
end
|