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

Fix #1259: add anchors to groups of checks #1293

Merged
merged 1 commit into from
Aug 17, 2023
Merged
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
13 changes: 13 additions & 0 deletions telescope/html/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,19 @@ section.project:not(:first-child) {
border-top: 1px solid rgba(0, 40, 100, 0.12);
}

section.project h3 a {
text-decoration: none;
color: var(--foreground);
}

section.project h3 a i {
display: none;
}

section.project h3 a:hover i {
display: inline-block;
}

.project-cards {
display: grid;
grid-gap: 0.5rem 0rem;
Expand Down
20 changes: 15 additions & 5 deletions telescope/html/js/app/components/Dashboard.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import TagListFilter from "./TagListFilter.mjs";
export default class Dashboard extends Component {
constructor() {
super();
this.firstLoad = true;
this.triggerRecheck = this.triggerRecheck.bind(this);
this.fetchCheckResult = this.fetchCheckResult.bind(this);
this.setFocusedCheck = this.setFocusedCheck.bind(this);
Expand Down Expand Up @@ -64,8 +65,6 @@ export default class Dashboard extends Component {
});
// Watch history to focus check.
window.addEventListener("hashchange", this.onHashChange);
// Check if page has state on load.
this.onHashChange();
}

componentWillUnmount() {
Expand All @@ -78,20 +77,31 @@ export default class Dashboard extends Component {

componentDidUpdate() {
this.updateFavicon();
// Check if page has state on first load (after render)
if (this.firstLoad) {
this.onHashChange();
this.firstLoad = false;
}
}

onHashChange() {
const [project, name] = window.location.hash.slice(1).split("/");
// Highlight check in page.
if (project && name) {
const hash = window.location.hash;
// Highlight check in page?
if (hash.includes("/")) {
const [project, name] = hash.slice(1).split("/")
this.setState({
focusedCheck: {
project,
name,
},
});
}
// Scroll to check?
if (hash.startsWith("#project-")) {
document.querySelector(hash).scrollIntoView();
}
}

updateFavicon() {
const { results } = this.state;

Expand Down
7 changes: 6 additions & 1 deletion telescope/html/js/app/components/Project.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,17 @@ export default class Project extends Component {
}

render({ name }) {
const slug = name.toLowerCase().replace(" ", "-");
return html`
<section class="project mt-3 pt-4">
<div class="float-right mt-1 lh-1">${this.renderStatus()}</div>
<h3 class="mb-4">
<i class="fa fa-layer-group mr-2"></i>
<span class="project-name">${name}</span>
<a href="#project-${slug}" id="project-${slug}">
<span class="project-name">${name}</span>
${" "}
<i class="fa fa-link"></i>
</a>
</h3>
<div class="project-cards mb-1">${this.renderChecks()}</div>
</section>
Expand Down
Loading