Fix issue #90: Add a docs button
All checks were successful
Test / test (push) Successful in 2s
All checks were successful
Test / test (push) Successful in 2s
This commit is contained in:
@@ -35,6 +35,11 @@ function ExitCampaign() {
|
|||||||
<TopSearchBar></TopSearchBar>
|
<TopSearchBar></TopSearchBar>
|
||||||
</div>
|
</div>
|
||||||
<div class="right">
|
<div class="right">
|
||||||
|
<!-- La documentació és una pàgina a part (/docs), i una pestanya nova deixa la
|
||||||
|
campanya tal com era: les notes obertes no es perden. -->
|
||||||
|
<a class="btn-primary docs-button sound-click" href="/docs" target="_blank" rel="noopener noreferrer">
|
||||||
|
{{ $t('main-menu.documentation') }}
|
||||||
|
</a>
|
||||||
<button class="btn-primary settings-button sound-click" type="button" @click="OpenCampaignSettings">
|
<button class="btn-primary settings-button sound-click" type="button" @click="OpenCampaignSettings">
|
||||||
{{ $t('main-menu.settings') }}
|
{{ $t('main-menu.settings') }}
|
||||||
</button>
|
</button>
|
||||||
@@ -85,6 +90,29 @@ function ExitCampaign() {
|
|||||||
padding: 5px 10px;
|
padding: 5px 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* L'enllaç a la documentació és un `<a>` 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 {
|
.top-bar-title {
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|||||||
@@ -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 = /<div class="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 `<a>` 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) ---
|
// --- How the documentation is laid out (Syndria98/dragonroll#85) ---
|
||||||
|
|
||||||
// The `<style>` of DocsView.vue read as `{ selector, media, declarations }` rules: the block is
|
// The `<style>` of DocsView.vue read as `{ selector, media, declarations }` rules: the block is
|
||||||
|
|||||||
Reference in New Issue
Block a user