mastodon-embed-timeline/examples/local-timeline-customized.html
2024-03-12 09:33:23 +00:00

241 lines
6.0 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Mastodon embed timeline</title>
<meta name="author" content="i.j" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="keywords" content="mastodon, embed timeline" />
<meta name="description" content="Mastodon embed timeline" />
<link rel="shortcut icon" href="#" />
<link rel="stylesheet" href="../dist/mastodon-timeline.min.css" />
<style>
* {
box-sizing: border-box;
}
html {
height: 100%;
}
body {
height: 100%;
background: lightgrey;
font-family: Arial, Helvetica, sans-serif;
font-size: 16px;
margin: 0;
}
.dummy-main-container {
display: flex;
flex-direction: row;
gap: 2rem;
height: 100%;
justify-content: center;
align-items: center;
padding: 1rem;
}
.dummy-wrapper-text,
.dummy-wrapper-timeline {
width: 50%;
max-width: 30rem;
height: calc(100% - 4rem);
padding: 0 1rem;
}
.dummy-wrapper-text h1,
.dummy-wrapper-text h2,
.dummy-wrapper-text p {
margin: 0 0 1rem 0;
}
.dummy-wrapper-text pre {
display: flex;
background: lightsteelblue;
border-left: 3px solid #563acc;
color: midnightblue;
page-break-inside: avoid;
font-family: monospace;
line-height: 1.5;
max-width: 100%;
overflow: auto;
word-wrap: break-word;
}
.dummy-wrapper-text hr {
margin: 2rem 0;
}
/* Example of customized CSS styles */
.mt-container {
font-family: monospace;
background-color: transparent;
border: 1px solid white;
}
.mt-container a,
.mt-container a:active,
.mt-container a:link {
color: darkgreen;
}
.mt-post-header {
margin-bottom: 0;
}
.mt-post-avatar-image-big img {
border-radius: 0;
}
.mt-post-header-user {
margin-right: auto;
}
.mt-post-header-date {
position: absolute;
bottom: 1rem;
left: 3.5rem;
}
.mt-post {
border-bottom: none;
box-shadow: 2px 2px 6px 2px rgba(0, 0, 0, 0.25);
margin-bottom: 1rem;
padding-bottom: 2rem;
}
.mt-post-txt,
.mt-post-media-wrapper {
width: calc(100% - 3rem);
margin-left: auto;
}
.mt-post-media,
.mt-post-media-spoiler > img,
.mt-post-media-spoiler > audio,
.mt-post-media > img,
.mt-post-media > video {
border-radius: 0;
}
</style>
</head>
<body>
<div class="dummy-main-container">
<!-- Title + Explained details of the example -->
<div class="dummy-wrapper-text">
<h1>🐘 Mastodon embed timeline</h1>
<h2>Local timeline (customized)</h2>
<p>
This example shows 10 posts from the following instance:
<br />
<a
href="https://mastodon.social/public/local"
target="_blank"
rel="nofollow noopener noreferrer"
>mastodon.social</a
>
</p>
<p>
Contains several CSS styles that change its appearance without the
need to modify the original CSS file:
</p>
<pre>
<code>
.mt-container {
font-family: monospace;
background-color: transparent;
border: 1px solid white;
}
.mt-container a,
.mt-container a:active,
.mt-container a:link {
color: darkgreen;
}
.mt-post-header {
margin-bottom: 0;
}
.mt-post-avatar-image-big img {
border-radius: 0;
}
.mt-post-header-user {
margin-right: auto;
}
.mt-post-header-date {
position: absolute;
bottom: 1rem;
left: 3.5rem;
}
.mt-post {
border-bottom: none;
box-shadow: 2px 2px 6px 2px rgba(0, 0, 0, 0.25);
margin-bottom: 1rem;
padding-bottom: 2rem;
}
.mt-post-txt,
.mt-post-media-wrapper {
width: calc(100% - 3rem);
margin-left: auto;
}
.mt-post-media,
.mt-post-media-spoiler > img,
.mt-post-media-spoiler > audio,
.mt-post-media > img,
.mt-post-media > video {
border-radius: 0;
}
</code>
</pre>
<p>
At JS level, it defaults to the light theme and the date is displayed
in US format using digits only. In order to achieve a minimalist
style, the following options have been changed at its initialization:
</p>
<pre>
<code>
&lt;script&gt;
const myTimeline = new MastodonTimeline.Init({
instanceUrl: "https://mastodon.online",
defaultTheme: "light",
dateLocale: "en-CA",
dateOptions: {
day: "2-digit",
month: "2-digit",
year: "numeric",
},
hideReplies: true,
hideUserAccount: true,
hidePreviewLink: true,
hideCounterBar: true,
txtMaxLines: "3",
disableCarousel: true,
btnSeeMore: "",
btnReload: ""
});
&lt;/script&gt;
</code>
</pre>
</div>
<div class="dummy-wrapper-timeline">
<!-- Mastodon Timeline -->
<div id="mt-container" class="mt-container">
<div class="mt-body" role="feed">
<div class="mt-loading-spinner"></div>
</div>
</div>
</div>
</div>
<!-- JavaScript -->
<script src="../dist/mastodon-timeline.umd.js"></script>
<script>
const myTimeline = new MastodonTimeline.Init({
instanceUrl: "https://mastodon.online",
defaultTheme: "light",
maxNbPostShow: "10",
dateLocale: "en-CA",
dateOptions: {
day: "2-digit",
month: "2-digit",
year: "numeric",
},
hideReplies: true,
hideUserAccount: true,
hidePreviewLink: true,
hideCounterBar: true,
txtMaxLines: "3",
disableCarousel: true,
btnSeeMore: "",
btnReload: "",
});
</script>
</body>
</html>