Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add solutions and instructions to accessible crossword page #27483

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
@(crosswordPage: crosswords.AccessibleCrosswordPage)(implicit request: RequestHeader, context: model.ApplicationContext)

@import views.html.fragments.crosswords._
@import model.GUDateTimeFormatNew

<div class="l-side-margins">
<article id="crossword" class="content content--article tonal tonal--tone-news" role="main">
@crosswordMetaHeader(crosswordPage, false)

<div class="content__main tonal__main tonal__main--tone-news">
<div class="gs-container">
<div class="js-content-main-column">
<div class="js-content-main-column content__main-column">
<section>
<h2>Puzzle description</h2>
<p>Note: We've recently added solutions to this page below.</p>
<p>This page provides a text-only description of the puzzle, via three lists. 'Blanks' specifies the location of cells which aren't in any clue. 'Across' and 'Down' list the clues in the format: "(starting square) clue text (answer length)".</p>
<p>Cells are specified via row number (top to bottom) and column letter (left to right)</p>
<div class="crossword__container crossword__container--accessible">
<div class="crossword__accessible-row-data-wrapper">
<div class="crossword__accessible-data">
Expand All @@ -28,6 +34,61 @@ <h3 class="crossword__clues-header">Down</h3>
</div>
</div>
</div>
</section>
<section>
<h2>Solutions</h2>
@if(crosswordPage.crossword.solutionAvailable) {
<div class="crossword__accessible-solutions-disclosure" data-component="crossword-solutions-disclosure">
<button data-component="crossword-solutions-disclosure-trigger" aria-expanded="false" aria-controls="solution-panel" class="button button--medium button--primary button--show-more collection__show-more modern-visible">
<svg width="12" height="8" aria-hidden="true" viewBox="-2 -2 14 12">
<g fill="none" transform="rotate(-90 6 4)">
<path fill="currentColor" d="M1.41.59l4.59 4.58 4.59-4.58 1.41 1.41-6 6-6-6z" />
<path d="M-6-8h24v24h-24z" />
</g>
</svg>
<span data-component="crossword-solutions-disclosure-trigger-label">Reveal solutions</span>
</button>
<div data-component="crossword-solutions-disclosure-panel" hidden>
<h3 class="crossword__clues-header">Across solutions</h3>
<table aria-label="Across solutions">
<thead>
<tr>
<th>Starting position</th>
<th>Clue</th>
<th>Solution</th>
</tr>
</thead>
@for(entry <- crosswordPage.crossword.acrossEntries) {
<tr>
<td>@entry.startPosition</td><td>@Html(entry.clue)</td><td>@Html(entry.solution)</td>
</tr>
}
</table>
<h3 class="crossword__clues-header">Down solutions</h3>
<table aria-label="Down solutions">
<thead>
<tr>
<th>Starting position</th>
<th>Clue</th>
<th>Solution</th>
</tr>
</thead>
@for(entry <- crosswordPage.crossword.downEntries) {
<tr>
<td>@entry.startPosition</td><td>@Html(entry.clue)</td><td>@Html(entry.solution)</td>
</tr>
}
</table>

</div>
</div>
} else {
<p>
Sorry, solutions are not available for this puzzle yet.
@crosswordPage.crossword.dateSolutionAvailable.map(solutionDate => s" They should be available from ${GUDateTimeFormatNew.formatDateForDisplay(solutionDate, request)}.")
</p>
}
</section>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,6 @@ <h1 itemprop="headline" class="content__headline js-score">@Html(crosswordPage.i
</div>
}

<div class="hide-from-leftcol crossword__clues-header">
<a href="https://app.adjust.com/16xt6hai" data-link-name="crossword-mobile-link">Download the Guardian app</a> for a better puzzles experience
</div>

<div class="hide-until-leftcol crossword__clues-header">
<a href="https://app.adjust.com/16xt6hai" data-link-name="crossword-desktop-link">Download the Guardian app</a> for a better puzzles experience
</div>

<div class="meta__extras meta__extras--crossword">
<div class="meta__social" data-component="share">
@fragments.social(crosswordPage.item.sharelinks.pageShares, "top")
Expand Down
2 changes: 2 additions & 0 deletions static/src/javascripts/bootstraps/enhanced/crosswords.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { initCrosswords } from 'common/modules/crosswords/main';
import { initCrosswordDiscussion } from 'common/modules/crosswords/comments';
import { initSeries } from 'common/modules/crosswords/series';
import {initAccessibleCrosswordSolutionsDisclosure} from "common/modules/crosswords/accessible-crossword-solutions";

export const init = () => {
initCrosswords();
initCrosswordDiscussion();
initAccessibleCrosswordSolutionsDisclosure()
initSeries();
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
export const initAccessibleCrosswordSolutionsDisclosure = () => {
var disclosureComponent = document.querySelector('[data-component="crossword-solutions-disclosure"]');
var trigger = disclosureComponent.querySelector('[data-component="crossword-solutions-disclosure-trigger"]');
var panel = disclosureComponent.querySelector('[data-component="crossword-solutions-disclosure-panel"]');
var label = trigger.querySelector('[data-component="crossword-solutions-disclosure-trigger-label"]');


trigger.addEventListener('click', function() {
var wasAlreadyExpanded = trigger.getAttribute('aria-expanded') === 'true';
trigger.setAttribute('aria-expanded', !wasAlreadyExpanded);
label.textContent = wasAlreadyExpanded ? 'Reveal solutions' : 'Hide solutions'
panel.hidden = wasAlreadyExpanded;
});
}
17 changes: 17 additions & 0 deletions static/src/stylesheets/module/crosswords/_accessible.scss
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,20 @@
border-bottom: 1px dotted $brightness-86;
padding-bottom: $gs-baseline * .75;
}

.crossword__accessible-solutions-disclosure {
padding-bottom: 1rem;

& h3 {
margin-top: 1rem;
}
}

.crossword__accessible-solutions-disclosure > button[aria-expanded="true"] > svg {
transform: rotate(90deg);
}

.button--show-more:focus {
outline: 5px solid #0077B6;
outline-offset: 3px;
}