Refactor typography styles

- Move all global typography styles to its own file. This makes it
  easier to find all the typography related definitions for newcomers.

- Prefix all typography related global CSS classes with a unique prefix
  `.txt-`. This allows us to grep the codebase and see exactly where
  they are applied. Another benefit of this convention is that it helps
  to avoid accidentally mixing global and local styles. Having global
  CSS classes that sometimes overlap with component CSS classes makes it
  very hard to reason about the resulting visuals and making changes
  unpredictable.

- Introduce CSS variables for standardised typography sizes and apply
  them to the whole codebase consistently. This way we can adjust the
  size in one place and it will be applied everywhere.

- Avoid using predefined HTML tags which might have differing styling
  from browser to browser, e.g. `<h1>`, `<strong>`. We should stick to
  applying styling either by adding a specific global CSS class or using
  the predefined CSS variables, this way we can be sure that the styles
  won't be overridden by browser defaults.

- Have a minimal set of modifiers `.txt-monospace` and `.txt-bold` and
  apply them consistently. Since `.txt-monospace` is defined via a CSS
  variable, we'll be able to switch out fonts via a user setting in the
  future.

Signed-off-by: Rūdolfs Ošiņš <rudolfs@osins.org>
This commit is contained in:
Rūdolfs Ošiņš
2022-09-09 14:50:26 +02:00
committed by Alexis Sellier
parent ff657efa93
commit 591c19a256
67 changed files with 309 additions and 314 deletions
+5 -5
View File
@@ -38,7 +38,7 @@
}
header .file-name {
font-weight: normal;
font-weight: var(--font-weight-normal);
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
@@ -49,14 +49,14 @@
padding: 0.5rem;
color: var(--color-secondary);
background-color: var(--color-secondary-background);
font-size: 0.75rem;
font-size: var(--font-size-tiny);
border-radius: var(--border-radius-small);
overflow-x: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.last-commit .hash {
font-weight: bold;
font-weight: var(--font-weight-bold);
font-family: var(--font-family-monospace);
margin-right: 0.25rem;
}
@@ -124,7 +124,7 @@
@media (max-width: 960px) {
.code,
.line-numbers {
font-size: 0.875rem;
font-size: var(--font-size-small);
}
.highlight {
display: none;
@@ -150,7 +150,7 @@
{#if blob.binary}
<div class="binary">
<div>👀</div>
<span class="small">Binary content</span>
<span class="txt-tiny">Binary content</span>
</div>
{:else}
{#if line}
+1 -1
View File
@@ -187,7 +187,7 @@
<Placeholder icon="🍂">
<span slot="title">
{#if path !== "/"}
<div><code>{path}</code></div>
<div class="txt-monospace">{path}</div>
{/if}
</span>
<span slot="body">
+1 -1
View File
@@ -42,7 +42,7 @@
label {
color: var(--color-foreground-faded);
display: block;
font-size: 0.75rem;
font-size: var(--font-size-tiny);
padding: 0.5rem 0.5rem 0 0.25rem;
}
</style>
+5 -5
View File
@@ -40,7 +40,7 @@
}
.sha1 {
color: var(--color-foreground-80);
font-size: 0.875rem;
font-size: var(--font-size-small);
}
.authorship {
display: flex;
@@ -58,15 +58,15 @@
<div class="commit">
<header>
<div class="summary">
<div class="text-medium">{commit.header.summary}</div>
<div class="desktop font-mono sha1">
<div class="txt-medium">{commit.header.summary}</div>
<div class="desktop txt-monospace sha1">
<span>{commit.header.sha1}</span>
</div>
<div class="mobile font-mono sha1 text-small">
<div class="mobile txt-monospace sha1 txt-small">
{formatCommit(commit.header.sha1)}
</div>
</div>
<pre class="description text-small">{commit.header.description}</pre>
<pre class="description txt-small">{commit.header.description}</pre>
<div class="authorship">
<CommitAuthorship {commit} />
{#if commit.context?.committer}
@@ -36,14 +36,14 @@
}
</style>
<span class="authorship text-xsmall">
<span class="authorship txt-tiny">
{#if commit.header.author.email === commit.header.committer.email}
<img
class="avatar"
alt="avatar"
src={gravatarURL(commit.header.committer.email)} />
{#if commit.context?.committer}
<span class="bold committer verified-committer">
<span class="txt-bold committer verified-committer">
{commit.context?.committer.peer.person.name}
</span>
<span>&nbsp;committed</span>
@@ -67,7 +67,7 @@
alt="avatar"
src={gravatarURL(commit.header.committer.email)} />
{#if commit.context?.committer}
<span class="bold committer verified-committer">
<span class="txt-bold committer verified-committer">
{commit.context?.committer.peer.person.name}
</span>
<span>&nbsp;committed</span>
@@ -80,7 +80,7 @@
{/if}
{#if showTime}
<span>&nbsp;</span>
<span class="desktop-inline text-xsmall time">
<span class="desktop-inline txt-tiny time">
{formatTimestamp(commit.header.committerTime)}
</span>
{/if}
+1 -1
View File
@@ -19,7 +19,7 @@
<style>
.hash {
font-family: var(--font-family-monospace);
font-size: 0.75rem;
font-size: var(--font-size-tiny);
padding: 0 1.5rem;
}
.commit-teaser {
@@ -28,7 +28,7 @@
border-radius: var(--border-radius-small);
box-shadow: 16px 16px 32px 32px var(--color-shadow);
color: var(--color-foreground);
font-size: 0.75rem;
font-size: var(--font-size-tiny);
left: -10rem;
margin-top: 0.5rem;
padding: 0.5rem 0;
@@ -75,7 +75,7 @@
<CommitAuthorship {commit} showAuthor={false} showTime={false} />
{#if commit.context.committer}
<div class="peer">
<span class="text-faded">{commit.context.committer.peer.id}</span>
<span class="faded">{commit.context.committer.peer.id}</span>
</div>
{/if}
</div>
+5 -5
View File
@@ -41,7 +41,7 @@
<style>
header {
font-size: 0.75rem;
font-size: var(--font-size-tiny);
padding: 0 2rem 0 8rem;
margin-bottom: 2rem;
display: flex;
@@ -131,7 +131,7 @@
class="stat commit-count clickable widget"
class:active={content === ProjectContent.History}
on:click={() => toggleContent(ProjectContent.History, true)}>
<strong>{tree.stats.commits}</strong>
<span class="txt-bold">{tree.stats.commits}</span>
commit(s)
</div>
{#if project.issues}
@@ -141,7 +141,7 @@
class:not-allowed={project.issues === 0}
class:clickable={project.issues > 0}
on:click={() => toggleContent(ProjectContent.Issues, false)}>
<strong>{project.issues}</strong>
<span class="txt-bold">{project.issues}</span>
issue(s)
</div>
{/if}
@@ -152,12 +152,12 @@
class:not-allowed={project.patches === 0}
class:clickable={project.patches > 0}
on:click={() => toggleContent(ProjectContent.Patches, false)}>
<strong>{project.patches}</strong>
<span class="txt-bold">{project.patches}</span>
patch(es)
</div>
{/if}
<div class="stat contributor-count widget">
<strong>{tree.stats.contributors}</strong>
<span class="txt-bold">{tree.stats.contributors}</span>
contributor(s)
</div>
</header>
+1 -1
View File
@@ -41,7 +41,7 @@
<style>
.history {
padding: 0 2rem 0 8rem;
font-size: 0.875rem;
font-size: var(--font-size-small);
}
.commit-group header {
color: var(--color-foreground-faded);
+7 -7
View File
@@ -39,7 +39,7 @@
flex-basis: 18rem;
margin-left: 1rem;
border-radius: var(--border-radius);
font-size: 0.875rem;
font-size: var(--font-size-small);
padding-left: 1rem;
}
.metadata-section {
@@ -47,7 +47,7 @@
border-bottom: 1px dashed var(--color-foreground-subtle);
}
.metadata-section-header {
font-size: 0.875rem;
font-size: var(--font-size-small);
margin-bottom: 0.75rem;
color: var(--color-foreground-faded);
}
@@ -63,7 +63,7 @@
background-color: var(--color-tertiary-background);
padding: 0.25rem 0.75rem;
margin-right: 0.5rem;
font-size: 0.875rem;
font-size: var(--font-size-small);
line-height: 1.6;
}
@@ -82,7 +82,7 @@
display: flex;
}
.id {
font-size: 0.75rem;
font-size: var(--font-size-tiny);
margin-left: 0.75rem;
color: var(--color-foreground-faded);
}
@@ -112,11 +112,11 @@
<header>
<div class="summary">
<div class="summary-left">
<span class="summary-title text-medium">
<span class="summary-title txt-medium">
{issue.title}
</span>
<span class="font-mono id desktop">{issue.id}</span>
<span class="font-mono id mobile">{formatObjectId(issue.id)}</span>
<span class="txt-monospace id desktop">{issue.id}</span>
<span class="txt-monospace id mobile">{formatObjectId(issue.id)}</span>
</div>
<div
class="summary-state"
+3 -3
View File
@@ -39,7 +39,7 @@
}
.issue-id {
color: var(--color-foreground-faded);
font-size: 0.75rem;
font-size: var(--font-size-tiny);
font-family: var(--font-family-monospace);
margin-left: 0.5rem;
}
@@ -56,7 +56,7 @@
}
.comment-count {
color: var(--color-foreground-70);
font-weight: bold;
font-weight: var(--font-weight-bold);
}
.comment-count .emoji {
margin-right: 0.25rem;
@@ -122,7 +122,7 @@
{#if commentCount > 0}
<div class="column-right">
<div class="comment-count">
<span class="text-xsmall emoji">💬</span>
<span class="txt-tiny emoji">💬</span>
<span>{commentCount}</span>
</div>
</div>
+1 -1
View File
@@ -44,7 +44,7 @@
<style>
.issues {
padding: 0 2rem 0 8rem;
font-size: 0.875rem;
font-size: var(--font-size-small);
}
.issues-list {
border-radius: var(--border-radius);
+4 -4
View File
@@ -64,7 +64,7 @@
margin-right: 0.75rem;
}
.id {
font-size: 0.75rem;
font-size: var(--font-size-tiny);
color: var(--color-foreground-faded);
}
.summary-state {
@@ -97,11 +97,11 @@
<header>
<div class="summary">
<div class="summary-left">
<span class="summary-title text-medium">
<span class="summary-title txt-medium">
{patch.title}
</span>
<span class="font-mono id desktop">{patch.id}</span>
<span class="font-mono id mobile">{formatObjectId(patch.id)}</span>
<span class="txt-monospace id desktop">{patch.id}</span>
<span class="txt-monospace id mobile">{formatObjectId(patch.id)}</span>
</div>
<div
class="summary-state"
+3 -3
View File
@@ -9,7 +9,7 @@
flex-basis: 18rem;
margin-left: 1rem;
border-radius: var(--border-radius-medium);
font-size: 0.875rem;
font-size: var(--font-size-small);
padding-left: 1rem;
}
.metadata-section {
@@ -17,7 +17,7 @@
border-bottom: 1px dashed var(--color-foreground-subtle);
}
.metadata-section-header {
font-size: 0.875rem;
font-size: var(--font-size-small);
margin-bottom: 0.75rem;
color: var(--color-foreground-faded);
}
@@ -33,7 +33,7 @@
background-color: var(--color-tertiary-background);
padding: 0.25rem 0.75rem;
margin-right: 0.5rem;
font-size: 0.875rem;
font-size: var(--font-size-small);
line-height: 1.6;
}
</style>
+3 -3
View File
@@ -57,7 +57,7 @@
border: none;
color: var(--color-foreground-80);
font-family: var(--font-family-monospace);
font-size: 0.75rem;
font-size: var(--font-size-tiny);
height: var(--button-tiny-height);
padding: 0.25rem 0.5rem;
background-color: var(--color-background);
@@ -72,7 +72,7 @@
}
</style>
<div class="bar text-small">
<div class="bar txt-small">
<ToggleButton
{options}
on:select={e => {
@@ -83,7 +83,7 @@
<Floating disabled={revisions.length <= 1}>
<button
slot="toggle"
class="text-small revision-toggle"
class="txt-small revision-toggle"
disabled={revisions.length <= 1}>
{formatRevisionName(revisions[revisionNumber], revisionNumber)}
</button>
+3 -3
View File
@@ -39,7 +39,7 @@
}
.patch-id {
color: var(--color-foreground-faded);
font-size: 0.75rem;
font-size: var(--font-size-tiny);
font-family: var(--font-family-monospace);
margin-left: 0.5rem;
}
@@ -56,7 +56,7 @@
}
.comment-count {
color: var(--color-foreground-70);
font-weight: bold;
font-weight: var(--font-weight-bold);
}
.comment-count .emoji {
margin-right: 0.25rem;
@@ -122,7 +122,7 @@
{#if commentCount > 0}
<div class="column-right">
<div class="comment-count">
<span class="text-xsmall emoji">💬</span>
<span class="txt-tiny emoji">💬</span>
<span>{commentCount}</span>
</div>
</div>
+1 -1
View File
@@ -41,7 +41,7 @@
<style>
.patches {
padding: 0 2rem 0 8rem;
font-size: 0.875rem;
font-size: var(--font-size-small);
}
.patches-list {
border-radius: var(--border-radius-small);
+1 -1
View File
@@ -33,7 +33,7 @@
console.debug("Not able to resolve peer identity for: ", p.id);
}
const key = p.person?.name
? `<strong>${p.person.name}</strong> ${p.id}`
? `<span class="txt-bold">${p.person.name}</span> ${p.id}`
: p.id;
return {
+5 -3
View File
@@ -94,11 +94,11 @@
{/if}
{:catch err}
<div class="container center-content">
<div class="error error-message text-xsmall">
<div class="error error-message txt-tiny">
<!-- TODO: Differentiate between (1) commit doesn't exist and (2) failed
to fetch - this needs a change to the backend. -->
API request to
<code class="text-xsmall">{err.url}</code>
<span class="txt-monospace">{err.url}</span>
failed
</div>
</div>
@@ -141,7 +141,9 @@
<div class="content">
{#if peer}
<Placeholder icon="🍂">
<span slot="title"><code>{formatSeedId(peer)}</code></span>
<span slot="title">
<span class="txt-monospace">{formatSeedId(peer)}</span>
</span>
<span slot="body">Couldn't load remote source tree.</span>
</Placeholder>
{:else}
+13 -7
View File
@@ -26,17 +26,17 @@
display: flex;
align-items: center;
justify-content: left;
font-size: 2rem;
font-size: var(--font-size-huge);
margin-bottom: 0.5rem;
}
.title .divider {
color: var(--color-foreground-subtle);
margin: 0 0.5rem;
font-weight: normal;
font-weight: var(--font-weight-normal);
}
.title .peer-id {
color: var(--color-foreground-subtle);
font-weight: normal;
font-weight: var(--font-weight-normal);
display: flex;
align-items: center;
}
@@ -47,7 +47,7 @@
}
.urn {
font-family: var(--font-family-monospace);
font-size: 0.75rem;
font-size: var(--font-size-tiny);
color: var(--color-foreground-faded);
overflow-wrap: anywhere;
display: flex;
@@ -66,6 +66,12 @@
padding: 0 2rem 0 8rem;
}
.truncate {
white-space: nowrap;
text-overflow: ellipsis;
overflow-x: hidden;
}
@media (max-width: 960px) {
.content {
padding-left: 2rem;
@@ -74,7 +80,7 @@
</style>
<header class="content">
<div class="title bold">
<div class="title txt-bold txt-title">
{#if project.profile}
<a
class="org-avatar"
@@ -86,7 +92,7 @@
</a>
<span class="divider">/</span>
{/if}
<span class="text-truncate">
<span class="truncate">
<Link to={rootPath()}>{project.name}</Link>
</span>
{#if peer}
@@ -98,7 +104,7 @@
{/if}
</div>
<div class="urn">
<span class="text-truncate">{project.urn}</span>
<span class="truncate">{project.urn}</span>
<Clipboard small text={project.urn} />
</div>
{#if !noDescription}
@@ -108,9 +108,6 @@
td.diff-line-number {
color: var(--color-foreground-4);
}
.file-path {
font-size: 1rem;
}
.browse {
display: flex;
}
@@ -119,7 +116,7 @@
<article id={file.path} class="changeset-file">
<header class="file-header" on:click={collapse}>
<div class="actions">
<p class="file-path">{file.path}</p>
<p class="txt-regular">{file.path}</p>
{#if mode === "created"}
<Badge variant="positive">created</Badge>
{:else if mode === "deleted"}
+7 -7
View File
@@ -79,17 +79,17 @@
border-color: var(--color-foreground-faded);
}
article .id {
font-size: 1rem;
font-weight: 600;
font-size: var(--font-size-regular);
font-weight: var(--font-weight-medium);
margin-bottom: 0.5rem;
}
article .description {
margin-bottom: 0.25rem;
font-size: 0.75rem;
font-size: var(--font-size-tiny);
}
article .stateHash {
color: var(--color-secondary);
font-size: 0.75rem;
font-size: var(--font-size-tiny);
min-height: 2rem;
display: flex;
align-items: center;
@@ -116,9 +116,9 @@
article .id .urn {
visibility: hidden;
color: var(--color-foreground-faded);
font-weight: normal;
font-weight: var(--font-weight-normal);
font-family: var(--font-family-monospace);
font-size: 0.75rem;
font-size: var(--font-size-tiny);
}
article .anchor-badge {
display: none;
@@ -152,7 +152,7 @@
{project.head}
{/if}
{:else}
<span class="subtle">✗ No head</span>
<span class="txt-missing">✗ No head</span>
{/if}
</slot>
</span>