Add theme switching button

Co-authored-by: Brandon Oxendine <brandon.oxendine@gmail.com>
Signed-off-by: Brandon Oxendine <brandon.oxendine@gmail.com>
Signed-off-by: Rūdolfs Ošiņš <rudolfs@osins.org>
This commit is contained in:
Rūdolfs Ošiņš
2022-09-15 12:45:56 +02:00
co-authored by Brandon Oxendine
parent 7a39306622
commit b35d46752f
56 changed files with 703 additions and 290 deletions
+8 -8
View File
@@ -31,7 +31,7 @@
padding: 0 0.5rem 0 1rem;
color: var(--color-foreground);
border-width: 1px 1px 0 1px;
border-color: var(--color-foreground-subtle);
border-color: var(--color-foreground-3);
border-style: solid;
border-top-left-radius: var(--border-radius-small);
border-top-right-radius: var(--border-radius-small);
@@ -48,7 +48,7 @@
.last-commit {
padding: 0.5rem;
color: var(--color-secondary);
background-color: var(--color-secondary-background);
background-color: var(--color-secondary-2);
font-size: var(--font-size-tiny);
border-radius: var(--border-radius-small);
overflow-x: hidden;
@@ -62,7 +62,7 @@
}
.line-numbers {
color: var(--color-foreground-subtle);
color: var(--color-foreground-4);
font-family: var(--font-family-sans-serif);
text-align: right;
user-select: none;
@@ -73,7 +73,7 @@
}
.line-number:hover,
.line-number.highlighted {
color: var(--color-foreground-90);
color: var(--color-foreground-6);
}
.code {
@@ -84,7 +84,7 @@
.container {
position: relative;
display: flex;
border: 1px solid var(--color-foreground-subtle);
border: 1px solid var(--color-foreground-3);
border-top-style: dashed;
border-bottom-left-radius: var(--border-radius-small);
border-bottom-right-radius: var(--border-radius-small);
@@ -97,8 +97,8 @@
align-items: center;
width: 100%;
height: 16rem;
background-color: var(--color-foreground-background);
color: var(--color-foreground-90);
background-color: var(--color-foreground-1);
color: var(--color-foreground-6);
font-family: var(--font-family-monospace);
}
.binary > * {
@@ -110,7 +110,7 @@
width: 100%;
height: 1.5rem;
top: 1rem;
background-color: var(--color-yellow-background-lighter);
background-color: var(--color-caution-3);
}
.no-scrollbar {
+4 -4
View File
@@ -42,7 +42,7 @@
cursor: pointer;
padding: 0.5rem 0.75rem;
color: var(--color-secondary);
background-color: var(--color-secondary-background);
background-color: var(--color-secondary-2);
border-radius: var(--border-radius-small) 0 0 var(--border-radius-small);
user-select: none;
}
@@ -50,12 +50,12 @@
cursor: not-allowed;
}
.branch:hover:not(.not-allowed) {
background-color: var(--color-foreground-background-lighter);
background-color: var(--color-foreground-2);
}
.commit .hash {
display: inline-block;
color: var(--color-secondary);
background-color: var(--color-secondary-background-darker);
background-color: var(--color-secondary-1);
padding: 0.5rem 0.75rem;
border-radius: 0 var(--border-radius-small) var(--border-radius-small) 0;
}
@@ -65,7 +65,7 @@
.stat {
font-family: var(--font-family-monospace);
padding: 0.5rem 0.75rem;
background: var(--color-foreground-background);
background: var(--color-foreground-1);
}
</style>
+29 -9
View File
@@ -1,10 +1,13 @@
<script lang="ts">
import type { Readable } from "svelte/store";
import type * as proj from "@app/project";
import type { Theme } from "@app/ThemeToggle.svelte";
import Loading from "@app/Loading.svelte";
import Placeholder from "@app/Placeholder.svelte";
import * as utils from "@app/utils";
import Button from "@app/Button.svelte";
import { theme } from "@app/ThemeToggle.svelte";
import Tree from "./Tree.svelte";
import Blob from "./Blob.svelte";
@@ -17,7 +20,7 @@
type State =
| { status: Status.Loading; path: string }
| { status: Status.Loaded; path: string; blob: proj.Blob };
| { status: Status.Loaded; path: string; blob: proj.Blob; theme: Theme };
export let project: proj.Project;
export let tree: proj.Tree;
@@ -33,8 +36,12 @@
// Whether the mobile file tree is visible.
let mobileFileTree = false;
const loadBlob = async (path: string): Promise<proj.Blob> => {
if (state.status === Status.Loaded && state.path === path) {
const loadBlob = async (path: string, theme: Theme): Promise<proj.Blob> => {
if (
state.status === Status.Loaded &&
state.path === path &&
state.theme === theme
) {
return state.blob;
}
@@ -42,10 +49,16 @@
const promise =
path === "/"
? project.getReadme(commit)
: project.getBlob(commit, path, { highlight: !isMarkdownPath });
: project.getBlob(
commit,
path,
isMarkdownPath
? { highlight: false }
: { highlight: true, theme: `base16-ocean.${theme}` },
);
state = { status: Status.Loading, path };
state = { status: Status.Loaded, path, blob: await promise };
state = { status: Status.Loaded, path, blob: await promise, theme };
return state.blob;
};
@@ -56,11 +69,11 @@
return project.getBlob(commit, finalPath, { highlight: false });
};
const onSelect = async ({ detail: newPath }: { detail: string }) => {
const onSelect = async (newPath: string, theme: Theme) => {
// Ensure we don't spend any time in a "loading" state. This means
// the loading spinner won't be shown, and instead the blob will be
// displayed once loaded.
const blob = await loadBlob(newPath);
const blob = await loadBlob(newPath, theme);
getBlob = new Promise(resolve => resolve(blob));
// Close mobile tree if user navigates to other file
@@ -79,7 +92,7 @@
mobileFileTree = !mobileFileTree;
};
$: getBlob = loadBlob(path);
$: getBlob = loadBlob(path, $theme);
$: loadingPath = state.status === Status.Loading ? state.path : null;
</script>
@@ -171,7 +184,14 @@
{#if tree.entries.length > 0}
<div class="column-left" class:column-left-visible={mobileFileTree}>
<div class="source-tree">
<Tree {tree} {path} {fetchTree} {loadingPath} on:select={onSelect} />
<Tree
{tree}
{path}
{fetchTree}
{loadingPath}
on:select={e => {
onSelect(e.detail, $theme);
}} />
</div>
</div>
<div class="column-right">
+8 -12
View File
@@ -9,9 +9,9 @@
<style>
.clone-button {
background-color: var(--color-yellow-background);
background-color: var(--color-caution-2);
border-radius: var(--border-radius-small);
color: var(--color-yellow);
color: var(--color-caution-6);
cursor: pointer;
font-family: var(--font-family-monospace);
min-width: max-content;
@@ -19,12 +19,12 @@
user-select: none;
}
.clone-button:hover {
background-color: var(--color-foreground-background-lighter);
background-color: var(--color-caution-3);
}
.dropdown {
background-color: var(--color-foreground-background);
background-color: var(--color-foreground-1);
border-radius: var(--border-radius-small);
box-shadow: 16px 16px 32px 32px var(--color-shadow);
box-shadow: var(--elevation-low);
margin-top: 0.5rem;
padding: 1rem;
position: absolute;
@@ -40,7 +40,7 @@
}
}
label {
color: var(--color-foreground-faded);
color: var(--color-foreground-6);
display: block;
font-size: var(--font-size-tiny);
padding: 0.5rem 0.5rem 0 0.25rem;
@@ -53,9 +53,7 @@
<div class="dropdown">
<Input
name="rad-clone-url"
value="rad clone rad://{seedHost}/{utils.parseRadicleId(urn)}"
class="yellow"
clipboard />
value="rad clone rad://{seedHost}/{utils.parseRadicleId(urn)}" />
<label for="rad-clone-url">
Use the <a
target="_blank"
@@ -68,9 +66,7 @@
<br />
<Input
name="git-clone-url"
value="https://{seedHost}/{utils.parseRadicleId(urn)}.git"
class="yellow"
clipboard />
value="https://{seedHost}/{utils.parseRadicleId(urn)}.git" />
<label for="git-clone-url">
Use Git to clone this repository from the URL above.
</label>
+2 -2
View File
@@ -25,7 +25,7 @@
}
header {
padding: 1rem;
background: var(--color-foreground-background-subtle);
background: var(--color-foreground-1);
border-radius: var(--border-radius);
margin-bottom: 1.5rem;
}
@@ -39,7 +39,7 @@
margin: 0.5rem 0 1rem 0;
}
.sha1 {
color: var(--color-foreground-80);
color: var(--color-foreground-5);
font-size: var(--font-size-small);
}
.authorship {
@@ -11,7 +11,7 @@
.authorship {
display: flex;
align-items: center;
color: var(--color-foreground-faded);
color: var(--color-foreground-5);
padding: 0.125rem 0;
}
.authorship .author,
+2 -2
View File
@@ -23,11 +23,11 @@
padding: 0 1.5rem;
}
.commit-teaser {
background-color: var(--color-foreground-background);
background-color: var(--color-foreground-1);
padding: 0.75rem 0rem;
}
.commit-teaser:hover {
background-color: var(--color-foreground-background-lighter);
background-color: var(--color-foreground-2);
}
.commit-teaser:first-child {
border-top-left-radius: var(--border-radius-small);
@@ -24,9 +24,9 @@
position: absolute;
}
.popup {
background-color: var(--color-foreground-background);
background-color: var(--color-foreground-1);
border-radius: var(--border-radius-small);
box-shadow: 16px 16px 32px 32px var(--color-shadow);
box-shadow: var(--elevation-low);
color: var(--color-foreground);
font-size: var(--font-size-tiny);
left: -10rem;
@@ -45,12 +45,13 @@
color: var(--color-tertiary);
}
.committer {
border-top: 1px dashed var(--color-foreground-subtle);
border-top: 1px dashed var(--color-foreground-4);
padding: 0.75rem;
}
.peer {
padding-top: 0.5rem;
word-break: break-all;
color: var(--color-foreground-5);
}
</style>
@@ -75,7 +76,7 @@
<CommitAuthorship {commit} showAuthor={false} showTime={false} />
{#if commit.context.committer}
<div class="peer">
<span class="faded">{commit.context.committer.peer.id}</span>
{commit.context.committer.peer.id}
</div>
{/if}
</div>
+4 -4
View File
@@ -56,23 +56,23 @@
cursor: pointer;
}
.clickable:hover {
background-color: var(--color-foreground-background-lighter);
background-color: var(--color-foreground-2);
}
.not-allowed {
cursor: not-allowed;
}
.not-allowed.widget {
color: var(--color-foreground-faded);
color: var(--color-foreground-5);
}
.stat {
font-family: var(--font-family-monospace);
padding: 0.5rem 0.75rem;
height: 2.125rem;
background: var(--color-foreground-background);
background: var(--color-foreground-1);
}
.stat.active {
color: var(--color-background);
background: var(--color-foreground-90);
background: var(--color-foreground);
}
@media (max-width: 960px) {
+3 -3
View File
@@ -44,20 +44,20 @@
font-size: var(--font-size-small);
}
.commit-group header {
color: var(--color-foreground-faded);
color: var(--color-foreground-6);
}
.commit-group-headers {
margin-bottom: 2rem;
}
.commit {
background-color: var(--color-foreground-background);
background-color: var(--color-foreground-1);
}
.commit:not(:last-child) {
border-bottom: 1px dashed var(--color-background);
}
.commit:hover {
background-color: var(--color-foreground-background-lighter);
background-color: var(--color-foreground-2);
cursor: pointer;
}
.commit:first-child {
+8 -7
View File
@@ -22,7 +22,7 @@
<style>
header {
padding: 1rem;
background: var(--color-foreground-background-subtle);
background: var(--color-foreground-1);
border-radius: var(--border-radius);
margin-bottom: 2rem;
}
@@ -44,23 +44,23 @@
}
.metadata-section {
margin-bottom: 1rem;
border-bottom: 1px dashed var(--color-foreground-subtle);
border-bottom: 1px dashed var(--color-foreground-4);
}
.metadata-section-header {
font-size: var(--font-size-small);
margin-bottom: 0.75rem;
color: var(--color-foreground-faded);
color: var(--color-foreground-5);
}
.metadata-section-body {
margin-bottom: 1.25rem;
}
.metadata-section-empty {
color: var(--color-foreground-90);
color: var(--color-foreground-6);
}
.label {
border-radius: var(--border-radius);
color: var(--color-tertiary);
background-color: var(--color-tertiary-background);
background-color: var(--color-tertiary-2);
padding: 0.25rem 0.75rem;
margin-right: 0.5rem;
font-size: var(--font-size-small);
@@ -84,7 +84,7 @@
.id {
font-size: var(--font-size-tiny);
margin-left: 0.75rem;
color: var(--color-foreground-faded);
color: var(--color-foreground-5);
}
.summary-state {
padding: 0.5rem 1rem;
@@ -92,9 +92,10 @@
}
.open {
color: var(--color-positive);
background-color: var(--color-positive-background);
background-color: var(--color-positive-2);
}
.closed {
color: var(--color-negative);
background-color: var(--color-negative-2);
}
.replies {
+5 -5
View File
@@ -30,15 +30,15 @@
display: flex;
align-items: center;
justify-content: space-between;
background-color: var(--color-foreground-background);
background-color: var(--color-foreground-1);
padding: 0.75rem 0;
}
.issue-teaser:hover {
background-color: var(--color-foreground-background-lighter);
background-color: var(--color-foreground-2);
cursor: pointer;
}
.issue-id {
color: var(--color-foreground-faded);
color: var(--color-foreground-5);
font-size: var(--font-size-tiny);
font-family: var(--font-family-monospace);
margin-left: 0.5rem;
@@ -55,7 +55,7 @@
flex-basis: 5rem;
}
.comment-count {
color: var(--color-foreground-70);
color: var(--color-foreground-4);
font-weight: var(--font-weight-bold);
}
.comment-count .emoji {
@@ -74,7 +74,7 @@
background-color: var(--color-positive);
}
.closed {
background-color: var(--color-negative-2);
background-color: var(--color-negative);
}
.summary {
display: flex;
+8 -7
View File
@@ -42,7 +42,7 @@
<style>
header {
padding: 1rem;
background: var(--color-foreground-background-subtle);
background: var(--color-foreground-1);
border-radius: var(--border-radius);
}
.patch {
@@ -65,22 +65,23 @@
}
.id {
font-size: var(--font-size-tiny);
color: var(--color-foreground-faded);
color: var(--color-foreground-5);
}
.summary-state {
padding: 0.5rem 1rem;
border-radius: 1.25rem;
}
.proposed {
color: var(--color-positive);
background-color: var(--color-positive-background);
color: var(--color-positive-6);
background-color: var(--color-positive-1);
}
.draft {
color: var(--color-positive);
background-color: var(--color-positive-background);
color: var(--color-positive-6);
background-color: var(--color-positive-1);
}
.archived {
background-color: var(--color-negative-2);
color: var(--color-negative-6);
background-color: var(--color-negative-1);
}
.flex {
display: flex;
+4 -4
View File
@@ -14,23 +14,23 @@
}
.metadata-section {
margin-bottom: 1rem;
border-bottom: 1px dashed var(--color-foreground-subtle);
border-bottom: 1px dashed var(--color-foreground-4);
}
.metadata-section-header {
font-size: var(--font-size-small);
margin-bottom: 0.75rem;
color: var(--color-foreground-faded);
color: var(--color-foreground-5);
}
.metadata-section-body {
margin-bottom: 1.25rem;
}
.metadata-section-empty {
color: var(--color-foreground-90);
color: var(--color-foreground-6);
}
.label {
border-radius: var(--border-radius);
color: var(--color-tertiary);
background-color: var(--color-tertiary-background);
background-color: var(--color-tertiary-2);
padding: 0.25rem 0.75rem;
margin-right: 0.5rem;
font-size: var(--font-size-small);
+3 -3
View File
@@ -55,7 +55,7 @@
.revision-toggle {
border-radius: var(--border-radius-small);
border: none;
color: var(--color-foreground-80);
color: var(--color-foreground-6);
font-family: var(--font-family-monospace);
font-size: var(--font-size-tiny);
height: var(--button-tiny-height);
@@ -63,12 +63,12 @@
background-color: var(--color-background);
}
.revision-toggle:hover {
background-color: var(--color-foreground-background);
background-color: var(--color-foreground-1);
color: var(--color-foreground);
cursor: pointer;
}
.revision-toggle:disabled {
color: var(--color-foreground-faded);
color: var(--color-foreground-5);
}
</style>
+5 -5
View File
@@ -30,15 +30,15 @@
display: flex;
align-items: center;
justify-content: space-between;
background-color: var(--color-foreground-background);
background-color: var(--color-foreground-1);
padding: 0.75rem 0;
}
.patch-teaser:hover {
background-color: var(--color-foreground-background-lighter);
background-color: var(--color-foreground-2);
cursor: pointer;
}
.patch-id {
color: var(--color-foreground-faded);
color: var(--color-foreground-5);
font-size: var(--font-size-tiny);
font-family: var(--font-family-monospace);
margin-left: 0.5rem;
@@ -55,7 +55,7 @@
flex-basis: 5rem;
}
.comment-count {
color: var(--color-foreground-70);
color: var(--color-foreground-4);
font-weight: var(--font-weight-bold);
}
.comment-count .emoji {
@@ -74,7 +74,7 @@
background-color: var(--color-positive);
}
.closed {
background-color: var(--color-negative-2);
background-color: var(--color-negative);
}
.summary {
display: flex;
+3 -3
View File
@@ -62,7 +62,7 @@
cursor: pointer;
padding: 0.5rem;
color: var(--color-secondary);
background-color: var(--color-secondary-background);
background-color: var(--color-secondary-2);
border-radius: var(--border-radius-small);
user-select: none;
}
@@ -73,7 +73,7 @@
margin: 0 0.5rem;
}
.peer:hover {
background-color: var(--color-foreground-background-lighter);
background-color: var(--color-foreground-2);
}
.stat {
display: flex;
@@ -81,7 +81,7 @@
font-family: var(--font-family-monospace);
padding: 0.5rem;
height: 2.125rem;
background: var(--color-foreground-background);
background: var(--color-foreground-1);
}
</style>
+3 -3
View File
@@ -30,12 +30,12 @@
margin-bottom: 0.5rem;
}
.title .divider {
color: var(--color-foreground-subtle);
color: var(--color-foreground-4);
margin: 0 0.5rem;
font-weight: var(--font-weight-normal);
}
.title .peer-id {
color: var(--color-foreground-subtle);
color: var(--color-foreground-5);
font-weight: var(--font-weight-normal);
display: flex;
align-items: center;
@@ -48,7 +48,7 @@
.urn {
font-family: var(--font-family-monospace);
font-size: var(--font-size-tiny);
color: var(--color-foreground-faded);
color: var(--color-foreground-5);
overflow-wrap: anywhere;
display: flex;
justify-content: left;
+1 -1
View File
@@ -10,7 +10,7 @@
article {
padding: 2rem;
max-width: 64rem;
background: var(--color-foreground-background-subtle);
background: var(--color-foreground-1);
border-radius: var(--border-radius);
}
</style>
@@ -19,7 +19,7 @@
<style>
.changeset-file {
border: 1px solid var(--color-foreground-3);
border: 1px solid var(--color-foreground-4);
border-radius: var(--border-radius-small);
min-width: var(--content-min-width);
margin-bottom: 2rem;
@@ -35,7 +35,7 @@
padding: 1rem;
}
main {
border-top: 1px dashed var(--color-foreground-3);
border-top: 1px dashed var(--color-foreground-4);
}
.changeset-file main {
overflow-x: auto;
@@ -53,9 +53,9 @@
}
.binary {
padding: 1rem;
color: var(--color-foreground-level-4);
color: var(--color-foreground-5);
text-align: center;
background-color: var(--color-foreground-1);
background-color: var(--color-foreground-2);
}
table.diff {
font-family: var(--font-family-monospace);
@@ -77,12 +77,12 @@
}
td.diff-line-number[data-type="+"],
td.diff-line-type[data-type="+"] {
background-color: var(--color-positive-background);
background-color: var(--color-positive-2);
color: var(--color-positive-6);
}
td.diff-line-number[data-type="-"],
td.diff-line-type[data-type="-"] {
background-color: var(--color-negative-background);
background-color: var(--color-negative-2);
color: var(--color-negative-6);
}
td.diff-line-number.left {
@@ -103,10 +103,10 @@
}
td.diff-expand-header {
padding-left: 0.5rem;
color: var(--color-foreground-4);
color: var(--color-foreground-5);
}
td.diff-line-number {
color: var(--color-foreground-4);
color: var(--color-foreground-5);
}
.browse {
display: flex;
+3 -3
View File
@@ -8,7 +8,7 @@
<style>
.file {
color: var(--color-foreground-90);
color: var(--color-foreground-6);
border-radius: var(--border-radius-small);
cursor: pointer;
display: flex;
@@ -20,12 +20,12 @@
}
.file:hover {
background-color: var(--color-foreground-background);
background-color: var(--color-foreground-1);
}
.file.active {
color: var(--color-foreground) !important;
background-color: var(--color-foreground-background);
background-color: var(--color-foreground-1);
}
.spinner {
+3 -3
View File
@@ -35,19 +35,19 @@
cursor: pointer;
padding: 0.25rem;
margin: 0.125rem 0;
color: var(--color-foreground-level-6);
color: var(--color-foreground-6);
user-select: none;
line-height: 1.5rem;
white-space: nowrap;
}
.folder:hover {
background-color: var(--color-foreground-background);
background-color: var(--color-foreground-1);
border-radius: var(--border-radius-small);
}
.folder-name {
margin-left: 0.25rem;
color: var(--color-light);
color: var(--color-secondary-6);
}
.container {
+5 -4
View File
@@ -24,7 +24,7 @@
flex-direction: row;
justify-content: space-between;
padding: 1rem;
border: 1px solid var(--color-secondary-faded);
border: 1px solid var(--color-secondary-5);
border-radius: var(--border-radius-small);
min-width: 36rem;
cursor: pointer;
@@ -57,7 +57,7 @@
white-space: nowrap;
}
article.project-faded {
border: 1px dashed var(--color-foreground-subtle);
border: 1px dashed var(--color-foreground-4);
cursor: not-allowed;
}
.activity {
@@ -66,12 +66,13 @@
}
article:hover {
border-color: var(--color-secondary);
background-color: var(--color-secondary-1);
}
article:hover .activity {
display: none !important;
}
article.project-faded:hover {
border-color: var(--color-foreground-faded);
border-color: var(--color-foreground-5);
}
article .id {
font-size: var(--font-size-regular);
@@ -98,7 +99,7 @@
}
article .id .urn {
visibility: hidden;
color: var(--color-foreground-faded);
color: var(--color-foreground-5);
font-weight: var(--font-weight-normal);
font-family: var(--font-family-monospace);
font-size: var(--font-size-tiny);