From 79249a7405eff7f5fc5d1ee2ab884b37c5ac37af Mon Sep 17 00:00:00 2001 From: Kyle McCormick Date: Fri, 16 Jun 2023 08:51:11 -0400 Subject: [PATCH] Revert "build: commit XModule SCSS entrypoints of generating them (#32290)" This reverts commit 0b455e0336fa54199fd992c2ce83a81c07dd07c2. --- pavelib/assets.py | 10 ++-- xmodule/annotatable_block.py | 10 ++++ xmodule/capa_block.py | 13 +++++ xmodule/conditional_block.py | 6 ++ .../include => css}/annotatable/display.scss | 0 .../sass/include => css}/capa/display.scss | 0 .../codemirror/codemirror.scss | 0 .../sass/include => css}/editor/edit.scss | 0 .../sass/include => css}/html/display.scss | 0 .../sass/include => css}/html/edit.scss | 0 .../{static/sass/include => css}/lti/lti.scss | 0 .../sass/include => css}/poll/display.scss | 0 .../sass/include => css}/problem/edit.scss | 0 .../include => css}/sequence/display.scss | 0 .../sass/include => css}/tabs/codemirror.scss | 0 .../sass/include => css}/tabs/tabs.scss | 0 .../video/accessible_menu.scss | 0 .../sass/include => css}/video/display.scss | 0 .../include => css}/word_cloud/display.scss | 0 xmodule/html_block.py | 7 +++ xmodule/library_content_block.py | 6 ++ xmodule/lti_block.py | 8 +++ xmodule/poll_block.py | 9 +++ xmodule/seq_block.py | 10 ++++ xmodule/split_test_block.py | 6 ++ xmodule/static/sass/cms/AboutBlockStudio.scss | 4 -- .../sass/cms/AnnotatableBlockStudio.scss | 3 - .../sass/cms/CourseInfoBlockStudio.scss | 4 -- .../static/sass/cms/CustomTagBlockStudio.scss | 3 - xmodule/static/sass/cms/HtmlBlockStudio.scss | 4 -- .../static/sass/cms/ProblemBlockStudio.scss | 4 -- .../static/sass/cms/StaticTabBlockStudio.scss | 4 -- xmodule/static/sass/cms/VideoBlockStudio.scss | 3 - .../static/sass/lms/AboutBlockPreview.scss | 3 - .../sass/lms/AnnotatableBlockPreview.scss | 3 - .../sass/lms/CourseInfoBlockPreview.scss | 3 - xmodule/static/sass/lms/HtmlBlockPreview.scss | 3 - xmodule/static/sass/lms/LTIBlockPreview.scss | 3 - xmodule/static/sass/lms/PollBlockPreview.scss | 3 - .../static/sass/lms/ProblemBlockPreview.scss | 3 - .../static/sass/lms/SequenceBlockPreview.scss | 3 - .../sass/lms/StaticTabBlockPreview.scss | 3 - .../static/sass/lms/VideoBlockPreview.scss | 4 -- .../sass/lms/WordCloudBlockPreview.scss | 3 - xmodule/static_content.py | 55 ++++++++++++++++++- xmodule/template_block.py | 6 ++ xmodule/word_cloud_block.py | 8 +++ xmodule/x_module.py | 11 ++++ 48 files changed, 159 insertions(+), 69 deletions(-) rename xmodule/{static/sass/include => css}/annotatable/display.scss (100%) rename xmodule/{static/sass/include => css}/capa/display.scss (100%) rename xmodule/{static/sass/include => css}/codemirror/codemirror.scss (100%) rename xmodule/{static/sass/include => css}/editor/edit.scss (100%) rename xmodule/{static/sass/include => css}/html/display.scss (100%) rename xmodule/{static/sass/include => css}/html/edit.scss (100%) rename xmodule/{static/sass/include => css}/lti/lti.scss (100%) rename xmodule/{static/sass/include => css}/poll/display.scss (100%) rename xmodule/{static/sass/include => css}/problem/edit.scss (100%) rename xmodule/{static/sass/include => css}/sequence/display.scss (100%) rename xmodule/{static/sass/include => css}/tabs/codemirror.scss (100%) rename xmodule/{static/sass/include => css}/tabs/tabs.scss (100%) rename xmodule/{static/sass/include => css}/video/accessible_menu.scss (100%) rename xmodule/{static/sass/include => css}/video/display.scss (100%) rename xmodule/{static/sass/include => css}/word_cloud/display.scss (100%) delete mode 100644 xmodule/static/sass/cms/AboutBlockStudio.scss delete mode 100644 xmodule/static/sass/cms/AnnotatableBlockStudio.scss delete mode 100644 xmodule/static/sass/cms/CourseInfoBlockStudio.scss delete mode 100644 xmodule/static/sass/cms/CustomTagBlockStudio.scss delete mode 100644 xmodule/static/sass/cms/HtmlBlockStudio.scss delete mode 100644 xmodule/static/sass/cms/ProblemBlockStudio.scss delete mode 100644 xmodule/static/sass/cms/StaticTabBlockStudio.scss delete mode 100644 xmodule/static/sass/cms/VideoBlockStudio.scss delete mode 100644 xmodule/static/sass/lms/AboutBlockPreview.scss delete mode 100644 xmodule/static/sass/lms/AnnotatableBlockPreview.scss delete mode 100644 xmodule/static/sass/lms/CourseInfoBlockPreview.scss delete mode 100644 xmodule/static/sass/lms/HtmlBlockPreview.scss delete mode 100644 xmodule/static/sass/lms/LTIBlockPreview.scss delete mode 100644 xmodule/static/sass/lms/PollBlockPreview.scss delete mode 100644 xmodule/static/sass/lms/ProblemBlockPreview.scss delete mode 100644 xmodule/static/sass/lms/SequenceBlockPreview.scss delete mode 100644 xmodule/static/sass/lms/StaticTabBlockPreview.scss delete mode 100644 xmodule/static/sass/lms/VideoBlockPreview.scss delete mode 100644 xmodule/static/sass/lms/WordCloudBlockPreview.scss diff --git a/pavelib/assets.py b/pavelib/assets.py index 953faf84dee2..19bb98ea071e 100644 --- a/pavelib/assets.py +++ b/pavelib/assets.py @@ -170,8 +170,9 @@ def get_theme_sass_dirs(system, theme_dir): css_dir = theme_dir / system / "static" / "css" certs_sass_dir = theme_dir / system / "static" / "certificates" / "sass" certs_css_dir = theme_dir / system / "static" / "certificates" / "css" - xmodule_sass_dir = path("xmodule") / "static" / "sass" / system - xmodule_lookup_dir = path("xmodule") / "static" / "sass" / "include" + xmodule_sass_folder = "modules" if system == 'lms' else "descriptors" + xmodule_sass_dir = path("common") / "static" / "xmodule" / xmodule_sass_folder / "scss" + xmodule_lookup_dir = path("xmodule") / "css" dependencies = SASS_LOOKUP_DEPENDENCIES.get(system, []) if sass_dir.isdir(): @@ -237,8 +238,9 @@ def get_system_sass_dirs(system): dirs = [] sass_dir = path(system) / "static" / "sass" css_dir = path(system) / "static" / "css" - xmodule_sass_dir = path("xmodule") / "static" / "sass" / system - xmodule_lookup_dir = path("xmodule") / "static" / "sass" / "include" + xmodule_sass_folder = "modules" if system == 'lms' else "descriptors" + xmodule_sass_dir = path("common") / "static" / "xmodule" / xmodule_sass_folder / "scss" + xmodule_lookup_dir = path("xmodule") / "css" dependencies = SASS_LOOKUP_DEPENDENCIES.get(system, []) dirs.append({ diff --git a/xmodule/annotatable_block.py b/xmodule/annotatable_block.py index e2c6a7a2c554..9ec6bf21dace 100644 --- a/xmodule/annotatable_block.py +++ b/xmodule/annotatable_block.py @@ -82,6 +82,11 @@ class AnnotatableBlock( ], 'xmodule_js': resource_filename(__name__, 'js/src/xmodule.js'), } + preview_view_css = { + 'scss': [ + resource_filename(__name__, 'css/annotatable/display.scss'), + ], + } studio_view_js = { 'js': [ @@ -89,6 +94,11 @@ class AnnotatableBlock( ], 'xmodule_js': resource_filename(__name__, 'js/src/xmodule.js'), } + studio_view_css = { + 'scss': [ + resource_filename(__name__, 'css/codemirror/codemirror.scss'), + ], + } studio_js_module_name = "XMLEditingDescriptor" mako_template = "widgets/raw-edit.html" diff --git a/xmodule/capa_block.py b/xmodule/capa_block.py index c70e619f27c9..2b2ec8082534 100644 --- a/xmodule/capa_block.py +++ b/xmodule/capa_block.py @@ -177,6 +177,12 @@ class ProblemBlock( 'xmodule_js': resource_filename(__name__, 'js/src/xmodule.js') } + preview_view_css = { + 'scss': [ + resource_filename(__name__, 'css/capa/display.scss'), + ], + } + studio_view_js = { 'js': [ resource_filename(__name__, 'js/src/problem/edit.js'), @@ -184,6 +190,13 @@ class ProblemBlock( 'xmodule_js': resource_filename(__name__, 'js/src/xmodule.js'), } + studio_view_css = { + 'scss': [ + resource_filename(__name__, 'css/editor/edit.scss'), + resource_filename(__name__, 'css/problem/edit.scss'), + ] + } + display_name = String( display_name=_("Display Name"), help=_("The display name for this component."), diff --git a/xmodule/conditional_block.py b/xmodule/conditional_block.py index 23ffbae43afa..7fe545d1a307 100644 --- a/xmodule/conditional_block.py +++ b/xmodule/conditional_block.py @@ -154,6 +154,9 @@ class ConditionalBlock( ], 'xmodule_js': resource_filename(__name__, 'js/src/xmodule.js'), } + preview_view_css = { + 'scss': [], + } mako_template = 'widgets/metadata-edit.html' studio_js_module_name = 'SequenceDescriptor' @@ -161,6 +164,9 @@ class ConditionalBlock( 'js': [resource_filename(__name__, 'js/src/sequence/edit.js')], 'xmodule_js': resource_filename(__name__, 'js/src/xmodule.js'), } + studio_view_css = { + 'scss': [], + } # Map # key: diff --git a/xmodule/static/sass/include/annotatable/display.scss b/xmodule/css/annotatable/display.scss similarity index 100% rename from xmodule/static/sass/include/annotatable/display.scss rename to xmodule/css/annotatable/display.scss diff --git a/xmodule/static/sass/include/capa/display.scss b/xmodule/css/capa/display.scss similarity index 100% rename from xmodule/static/sass/include/capa/display.scss rename to xmodule/css/capa/display.scss diff --git a/xmodule/static/sass/include/codemirror/codemirror.scss b/xmodule/css/codemirror/codemirror.scss similarity index 100% rename from xmodule/static/sass/include/codemirror/codemirror.scss rename to xmodule/css/codemirror/codemirror.scss diff --git a/xmodule/static/sass/include/editor/edit.scss b/xmodule/css/editor/edit.scss similarity index 100% rename from xmodule/static/sass/include/editor/edit.scss rename to xmodule/css/editor/edit.scss diff --git a/xmodule/static/sass/include/html/display.scss b/xmodule/css/html/display.scss similarity index 100% rename from xmodule/static/sass/include/html/display.scss rename to xmodule/css/html/display.scss diff --git a/xmodule/static/sass/include/html/edit.scss b/xmodule/css/html/edit.scss similarity index 100% rename from xmodule/static/sass/include/html/edit.scss rename to xmodule/css/html/edit.scss diff --git a/xmodule/static/sass/include/lti/lti.scss b/xmodule/css/lti/lti.scss similarity index 100% rename from xmodule/static/sass/include/lti/lti.scss rename to xmodule/css/lti/lti.scss diff --git a/xmodule/static/sass/include/poll/display.scss b/xmodule/css/poll/display.scss similarity index 100% rename from xmodule/static/sass/include/poll/display.scss rename to xmodule/css/poll/display.scss diff --git a/xmodule/static/sass/include/problem/edit.scss b/xmodule/css/problem/edit.scss similarity index 100% rename from xmodule/static/sass/include/problem/edit.scss rename to xmodule/css/problem/edit.scss diff --git a/xmodule/static/sass/include/sequence/display.scss b/xmodule/css/sequence/display.scss similarity index 100% rename from xmodule/static/sass/include/sequence/display.scss rename to xmodule/css/sequence/display.scss diff --git a/xmodule/static/sass/include/tabs/codemirror.scss b/xmodule/css/tabs/codemirror.scss similarity index 100% rename from xmodule/static/sass/include/tabs/codemirror.scss rename to xmodule/css/tabs/codemirror.scss diff --git a/xmodule/static/sass/include/tabs/tabs.scss b/xmodule/css/tabs/tabs.scss similarity index 100% rename from xmodule/static/sass/include/tabs/tabs.scss rename to xmodule/css/tabs/tabs.scss diff --git a/xmodule/static/sass/include/video/accessible_menu.scss b/xmodule/css/video/accessible_menu.scss similarity index 100% rename from xmodule/static/sass/include/video/accessible_menu.scss rename to xmodule/css/video/accessible_menu.scss diff --git a/xmodule/static/sass/include/video/display.scss b/xmodule/css/video/display.scss similarity index 100% rename from xmodule/static/sass/include/video/display.scss rename to xmodule/css/video/display.scss diff --git a/xmodule/static/sass/include/word_cloud/display.scss b/xmodule/css/word_cloud/display.scss similarity index 100% rename from xmodule/static/sass/include/word_cloud/display.scss rename to xmodule/css/word_cloud/display.scss diff --git a/xmodule/html_block.py b/xmodule/html_block.py index c9f3ddbf4d69..48786c2c5611 100644 --- a/xmodule/html_block.py +++ b/xmodule/html_block.py @@ -152,6 +152,7 @@ def studio_view(self, _context): ], 'xmodule_js': resource_filename(__name__, 'js/src/xmodule.js'), } + preview_view_css = {'scss': [resource_filename(__name__, 'css/html/display.scss')]} uses_xmodule_styles_setup = True @@ -167,6 +168,12 @@ def studio_view(self, _context): ], 'xmodule_js': resource_filename(__name__, 'js/src/xmodule.js'), } + studio_view_css = { + 'scss': [ + resource_filename(__name__, 'css/editor/edit.scss'), + resource_filename(__name__, 'css/html/edit.scss') + ] + } # VS[compat] TODO (cpennington): Delete this method once all fall 2012 course # are being edited in the cms diff --git a/xmodule/library_content_block.py b/xmodule/library_content_block.py index 2e405371d017..7193247f58d5 100644 --- a/xmodule/library_content_block.py +++ b/xmodule/library_content_block.py @@ -99,6 +99,9 @@ class LibraryContentBlock( 'js': [], 'xmodule_js': resource_filename(__name__, 'js/src/xmodule.js'), } + preview_view_css = { + 'scss': [], + } mako_template = 'widgets/metadata-edit.html' studio_js_module_name = "VerticalDescriptor" @@ -108,6 +111,9 @@ class LibraryContentBlock( ], 'xmodule_js': resource_filename(__name__, 'js/src/xmodule.js'), } + studio_view_css = { + 'scss': [], + } show_in_read_only_mode = True diff --git a/xmodule/lti_block.py b/xmodule/lti_block.py index 66bb4e2049c7..76c03d73a671 100644 --- a/xmodule/lti_block.py +++ b/xmodule/lti_block.py @@ -378,6 +378,11 @@ class LTIBlock( ], 'xmodule_js': resource_filename(__name__, 'js/src/xmodule.js'), } + preview_view_css = { + 'scss': [ + resource_filename(__name__, 'css/lti/lti.scss') + ], + } mako_template = 'widgets/metadata-only-edit.html' @@ -388,6 +393,9 @@ class LTIBlock( ], 'xmodule_js': resource_filename(__name__, 'js/src/xmodule.js'), } + studio_view_css = { + 'scss': [], + } def studio_view(self, _context): """ diff --git a/xmodule/poll_block.py b/xmodule/poll_block.py index 3141c7b71984..0ce6d38e1e51 100644 --- a/xmodule/poll_block.py +++ b/xmodule/poll_block.py @@ -92,6 +92,11 @@ class PollBlock( ], 'xmodule_js': resource_filename(__name__, 'js/src/xmodule.js'), } + preview_view_css = { + 'scss': [ + resource_filename(__name__, 'css/poll/display.scss') + ], + } # There is no studio_view() for this XBlock but this is needed to make the # the static_content command happy. @@ -100,6 +105,10 @@ class PollBlock( 'xmodule_js': resource_filename(__name__, 'js/src/xmodule.js') } + studio_view_css = { + 'scss': [] + } + def handle_ajax(self, dispatch, data): # lint-amnesty, pylint: disable=unused-argument """Ajax handler. diff --git a/xmodule/seq_block.py b/xmodule/seq_block.py index c46bb97e0fee..250a69d83b6a 100644 --- a/xmodule/seq_block.py +++ b/xmodule/seq_block.py @@ -278,6 +278,12 @@ class SequenceBlock( 'xmodule_js': resource_filename(__name__, 'js/src/xmodule.js') } + preview_view_css = { + 'scss': [ + resource_filename(__name__, 'css/sequence/display.scss'), + ], + } + # There is no studio_view() for this XBlock but this is needed to make the # the static_content command happy. studio_view_js = { @@ -285,6 +291,10 @@ class SequenceBlock( 'xmodule_js': resource_filename(__name__, 'js/src/xmodule.js') } + studio_view_css = { + 'scss': [] + } + def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) diff --git a/xmodule/split_test_block.py b/xmodule/split_test_block.py index 229578caef0c..b638eb7a50ba 100644 --- a/xmodule/split_test_block.py +++ b/xmodule/split_test_block.py @@ -162,6 +162,9 @@ class SplitTestBlock( # lint-amnesty, pylint: disable=abstract-method 'js': [], 'xmodule_js': resource_filename(__name__, 'js/src/xmodule.js'), } + preview_view_css = { + 'scss': [], + } mako_template = "widgets/metadata-only-edit.html" studio_js_module_name = 'SequenceDescriptor' @@ -169,6 +172,9 @@ class SplitTestBlock( # lint-amnesty, pylint: disable=abstract-method 'js': [resource_filename(__name__, 'js/src/sequence/edit.js')], 'xmodule_js': resource_filename(__name__, 'js/src/xmodule.js'), } + studio_view_css = { + 'scss': [], + } @cached_property def child_block(self): diff --git a/xmodule/static/sass/cms/AboutBlockStudio.scss b/xmodule/static/sass/cms/AboutBlockStudio.scss deleted file mode 100644 index 0af42e47ff02..000000000000 --- a/xmodule/static/sass/cms/AboutBlockStudio.scss +++ /dev/null @@ -1,4 +0,0 @@ -.xmodule_edit.xmodule_AboutBlock { - @import "editor/edit.scss"; - @import "html/edit.scss"; -} diff --git a/xmodule/static/sass/cms/AnnotatableBlockStudio.scss b/xmodule/static/sass/cms/AnnotatableBlockStudio.scss deleted file mode 100644 index 8f2852422d7d..000000000000 --- a/xmodule/static/sass/cms/AnnotatableBlockStudio.scss +++ /dev/null @@ -1,3 +0,0 @@ -.xmodule_edit.xmodule_AnnotatableBlock { - @import "codemirror/codemirror.scss"; -} diff --git a/xmodule/static/sass/cms/CourseInfoBlockStudio.scss b/xmodule/static/sass/cms/CourseInfoBlockStudio.scss deleted file mode 100644 index df1af8311546..000000000000 --- a/xmodule/static/sass/cms/CourseInfoBlockStudio.scss +++ /dev/null @@ -1,4 +0,0 @@ -.xmodule_edit.xmodule_CourseInfoBlock { - @import "editor/edit.scss"; - @import "html/edit.scss"; -} diff --git a/xmodule/static/sass/cms/CustomTagBlockStudio.scss b/xmodule/static/sass/cms/CustomTagBlockStudio.scss deleted file mode 100644 index 3abd162c808d..000000000000 --- a/xmodule/static/sass/cms/CustomTagBlockStudio.scss +++ /dev/null @@ -1,3 +0,0 @@ -.xmodule_edit.xmodule_CustomTagBlock { - @import "codemirror/codemirror.scss"; -} diff --git a/xmodule/static/sass/cms/HtmlBlockStudio.scss b/xmodule/static/sass/cms/HtmlBlockStudio.scss deleted file mode 100644 index 350a80cc5d84..000000000000 --- a/xmodule/static/sass/cms/HtmlBlockStudio.scss +++ /dev/null @@ -1,4 +0,0 @@ -.xmodule_edit.xmodule_HtmlBlock { - @import "editor/edit.scss"; - @import "html/edit.scss"; -} diff --git a/xmodule/static/sass/cms/ProblemBlockStudio.scss b/xmodule/static/sass/cms/ProblemBlockStudio.scss deleted file mode 100644 index 03d3cf1e2a98..000000000000 --- a/xmodule/static/sass/cms/ProblemBlockStudio.scss +++ /dev/null @@ -1,4 +0,0 @@ -.xmodule_edit.xmodule_ProblemBlock { - @import "editor/edit.scss"; - @import "problem/edit.scss"; -} diff --git a/xmodule/static/sass/cms/StaticTabBlockStudio.scss b/xmodule/static/sass/cms/StaticTabBlockStudio.scss deleted file mode 100644 index 37fa9ca36030..000000000000 --- a/xmodule/static/sass/cms/StaticTabBlockStudio.scss +++ /dev/null @@ -1,4 +0,0 @@ -.xmodule_edit.xmodule_StaticTabBlock { - @import "editor/edit.scss"; - @import "html/edit.scss"; -} diff --git a/xmodule/static/sass/cms/VideoBlockStudio.scss b/xmodule/static/sass/cms/VideoBlockStudio.scss deleted file mode 100644 index eb966091ce46..000000000000 --- a/xmodule/static/sass/cms/VideoBlockStudio.scss +++ /dev/null @@ -1,3 +0,0 @@ -.xmodule_edit.xmodule_VideoBlock { - @import "tabs/tabs.scss"; -} diff --git a/xmodule/static/sass/lms/AboutBlockPreview.scss b/xmodule/static/sass/lms/AboutBlockPreview.scss deleted file mode 100644 index 1df920bc232b..000000000000 --- a/xmodule/static/sass/lms/AboutBlockPreview.scss +++ /dev/null @@ -1,3 +0,0 @@ -.xmodule_display.xmodule_AboutBlock { - @import "html/display.scss"; -} diff --git a/xmodule/static/sass/lms/AnnotatableBlockPreview.scss b/xmodule/static/sass/lms/AnnotatableBlockPreview.scss deleted file mode 100644 index 66e1e756f3da..000000000000 --- a/xmodule/static/sass/lms/AnnotatableBlockPreview.scss +++ /dev/null @@ -1,3 +0,0 @@ -.xmodule_display.xmodule_AnnotatableBlock { - @import "annotatable/display.scss"; -} diff --git a/xmodule/static/sass/lms/CourseInfoBlockPreview.scss b/xmodule/static/sass/lms/CourseInfoBlockPreview.scss deleted file mode 100644 index ff6353df74e2..000000000000 --- a/xmodule/static/sass/lms/CourseInfoBlockPreview.scss +++ /dev/null @@ -1,3 +0,0 @@ -.xmodule_display.xmodule_CourseInfoBlock { - @import "html/display.scss"; -} diff --git a/xmodule/static/sass/lms/HtmlBlockPreview.scss b/xmodule/static/sass/lms/HtmlBlockPreview.scss deleted file mode 100644 index 09610448fed5..000000000000 --- a/xmodule/static/sass/lms/HtmlBlockPreview.scss +++ /dev/null @@ -1,3 +0,0 @@ -.xmodule_display.xmodule_HtmlBlock { - @import "html/display.scss"; -} diff --git a/xmodule/static/sass/lms/LTIBlockPreview.scss b/xmodule/static/sass/lms/LTIBlockPreview.scss deleted file mode 100644 index ea92202df2ad..000000000000 --- a/xmodule/static/sass/lms/LTIBlockPreview.scss +++ /dev/null @@ -1,3 +0,0 @@ -.xmodule_display.xmodule_LTIBlock { - @import "lti/lti.scss"; -} diff --git a/xmodule/static/sass/lms/PollBlockPreview.scss b/xmodule/static/sass/lms/PollBlockPreview.scss deleted file mode 100644 index 85110778c742..000000000000 --- a/xmodule/static/sass/lms/PollBlockPreview.scss +++ /dev/null @@ -1,3 +0,0 @@ -.xmodule_display.xmodule_PollBlock { - @import "poll/display.scss"; -} diff --git a/xmodule/static/sass/lms/ProblemBlockPreview.scss b/xmodule/static/sass/lms/ProblemBlockPreview.scss deleted file mode 100644 index 5175529246b0..000000000000 --- a/xmodule/static/sass/lms/ProblemBlockPreview.scss +++ /dev/null @@ -1,3 +0,0 @@ -.xmodule_display.xmodule_ProblemBlock { - @import "capa/display.scss"; -} diff --git a/xmodule/static/sass/lms/SequenceBlockPreview.scss b/xmodule/static/sass/lms/SequenceBlockPreview.scss deleted file mode 100644 index 0c5aa3c82c49..000000000000 --- a/xmodule/static/sass/lms/SequenceBlockPreview.scss +++ /dev/null @@ -1,3 +0,0 @@ -.xmodule_display.xmodule_SequenceBlock { - @import "sequence/display.scss"; -} diff --git a/xmodule/static/sass/lms/StaticTabBlockPreview.scss b/xmodule/static/sass/lms/StaticTabBlockPreview.scss deleted file mode 100644 index 5c044e659b28..000000000000 --- a/xmodule/static/sass/lms/StaticTabBlockPreview.scss +++ /dev/null @@ -1,3 +0,0 @@ -.xmodule_display.xmodule_StaticTabBlock { - @import "html/display.scss"; -} diff --git a/xmodule/static/sass/lms/VideoBlockPreview.scss b/xmodule/static/sass/lms/VideoBlockPreview.scss deleted file mode 100644 index ccd9a3ed1326..000000000000 --- a/xmodule/static/sass/lms/VideoBlockPreview.scss +++ /dev/null @@ -1,4 +0,0 @@ -.xmodule_display.xmodule_VideoBlock { - @import "video/display.scss"; - @import "video/accessible_menu.scss"; -} diff --git a/xmodule/static/sass/lms/WordCloudBlockPreview.scss b/xmodule/static/sass/lms/WordCloudBlockPreview.scss deleted file mode 100644 index 884112a4804c..000000000000 --- a/xmodule/static/sass/lms/WordCloudBlockPreview.scss +++ /dev/null @@ -1,3 +0,0 @@ -.xmodule_display.xmodule_WordCloudBlock { - @import "word_cloud/display.scss"; -} diff --git a/xmodule/static_content.py b/xmodule/static_content.py index 80b0b1d14b97..6730dcb7a0ea 100755 --- a/xmodule/static_content.py +++ b/xmodule/static_content.py @@ -1,7 +1,7 @@ # /usr/bin/env python """ -This module has utility functions for gathering up the javascript -that is defined by XModules and XModuleDescriptors +This module has utility functions for gathering up the static content +that is defined by XModules and XModuleDescriptors (javascript and css) """ @@ -47,6 +47,12 @@ class VideoBlock(HTMLSnippet): # lint-amnesty, pylint: disable=abstract-method ], 'xmodule_js': resource_filename(__name__, 'js/src/xmodule.js') } + preview_view_css = { + 'scss': [ + resource_filename(__name__, 'css/video/display.scss'), + resource_filename(__name__, 'css/video/accessible_menu.scss'), + ], + } studio_view_js = { 'js': [ @@ -55,6 +61,12 @@ class VideoBlock(HTMLSnippet): # lint-amnesty, pylint: disable=abstract-method 'xmodule_js': resource_filename(__name__, 'js/src/xmodule.js'), } + studio_view_css = { + 'scss': [ + resource_filename(__name__, 'css/tabs/tabs.scss'), + ] + } + # List of XBlocks which use this static content setup. # Should only be used for XModules being converted to XBlocks. @@ -77,11 +89,21 @@ class VideoBlock(HTMLSnippet): # lint-amnesty, pylint: disable=abstract-method ] +def write_module_styles(output_root): + """Write all registered XModule css, sass, and scss files to output root.""" + return _write_styles('.xmodule_display', output_root, XBLOCK_CLASSES, 'get_preview_view_css', 'Preview') + + def write_module_js(output_root): """Write all registered XModule js and coffee files to output root.""" return _write_js(output_root, XBLOCK_CLASSES, 'get_preview_view_js') +def write_descriptor_styles(output_root): + """Write all registered XModuleDescriptor css, sass, and scss files to output root.""" + return _write_styles('.xmodule_edit', output_root, XBLOCK_CLASSES, 'get_studio_view_css', 'Studio') + + def write_descriptor_js(output_root): """Write all registered XModuleDescriptor js and coffee files to output root.""" return _write_js(output_root, XBLOCK_CLASSES, 'get_studio_view_js') @@ -98,6 +120,33 @@ def _ensure_dir(directory): raise +def _write_styles(selector, output_root, classes, css_attribute, suffix): + """ + Write the css fragments from all XModules in `classes` + into `output_root` as individual files + """ + contents = {} + xmodule_scss_path = resource_filename(__name__, "") + "/css/" + + for class_ in classes: + class_css = getattr(class_, css_attribute)() + rel_fragment_paths = [] + for fragment_path in class_css.get('scss', []): + rel_fragment_path = fragment_path.split(xmodule_scss_path)[1] + rel_fragment_paths.append(rel_fragment_path) + + module_styles_lines = [] + module_styles_lines.append("""{selector}.xmodule_{class_.__name__} {{""".format( + class_=class_, selector=selector + )) + module_styles_lines.extend(f' @import "{path}";' for path in rel_fragment_paths) + module_styles_lines.append('}') + + contents[f"{class_.__name__}{suffix}.scss"] = '\n'.join(module_styles_lines) + + _write_files(output_root, contents) + + def _write_js(output_root, classes, js_attribute): """ Write the javascript fragments from all XModules in `classes` @@ -245,7 +294,9 @@ def main(): root = path(args['']) descriptor_files = write_descriptor_js(root / 'descriptors/js') + write_descriptor_styles(root / 'descriptors/scss') module_files = write_module_js(root / 'modules/js') + write_module_styles(root / 'modules/scss') write_webpack(root / 'webpack.xmodule.config.js', module_files, descriptor_files) diff --git a/xmodule/template_block.py b/xmodule/template_block.py index abf1f2c725a9..71b2c21f1441 100644 --- a/xmodule/template_block.py +++ b/xmodule/template_block.py @@ -69,10 +69,16 @@ class CustomTagBlock(CustomTagTemplateBlock): # pylint: disable=abstract-method 'js': [], 'xmodule_js': resource_filename(__name__, 'js/src/xmodule.js'), } + preview_view_css = { + 'scss': [], + } studio_view_js = { 'js': [resource_filename(__name__, 'js/src/raw/edit/xml.js')], 'xmodule_js': resource_filename(__name__, 'js/src/xmodule.js'), } + studio_view_css = { + 'scss': [resource_filename(__name__, 'css/codemirror/codemirror.scss')], + } def studio_view(self, _context): """ diff --git a/xmodule/word_cloud_block.py b/xmodule/word_cloud_block.py index 8fe741b881db..d7d35dedc5f3 100644 --- a/xmodule/word_cloud_block.py +++ b/xmodule/word_cloud_block.py @@ -118,6 +118,11 @@ class WordCloudBlock( # pylint: disable=abstract-method ], 'xmodule_js': resource_filename(__name__, 'js/src/xmodule.js'), } + preview_view_css = { + 'scss': [ + resource_filename(__name__, 'css/word_cloud/display.scss'), + ], + } studio_view_js = { 'js': [ @@ -125,6 +130,9 @@ class WordCloudBlock( # pylint: disable=abstract-method ], 'xmodule_js': resource_filename(__name__, 'js/src/xmodule.js'), } + studio_view_css = { + 'scss': [], + } studio_js_module_name = "MetadataOnlyEditingDescriptor" mako_template = "widgets/metadata-only-edit.html" diff --git a/xmodule/x_module.py b/xmodule/x_module.py index b1c8d5bfb07f..c2e57a05988a 100644 --- a/xmodule/x_module.py +++ b/xmodule/x_module.py @@ -215,6 +215,9 @@ class HTMLSnippet: preview_view_js = {} studio_view_js = {} + preview_view_css = {} + studio_view_css = {} + @classmethod def get_preview_view_js(cls): return cls.preview_view_js @@ -231,6 +234,14 @@ def get_studio_view_js(cls): def get_studio_view_js_bundle_name(cls): return cls.__name__ + 'Studio' + @classmethod + def get_preview_view_css(cls): + return cls.preview_view_css + + @classmethod + def get_studio_view_css(cls): + return cls.studio_view_css + def get_html(self): """ Return the html used to display this snippet