Improve open-with dropdown

This commit is contained in:
Râu Cao 2024-10-22 11:27:58 +02:00
parent 96254b38be
commit 4534147050
Signed by: raucao
GPG Key ID: 37036C356E56CC51
3 changed files with 55 additions and 14 deletions

View File

@ -1,7 +1,11 @@
@import url("/assets/css/fonts/merriweather.css"); @import url("/assets/css/fonts/merriweather.css");
html {
font-size: 16px;
}
body { body {
font-size: 18px; font-size: 1.125rem;
font-family: "Merriweather", serif; font-family: "Merriweather", serif;
} }
@ -10,14 +14,14 @@ img {
} }
img.avatar { img.avatar {
height: 48px; height: 3rem;
width: 48px; width: 3rem;
border-radius: 50%; border-radius: 50%;
} }
.profile-page img.avatar { .profile-page img.avatar {
height: 128px; height: 8rem;
width: 128px; width: 8rem;
} }
h1 { h1 {
@ -51,7 +55,7 @@ pre code {
main { main {
display: block; display: block;
max-width: 728px; max-width: 44rem;
margin: 12rem auto 24rem auto; margin: 12rem auto 24rem auto;
} }
@ -111,10 +115,11 @@ main article footer {
.dropdown-content { .dropdown-content {
display: none; display: none;
position: absolute; position: absolute;
min-width: 160px; min-width: 12rem;
border-radius: 5px; border-radius: 5px;
box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2); box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
z-index: 1; z-index: 1;
font-size: 1rem;
} }
.dropdown-content a { .dropdown-content a {
@ -123,6 +128,36 @@ main article footer {
display: block; display: block;
} }
.dropdown-content h4.title {
font-size: 0.875rem;
margin: 0;
padding: 0.6rem 1rem;
border-top: 1px solid;
}
.dropdown:hover .dropdown-content { .dropdown:hover .dropdown-content {
display: block; display: block;
} }
@media (max-width: 768px) {
html {
font-size: 14px;
}
main {
max-width: 100%;
margin: 4rem 1rem 8rem 1rem;
}
.dropdown-content {
bottom: 100%;
}
.dropdown-content a {
padding: 0.8rem 1.2rem;
}
.dropdown-content h4.title {
padding: 0.8rem 1.2rem;
}
}

View File

@ -53,6 +53,11 @@ main header .meta .name a {
background-color: #f1f1f1; background-color: #f1f1f1;
} }
.dropdown-content h4.title {
color: #888;
border-color: #f1f1f1;
}
.dropdown:hover .dropdown-button { .dropdown:hover .dropdown-button {
background-color: #fff; background-color: #fff;
border-color: #fff; border-color: #fff;

15
html.ts
View File

@ -98,26 +98,27 @@ export function profilePageHtml(profile: Profile, articles: Article[]): string {
} }
function openWithNostrAppHtml(bech32Id): string { function openWithNostrAppHtml(bech32Id): string {
let linksHtml = ""; let appLinksHtml = "";
const links = [ const appLinks = [
{ title: "Nostr Link", href: `nostr:${bech32Id}` },
{ title: "Habla", href: `https://habla.news/a/${bech32Id}` }, { title: "Habla", href: `https://habla.news/a/${bech32Id}` },
{ {
title: "noStrudel", title: "noStrudel",
href: `https://nostrudel.ninja/#/articles/${bech32Id}`, href: `https://nostrudel.ninja/#/articles/${bech32Id}`,
}, },
{ title: "Coracle", href: `https://coracle.social/${bech32Id}` } { title: "Coracle", href: `https://coracle.social/${bech32Id}` },
]; ];
for (const link of links) { for (const link of appLinks) {
linksHtml += `<a href="${link.href}" target="_blank">${link.title}</a>`; appLinksHtml += `<a href="${link.href}" target="_blank">${link.title}</a>`;
} }
return ` return `
<div class="open-with dropdown"> <div class="open-with dropdown">
<button class="dropdown-button">Open with Nostr app</button> <button class="dropdown-button">Open with Nostr app</button>
<div class="dropdown-content"> <div class="dropdown-content">
${linksHtml} <a href="nostr:${bech32Id}" target="_blank">🔗&nbsp; Nostr Link</a>
<h4 class="title">Apps</h4>
${appLinksHtml}
</div> </div>
</div> </div>
`; `;