Skip to content

Draft: Flyout: Build status indicator #446

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

Draft
wants to merge 1 commit 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
23 changes: 23 additions & 0 deletions src/flyout.css
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,36 @@ header > span svg.icon {
vertical-align: middle;
}

header > span.build-status {
width: var(
--readthedocs-flyout-header-font-size,
calc(var(--addons-flyout-font-size) * 1.125)
);
}

header > img.logo {
text-align: center;
max-width: 106px;
max-height: 22px;
margin-right: 10px;
}

.build-status-gray {
color: gray;
}

.build-status-green {
color: green;
}

.build-status-red {
color: red;
}

.build-status-yellow {
color: yellow;
}

main {
padding: 5px;
padding-bottom: 15px;
Expand Down
27 changes: 25 additions & 2 deletions src/flyout.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ import { ajv } from "./data-validation";
import READTHEDOCS_LOGO_WORDMARK from "./images/logo-wordmark-light.svg";
import READTHEDOCS_LOGO from "./images/logo-light.svg";
import { library, icon } from "@fortawesome/fontawesome-svg-core";
import { faCodeBranch, faLanguage } from "@fortawesome/free-solid-svg-icons";
import {
faCodeBranch,
faLanguage,
faCircle,
} from "@fortawesome/free-solid-svg-icons";
import { html, nothing, render, LitElement } from "lit";
import { classMap } from "lit/directives/class-map.js";
import { default as objectPath } from "object-path";
Expand Down Expand Up @@ -70,12 +74,31 @@ export class FlyoutElement extends LitElement {
renderHeader() {
library.add(faCodeBranch);
library.add(faLanguage);
library.add(faCircle);
const iconCodeBranch = icon(faCodeBranch, {
classes: ["icon"],
});
const iconLanguage = icon(faLanguage, {
classes: ["icon"],
});

let buildStatus = nothing;
const buildState = this.config.builds.current.state.code;
const buildSuccess = this.config.builds.current.success;
let buildStatusClass = "build-status-gray";
if (buildState === "finished" && buildSuccess) {
buildStatusClass = "build-status-green";
} else if (buildState === "finished" && !buildSuccess) {
buildStatusClass = "build-status-red";
} else {
buildStatusClass = "build-status-yellow";
}
buildStatus = html`<span
class="build-status ${buildStatusClass}"
title="State: ${buildState}. Success: ${buildSuccess}"
>${icon(faCircle).node[0]}</span
>`;

let version = nothing;
if (
this.config.projects.current.versioning_scheme !==
Expand All @@ -97,7 +120,7 @@ export class FlyoutElement extends LitElement {
return html`
<header @click="${this._toggleOpen}">
<img class="logo" src="${this.readthedocsLogo}" alt="Read the Docs" />
${translation} ${version}
${translation} ${version} ${buildStatus}
</header>
`;
}
Expand Down