2
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2026-03-04 01:15:08 +08:00
discourse/app/serializers/theme_index_serializer.rb
Yuriy Kurant db10d595e7
FEATURE: enhance screenshot support for themes with dark/light modes (#36422)
Enable theme cards to show dark and light mode screenshots.

### Context
Prior to this change, a single screenshot was displayed only.

### Changes
* introduce separate fields: `screenshot_light_url` and
`screenshot_dark_url`
* displays both screenshots (horizontally scrollable)
* limits display of screenshots to the files named `light` and `dark`
only

### Result


https://github.com/user-attachments/assets/4d845f32-9120-49b8-8f05-ba7790ce1629

---------

Co-authored-by: Yuriy Kurant <yuriy@discourse.org>
2025-12-10 11:23:21 +10:00

18 lines
480 B
Ruby

# frozen_string_literal: true
class ThemeIndexSerializer < BasicThemeSerializer
attributes :user_selectable,
:screenshot_dark_url,
:screenshot_light_url,
:remote_theme_id,
:enabled?,
:supported?,
:system
has_one :color_scheme, serializer: ColorSchemeSerializer, embed: :object
has_one :remote_theme, serializer: RemoteThemeSerializer, embed: :objects
def system
object.system?
end
end