mirror of
https://github.com/discourse/discourse.git
synced 2025-06-19 22:23:04 +08:00

Previously we were compiling core and theme CSS into two targets: Desktop and Mobile. The majority of both files was the 'common' css. This commit splits those common styles into their own targets so that there is less duplication. This should improve compilation times + cache reuse, as well as opening the door for experiments with media-query-based mobile-modes. The only functional change is that we can no longer use `@extend` to copy 'common' rules in core to mobile/desktop. This is probably for the best. Duplication and/or mixins are a more native-css pattern for this. Plugins already have a common / mobile / desktop pattern, so are unchanged by this commit.
36 lines
924 B
Ruby
36 lines
924 B
Ruby
# frozen_string_literal: true
|
|
|
|
class Stylesheet::Manager::ScssChecker
|
|
def initialize(target, theme_ids)
|
|
@target = target.to_sym
|
|
@theme_ids = theme_ids
|
|
end
|
|
|
|
def has_scss(theme_id)
|
|
!!get_themes_with_scss[theme_id]
|
|
end
|
|
|
|
private
|
|
|
|
def get_themes_with_scss
|
|
@themes_with_scss ||=
|
|
begin
|
|
theme_target = @target.to_sym
|
|
theme_target = :common if theme_target == :common_theme || theme_target == :embedded_theme
|
|
theme_target = :mobile if theme_target == :mobile_theme
|
|
theme_target = :desktop if theme_target == :desktop_theme
|
|
name = @target == :embedded_theme ? :embedded_scss : :scss
|
|
|
|
results =
|
|
Theme
|
|
.where(id: @theme_ids)
|
|
.left_joins(:theme_fields)
|
|
.where(theme_fields: { target_id: Theme.targets[theme_target], name: name })
|
|
.group(:id)
|
|
.size
|
|
|
|
results
|
|
end
|
|
end
|
|
end
|