Skip to content

Commit

Permalink
perf: modify checkbox icon with Liquid
Browse files Browse the repository at this point in the history
Also optimize list padding start
  • Loading branch information
cotes2020 committed Oct 24, 2022
1 parent e48d66e commit 1fd665b
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 28 deletions.
12 changes: 8 additions & 4 deletions _includes/refactor-content.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,15 @@
%}
{% endif %}

<!-- Add attribute 'hide-bullet' to the checkbox list -->

{% if _content contains '<li class="task-list-item"><' %}
<!-- Change the icon of checkbox -->
{% if _content contains '<input type="checkbox"' %}
{% assign _content = _content
| replace: '"task-list-item"><', '"task-list-item" hide-bullet><'
| replace:
'<input type="checkbox" class="task-list-item-checkbox" disabled="disabled" checked="checked" />',
'<i class="fas fa-check-circle fa-fw checked"></i>'
| replace:
'<input type="checkbox" class="task-list-item-checkbox" disabled="disabled" />',
'<i class="far fa-circle fa-fw"></i>'
%}
{% endif %}

Expand Down
12 changes: 0 additions & 12 deletions _javascript/utils/checkbox.js

This file was deleted.

24 changes: 16 additions & 8 deletions _sass/addon/commons.scss
Original file line number Diff line number Diff line change
Expand Up @@ -468,31 +468,39 @@ img[data-src] {

li {
margin: 0.25rem 0;
padding-left: 0.4rem;
padding-left: 0.25rem;
}

ol,
ul {
-webkit-padding-start: 1.25rem;
padding-inline-start: 1.25rem;
-webkit-padding-start: 1rem;
padding-inline-start: 1rem;
margin: 0.5rem 0;
}
}

ul {
/* attribute 'hide-bullet' was added by liquid */
.task-list-item[hide-bullet] {
ul.task-list {
-webkit-padding-start: 1.25rem;
padding-inline-start: 1.25rem;

li {
list-style-type: none;
padding-left: 0;

> i { /* checkbox icon */
margin: 0 0.5rem 0.2rem -1.4rem;
vertical-align: middle;
width: 2rem;
margin-left: -1.25rem;
color: var(--checkbox-color);

&.checked {
color: var(--checkbox-checked-color);
}
}

ul {
-webkit-padding-start: 1.75rem;
padding-inline-start: 1.75rem;
}
}

input[type="checkbox"] {
Expand Down
2 changes: 1 addition & 1 deletion assets/js/dist/page.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 1fd665b

Please sign in to comment.