blog visitor frontend (pretty much) done!

This commit is contained in:
ari melody 2025-06-24 01:32:30 +01:00
parent 3d64333b4f
commit faf6095d16
Signed by: ari
GPG key ID: CF99829C92678188
16 changed files with 903 additions and 463 deletions

View file

@ -1,28 +1,15 @@
document.addEventListener('readystatechange', () => {
document.querySelectorAll('.comment-hover').forEach((/** @type {HTMLDivElement} */ comment) => {
/** @type {HTMLLinkElement} */
const commentBody = comment.querySelector('a.comment-body');
import { hijackClickEvent } from "./main.js";
comment.querySelectorAll('a').forEach((/** @type {HTMLLinkElement} */ element) => {
element.addEventListener('click', event => {
event.stopPropagation();
});
});
comment.addEventListener('click', () => {
commentBody.click();
});
comment.style.cursor = 'pointer';
comment.role = 'link';
});
document.getElementById('blog-copy-link').addEventListener('click', event => {
event.preventDefault();
if (navigator.clipboard === undefined) {
console.error("clipboard is not supported by this browser!");
return;
}
navigator.clipboard.writeText(location.protocol + "//" + location.host + location.pathname);
});
document.querySelectorAll('article.blog-post').forEach(element => {
const link = element.querySelector('.blog-title a');
hijackClickEvent(element, link);
});
document.querySelectorAll('article.blog-post').forEach(element => {
const link = element.querySelector('.blog-title a');
hijackClickEvent(element, link);
});
document.getElementById('load-more').addEventListener('click', event => {
event.preventDefault();
alert('ok');
});

16
public/script/blogpost.js Normal file
View file

@ -0,0 +1,16 @@
import { hijackClickEvent } from "./main.js";
document.querySelectorAll('.comment-hover').forEach((/** @type {HTMLDivElement} */ comment) => {
/** @type {HTMLLinkElement} */
const commentDate = comment.querySelector('.comment-date');
hijackClickEvent(comment, commentDate);
});
document.getElementById('blog-copy-link').addEventListener('click', event => {
event.preventDefault();
if (navigator.clipboard === undefined) {
console.error("clipboard is not supported by this browser!");
return;
}
navigator.clipboard.writeText(location.protocol + "//" + location.host + location.pathname);
});

View file

@ -1,249 +1,70 @@
:root {
--like: rgb(223, 104, 104);
--repost: rgb(162, 223, 73);
--bluesky: rgb(16, 131, 254);
--mastodon: rgb(86, 58, 204);
}
main {
width: min(calc(100% - 4rem), 1200px);
margin: 0 auto 1rem auto;
}
#blog-sidebar {
position: fixed;
width: 3em;
padding: 3em;
transform: translate(-9em, -1em);
overflow: clip;
opacity: .5;
transition: opacity .2s;
}
#blog-sidebar:hover {
opacity: 1;
}
#blog-sidebar ul {
margin: 0;
padding: .3em;
list-style: none;
display: flex;
flex-direction: column;
gap: .3em;
article.blog-post {
margin-bottom: 1rem;
padding: 1.5rem;
border: 1px solid #8882;
border-radius: 4px;
border: 1px solid var(--on-background);
box-shadow: 4px 4px 4px #0001;
}
#blog-sidebar a {
width: 35px;
height: 35px;
display: block;
padding: .2em;
border-radius: 2px;
background-color: #ffffff08;
transition: background-color .1s;
text-decoration: none;
}
#blog-sidebar a:hover {
background: #0001;
}
#blog-sidebar a:active {
background: #0002;
cursor: pointer;
}
#blog-sidebar a img {
display: block;
width: 100%;
height: 100%;
object-fit: contain;
.blog-post h2:hover,
.blog-post p:hover {
background: none;
}
#blog-sidebar span {
width: 100%;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
font-size: 1.5em;
.blog-title {
margin: 0;
}
.blog-title a {
display: inherit;
text-wrap: nowrap;
text-overflow: ellipsis;
overflow: hidden;
}
.blog p:hover,
.comment p:hover {
background: inherit;
.blog-meta {
margin: 0;
}
article.blog {
font-family: 'Lora', serif;
font-size: 24px;
.blog-author {
margin: 0;
font-size: .8em;
}
.blog-author img {
width: 1.3em;
height: 1.3em;
display: inline-block;
transform: translate(0, 4px);
border-radius: 4px;
}
.blog-date {
margin-top: -1em;
opacity: .75;
}
.blog p {
line-height: 1.5em;
}
.blog sub {
opacity: .75;
}
.blog pre {
max-height: 15em;
padding: .5em;
font-size: .9em;
border: 1px solid #8884;
border-radius: 2px;
overflow: scroll;
background: var(--background-alt);
}
.blog p code {
padding: .2em .3em;
font-size: .9em;
border: 1px solid #8884;
border-radius: 2px;
background: var(--background-alt);
}
.blog img {
max-height: 50%;
max-width: 100%;
display: block;
}
.blog i.end-mark {
width: 1.2em;
height: 1.2em;
margin-top: -.2em;
display: inline-block;
transform: translateY(.2em);
background: url("/img/aridoodle.png");
background-size: contain;
background-repeat: no-repeat;
background-position: center;
}
/* COMMENTS */
#interactions {
margin: 1em 0;
display: flex;
flex-direction: row;
gap: .5em;
flex-wrap: wrap;
}
.btn {
display: inline-block;
padding: .4em .6em;
border: 1px solid var(--on-background);
border-radius: 2px;
color: inherit;
text-decoration: none;
font-weight: 600;
}
#interactions .likes,
#interactions .reposts {
padding: 0 .5em;
min-width: fit-content;
font-family: monospace;
text-align: center;
line-height: 2em;
border: 1px solid var(--on-background);
border-radius: 2px;
text-wrap: nowrap;
}
#interactions .likes {
border-color: var(--on-background);
}
#interactions .reposts {
border-color: var(--on-background);
}
.comment-callout {
padding-bottom: 1em;
text-align: center;
border-radius: 2px;
border-bottom: 1px solid #8884;
}
.bluesky {
color: var(--bluesky);
}
.mastodon {
color: var(--mastodon);
}
.comment {
font-family: 'Inter', 'Arial', sans-serif;
font-size: 1em;
}
.comment .comment-hover {
padding: 1em;
transition: background-color .1s;
}
.comment .comment-hover:hover {
background-color: #8881;
}
.comment .comment-header a {
display: flex;
gap: .5em;
font-weight: 600;
color: var(--primary);
text-decoration: none;
align-items: center;
overflow: hidden;
text-overflow: ellipsis;
}
.comment .comment-header a .display-name {
overflow: inherit;
text-overflow: inherit;
}
.comment .comment-header a .handle {
opacity: .5;
font-family: monospace;
font-size: .9em;
overflow: inherit;
text-overflow: inherit;
}
.comment .comment-header img.avatar {
width: 1.5em;
height: 1.5em;
}
.comment .comment-body {
color: inherit;
text-decoration: none;
}
.comment p.comment-text {
margin: .5em 0;
white-space: break-spaces;
}
.comment .comment-footer {
margin: 0;
font-size: .8em;
opacity: .5;
opacity: .75;
}
.comment .comment-replies {
margin-left: 1em;
border-left: 2px solid #8884;
.blog-description {
margin: .5em 0 0 0;
display: -webkit-box;
font-size: .8em;
-webkit-line-clamp: 3;
-webkit-box-orient: vertical;
overflow: hidden;
}
#load-more {
margin: 0 auto;
padding: .5em 2em;
display: block;
font-family: inherit;
font-size: inherit;
}
@media screen and (max-width: 1500px) {
#blog-sidebar {
display: none;
}
}

314
public/style/blogpost.css Normal file
View file

@ -0,0 +1,314 @@
:root {
--like: rgb(223, 104, 104);
--boost: rgb(162, 223, 73);
--bluesky: rgb(16, 131, 254);
--mastodon: rgb(86, 58, 204);
}
main {
width: min(calc(100% - 4rem), 1200px);
margin: 0 auto 1rem auto;
}
#blog-sidebar {
position: fixed;
width: 3em;
padding: 3em;
transform: translate(-9em, -1em);
overflow: clip;
opacity: .5;
transition: opacity .2s;
}
#blog-sidebar:hover {
opacity: 1;
}
#blog-sidebar ul {
margin: 0;
padding: .3em;
list-style: none;
display: flex;
flex-direction: column;
gap: .3em;
border-radius: 4px;
border: 1px solid var(--on-background);
box-shadow: 4px 4px 4px #0001;
}
#blog-sidebar a {
width: 35px;
height: 35px;
display: block;
padding: .2em;
border-radius: 2px;
text-decoration: none;
}
#blog-sidebar a:hover {
background: #0001;
}
#blog-sidebar a:active {
background: #0002;
}
#blog-sidebar a img {
display: block;
width: 100%;
height: 100%;
object-fit: contain;
}
#blog-sidebar span {
width: 100%;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
font-size: 1.5em;
}
#blog-sidebar hr {
margin: 0;
}
.blog p:hover,
.comment p:hover {
background: inherit;
}
article.blog {
font-size: 22px;
}
.blog h1 {
margin-bottom: 0;
font-size: 1.8em;
}
.blog-author {
margin: .2em 0;
}
.blog .blog-author img {
width: 1.3em;
height: 1.3em;
display: inline-block;
transform: translate(0, 6px);
border-radius: 4px;
}
.blog-date {
margin: .5em 0;
font-size: .7em;
}
.blog-modified-date {
font-style: italic;
opacity: .75;
}
#blog-content {
font-family: 'Lora', serif;
}
.blog p {
line-height: 1.5em;
}
.blog sub {
opacity: .75;
}
.blog pre {
max-height: 15em;
padding: .5em;
font-size: .9em;
border: 1px solid #8884;
border-radius: 2px;
overflow: scroll;
background: var(--background-alt);
}
.blog p code {
padding: .2em .3em;
font-size: .9em;
border: 1px solid #8884;
border-radius: 2px;
background: var(--background-alt);
}
.blog img {
max-height: 50%;
max-width: 100%;
display: block;
}
.blog i.end-mark {
width: 1.2em;
height: 1.2em;
margin-top: -.2em;
display: inline-block;
transform: translateY(.2em);
background: url("/img/aridoodle.png");
background-size: contain;
background-repeat: no-repeat;
background-position: center;
}
/* COMMENTS */
#interactions {
margin: 1em 0;
display: flex;
flex-direction: row;
gap: .5em;
flex-wrap: wrap;
align-items: center;
}
.btn {
display: inline-block;
padding: .4em .6em;
border: 1px solid var(--on-background);
border-radius: 2px;
color: inherit;
text-decoration: none;
font-weight: 600;
}
#interactions button {
min-width: fit-content;
padding: 0 .75em 0 .5em;
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
gap: .5em;
font-family: monospace;
font-size: inherit;
text-align: center;
line-height: 2em;
text-wrap: nowrap;
color: inherit;
background: none;
border: 1px solid var(--on-background);
border-radius: 4px;
}
#interactions button:hover {
background: #0001;
}
#interactions button:active {
background: #0002;
}
#interactions img {
width: 1.5em;
height: 1.5em;
display: inline-block;
}
.comment-callout {
margin: 0 0 0 1em;
}
.comment-callout:hover {
background: none;
}
.bluesky {
color: var(--bluesky);
}
.mastodon {
color: var(--mastodon);
}
.comment {
font-family: 'Inter', 'Arial', sans-serif;
font-size: 1em;
}
.comment .comment-hover {
padding: 1em;
transition: background-color .1s;
cursor: pointer;
}
.comment .comment-hover:hover {
background-color: #8881;
}
.comment .comment-header a {
display: flex;
gap: .5em;
font-weight: 600;
color: var(--primary);
text-decoration: none;
align-items: center;
overflow: hidden;
text-overflow: ellipsis;
}
.comment .comment-header a .display-name {
overflow: inherit;
text-overflow: inherit;
}
.comment .comment-header a .handle {
opacity: .5;
font-family: monospace;
font-size: .9em;
overflow: inherit;
text-overflow: inherit;
}
.comment .comment-header img.avatar {
width: 1.5em;
height: 1.5em;
border-radius: 4px;
}
.comment .comment-body {
color: inherit;
text-decoration: none;
}
.comment p.comment-text {
margin: .5em 0;
white-space: break-spaces;
}
.comment .comment-footer {
margin: 0;
font-size: .8em;
}
.comment .comment-footer .comment-footer-static {
opacity: .5;
}
.comment .comment-replies {
margin-left: 1em;
border-left: 2px solid #8884;
}
.comment .comment-date {
transition: opacity .2s;
}
@media screen and (prefers-color-scheme: dark) {
#blog-sidebar a:hover {
background: #fff2;
}
#blog-sidebar a:active {
background: #fff4;
}
.comment-date {
opacity: .5;
}
}

View file

@ -38,7 +38,7 @@ a:hover {
text-decoration: underline;
}
a.link-button {
.link-button {
padding: .3em .5em;
border: 1px solid var(--links);
color: var(--links);
@ -51,7 +51,7 @@ a.link-button {
opacity: 0;
}
a.link-button:hover {
.link-button:hover {
color: #eee;
border-color: #eee;
background-color: var(--links) !important;