diff --git a/frontend/app/components/viewer/TopBar.vue b/frontend/app/components/viewer/TopBar.vue index 2d4cba90..083acca4 100644 --- a/frontend/app/components/viewer/TopBar.vue +++ b/frontend/app/components/viewer/TopBar.vue @@ -35,6 +35,11 @@ function ExitCampaign() {
+ + + {{ $t('main-menu.documentation') }} + @@ -85,6 +90,29 @@ function ExitCampaign() { padding: 5px 10px; } +/* L'enllaç a la documentació és un `` i els botons estan estilats per element, així + que li toca portar el mateix look que els dos que té al costat. */ +.docs-button { + padding: 5px 10px; + margin: 5px 0; + font-size: 15px; + border-radius: 6px; + border: solid 1px var(--color-border); + background-color: var(--color-button-background); + color: var(--color-text); + text-align: center; + text-decoration: none; + transition: 300ms background-color; +} + +.docs-button:hover { + background-color: var(--color-button-hover); +} + +.docs-button:active { + background-color: var(--color-button-active); +} + .top-bar-title { padding: 10px; display: flex; diff --git a/tests/docs.test.js b/tests/docs.test.js index 587f08a8..d78d5b53 100644 --- a/tests/docs.test.js +++ b/tests/docs.test.js @@ -327,6 +327,43 @@ test("the main menu points at the documentation", () => { } }); +// Inside a campaign the documentation is reached from the top bar, on the left of the campaign +// settings button (Syndria98/dragonroll#90). +test("the campaign top bar points at the documentation", () => { + const topBar = readRepoFile("frontend", "app", "components", "viewer", "TopBar.vue"); + const right = /
([\s\S]*?)<\/div>/.exec(topBar)?.[1]; + assert.ok(right, "expected the top bar to have its buttons in a right-hand group"); + + assert.match(right, /href="\/docs"/, "the top bar has to link to /docs"); + assert.match(right, /main-menu\.documentation/, "under the same label the main menu uses"); + + // To the left of the settings button: the group is read left to right, so the link has to + // come first in it. + const docsAt = right.indexOf('href="/docs"'); + const settingsAt = right.indexOf("OpenCampaignSettings"); + assert.ok( + docsAt !== -1 && settingsAt !== -1 && docsAt < settingsAt, + "the documentation button sits on the left of the settings button" + ); + + // /docs is another page, and the open notes of the campaign live only in memory, so the link + // opens it somewhere that does not throw the campaign away. + assert.match(right, /target="_blank"/, "the campaign stays as it was behind the documentation"); + assert.match(right, /rel="[^"]*noopener/, "a tab the app does not control must not be able to reach it"); + + // The link is an `` and the buttons are styled by element, so it carries its own look, in + // theme colours like everything else. + const look = /\.docs-button\s*\{[^}]*\}/.exec(topBar)?.[0]; + assert.ok(look, "the documentation link has to look like the buttons next to it"); + for (const declaration of [ + "background-color: var\\(--color-button-background\\)", + "color: var\\(--color-text\\)", + "border: solid 1px var\\(--color-border\\)", + ]) { + assert.match(look, new RegExp(declaration), "the link's look uses the theme's colours"); + } +}); + // --- How the documentation is laid out (Syndria98/dragonroll#85) --- // The `