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:
Penar Musaraj 2020-12-30 15:29:10 -05:00 committed by GitHub
parent 13e39d8b9f
commit 303f229e98
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 202 additions and 15 deletions

View File

@ -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";

View File

@ -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 {

View 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";

View 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";

View 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";

View File

@ -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. */

View 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";

View File

@ -0,0 +1,3 @@
@import "user-card";
@import "user-info";
@import "user-stream-item";

View File

@ -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. */

View 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";

View File

@ -0,0 +1,3 @@
@import "topic-footer-mobile-dropdown";
@import "user-card";
@import "user-stream-item";

View File

@ -0,0 +1,4 @@
@import "category-drop";
@import "dropdown-select-box";
@import "select-kit";
@import "tag-drop";

View File

@ -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";

View File

@ -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)

View File

@ -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