From 55aeca65c2f1382c6b4a3b7f3f7e9de9f6fe94bc Mon Sep 17 00:00:00 2001 From: farhan Date: Thu, 24 Oct 2024 16:28:10 +0500 Subject: [PATCH 1/2] feat!: Dropping Sass support from builtin poll block, replacing with vanilla CSS --- xmodule/assets/poll/_display.scss | 16 +- xmodule/poll_block.py | 4 +- .../css-builtin-blocks/PollBlockDisplay.css | 221 ++++++++++++++++++ 3 files changed, 231 insertions(+), 10 deletions(-) create mode 100644 xmodule/static/css-builtin-blocks/PollBlockDisplay.css diff --git a/xmodule/assets/poll/_display.scss b/xmodule/assets/poll/_display.scss index 7c07f89376b2..7c9b21bf205e 100644 --- a/xmodule/assets/poll/_display.scss +++ b/xmodule/assets/poll/_display.scss @@ -20,13 +20,13 @@ div.poll_question { h3 { margin-top: 0; - margin-bottom: ($baseline*0.75); + margin-bottom: calc((var(--baseline)*0.75)); color: #fe57a1; font-size: 1.9em; &.problem-header { div.staff { - margin-top: ($baseline*1.5); + margin-top: calc((var(--baseline)*1.5)); font-size: 80%; } } @@ -44,7 +44,7 @@ div.poll_question { } .poll_answer { - margin-bottom: $baseline; + margin-bottom: var(--baseline); &.short { clear: both; @@ -107,7 +107,7 @@ div.poll_question { font-weight: bold; letter-spacing: normal; line-height: 25.59375px; - margin-bottom: ($baseline*0.75); + margin-bottom: calc((var(--baseline)*0.75)); margin: 0; padding: 0px; text-align: center; @@ -145,9 +145,9 @@ div.poll_question { width: 80%; text-align: left; min-height: 30px; - margin-left: $baseline; + margin-left: var(--baseline); height: auto; - margin-bottom: $baseline; + margin-bottom: var(--baseline); &.short { width: 100px; @@ -157,7 +157,7 @@ div.poll_question { .stats { min-height: 40px; - margin-top: $baseline; + margin-top: var(--baseline); clear: both; &.short { @@ -174,7 +174,7 @@ div.poll_question { border: 1px solid black; display: inline; float: left; - margin-right: ($baseline/2); + margin-right: calc((var(--baseline)/2)); &.short { width: 65%; diff --git a/xmodule/poll_block.py b/xmodule/poll_block.py index f09889f506e6..a1c9686f42ac 100644 --- a/xmodule/poll_block.py +++ b/xmodule/poll_block.py @@ -21,7 +21,7 @@ from openedx.core.djangolib.markup import Text, HTML from xmodule.mako_block import MakoTemplateBlockBase from xmodule.stringify import stringify_children -from xmodule.util.builtin_assets import add_webpack_js_to_fragment, add_sass_to_fragment +from xmodule.util.builtin_assets import add_webpack_js_to_fragment, add_css_to_fragment from xmodule.x_module import ( ResourceTemplates, shim_xmodule_js, @@ -136,7 +136,7 @@ def student_view(self, _context): 'configuration_json': self.dump_poll(), } fragment.add_content(self.runtime.service(self, 'mako').render_lms_template('poll.html', params)) - add_sass_to_fragment(fragment, 'PollBlockDisplay.scss') + add_css_to_fragment(fragment, 'PollBlockDisplay.css') add_webpack_js_to_fragment(fragment, 'PollBlockDisplay') shim_xmodule_js(fragment, 'Poll') return fragment diff --git a/xmodule/static/css-builtin-blocks/PollBlockDisplay.css b/xmodule/static/css-builtin-blocks/PollBlockDisplay.css new file mode 100644 index 000000000000..f617dc960d38 --- /dev/null +++ b/xmodule/static/css-builtin-blocks/PollBlockDisplay.css @@ -0,0 +1,221 @@ +@import url("https://fonts.googleapis.com/css?family=Open+Sans:300,400,400i,600,700"); + +.xmodule_display.xmodule_PollBlock { + /* stylelint-disable-line */ + /* stylelint-disable-line */ +} + +@media print { + .xmodule_display.xmodule_PollBlock div.poll_question { + display: block; + width: auto; + padding: 0; + } + + .xmodule_display.xmodule_PollBlock div.poll_question canvas, .xmodule_display.xmodule_PollBlock div.poll_question img { + page-break-inside: avoid; + } +} + +.xmodule_display.xmodule_PollBlock div.poll_question .inline { + display: inline; +} + +.xmodule_display.xmodule_PollBlock div.poll_question h3 { + margin-top: 0; + margin-bottom: calc((var(--baseline) * 0.75)); + color: #fe57a1; + font-size: 1.9em; +} + +.xmodule_display.xmodule_PollBlock div.poll_question h3.problem-header div.staff { + margin-top: calc((var(--baseline) * 1.5)); + font-size: 80%; +} + +@media print { + .xmodule_display.xmodule_PollBlock div.poll_question h3 { + display: block; + width: auto; + border-right: 0; + } +} + +.xmodule_display.xmodule_PollBlock div.poll_question p { + text-align: justify; + font-weight: bold; +} + +.xmodule_display.xmodule_PollBlock div.poll_question .poll_answer { + margin-bottom: var(--baseline); +} + +.xmodule_display.xmodule_PollBlock div.poll_question .poll_answer.short { + clear: both; +} + +.xmodule_display.xmodule_PollBlock div.poll_question .poll_answer .question { + height: auto; + clear: both; + min-height: 30px; +} + +.xmodule_display.xmodule_PollBlock div.poll_question .poll_answer .question.short { + clear: none; + width: 30%; + display: inline; + float: left; +} + +.xmodule_display.xmodule_PollBlock div.poll_question .poll_answer .question .button { + -webkit-appearance: none; + -webkit-background-clip: padding-box; + -webkit-border-image: none; + -webkit-box-align: center; + -webkit-box-shadow: white 0px 1px 0px 0px inset; + -webkit-font-smoothing: antialiased; + -webkit-rtl-ordering: logical; + -webkit-user-select: text; + -webkit-writing-mode: horizontal-tb; + background-clip: padding-box; + background-color: #eeeeee; + background-image: -webkit-linear-gradient(top, #eeeeee, #d2d2d2); + border-bottom-color: #cacaca; + border-bottom-left-radius: 3px; + border-bottom-right-radius: 3px; + border-bottom-style: solid; + border-bottom-width: 1px; + border-left-color: #cacaca; + border-left-style: solid; + border-left-width: 1px; + border-right-color: #cacaca; + border-right-style: solid; + border-right-width: 1px; + border-top-color: #cacaca; + border-top-left-radius: 3px; + border-top-right-radius: 3px; + border-top-style: solid; + border-top-width: 1px; + box-shadow: white 0px 1px 0px 0px inset; + box-sizing: border-box; + color: #333333; + /* display: inline-block; */ + display: inline; + float: left; + font-family: 'Open Sans', Verdana, Geneva, sans-serif; + font-size: 13px; + font-style: normal; + font-variant: normal; + font-weight: bold; + letter-spacing: normal; + line-height: 25.59375px; + margin-bottom: calc((var(--baseline) * 0.75)); + margin: 0; + padding: 0px; + text-align: center; + text-decoration: none; + text-indent: 0px; + text-shadow: #f8f8f8 0px 1px 0px; + text-transform: none; + vertical-align: top; + white-space: pre-line; + width: 25px; + height: 25px; + word-spacing: 0px; + writing-mode: lr-tb; +} + +.xmodule_display.xmodule_PollBlock div.poll_question .poll_answer .question .button.answered { + -webkit-box-shadow: #61b8e1 0px 1px 0px 0px inset; + background-color: #1d9dd9; + background-image: -webkit-linear-gradient(top, #1d9dd9, #0e7cb0); + border-bottom-color: #0d72a2; + border-left-color: #0d72a2; + border-right-color: #0d72a2; + border-top-color: #0d72a2; + box-shadow: #61b8e1 0px 1px 0px 0px inset; + color: white; + text-shadow: #076794 0px 1px 0px; + background-image: none; +} + +.xmodule_display.xmodule_PollBlock div.poll_question .poll_answer .question .text { + display: inline; + float: left; + width: 80%; + text-align: left; + min-height: 30px; + margin-left: var(--baseline); + height: auto; + margin-bottom: var(--baseline); +} + +.xmodule_display.xmodule_PollBlock div.poll_question .poll_answer .question .text.short { + width: 100px; +} + +.xmodule_display.xmodule_PollBlock div.poll_question .poll_answer .stats { + min-height: 40px; + margin-top: var(--baseline); + clear: both; +} + +.xmodule_display.xmodule_PollBlock div.poll_question .poll_answer .stats.short { + margin-top: 0; + clear: none; + display: inline; + float: right; + width: 70%; +} + +.xmodule_display.xmodule_PollBlock div.poll_question .poll_answer .stats .bar { + width: 75%; + height: 20px; + border: 1px solid black; + display: inline; + float: left; + margin-right: calc((var(--baseline) / 2)); +} + +.xmodule_display.xmodule_PollBlock div.poll_question .poll_answer .stats .bar.short { + width: 65%; + height: 20px; + margin-top: 3px; +} + +.xmodule_display.xmodule_PollBlock div.poll_question .poll_answer .stats .bar .percent { + background-color: gray; + width: 0; + height: 20px; +} + +.xmodule_display.xmodule_PollBlock div.poll_question .poll_answer .stats .number { + width: 80px; + display: inline; + float: right; + height: 28px; + text-align: right; +} + +.xmodule_display.xmodule_PollBlock div.poll_question .poll_answer .stats .number.short { + width: 120px; + height: auto; +} + +.xmodule_display.xmodule_PollBlock div.poll_question .poll_answer.answered { + -webkit-box-shadow: #61b8e1 0 1px 0 0 inset; + background-color: #1d9dd9; + background-image: -webkit-linear-gradient(top, #1d9dd9, #0e7cb0); + border-bottom-color: #0d72a2; + border-left-color: #0d72a2; + border-right-color: #0d72a2; + border-top-color: #0d72a2; + box-shadow: #61b8e1 0 1px 0 0 inset; + color: white; + text-shadow: #076794 0 1px 0; +} + +.xmodule_display.xmodule_PollBlock div.poll_question .button.reset-button { + clear: both; + float: right; +} From 7f1611ed9039b425e5ed094f7160e68f518298c2 Mon Sep 17 00:00:00 2001 From: farhan Date: Fri, 25 Oct 2024 18:35:23 +0500 Subject: [PATCH 2/2] chore: remove scss files related to the poll block --- xmodule/assets/PollBlockDisplay.scss | 3 - xmodule/assets/poll/_display.scss | 226 --------------------------- 2 files changed, 229 deletions(-) delete mode 100644 xmodule/assets/PollBlockDisplay.scss delete mode 100644 xmodule/assets/poll/_display.scss diff --git a/xmodule/assets/PollBlockDisplay.scss b/xmodule/assets/PollBlockDisplay.scss deleted file mode 100644 index 85110778c742..000000000000 --- a/xmodule/assets/PollBlockDisplay.scss +++ /dev/null @@ -1,3 +0,0 @@ -.xmodule_display.xmodule_PollBlock { - @import "poll/display.scss"; -} diff --git a/xmodule/assets/poll/_display.scss b/xmodule/assets/poll/_display.scss deleted file mode 100644 index 7c9b21bf205e..000000000000 --- a/xmodule/assets/poll/_display.scss +++ /dev/null @@ -1,226 +0,0 @@ -@import 'bourbon/bourbon'; -@import 'lms/theme/variables'; -@import 'bootstrap/scss/variables'; -@import 'lms/theme/variables-v1'; - -div.poll_question { - @media print { - display: block; - width: auto; - padding: 0; - - canvas, img { - page-break-inside: avoid; - } - } - - .inline { - display: inline; - } - - h3 { - margin-top: 0; - margin-bottom: calc((var(--baseline)*0.75)); - color: #fe57a1; - font-size: 1.9em; - - &.problem-header { - div.staff { - margin-top: calc((var(--baseline)*1.5)); - font-size: 80%; - } - } - - @media print { - display: block; - width: auto; - border-right: 0; - } - } - - p { - text-align: justify; - font-weight: bold; - } - - .poll_answer { - margin-bottom: var(--baseline); - - &.short { - clear: both; - } - - .question { - height: auto; - clear: both; - min-height: 30px; - - &.short { - clear: none; - width: 30%; - display: inline; - float: left; - } - - .button { - @extend %ui-fake-link; - - -webkit-appearance: none; - -webkit-background-clip: padding-box; - -webkit-border-image: none; - -webkit-box-align: center; - -webkit-box-shadow: rgb(255, 255, 255) 0px 1px 0px 0px inset; - -webkit-font-smoothing: antialiased; - -webkit-rtl-ordering: logical; - -webkit-user-select: text; - -webkit-writing-mode: horizontal-tb; - background-clip: padding-box; - background-color: rgb(238, 238, 238); - background-image: -webkit-linear-gradient(top, rgb(238, 238, 238), rgb(210, 210, 210)); - border-bottom-color: rgb(202, 202, 202); - border-bottom-left-radius: 3px; - border-bottom-right-radius: 3px; - border-bottom-style: solid; - border-bottom-width: 1px; - border-left-color: rgb(202, 202, 202); - border-left-style: solid; - border-left-width: 1px; - border-right-color: rgb(202, 202, 202); - border-right-style: solid; - border-right-width: 1px; - border-top-color: rgb(202, 202, 202); - border-top-left-radius: 3px; - border-top-right-radius: 3px; - border-top-style: solid; - border-top-width: 1px; - box-shadow: rgb(255, 255, 255) 0px 1px 0px 0px inset; - box-sizing: border-box; - color: rgb(51, 51, 51); - - /* display: inline-block; */ - display: inline; - float: left; - font-family: 'Open Sans', Verdana, Geneva, sans-serif; - font-size: 13px; - font-style: normal; - font-variant: normal; - font-weight: bold; - letter-spacing: normal; - line-height: 25.59375px; - margin-bottom: calc((var(--baseline)*0.75)); - margin: 0; - padding: 0px; - text-align: center; - text-decoration: none; - text-indent: 0px; - text-shadow: rgb(248, 248, 248) 0px 1px 0px; - text-transform: none; - vertical-align: top; - white-space: pre-line; - width: 25px; - height: 25px; - word-spacing: 0px; - writing-mode: lr-tb; - } - - .button.answered { - -webkit-box-shadow: rgb(97, 184, 225) 0px 1px 0px 0px inset; - background-color: rgb(29, 157, 217); - background-image: -webkit-linear-gradient(top, rgb(29, 157, 217), rgb(14, 124, 176)); - border-bottom-color: rgb(13, 114, 162); - border-left-color: rgb(13, 114, 162); - border-right-color: rgb(13, 114, 162); - border-top-color: rgb(13, 114, 162); - box-shadow: rgb(97, 184, 225) 0px 1px 0px 0px inset; - color: rgb(255, 255, 255); - text-shadow: rgb(7, 103, 148) 0px 1px 0px; - background-image: none; - } - - .text { - @extend %ui-fake-link; - - display: inline; - float: left; - width: 80%; - text-align: left; - min-height: 30px; - margin-left: var(--baseline); - height: auto; - margin-bottom: var(--baseline); - - &.short { - width: 100px; - } - } - } - - .stats { - min-height: 40px; - margin-top: var(--baseline); - clear: both; - - &.short { - margin-top: 0; - clear: none; - display: inline; - float: right; - width: 70%; - } - - .bar { - width: 75%; - height: 20px; - border: 1px solid black; - display: inline; - float: left; - margin-right: calc((var(--baseline)/2)); - - &.short { - width: 65%; - height: 20px; - margin-top: 3px; - } - - .percent { - background-color: gray; - width: 0; - height: 20px; - - &.short { } - } - } - - .number { - width: 80px; - display: inline; - float: right; - height: 28px; - text-align: right; - - &.short { - width: 120px; - height: auto; - } - } - } - } - - .poll_answer.answered { - -webkit-box-shadow: rgb(97, 184, 225) 0 1px 0 0 inset; - background-color: rgb(29, 157, 217); - background-image: -webkit-linear-gradient(top, rgb(29, 157, 217), rgb(14, 124, 176)); - border-bottom-color: rgb(13, 114, 162); - border-left-color: rgb(13, 114, 162); - border-right-color: rgb(13, 114, 162); - border-top-color: rgb(13, 114, 162); - box-shadow: rgb(97, 184, 225) 0 1px 0 0 inset; - color: rgb(255, 255, 255); - text-shadow: rgb(7, 103, 148) 0 1px 0; - } - - .button.reset-button { - clear: both; - float: right; - } -}