Skip to content

Commit 2b91775

Browse files
committed
Make checkmarks tab-able
1 parent 3ac0c2e commit 2b91775

12 files changed

+31
-25
lines changed

css/application.css

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

css/complete.css

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

css/story.css

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

includes/functions/_shortcodes.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -703,7 +703,7 @@ function fictioneer_shortcode_chapter_list( $attr ) {
703703

704704
<?php if ( $can_checkmarks && ! empty( $chapter_story_id ) && get_post_status( $chapter_story_id ) === 'publish' ) : ?>
705705
<div class="chapter-group__list-item-right">
706-
<label class="checkmark chapter-group__list-item-checkmark" data-type="chapter" data-story-id="<?php echo $chapter_story_id; ?>" data-id="<?php echo $post_id; ?>"><i class="fa-solid fa-check"></i></label>
706+
<button class="checkmark chapter-group__list-item-checkmark" data-type="chapter" data-story-id="<?php echo $chapter_story_id; ?>" data-id="<?php echo $post_id; ?>"><i class="fa-solid fa-check"></i></button>
707707
</div>
708708
<?php endif; ?>
709709
</li>

js/application.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/checkmarks.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

partials/_story-content.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@
310310

311311
<?php if ( get_option( 'fictioneer_enable_checkmarks' ) ) : ?>
312312
<div class="chapter-group__list-item-right">
313-
<label class="checkmark chapter-group__list-item-checkmark" data-type="chapter" data-story-id="<?php echo $story_id; ?>" data-id="<?php echo $chapter['id']; ?>"><i class="fa-solid fa-check"></i></label>
313+
<button class="checkmark chapter-group__list-item-checkmark" data-type="chapter" data-story-id="<?php echo $story_id; ?>" data-id="<?php echo $chapter['id']; ?>"><i class="fa-solid fa-check"></i></button>
314314
</div>
315315
<?php endif; ?>
316316

partials/_story-footer.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@
5252
<?php echo $story['rating']; ?>
5353
</span>
5454
<?php if ( $story['chapter_count'] > 0 ): ?>
55-
<label class="checkmark story__meta-checkmark" data-type="story" data-story-id="<?php echo $story_id; ?>" data-id="<?php echo $story_id; ?>" data-status="<?php echo esc_attr( $story['status'] ); ?>">
55+
<button class="checkmark story__meta-checkmark" data-type="story" data-story-id="<?php echo $story_id; ?>" data-id="<?php echo $story_id; ?>" data-status="<?php echo esc_attr( $story['status'] ); ?>">
5656
<i class="fa-solid fa-check"></i>
57-
</label>
57+
</button>
5858
<?php endif; ?>
5959
</div>
6060
</footer>

src/js/application.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1165,7 +1165,7 @@ _$$('[for*=group-toggle]').forEach(element => {
11651165
list = e.currentTarget.closest('.chapter-group').querySelector('.chapter-group__list');
11661166
list.style.height = '';
11671167

1168-
list.querySelectorAll('a').forEach(element => {
1168+
list.querySelectorAll('a, button').forEach(element => {
11691169
element.tabIndex = element.tabIndex == '-1' ? '0' : '-1';
11701170
});
11711171
}

src/js/checkmarks.js

+9-9
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ function fcn_initializeCheckmarks() {
2323
fcn_fetchCheckmarksFromDatabase();
2424

2525
// Listen for clicks on checkmarks
26-
_$$('label.checkmark').forEach(element => {
26+
_$$('button.checkmark').forEach(element => {
2727
element.addEventListener(
2828
'click',
2929
(e) => {
@@ -123,7 +123,7 @@ function fcn_toggleCheckmark(story, type, chapter = null, source = null, mode =
123123

124124
// Not complete anymore
125125
fcn_removeItemOnce(fcn_checkmarks.data[story], story);
126-
_$('label[data-type=story]')?.classList.remove('marked');
126+
_$('button[data-type=story]')?.classList.remove('marked');
127127
} else {
128128
// Add chapter checkmark to JSON
129129
fcn_checkmarks.data[story].push(chapter);
@@ -142,8 +142,8 @@ function fcn_toggleCheckmark(story, type, chapter = null, source = null, mode =
142142
fcn_checkmarks.data[story] = [];
143143

144144
if (!unsetAll) {
145-
// (Re-)add checkmarks to JSON based on labels
146-
_$$('label.checkmark').forEach(item => {
145+
// (Re-)add checkmarks to JSON based on buttons
146+
_$$('button.checkmark').forEach(item => {
147147
fcn_checkmarks.data[story].push(parseInt(item.dataset.id));
148148
});
149149

@@ -232,17 +232,17 @@ function fcn_updateCheckmarksView() {
232232
// Completed story?
233233
if (completed) {
234234
// Add all checkmarks (if missing)
235-
_$$('label.checkmark').forEach(item => {
235+
_$$('button.checkmark').forEach(item => {
236236
let checkId = parseInt(item.dataset.id);
237237
if (!fcn_checkmarks.data[storyId].includes(checkId)) fcn_checkmarks.data[storyId].push(checkId);
238238
});
239-
240-
// Add ribbon to thumbnail (if any)
241-
_$$$('ribbon-read')?.classList.toggle('hidden', !completed);
242239
}
243240

241+
// Add ribbon to thumbnail if complete and present
242+
_$$$('ribbon-read')?.classList.toggle('hidden', !completed);
243+
244244
// Update checkmarks on story pages
245-
_$$('label.checkmark')?.forEach(item => {
245+
_$$('button.checkmark')?.forEach(item => {
246246
let checkStoryId = parseInt(item.dataset.storyId);
247247
if (!fcn_checkmarks.data.hasOwnProperty(checkStoryId)) return;
248248
item.classList.toggle('marked', fcn_checkmarks.data[checkStoryId].includes(parseInt(item.dataset.id)));

src/scss/_story.scss

+9-6
Original file line numberDiff line numberDiff line change
@@ -283,8 +283,8 @@ $header_breakpoint: 640px;
283283
}
284284

285285
&__footer {
286-
padding-top: 1rem;
287-
padding-bottom: 2rem;
286+
padding-top: .75rem;
287+
padding-bottom: 1.75rem;
288288
}
289289

290290
&__meta {
@@ -295,15 +295,15 @@ $header_breakpoint: 640px;
295295
font-family: var(--font-note);
296296
font-size: var(--fs-ds); // 14px (desktop) to 13px (mobile)
297297
line-height: 1.75rem;
298-
padding-right: 8px;
298+
padding: .25rem 8px .25rem 0;
299299
white-space: nowrap;
300300

301301
> *:not(:first-child) {
302302
@include bp(640px) {
303303
margin-left: 1.5rem;
304304
}
305305

306-
&:not(label)::before {
306+
&:not(.checkmark)::before {
307307
content: unicode("2022");
308308
color: var(--fg-800);
309309
font-family: var(--font-base);
@@ -315,8 +315,8 @@ $header_breakpoint: 640px;
315315
}
316316
}
317317

318-
label {
319-
margin-left: 1.5rem;
318+
.checkmark {
319+
margin-left: 1.25rem;
320320
}
321321

322322
> span {
@@ -333,8 +333,11 @@ $header_breakpoint: 640px;
333333
}
334334

335335
.checkmark {
336+
--focus-offset: 2px;
336337
color: var(--fg-600);
337338
font-size: 18px;
339+
padding: 0 4px;
340+
margin-right: -4px;
338341

339342
&:not(.marked) {
340343
color: var(--checkmark-not-checked);

src/scss/common/_base.scss

+3
Original file line numberDiff line numberDiff line change
@@ -638,8 +638,11 @@ html:not(.logged-in) body:not(.logged-in) {
638638
}
639639

640640
.checkmark {
641+
--focus-offset: 2px;
641642
color: var(--fg-600);
642643
font-size: 18px;
644+
padding: 0 4px;
645+
margin-right: -4px;
643646

644647
&:not(.marked) {
645648
color: var(--checkmark-not-checked);

0 commit comments

Comments
 (0)