Skip to content

Commit 8716a8d

Browse files
committed
Display: Fix legacy checkboxes applying new styles
1 parent 45fa5b2 commit 8716a8d

4 files changed

Lines changed: 36 additions & 15 deletions

File tree

assets/css/app.scss

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -644,9 +644,6 @@ form .field {
644644
td {
645645
padding: 12px;
646646
}
647-
input[type="checkbox"] {
648-
transform: scale(1.2);
649-
}
650647
.save-button {
651648
background-color: #4CAF50;
652649
color: white;
@@ -659,10 +656,6 @@ form .field {
659656
.save-button:hover {
660657
background-color: #45a049;
661658
}
662-
input[type="checkbox"] {
663-
transform: scale(1);
664-
margin: 0 auto;
665-
}
666659
}
667660

668661
.files-info-page {
@@ -1036,11 +1029,6 @@ img.course-tool__icon {
10361029
textarea {
10371030
@apply focus:outline-0 focus:border-primary focus:rounded-md focus:transition;
10381031
}
1039-
1040-
input[type="checkbox"],
1041-
input[type="radio"] {
1042-
@apply focus:outline-2 focus:outline-primary rounded-full;
1043-
}
10441032
}
10451033
@layer components {
10461034
.form-group:focus-within,

assets/css/scss/atoms/_checkbox.scss

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,12 @@
8585
@apply text-body-2 w-5 h-5;
8686
}
8787
}
88+
89+
/* legacy checkboxes */
90+
.p-checkbox-box .p-checkbox-icon {
91+
@apply hidden;
92+
}
93+
94+
.p-checkbox-input:checked + .p-checkbox-box .p-checkbox-icon {
95+
@apply block;
96+
}

public/main/inc/lib/display.lib.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -873,6 +873,28 @@ public static function input($type, $name, $value, $attributes = [])
873873
$attributes['value'] = $value;
874874
}
875875

876+
if ('checkbox' === $type) {
877+
$attributes['class'] ??= 'p-checkbox-input';
878+
}
879+
880+
$inputBase = self::tag('input', '', $attributes);
881+
882+
if ('checkbox' === $type) {
883+
$isChecked = isset($attributes['checked']) && 'checked' === $attributes['checked'];
884+
$compontentCheckedClass = $isChecked ? 'p-checkbox-checked' : '';
885+
886+
return <<<HTML
887+
<div class="p-checkbox p-component $compontentCheckedClass">
888+
$inputBase
889+
<div class="p-checkbox-box">
890+
<svg class="p-icon p-checkbox-icon" width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
891+
<path d="M4.86199 11.5948C4.78717 11.5923 4.71366 11.5745 4.64596 11.5426C4.57826 11.5107 4.51779 11.4652 4.46827 11.4091L0.753985 7.69483C0.683167 7.64891 0.623706 7.58751 0.580092 7.51525C0.536478 7.44299 0.509851 7.36177 0.502221 7.27771C0.49459 7.19366 0.506156 7.10897 0.536046 7.03004C0.565935 6.95111 0.613367 6.88 0.674759 6.82208C0.736151 6.76416 0.8099 6.72095 0.890436 6.69571C0.970973 6.67046 1.05619 6.66385 1.13966 6.67635C1.22313 6.68886 1.30266 6.72017 1.37226 6.76792C1.44186 6.81567 1.4997 6.8786 1.54141 6.95197L4.86199 10.2503L12.6397 2.49483C12.7444 2.42694 12.8689 2.39617 12.9932 2.40745C13.1174 2.41873 13.2343 2.47141 13.3251 2.55705C13.4159 2.64268 13.4753 2.75632 13.4938 2.87973C13.5123 3.00315 13.4888 3.1292 13.4271 3.23768L5.2557 11.4091C5.20618 11.4652 5.14571 11.5107 5.07801 11.5426C5.01031 11.5745 4.9368 11.5923 4.86199 11.5948Z" fill="currentColor"></path>
892+
</svg>
893+
</div>
894+
</div>
895+
HTML;
896+
}
897+
876898
if ('text' === $type) {
877899
$attributes['class'] = isset($attributes['class'])
878900
? $attributes['class'].' p-inputtext p-component '

public/main/inc/lib/sortable_table.class.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1058,11 +1058,13 @@ public function filter_data($row)
10581058
}
10591059
if (count($this->form_actions) > 0) {
10601060
if (strlen($row[0]) > 0) {
1061-
$row[0] = '<div class="checkbox" ><label><input type="checkbox" name="'.$this->checkbox_name.'[]" value="'.$row[0].'"';
1061+
$checkboxParams = [];
1062+
10621063
if (isset($_GET[$this->param_prefix.'selectall'])) {
1063-
$row[0] .= ' checked="checked"';
1064+
$checkboxParams['checked'] = 'checked';
10641065
}
1065-
$row[0] .= '/><span class="checkbox-material"><span class="check"></span></span></label></div>';
1066+
1067+
$row[0] = Display::input('checkbox', $this->checkbox_name.'[]', $row[0], $checkboxParams);
10661068
}
10671069
}
10681070
if (is_array($row)) {

0 commit comments

Comments
 (0)