Skip to content

Commit

Permalink
Grid section title / badges - work in progress.
Browse files Browse the repository at this point in the history
  • Loading branch information
gjb2048 committed Aug 30, 2024
1 parent e8a0309 commit 33fb278
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 12 deletions.
3 changes: 0 additions & 3 deletions classes/output/courseformat/content.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,6 @@ public function export_for_template(\renderer_base $output) {
// Section badge in grid box.
$data->sectionbadgeingridbox = ($coursesettings['sectionbadgeingridbox'] == 2);

// Title and / org badge?
$data->sectiontitleandorbadgeingridbox = ($data->sectiontitleingridbox || $data->sectionbadgeingridbox);

// Popup.
if (!$editing) {
$data->popup = false;
Expand Down
6 changes: 6 additions & 0 deletions styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@
position: relative;
}

.format-grid .thegrid .grid-image .grid-badge-middle {
left: 0;
position: absolute;
right: 0;
}

.format-grid .thegrid .grid-generatedimage {
background-size: contain;
height: 140px;
Expand Down
28 changes: 19 additions & 9 deletions templates/grid.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
* number - Section number.
* sectiontitleingridbox - Show the section title?
* sectionbadgeingridbox - Show the section bagde if any?
* sectiontitleandorbadgeingridbox - Is the title and or badge in the grid box?
* iscurrent - Current section?
* sectionurl - Section URL.
* sectionname - Section name.
Expand Down Expand Up @@ -66,7 +65,6 @@
],
"sectiontitleingridbox": true,
"sectionbadgeingridbox": true,
"sectiontitleandorbadgeingridbox": true,
"showcompletion": true
}
}}
Expand All @@ -87,11 +85,9 @@
{{#popup}}
<div class="grid-modal grid-section-inner d-flex flex-column h-100 justify-content-between" data-toggle="modal" data-target="#gridPopup" data-section="{{number}}" tabindex="0">
{{/popup}}
{{#sectiontitleandorbadgeingridbox}}
{{#sectiontitleingridbox}}
<div class="card-header text-truncate h-100">
{{#sectiontitleingridbox}}
<h3 class="h4">{{{sectionname}}}</h3>
{{/sectiontitleingridbox}}
{{#sectionbadgeingridbox}}{{#hasbadge}}
<div data-region="sectionbadges" class="sectionbadges d-flex">
{{$ core_courseformat/local/content/section/badges }}
Expand All @@ -100,20 +96,34 @@
</div>
{{/hasbadge}}{{/sectionbadgeingridbox}}
</div>
{{/sectiontitleandorbadgeingridbox}}
{{/sectiontitleingridbox}}
{{#imageuri}}
<div class="grid-image card-img-bottom text-center">
<div class="grid-image card-img-bottom{{^sectiontitleingridbox}} card-img-top{{/sectiontitleingridbox}} text-center">
<img src="{{imageuri}}" alt="{{imagealttext}}" loading="lazy">
{{^sectiontitleingridbox}}{{#hasbadge}}
<div data-region="sectionbadges" class="sectionbadges d-flex justify-content-center align-items-center h-100 grid-badge-middle">
{{$ core_courseformat/local/content/section/badges }}
{{> core_courseformat/local/content/section/badges }}
{{/ core_courseformat/local/content/section/badges }}
</div>
{{/hasbadge}}{{/sectiontitleingridbox}}
{{#sectioncompletionmarkup}}{{{sectioncompletionmarkup}}}{{/sectioncompletionmarkup}}
</div>
{{/imageuri}}
{{#generatedimageuri}}
<div class="grid-generatedimage card-img-bottom{{^sectiontitleandorbadgeingridbox}} card-img-top{{/sectiontitleandorbadgeingridbox}} text-center" style="background-image: url('{{generatedimageuri}}');">
<div class="grid-generatedimage card-img-bottom{{^sectiontitleingridbox}} card-img-top{{/sectiontitleingridbox}} text-center" style="background-image: url('{{generatedimageuri}}');">
{{^sectiontitleingridbox}}{{#hasbadge}}
<div data-region="sectionbadges" class="sectionbadges d-flex justify-content-center align-items-center h-100">
{{$ core_courseformat/local/content/section/badges }}
{{> core_courseformat/local/content/section/badges }}
{{/ core_courseformat/local/content/section/badges }}
</div>
{{/hasbadge}}{{/sectiontitleingridbox}}
{{#sectioncompletionmarkup}}{{{sectioncompletionmarkup}}}{{/sectioncompletionmarkup}}
</div>
{{/generatedimageuri}}
{{#imageerror}}
<div class="grid-image-error card-img-bottom{{^sectiontitleandorbadgeingridbox}} card-img-top{{/sectiontitleandorbadgeingridbox}} text-center">
<div class="grid-image-error card-img-bottom{{^sectiontitleingridbox}} card-img-top{{/sectiontitleingridbox}} text-center">
<p><small>{{imageerror}}</small></p>
{{#sectioncompletionmarkup}}{{{sectioncompletionmarkup}}}{{/sectioncompletionmarkup}}
</div>
Expand Down

0 comments on commit 33fb278

Please sign in to comment.