MDL-73274 theme_boost: add block/activity styling

This commit is contained in:
Bas Brands 2021-12-15 09:46:26 +01:00
parent 508fe3937e
commit a8b6912e44
14 changed files with 63 additions and 86 deletions

View file

@ -27,31 +27,13 @@ defined('MOODLE_INTERNAL') || die();
user_preference_allow_ajax_update('drawer-open-nav', PARAM_ALPHA);
require_once($CFG->libdir . '/behat/lib.php');
// Add-a-block in editing mode.
if (isset($PAGE->theme->addblockposition) &&
$PAGE->user_is_editing() &&
$PAGE->user_can_edit_blocks() &&
$PAGE->pagelayout !== 'mycourses'
) {
$url = new moodle_url($PAGE->url, ['bui_addblock' => '', 'sesskey' => sesskey()]);
$block = new block_contents;
$block->content = $OUTPUT->render_from_template('core/add_block_button',
[
'link' => $url->out(false),
'escapedlink' => "?{$url->get_query_string(false)}",
'pageType' => $PAGE->pagetype,
'pageLayout' => $PAGE->pagelayout,
]
);
$PAGE->blocks->add_fake_block($block, BLOCK_POS_RIGHT);
}
// Add block button in editing mode.
$addblockbutton = $OUTPUT->addblockbutton();
$extraclasses = [];
$bodyattributes = $OUTPUT->body_attributes($extraclasses);
$blockshtml = $OUTPUT->blocks('side-pre');
$hasblocks = strpos($blockshtml, 'data-block=') !== false;
$hasblocks = (strpos($blockshtml, 'data-block=') !== false || !empty($addblockbutton));
$secondarynavigation = false;
$overflow = '';
@ -89,6 +71,7 @@ $templatecontext = [
'hasregionmainsettingsmenu' => !empty($regionmainsettingsmenu),
'headercontent' => $headercontent,
'overflow' => $overflow,
'addblockbutton' => $addblockbutton,
];
$nav = $PAGE->flatnav;
$templatecontext['firstcollectionlabel'] = $nav->get_collectionlabel();

View file

@ -27,22 +27,8 @@ defined('MOODLE_INTERNAL') || die();
require_once($CFG->libdir . '/behat/lib.php');
require_once($CFG->dirroot . '/course/lib.php');
// Add-a-block in editing mode.
if (isset($PAGE->theme->addblockposition) && $PAGE->user_is_editing() && $PAGE->user_can_edit_blocks()) {
$url = new moodle_url($PAGE->url, ['bui_addblock' => '', 'sesskey' => sesskey()]);
$block = new block_contents;
$block->content = $OUTPUT->render_from_template('core/add_block_button',
[
'link' => $url->out(false),
'escapedlink' => "?{$url->get_query_string(false)}",
'pageType' => $PAGE->pagetype,
'pageLayout' => $PAGE->pagelayout,
]
);
$PAGE->blocks->add_fake_block($block, BLOCK_POS_RIGHT);
}
// Add block button in editing mode.
$addblockbutton = $OUTPUT->addblockbutton();
user_preference_allow_ajax_update('drawer-open-nav', PARAM_ALPHA);
user_preference_allow_ajax_update('drawer-open-index', PARAM_BOOL);
@ -66,7 +52,7 @@ if ($courseindexopen) {
}
$blockshtml = $OUTPUT->blocks('side-pre');
$hasblocks = strpos($blockshtml, 'data-block=') !== false;
$hasblocks = (strpos($blockshtml, 'data-block=') !== false || !empty($addblockbutton));
if (!$hasblocks) {
$blockdraweropen = false;
}
@ -118,6 +104,7 @@ $templatecontext = [
'hasregionmainsettingsmenu' => !empty($regionmainsettingsmenu),
'overflow' => $overflow,
'headercontent' => $headercontent,
'addblockbutton' => $addblockbutton
];
$nav = $PAGE->flatnav;

View file

@ -1253,6 +1253,9 @@ $activity-add-hover: theme-color-level('primary', -10) !default;
&:hover {
cursor: pointer;
background-color: $activity-add-hover;
.activity-add-text {
text-decoration: underline;
}
}
width: 100%;
border-radius: 4px;

View file

@ -14555,6 +14555,9 @@ span.editinstructions {
.block-add:hover {
cursor: pointer;
background-color: #cfe2f2; }
.activity-add:hover .activity-add-text,
.block-add:hover .activity-add-text {
text-decoration: underline; }
#changenumsections {
border-top: 1px solid #3584c9; }

View file

@ -92,6 +92,7 @@
</section>
{{#hasblocks}}
<section data-region="blocks-column" class="d-print-none" aria-label="{{#str}}blocks{{/str}}">
{{{ addblockbutton }}}
{{{ sidepreblocks }}}
</section>
{{/hasblocks}}

View file

@ -45,7 +45,8 @@
"navdraweropen": false,
"blockdraweropen": true,
"regionmainsettingsmenu": "",
"hasregionmainsettingsmenu": false
"hasregionmainsettingsmenu": false,
"addblockbutton": ""
}
}}
{{> theme_boost/head }}
@ -75,6 +76,7 @@
{{$drawerclasses}}drawer drawer-right{{#blockdraweropen}} show{{/blockdraweropen}}{{/drawerclasses}}
{{$drawercontent}}
<section class="d-print-none" aria-label="{{#str}}blocks{{/str}}">
{{{ addblockbutton }}}
{{{ sidepreblocks }}}
</section>
{{/drawercontent}}

View file

@ -14555,6 +14555,9 @@ span.editinstructions {
.block-add:hover {
cursor: pointer;
background-color: #cfe2f2; }
.activity-add:hover .activity-add-text,
.block-add:hover .activity-add-text {
text-decoration: underline; }
#changenumsections {
border-top: 1px solid #3584c9; }