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

[frontend] Scroll to highlighted toot, improve highlight #885

Merged
merged 1 commit into from
Oct 3, 2022
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
2 changes: 1 addition & 1 deletion web/source/css/_colors.css
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ $button-danger-fg: $gray1;
$button-danger-hover-bg: $orange2;

$toot-focus-bg: $gray5;
$toot-unfocus-bg: $gray3;
$toot-unfocus-bg: $gray2;

$toot-info-bg: $gray4;

Expand Down
8 changes: 8 additions & 0 deletions web/source/frontend/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ const Photoswipe = require("photoswipe/dist/umd/photoswipe.umd.min.js");
const PhotoswipeLightbox = require("photoswipe/dist/umd/photoswipe-lightbox.umd.min.js");
const PhotoswipeCaptionPlugin = require("photoswipe-dynamic-caption-plugin").default;

let [_, _user, type, id] = window.location.pathname.split("/");
if (type == "statuses") {
let firstStatus = document.getElementsByClassName("thread")[0].children[0];
if (firstStatus.id != id) {
document.getElementById(id).scrollIntoView();
}
}

const lightbox = new PhotoswipeLightbox({
gallery: '.photoswipe-gallery',
children: 'a',
Expand Down
6 changes: 3 additions & 3 deletions web/template/thread.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
<main>
<div data-nosnippet class="thread">
{{range .context.Ancestors}}
<div class="toot">
<div class="toot" id="{{.ID}}">
{{ template "status.tmpl" .}}
</div>
{{end}}
<div class="toot expanded">
<div class="toot expanded" id="{{.status.ID}}">
{{ template "status.tmpl" .status}}
</div>
{{range .context.Descendants}}
<div class="toot">
<div class="toot" id="{{.ID}}">
{{ template "status.tmpl" .}}
</div>
{{end}}
Expand Down