mirror of
https://github.com/wukko/cobalt.git
synced 2024-11-15 12:50:01 +00:00
web/updates: make changelogs look nicer
- fixes horizontal scrolling on mobile - removes text backdrop - improves readability
This commit is contained in:
parent
1ec9d92eb2
commit
6e374fde62
3 changed files with 86 additions and 79 deletions
|
@ -2,15 +2,17 @@
|
||||||
export let version: string;
|
export let version: string;
|
||||||
export let title: string;
|
export let title: string;
|
||||||
export let date: string;
|
export let date: string;
|
||||||
export let banner: { file: string, alt: string } | undefined;
|
export let banner: { file: string; alt: string } | undefined;
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<main>
|
<main>
|
||||||
<h1>
|
<div id="changelog-header">
|
||||||
<div class="changelog-version">{ version }</div>
|
<div class="changelog-info">
|
||||||
<div class="changelog-title">{ title }</div>
|
<div class="changelog-version">{version}</div>
|
||||||
</h1>
|
<div class="changelog-date">{date}</div>
|
||||||
<small>{ date }</small>
|
</div>
|
||||||
|
<h1 class="changelog-title">{title}</h1>
|
||||||
|
</div>
|
||||||
<div class="changelog-content">
|
<div class="changelog-content">
|
||||||
{#if banner}
|
{#if banner}
|
||||||
<img
|
<img
|
||||||
|
@ -27,53 +29,53 @@
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
main {
|
main {
|
||||||
padding: 1em;
|
overflow-x: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
img {
|
#changelog-header {
|
||||||
max-width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
h1 {
|
|
||||||
padding-top: 1em;
|
|
||||||
}
|
|
||||||
|
|
||||||
.contents :global(.text-backdrop) {
|
|
||||||
border-radius: 4px;
|
|
||||||
background-color: var(--button);
|
|
||||||
color: var(--background);
|
|
||||||
padding: 0.3rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.contents :global(.text-backdrop.link) {
|
|
||||||
text-decoration: underline;
|
|
||||||
}
|
|
||||||
|
|
||||||
h1 {
|
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: start;
|
align-items: start;
|
||||||
|
gap: calc(var(--padding) / 2);
|
||||||
|
padding: 1em 0; /* match default <p> padding */
|
||||||
}
|
}
|
||||||
|
|
||||||
h1 .changelog-version {
|
.changelog-info {
|
||||||
padding: .15rem .5rem;
|
display: flex;
|
||||||
border-radius: 4px;
|
flex-direction: row;
|
||||||
background-color: var(--button-hover);
|
align-items: center;
|
||||||
|
gap: 14px;
|
||||||
}
|
}
|
||||||
|
|
||||||
h1 .changelog-title {
|
.changelog-version {
|
||||||
padding: .15rem 0;
|
padding: 3px 8px;
|
||||||
text-align: left;
|
border-radius: 6px;
|
||||||
|
background-color: var(--secondary);
|
||||||
|
color: var(--primary);
|
||||||
|
font-size: 21px;
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
.changelog-date {
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 500;
|
||||||
|
color: var(--gray);
|
||||||
|
}
|
||||||
|
|
||||||
|
.changelog-title {
|
||||||
|
padding: 0;
|
||||||
|
line-height: 1.2;
|
||||||
}
|
}
|
||||||
|
|
||||||
.changelog-banner {
|
.changelog-banner {
|
||||||
padding: 2em;
|
|
||||||
width: 100%;
|
|
||||||
max-height: 300pt;
|
|
||||||
min-height: 210pt;
|
|
||||||
display: block;
|
display: block;
|
||||||
object-fit: cover;
|
object-fit: cover;
|
||||||
|
max-height: 320pt;
|
||||||
|
min-height: 210pt;
|
||||||
|
width: 100%;
|
||||||
|
max-width: 100;
|
||||||
aspect-ratio: 16/9;
|
aspect-ratio: 16/9;
|
||||||
|
border-radius: var(--padding);
|
||||||
}
|
}
|
||||||
|
|
||||||
.changelog-content {
|
.changelog-content {
|
||||||
|
@ -84,5 +86,7 @@
|
||||||
|
|
||||||
.contents {
|
.contents {
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
|
line-height: 1.5;
|
||||||
|
font-size: 15px;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
<!-- Workaround for https://github.com/pngwn/MDsveX/issues/116 -->
|
<!-- Workaround for https://github.com/pngwn/MDsveX/issues/116 -->
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import ChangelogEntry from "./ChangelogEntry.svelte";
|
import ChangelogEntry from "./ChangelogEntry.svelte";
|
||||||
export let version = '';
|
export let version = "";
|
||||||
export let title = '';
|
export let title = "";
|
||||||
export let date = '';
|
export let date = "";
|
||||||
export let banner = undefined;
|
export let banner = undefined;
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { t } from '$lib/i18n/translations';
|
import { t } from "$lib/i18n/translations";
|
||||||
import { page } from '$app/stores';
|
import { page } from "$app/stores";
|
||||||
|
|
||||||
import { getAllChangelogs } from '$lib/changelogs';
|
import { getAllChangelogs } from "$lib/changelogs";
|
||||||
import type { ChangelogImport } from '$lib/types/changelogs';
|
import type { ChangelogImport } from "$lib/types/changelogs";
|
||||||
|
|
||||||
import IconChevronLeft from '@tabler/icons-svelte/IconChevronLeft.svelte';
|
import IconChevronLeft from "@tabler/icons-svelte/IconChevronLeft.svelte";
|
||||||
import IconChevronRight from '@tabler/icons-svelte/IconChevronRight.svelte';
|
import IconChevronRight from "@tabler/icons-svelte/IconChevronRight.svelte";
|
||||||
|
|
||||||
const changelogs = getAllChangelogs();
|
const changelogs = getAllChangelogs();
|
||||||
const versions = Object.keys(changelogs);
|
const versions = Object.keys(changelogs);
|
||||||
|
|
||||||
let changelog: ChangelogImport & { version: string } | undefined;
|
let changelog: (ChangelogImport & { version: string }) | undefined;
|
||||||
let currentIndex = 0;
|
let currentIndex = 0;
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -24,38 +24,36 @@
|
||||||
|
|
||||||
const loadChangelog = async () => {
|
const loadChangelog = async () => {
|
||||||
const version = versions[currentIndex];
|
const version = versions[currentIndex];
|
||||||
const log = await changelogs[version]() as ChangelogImport;
|
const log = (await changelogs[version]()) as ChangelogImport;
|
||||||
if (!log) {
|
if (!log) {
|
||||||
return; // FIXME: now wot
|
return; // FIXME: now wot
|
||||||
}
|
}
|
||||||
|
|
||||||
changelog = {
|
changelog = {
|
||||||
...log,
|
...log,
|
||||||
version
|
version,
|
||||||
};
|
};
|
||||||
|
|
||||||
window.location.hash = version;
|
window.location.hash = version;
|
||||||
}
|
};
|
||||||
|
|
||||||
const loadNext = () => {
|
const loadNext = () => {
|
||||||
if (currentIndex < versions.length - 1)
|
if (currentIndex < versions.length - 1) ++currentIndex;
|
||||||
++currentIndex;
|
};
|
||||||
}
|
|
||||||
|
|
||||||
const loadPrev = () => {
|
const loadPrev = () => {
|
||||||
if (currentIndex > 0)
|
if (currentIndex > 0) --currentIndex;
|
||||||
--currentIndex;
|
};
|
||||||
}
|
|
||||||
|
|
||||||
const preloadNext = () => {
|
const preloadNext = () => {
|
||||||
if (!next) return;
|
if (!next) return;
|
||||||
changelogs[next]().catch(() => {});
|
changelogs[next]().catch(() => {});
|
||||||
}
|
};
|
||||||
|
|
||||||
const handleKeydown = (e: KeyboardEvent) => {
|
const handleKeydown = (e: KeyboardEvent) => {
|
||||||
if (e.key === 'ArrowLeft') loadPrev();
|
if (e.key === "ArrowLeft") loadPrev();
|
||||||
else if (e.key === 'ArrowRight') loadNext();
|
else if (e.key === "ArrowRight") loadNext();
|
||||||
}
|
};
|
||||||
|
|
||||||
$: prev = versions[currentIndex - 1];
|
$: prev = versions[currentIndex - 1];
|
||||||
$: next = versions[currentIndex + 1];
|
$: next = versions[currentIndex + 1];
|
||||||
|
@ -75,26 +73,29 @@
|
||||||
<div class="button-wrapper-desktop">
|
<div class="button-wrapper-desktop">
|
||||||
<button on:click={loadPrev} disabled={!prev}>
|
<button on:click={loadPrev} disabled={!prev}>
|
||||||
<IconChevronLeft />
|
<IconChevronLeft />
|
||||||
{ prev || '' }
|
{prev || ""}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="changelog-wrapper">
|
<div class="changelog-wrapper">
|
||||||
<svelte:component this={changelog.default} version={changelog.version} />
|
<svelte:component
|
||||||
<div class="button-wrapper-mobile">
|
this={changelog.default}
|
||||||
<button on:click={loadPrev} disabled={!prev}>
|
version={changelog.version}
|
||||||
<IconChevronLeft />
|
/>
|
||||||
{ prev || '' }
|
<div class="button-wrapper-mobile">
|
||||||
</button>
|
<button on:click={loadPrev} disabled={!prev}>
|
||||||
<button
|
<IconChevronLeft />
|
||||||
on:click={loadNext}
|
{prev || ""}
|
||||||
on:focus={preloadNext}
|
</button>
|
||||||
on:mousemove={preloadNext}
|
<button
|
||||||
disabled={!next}
|
on:click={loadNext}
|
||||||
>
|
on:focus={preloadNext}
|
||||||
{ next || '' }
|
on:mousemove={preloadNext}
|
||||||
|
disabled={!next}
|
||||||
|
>
|
||||||
|
{next || ""}
|
||||||
<IconChevronRight />
|
<IconChevronRight />
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="button-wrapper-desktop">
|
<div class="button-wrapper-desktop">
|
||||||
<button
|
<button
|
||||||
|
@ -103,7 +104,7 @@
|
||||||
on:mousemove={preloadNext}
|
on:mousemove={preloadNext}
|
||||||
disabled={!next}
|
disabled={!next}
|
||||||
>
|
>
|
||||||
{ next || '' }
|
{next || ""}
|
||||||
<IconChevronRight />
|
<IconChevronRight />
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
@ -132,7 +133,9 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.changelog-wrapper {
|
.changelog-wrapper {
|
||||||
max-width: 768pt;
|
max-width: 850px;
|
||||||
|
overflow-x: hidden;
|
||||||
|
padding: var(--padding);
|
||||||
}
|
}
|
||||||
|
|
||||||
button[disabled] {
|
button[disabled] {
|
||||||
|
@ -144,7 +147,7 @@
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
@media only screen and (max-width: 992pt) {
|
@media only screen and (max-width: 1150px) {
|
||||||
.button-wrapper-mobile {
|
.button-wrapper-mobile {
|
||||||
display: flex;
|
display: flex;
|
||||||
padding-bottom: 1rem;
|
padding-bottom: 1rem;
|
||||||
|
|
Loading…
Reference in a new issue