mirror of
https://github.com/discourse/discourse.git
synced 2025-01-18 16:52:45 +08:00
DEV: Use indexes when importing SCSS from a folder (#11591)
By default, SCSS does not support globbing. This removes our magic and uses index files to import all files in a folder.
This commit is contained in:
parent
13e39d8b9f
commit
303f229e98
|
@ -6,11 +6,11 @@
|
|||
@import "common/foundation/base";
|
||||
@import "common/foundation/mixins";
|
||||
@import "common/foundation/variables";
|
||||
@import "common/select-kit/*";
|
||||
@import "common/components/*";
|
||||
@import "common/select-kit/_index";
|
||||
@import "common/components/_index";
|
||||
@import "common/input_tip";
|
||||
@import "common/topic-entrance";
|
||||
@import "common/printer-friendly";
|
||||
@import "common/base/*";
|
||||
@import "common/base/_index";
|
||||
@import "common/d-editor";
|
||||
@import "common/topic-timeline";
|
||||
|
|
|
@ -225,7 +225,7 @@ table.api-keys {
|
|||
display: none;
|
||||
}
|
||||
input {
|
||||
max-width: calc(100% - 10px;);
|
||||
max-width: calc(100% - 10px);
|
||||
}
|
||||
.select-kit,
|
||||
.select-kit.multi-select {
|
||||
|
|
53
app/assets/stylesheets/common/base/_index.scss
Normal file
53
app/assets/stylesheets/common/base/_index.scss
Normal file
|
@ -0,0 +1,53 @@
|
|||
@import "_topic-list";
|
||||
@import "about";
|
||||
@import "activation";
|
||||
@import "alert";
|
||||
@import "bbcode";
|
||||
@import "cat_reorder";
|
||||
@import "category-list";
|
||||
@import "code_highlighting";
|
||||
@import "colorpicker";
|
||||
@import "compose";
|
||||
@import "composer-user-selector";
|
||||
@import "crawler_layout";
|
||||
@import "d-icon";
|
||||
@import "d-popover";
|
||||
@import "directory";
|
||||
@import "discourse";
|
||||
@import "edit-category";
|
||||
@import "edit-topic-status-update-modal";
|
||||
@import "ember-select";
|
||||
@import "emoji";
|
||||
@import "exception";
|
||||
@import "explain-reviewable";
|
||||
@import "faqs";
|
||||
@import "group";
|
||||
@import "groups";
|
||||
@import "header";
|
||||
@import "history";
|
||||
@import "lightbox";
|
||||
@import "login";
|
||||
@import "magnific-popup";
|
||||
@import "menu-panel";
|
||||
@import "modal";
|
||||
@import "not-found";
|
||||
@import "onebox";
|
||||
@import "popup-menu";
|
||||
@import "redirection";
|
||||
@import "request_access";
|
||||
@import "request-group-membership-form";
|
||||
@import "reviewables";
|
||||
@import "rtl";
|
||||
@import "search-menu";
|
||||
@import "search";
|
||||
@import "share_link";
|
||||
@import "shared-drafts";
|
||||
@import "tagging";
|
||||
@import "tooltip";
|
||||
@import "topic-admin-menu";
|
||||
@import "topic-post";
|
||||
@import "topic";
|
||||
@import "upload";
|
||||
@import "user-badges";
|
||||
@import "user";
|
||||
@import "username_tagsinput";
|
28
app/assets/stylesheets/common/components/_index.scss
Normal file
28
app/assets/stylesheets/common/components/_index.scss
Normal file
|
@ -0,0 +1,28 @@
|
|||
@import "badges";
|
||||
@import "banner";
|
||||
@import "bookmark-list";
|
||||
@import "bookmark-modal";
|
||||
@import "buttons";
|
||||
@import "conditional-loading-section";
|
||||
@import "convert-to-public-topic-modal";
|
||||
@import "date-input";
|
||||
@import "date-picker";
|
||||
@import "date-time-input-range";
|
||||
@import "date-time-input";
|
||||
@import "footer-nav";
|
||||
@import "group-member-dropdown";
|
||||
@import "groups-form-membership-fields";
|
||||
@import "hashtag";
|
||||
@import "iframed-html";
|
||||
@import "ignored-user-list";
|
||||
@import "keyboard_shortcuts";
|
||||
@import "navs";
|
||||
@import "share-and-invite-modal";
|
||||
@import "svg";
|
||||
@import "tap-tile";
|
||||
@import "time-input";
|
||||
@import "user-card";
|
||||
@import "user-info";
|
||||
@import "user-stream-item";
|
||||
@import "user-stream";
|
||||
@import "widget-dropdown";
|
26
app/assets/stylesheets/common/select-kit/_index.scss
Normal file
26
app/assets/stylesheets/common/select-kit/_index.scss
Normal file
|
@ -0,0 +1,26 @@
|
|||
@import "categories-admin-dropdown";
|
||||
@import "category-chooser";
|
||||
@import "category-drop";
|
||||
@import "category-row";
|
||||
@import "category-selector";
|
||||
@import "color-palettes";
|
||||
@import "combo-box";
|
||||
@import "composer-actions";
|
||||
@import "dropdown-select-box";
|
||||
@import "future-date-input-selector";
|
||||
@import "icon-picker";
|
||||
@import "list-setting";
|
||||
@import "mini-tag-chooser";
|
||||
@import "multi-select";
|
||||
@import "notifications-button";
|
||||
@import "notifications-filter";
|
||||
@import "period-chooser";
|
||||
@import "pinned-button";
|
||||
@import "select-kit";
|
||||
@import "single-select";
|
||||
@import "tag-chooser";
|
||||
@import "tag-drop";
|
||||
@import "toolbar-popup-menu-options";
|
||||
@import "topic-notifications-button";
|
||||
@import "user-notifications-dropdown";
|
||||
@import "user-row";
|
|
@ -1,9 +1,9 @@
|
|||
@import "common";
|
||||
|
||||
@import "desktop/*";
|
||||
@import "desktop/_index";
|
||||
|
||||
// Import all component-specific files
|
||||
@import "desktop/components/*";
|
||||
@import "desktop/components/_index";
|
||||
|
||||
/* These files doesn't actually exist, they are injected by Stylesheet::Compiler. */
|
||||
|
||||
|
|
18
app/assets/stylesheets/desktop/_index.scss
Normal file
18
app/assets/stylesheets/desktop/_index.scss
Normal file
|
@ -0,0 +1,18 @@
|
|||
@import "admin_customize";
|
||||
@import "banner";
|
||||
@import "category-list";
|
||||
@import "compose";
|
||||
@import "discourse";
|
||||
@import "edit-category";
|
||||
@import "group";
|
||||
@import "header";
|
||||
@import "history";
|
||||
@import "latest-topic-list";
|
||||
@import "login";
|
||||
@import "menu-panel";
|
||||
@import "modal";
|
||||
@import "topic-list";
|
||||
@import "topic-post";
|
||||
@import "topic";
|
||||
@import "upload";
|
||||
@import "user";
|
3
app/assets/stylesheets/desktop/components/_index.scss
Normal file
3
app/assets/stylesheets/desktop/components/_index.scss
Normal file
|
@ -0,0 +1,3 @@
|
|||
@import "user-card";
|
||||
@import "user-info";
|
||||
@import "user-stream-item";
|
|
@ -1,11 +1,11 @@
|
|||
@import "common";
|
||||
|
||||
@import "mobile/*";
|
||||
@import "mobile/_index";
|
||||
|
||||
// Import all component-specific files
|
||||
@import "mobile/components/*";
|
||||
@import "mobile/components/_index";
|
||||
|
||||
@import "mobile/select-kit/*";
|
||||
@import "mobile/select-kit/_index";
|
||||
|
||||
/* These files doesn't actually exist, they are injected by Stylesheet::Compiler. */
|
||||
|
||||
|
|
33
app/assets/stylesheets/mobile/_index.scss
Normal file
33
app/assets/stylesheets/mobile/_index.scss
Normal file
|
@ -0,0 +1,33 @@
|
|||
@import "admin_badges";
|
||||
@import "admin_customize";
|
||||
@import "admin_emojis";
|
||||
@import "admin_report_counters";
|
||||
@import "admin_report_table";
|
||||
@import "admin_report";
|
||||
@import "admin_reports";
|
||||
@import "alert";
|
||||
@import "banner";
|
||||
@import "buttons";
|
||||
@import "compose";
|
||||
@import "dashboard";
|
||||
@import "directory";
|
||||
@import "discourse";
|
||||
@import "edit-category";
|
||||
@import "emoji";
|
||||
@import "group";
|
||||
@import "header";
|
||||
@import "history";
|
||||
@import "lightbox";
|
||||
@import "login";
|
||||
@import "menu-panel";
|
||||
@import "modal";
|
||||
@import "push-notifications-mobile";
|
||||
@import "reviewables";
|
||||
@import "ring";
|
||||
@import "search";
|
||||
@import "topic-list";
|
||||
@import "topic-post";
|
||||
@import "topic";
|
||||
@import "upload";
|
||||
@import "user-badges";
|
||||
@import "user";
|
3
app/assets/stylesheets/mobile/components/_index.scss
Normal file
3
app/assets/stylesheets/mobile/components/_index.scss
Normal file
|
@ -0,0 +1,3 @@
|
|||
@import "topic-footer-mobile-dropdown";
|
||||
@import "user-card";
|
||||
@import "user-stream-item";
|
4
app/assets/stylesheets/mobile/select-kit/_index.scss
Normal file
4
app/assets/stylesheets/mobile/select-kit/_index.scss
Normal file
|
@ -0,0 +1,4 @@
|
|||
@import "category-drop";
|
||||
@import "dropdown-select-box";
|
||||
@import "select-kit";
|
||||
@import "tag-drop";
|
|
@ -5,7 +5,7 @@
|
|||
@import "common/foundation/colors";
|
||||
@import "common/foundation/variables";
|
||||
@import "common/foundation/mixins";
|
||||
@import "common/select-kit/*";
|
||||
@import "common/select-kit/_index";
|
||||
@import "common/components/svg";
|
||||
@import "common/base/modal";
|
||||
|
||||
|
|
|
@ -315,11 +315,7 @@ module Stylesheet
|
|||
end
|
||||
|
||||
def imports(asset, parent_path)
|
||||
if asset[-1] == "*"
|
||||
Dir["#{Stylesheet::Common::ASSET_ROOT}/#{asset}.scss"].map do |path|
|
||||
Import.new(asset[0..-2] + File.basename(path, ".*"))
|
||||
end
|
||||
elsif callback = Importer.special_imports[asset]
|
||||
if callback = Importer.special_imports[asset]
|
||||
instance_eval(&callback)
|
||||
else
|
||||
path, source = match_theme_import(asset, parent_path)
|
||||
|
|
|
@ -106,4 +106,27 @@ describe Stylesheet::Compiler do
|
|||
end
|
||||
|
||||
end
|
||||
|
||||
describe "indexes" do
|
||||
it "include all SCSS files in their respective folders" do
|
||||
refs = []
|
||||
|
||||
Dir.glob(Rails.root.join('app/assets/stylesheets/**/*/')).each do |dir|
|
||||
Dir.glob("#{dir}_index.scss").each do |indexfile|
|
||||
contents = File.read indexfile
|
||||
|
||||
files = Dir["#{dir}*.scss"]
|
||||
files -= Dir["#{dir}_index.scss"]
|
||||
files.each do |path|
|
||||
filename = File.basename(path, ".scss")
|
||||
if !contents.match(/@import "#{filename}";/)
|
||||
refs << "#{filename} import missing in #{indexfile}"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
expect(refs).to eq([])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue
Block a user