Skip to content

Commit

Permalink
refactor: remove xmodule CSS classes
Browse files Browse the repository at this point in the history
  • Loading branch information
kdmccormick committed Jan 2, 2025
1 parent 645e898 commit bdf5866
Showing 1 changed file with 5 additions and 22 deletions.
27 changes: 5 additions & 22 deletions openedx/core/lib/xblock_utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,31 +102,14 @@ def wrap_xblock(
if context:
data.update(context.get('wrap_xblock_data', {}))

css_classes = [
'xblock',
f'xblock-{markupsafe.escape(view)}',
'xblock-{}-{}'.format(
markupsafe.escape(view),
markupsafe.escape(block.scope_ids.block_type),
)
]

view_safe = markupsafe.escape(view)
block_type_safe = markupsafe.escape(block.scope_ids.block_type)
css_classes = ['xblock', f'xblock-{view_safe}', f'xblock-{view_safe}-{block_type_safe}']
if view in PREVIEW_VIEWS:
css_classes += ['xblock-display', f'xblock-display-{block_type_safe}']
if view == STUDENT_VIEW and getattr(block, 'HIDDEN', False):
css_classes.append('is-hidden')

# TODO: This special case will be removed when we update the SCSS under
# xmodule/assets to use the standard XBlock CSS classes.
# See https://github.com/openedx/edx-platform/issues/32617.
if getattr(block, 'uses_xmodule_styles_setup', False):
if view in PREVIEW_VIEWS:
# The block is acting as an XModule
css_classes.append('xmodule_display')
elif view == STUDIO_VIEW:
# The block is acting as an XModuleDescriptor
css_classes.append('xmodule_edit')

css_classes.append('xmodule_' + markupsafe.escape(class_name))

if frag.js_init_fn:
data['init'] = frag.js_init_fn
data['runtime-class'] = runtime_class
Expand Down

0 comments on commit bdf5866

Please sign in to comment.