diff --git a/.eslintrc.js b/.eslintrc.js index a7617cc..f1b111a 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,11 +1,12 @@ module.exports = { env: { browser: true, - commonjs: true, + node: true, es2021: true, }, extends: 'eslint:recommended', parserOptions: { + sourceType: 'module', ecmaVersion: 'latest', }, ignorePatterns: ['dist', 'node_modules'], diff --git a/esbuild.mjs b/esbuild.mjs new file mode 100644 index 0000000..2c76bc2 --- /dev/null +++ b/esbuild.mjs @@ -0,0 +1,28 @@ +import * as esbuild from 'esbuild'; +import { config } from 'dotenv'; + +config(); + +const isProduction = process.env.NODE_ENV !== 'development'; + +const options = { + entryPoints: ['src/js/*.js'], + format: 'esm', + bundle: true, + splitting: true, + outdir: 'dist/js', + // run `npx browserslist` to find updated minimum versions to set here + target: ['chrome109', 'edge109', 'firefox109', 'safari15.5', 'opera94'], + sourcemap: isProduction ? false : 'inline', + minify: isProduction, + logLevel: 'info', +}; + +if (!isProduction) { + // watch for changes and rebuild during development + let context = await esbuild.context(options); + await context.watch(); +} else { + // build once and exit + await esbuild.build(options); +} diff --git a/package-lock.json b/package-lock.json index 7df0127..9ad8749 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,6 +13,7 @@ "@sindresorhus/slugify": "^1.1.2", "airtable": "^0.12.2", "dotenv": "^16.4.5", + "esbuild": "^0.20.1", "isomorphic-dompurify": "^2.4.0", "marked": "^12.0.0", "sass": "^1.71.1" @@ -446,6 +447,351 @@ "postcss-selector-parser": "^6.0.13" } }, + "node_modules/@esbuild/aix-ppc64": { + "version": "0.20.1", + "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.20.1.tgz", + "integrity": "sha512-m55cpeupQ2DbuRGQMMZDzbv9J9PgVelPjlcmM5kxHnrBdBx6REaEd7LamYV7Dm8N7rCyR/XwU6rVP8ploKtIkA==", + "cpu": [ + "ppc64" + ], + "optional": true, + "os": [ + "aix" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/android-arm": { + "version": "0.20.1", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.20.1.tgz", + "integrity": "sha512-4j0+G27/2ZXGWR5okcJi7pQYhmkVgb4D7UKwxcqrjhvp5TKWx3cUjgB1CGj1mfdmJBQ9VnUGgUhign+FPF2Zgw==", + "cpu": [ + "arm" + ], + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/android-arm64": { + "version": "0.20.1", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.20.1.tgz", + "integrity": "sha512-hCnXNF0HM6AjowP+Zou0ZJMWWa1VkD77BXe959zERgGJBBxB+sV+J9f/rcjeg2c5bsukD/n17RKWXGFCO5dD5A==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/android-x64": { + "version": "0.20.1", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.20.1.tgz", + "integrity": "sha512-MSfZMBoAsnhpS+2yMFYIQUPs8Z19ajwfuaSZx+tSl09xrHZCjbeXXMsUF/0oq7ojxYEpsSo4c0SfjxOYXRbpaA==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/darwin-arm64": { + "version": "0.20.1", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.20.1.tgz", + "integrity": "sha512-Ylk6rzgMD8klUklGPzS414UQLa5NPXZD5tf8JmQU8GQrj6BrFA/Ic9tb2zRe1kOZyCbGl+e8VMbDRazCEBqPvA==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/darwin-x64": { + "version": "0.20.1", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.20.1.tgz", + "integrity": "sha512-pFIfj7U2w5sMp52wTY1XVOdoxw+GDwy9FsK3OFz4BpMAjvZVs0dT1VXs8aQm22nhwoIWUmIRaE+4xow8xfIDZA==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/freebsd-arm64": { + "version": "0.20.1", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.20.1.tgz", + "integrity": "sha512-UyW1WZvHDuM4xDz0jWun4qtQFauNdXjXOtIy7SYdf7pbxSWWVlqhnR/T2TpX6LX5NI62spt0a3ldIIEkPM6RHw==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/freebsd-x64": { + "version": "0.20.1", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.20.1.tgz", + "integrity": "sha512-itPwCw5C+Jh/c624vcDd9kRCCZVpzpQn8dtwoYIt2TJF3S9xJLiRohnnNrKwREvcZYx0n8sCSbvGH349XkcQeg==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-arm": { + "version": "0.20.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.20.1.tgz", + "integrity": "sha512-LojC28v3+IhIbfQ+Vu4Ut5n3wKcgTu6POKIHN9Wpt0HnfgUGlBuyDDQR4jWZUZFyYLiz4RBBBmfU6sNfn6RhLw==", + "cpu": [ + "arm" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-arm64": { + "version": "0.20.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.20.1.tgz", + "integrity": "sha512-cX8WdlF6Cnvw/DO9/X7XLH2J6CkBnz7Twjpk56cshk9sjYVcuh4sXQBy5bmTwzBjNVZze2yaV1vtcJS04LbN8w==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-ia32": { + "version": "0.20.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.20.1.tgz", + "integrity": "sha512-4H/sQCy1mnnGkUt/xszaLlYJVTz3W9ep52xEefGtd6yXDQbz/5fZE5dFLUgsPdbUOQANcVUa5iO6g3nyy5BJiw==", + "cpu": [ + "ia32" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-loong64": { + "version": "0.20.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.20.1.tgz", + "integrity": "sha512-c0jgtB+sRHCciVXlyjDcWb2FUuzlGVRwGXgI+3WqKOIuoo8AmZAddzeOHeYLtD+dmtHw3B4Xo9wAUdjlfW5yYA==", + "cpu": [ + "loong64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-mips64el": { + "version": "0.20.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.20.1.tgz", + "integrity": "sha512-TgFyCfIxSujyuqdZKDZ3yTwWiGv+KnlOeXXitCQ+trDODJ+ZtGOzLkSWngynP0HZnTsDyBbPy7GWVXWaEl6lhA==", + "cpu": [ + "mips64el" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-ppc64": { + "version": "0.20.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.20.1.tgz", + "integrity": "sha512-b+yuD1IUeL+Y93PmFZDZFIElwbmFfIKLKlYI8M6tRyzE6u7oEP7onGk0vZRh8wfVGC2dZoy0EqX1V8qok4qHaw==", + "cpu": [ + "ppc64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-riscv64": { + "version": "0.20.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.20.1.tgz", + "integrity": "sha512-wpDlpE0oRKZwX+GfomcALcouqjjV8MIX8DyTrxfyCfXxoKQSDm45CZr9fanJ4F6ckD4yDEPT98SrjvLwIqUCgg==", + "cpu": [ + "riscv64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-s390x": { + "version": "0.20.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.20.1.tgz", + "integrity": "sha512-5BepC2Au80EohQ2dBpyTquqGCES7++p7G+7lXe1bAIvMdXm4YYcEfZtQrP4gaoZ96Wv1Ute61CEHFU7h4FMueQ==", + "cpu": [ + "s390x" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-x64": { + "version": "0.20.1", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.20.1.tgz", + "integrity": "sha512-5gRPk7pKuaIB+tmH+yKd2aQTRpqlf1E4f/mC+tawIm/CGJemZcHZpp2ic8oD83nKgUPMEd0fNanrnFljiruuyA==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/netbsd-x64": { + "version": "0.20.1", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.20.1.tgz", + "integrity": "sha512-4fL68JdrLV2nVW2AaWZBv3XEm3Ae3NZn/7qy2KGAt3dexAgSVT+Hc97JKSZnqezgMlv9x6KV0ZkZY7UO5cNLCg==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/openbsd-x64": { + "version": "0.20.1", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.20.1.tgz", + "integrity": "sha512-GhRuXlvRE+twf2ES+8REbeCb/zeikNqwD3+6S5y5/x+DYbAQUNl0HNBs4RQJqrechS4v4MruEr8ZtAin/hK5iw==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/sunos-x64": { + "version": "0.20.1", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.20.1.tgz", + "integrity": "sha512-ZnWEyCM0G1Ex6JtsygvC3KUUrlDXqOihw8RicRuQAzw+c4f1D66YlPNNV3rkjVW90zXVsHwZYWbJh3v+oQFM9Q==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/win32-arm64": { + "version": "0.20.1", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.20.1.tgz", + "integrity": "sha512-QZ6gXue0vVQY2Oon9WyLFCdSuYbXSoxaZrPuJ4c20j6ICedfsDilNPYfHLlMH7vGfU5DQR0czHLmJvH4Nzis/A==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/win32-ia32": { + "version": "0.20.1", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.20.1.tgz", + "integrity": "sha512-HzcJa1NcSWTAU0MJIxOho8JftNp9YALui3o+Ny7hCh0v5f90nprly1U3Sj1Ldj/CvKKdvvFsCRvDkpsEMp4DNw==", + "cpu": [ + "ia32" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/win32-x64": { + "version": "0.20.1", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.20.1.tgz", + "integrity": "sha512-0MBh53o6XtI6ctDnRMeQ+xoCN8kD2qI1rY1KgF/xdWQwoFeKou7puvDfV8/Wv4Ctx2rRpET/gGdz3YlNtNACSA==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=12" + } + }, "node_modules/@eslint-community/eslint-utils": { "version": "4.4.0", "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz", @@ -1482,6 +1828,43 @@ "node": ">= 0.4" } }, + "node_modules/esbuild": { + "version": "0.20.1", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.20.1.tgz", + "integrity": "sha512-OJwEgrpWm/PCMsLVWXKqvcjme3bHNpOgN7Tb6cQnR5n0TPbQx1/Xrn7rqM+wn17bYeT6MGB5sn1Bh5YiGi70nA==", + "hasInstallScript": true, + "bin": { + "esbuild": "bin/esbuild" + }, + "engines": { + "node": ">=12" + }, + "optionalDependencies": { + "@esbuild/aix-ppc64": "0.20.1", + "@esbuild/android-arm": "0.20.1", + "@esbuild/android-arm64": "0.20.1", + "@esbuild/android-x64": "0.20.1", + "@esbuild/darwin-arm64": "0.20.1", + "@esbuild/darwin-x64": "0.20.1", + "@esbuild/freebsd-arm64": "0.20.1", + "@esbuild/freebsd-x64": "0.20.1", + "@esbuild/linux-arm": "0.20.1", + "@esbuild/linux-arm64": "0.20.1", + "@esbuild/linux-ia32": "0.20.1", + "@esbuild/linux-loong64": "0.20.1", + "@esbuild/linux-mips64el": "0.20.1", + "@esbuild/linux-ppc64": "0.20.1", + "@esbuild/linux-riscv64": "0.20.1", + "@esbuild/linux-s390x": "0.20.1", + "@esbuild/linux-x64": "0.20.1", + "@esbuild/netbsd-x64": "0.20.1", + "@esbuild/openbsd-x64": "0.20.1", + "@esbuild/sunos-x64": "0.20.1", + "@esbuild/win32-arm64": "0.20.1", + "@esbuild/win32-ia32": "0.20.1", + "@esbuild/win32-x64": "0.20.1" + } + }, "node_modules/escape-html": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", diff --git a/package.json b/package.json index 5945222..424e408 100644 --- a/package.json +++ b/package.json @@ -10,11 +10,15 @@ }, "scripts": { "prestart": "rm -rf dist", - "start": "npm run eleventy:watch & npm run sass:watch", - "build": "eleventy && npm run sass", - "eleventy:watch": "eleventy --serve --incremental", - "sass": "sass ./src/css/styles.scss:./dist/styles.css --no-source-map", - "sass:watch": "sass ./src/css/styles.scss:./dist/styles.css --watch", + "prebuild": "rm -rf dist", + "start": "npm run eleventy:dev & npm run sass:dev & npm run js:dev", + "build": "npm run eleventy:build && npm run sass:build && npm run js:build", + "eleventy:build": "eleventy", + "eleventy:dev": "eleventy --serve --incremental", + "sass:build": "sass ./src/css/styles.scss:./dist/styles.css --style=compressed --no-source-map", + "sass:dev": "sass ./src/css/styles.scss:./dist/styles.css --watch", + "js:build": "NODE_ENV=production node esbuild.mjs", + "js:dev": "NODE_ENV=development node esbuild.mjs", "lint": "npm run lint:css && npm run lint:js", "lint:css": "stylelint \"src/**/*.{css,scss,sass}\" --color --formatter verbose", "lint:js": "DEBUG=eslint:cli-engine eslint .", @@ -32,8 +36,14 @@ "@sindresorhus/slugify": "^1.1.2", "airtable": "^0.12.2", "dotenv": "^16.4.5", + "esbuild": "^0.20.1", "isomorphic-dompurify": "^2.4.0", "marked": "^12.0.0", "sass": "^1.71.1" - } + }, + "browserslist": [ + ">0.5%", + "last 10 versions", + "Firefox ESR" + ] } diff --git a/pages/all/flash-cards/index.njk b/pages/all/flash-cards/index.njk index 4cfcfe9..b8a8fa9 100644 --- a/pages/all/flash-cards/index.njk +++ b/pages/all/flash-cards/index.njk @@ -51,7 +51,5 @@ eleventyExcludeFromCollections: true {% endblock %} {% block scripts %} - + {% endblock %} diff --git a/pages/all/multiple-choice/index.njk b/pages/all/multiple-choice/index.njk index 9c34dba..3ee94cd 100644 --- a/pages/all/multiple-choice/index.njk +++ b/pages/all/multiple-choice/index.njk @@ -51,8 +51,5 @@ eleventyExcludeFromCollections: true {% endblock %} {% block scripts %} - + {% endblock %} diff --git a/pages/all/short-answer/index.njk b/pages/all/short-answer/index.njk index 0d0c572..b7b0281 100644 --- a/pages/all/short-answer/index.njk +++ b/pages/all/short-answer/index.njk @@ -51,8 +51,5 @@ eleventyExcludeFromCollections: true {% endblock %} {% block scripts %} - + {% endblock %} diff --git a/pages/flash-cards/index.njk b/pages/flash-cards/index.njk index 242b178..3d1a522 100644 --- a/pages/flash-cards/index.njk +++ b/pages/flash-cards/index.njk @@ -49,7 +49,5 @@ eleventyExcludeFromCollections: true {% endblock %} {% block scripts %} - + {% endblock %} diff --git a/pages/index.njk b/pages/index.njk index d363074..269842d 100644 --- a/pages/index.njk +++ b/pages/index.njk @@ -36,7 +36,5 @@ description: A quiz game and study tool to help those at all skill levels to lea {% endblock %} {% block scripts %} - + {% endblock %} diff --git a/pages/multiple-choice/index.njk b/pages/multiple-choice/index.njk index b006cd1..1dd179f 100644 --- a/pages/multiple-choice/index.njk +++ b/pages/multiple-choice/index.njk @@ -51,8 +51,5 @@ eleventyExcludeFromCollections: true {% endblock %} {% block scripts %} - + {% endblock %} diff --git a/pages/questions.ejs b/pages/questions.ejs index 1a03ca5..a5869b8 100644 --- a/pages/questions.ejs +++ b/pages/questions.ejs @@ -2,5 +2,4 @@ permalink: /questions.json eleventyExcludeFromCollections: true --- - <%- JSON.stringify(questionData.questions) -%> diff --git a/pages/short-answer/index.njk b/pages/short-answer/index.njk index 287ea85..574837c 100644 --- a/pages/short-answer/index.njk +++ b/pages/short-answer/index.njk @@ -50,8 +50,5 @@ eleventyExcludeFromCollections: true {% endblock %} {% block scripts %} - + {% endblock %} diff --git a/src/js/flash-cards.js b/src/js/flash-cards.js new file mode 100644 index 0000000..3940984 --- /dev/null +++ b/src/js/flash-cards.js @@ -0,0 +1,3 @@ +import { updatePaginationLinks } from './helpers/update-pagination-links'; + +updatePaginationLinks(); diff --git a/src/js/game-selection.js b/src/js/game-selection.js new file mode 100644 index 0000000..976731f --- /dev/null +++ b/src/js/game-selection.js @@ -0,0 +1,3 @@ +import { interceptCategoryNavigation } from './helpers/intercept-category-navigation'; + +interceptCategoryNavigation(); diff --git a/src/js/helpers/get-questions.js b/src/js/helpers/get-questions.js new file mode 100644 index 0000000..ccb85aa --- /dev/null +++ b/src/js/helpers/get-questions.js @@ -0,0 +1,20 @@ +export const getQuestions = async () => { + const response = await fetch('/questions.json'); + const questions = await response.json(); + + return questions; +}; + +export const getRelevantQuestions = (questions, category, isMultipleChoice) => { + return questions.filter((question) => { + if (!isMultipleChoice && question['Multiple Choice Only']) { + return false; + } + + if (category !== 'All' && !question.Tags.some((tag) => tag === category)) { + return false; + } + + return true; + }); +}; diff --git a/src/js/intercept-category-navigation.js b/src/js/helpers/intercept-category-navigation.js similarity index 63% rename from src/js/intercept-category-navigation.js rename to src/js/helpers/intercept-category-navigation.js index e401cd1..288c624 100644 --- a/src/js/intercept-category-navigation.js +++ b/src/js/helpers/intercept-category-navigation.js @@ -1,25 +1,6 @@ -const getQuestions = async () => { - const response = await fetch('/questions.json'); - const questions = await response.json(); +import { getQuestions, getRelevantQuestions } from './get-questions'; - return questions; -}; - -const getRelevantQuestions = (questions, category, isMultipleChoice) => { - return questions.filter((question) => { - if (!isMultipleChoice && question['Multiple Choice Only']) { - return false; - } - - if (category !== 'All' && !question.Tags.some((tag) => tag === category)) { - return false; - } - - return true; - }); -}; - -(async () => { +export const interceptCategoryNavigation = async () => { sessionStorage.removeItem('questions'); sessionStorage.removeItem('questionStatus'); const questions = await getQuestions(); @@ -47,4 +28,4 @@ const getRelevantQuestions = (questions, category, isMultipleChoice) => { window.location.href = questionOrder[0]; }); }); -})(); +}; diff --git a/src/js/helpers/multiple-choice-options.js b/src/js/helpers/multiple-choice-options.js new file mode 100644 index 0000000..6a14377 --- /dev/null +++ b/src/js/helpers/multiple-choice-options.js @@ -0,0 +1,38 @@ +const getOptionButtons = () => { + return document.querySelectorAll('.js-multiple-choice'); +}; + +const handleOptionButtonClick = (event) => { + const isPressed = event.target.getAttribute('aria-pressed') === 'true'; + const isCorrect = event.target.dataset.correct === 'true'; + + const optionButtons = getOptionButtons(); + const explanation = document.querySelector('.js-explanation'); + const explanationSection = document.querySelector('.js-explanation-section'); + + if (!explanation || !explanationSection) { + return; + } + + const explanationContent = explanation.innerHTML; + + optionButtons.forEach((button) => { + button.setAttribute('aria-pressed', 'false'); + }); + + event.target.setAttribute('aria-pressed', isPressed ? 'false' : 'true'); + explanationSection.innerHTML = `