Radish alpha
r
Radicle web interface
Radicle
Git (anonymous pull)
Log in to clone via SSH
Change titles to font-weight semibold
Sebastian Martinez committed 2 years ago
commit 196beca898012b1e5704476ff8ef1a88210e5c0a
parent 20f895df6ed42a0a731420534eb3308dba34c7aa
9 files changed +47 -11
modified src/components/InlineMarkdown.svelte
@@ -3,13 +3,19 @@

  import markdown from "@app/lib/markdown";
  import { twemoji } from "@app/lib/utils";
+
  import { Renderer } from "@app/lib/markdown";

  export let content: string;
+
  export let stripEmphasizedStyling: boolean = false;
  export let fontSize: "tiny" | "small" | "regular" | "medium" | "large" =
    "small";

  const render = (content: string): string =>
-
    dompurify.sanitize(markdown.parseInline(content) as string);
+
    dompurify.sanitize(
+
      markdown.parseInline(content, {
+
        renderer: new Renderer(undefined, stripEmphasizedStyling),
+
      }) as string,
+
    );
</script>

<style>
modified src/components/Markdown.svelte
@@ -92,7 +92,7 @@
  function render(content: string): string {
    return dompurify.sanitize(
      markdown.parse(content, {
-
        renderer: new Renderer(linkBaseUrl),
+
        renderer: new Renderer(linkBaseUrl, false),
      }) as string,
    );
  }
modified src/components/ProjectCard.svelte
@@ -83,9 +83,7 @@
    font-weight: var(--font-weight-medium);
  }
  .name {
-
    white-space: nowrap;
-
    overflow-x: hidden;
-
    text-overflow: ellipsis;
+
    font-weight: var(--font-weight-semibold);
  }
  .rid {
    visibility: hidden;
@@ -107,7 +105,7 @@
  <div class="left">
    <div class="text">
      <div class="title">
-
        <span class="name" title={name}>
+
        <span class="name txt-overflow" title={name}>
          {name}
        </span>
        {#if visibility === "private"}
modified src/lib/markdown.ts
@@ -102,14 +102,16 @@ const anchorMarkedExtension = {

export class Renderer extends BaseRenderer {
  #baseUrl: string | undefined;
+
  #stripEmphasizedStyling: boolean | undefined;

  /**
   * If `baseUrl` is provided, all hrefs attributes in anchor tags, except those
   * starting with `#`, are resolved with respect to `baseUrl`
   */
-
  constructor(baseUrl: string | undefined) {
+
  constructor(baseUrl: string | undefined, stripEmphasizedStyling: boolean) {
    super();
    this.#baseUrl = baseUrl;
+
    this.#stripEmphasizedStyling = stripEmphasizedStyling;
  }
  // Overwrites the rendering of heading tokens.
  // Since there are possible non ASCII characters in headings,
@@ -125,6 +127,14 @@ export class Renderer extends BaseRenderer {
    return `<h${level} id="${escapedText}">${text}</h${level}>`;
  }

+
  strong(text: string) {
+
    return this.#stripEmphasizedStyling ? text : `<strong>${text}</strong>`;
+
  }
+

+
  em(text: string) {
+
    return this.#stripEmphasizedStyling ? text : `<em>${text}</em>`;
+
  }
+

  link(href: string, _title: string, text: string): string {
    if (href.startsWith("#")) {
      // By lowercasing we avoid casing mismatches, between headings and links.
modified src/views/projects/Commit.svelte
@@ -23,6 +23,9 @@
    margin-bottom: 3rem;
    border-radius: var(--border-radius-small);
  }
+
  .title {
+
    font-weight: var(--font-weight-semibold);
+
  }
  .description {
    font-family: var(--font-family-monospace);
    margin: 1rem 0;
@@ -33,7 +36,12 @@
<Layout {baseUrl} {project}>
  <div class="commit">
    <div class="header">
-
      <InlineMarkdown fontSize="large" content={header.summary} />
+
      <span class="title">
+
        <InlineMarkdown
+
          stripEmphasizedStyling
+
          fontSize="large"
+
          content={header.summary} />
+
      </span>
      <pre class="description txt-small">{header.description}</pre>
      <CommitAuthorship {header}>
        <span class="global-commit">{formatCommit(header.id)}</span>
modified src/views/projects/Issue.svelte
@@ -453,6 +453,7 @@
    display: flex;
    align-items: center;
    gap: 0.5rem;
+
    font-weight: var(--font-weight-semibold);
    font-size: var(--font-size-large);
    height: 2.5rem;
  }
@@ -484,7 +485,10 @@
            <span class="txt-missing">No title</span>
          {:else}
            <div class="title">
-
              <InlineMarkdown fontSize="large" content={issue.title} />
+
              <InlineMarkdown
+
                stripEmphasizedStyling
+
                fontSize="large"
+
                content={issue.title} />
            </div>
          {/if}
          {#if session && role.isDelegateOrAuthor(session.publicKey, project.delegates, issue.author.id) && issueState === "read"}
modified src/views/projects/Issue/New.svelte
@@ -141,7 +141,10 @@
                bind:value={issueTitle}
                showKeyHint={false} />
            {:else if issueTitle}
-
              <InlineMarkdown fontSize="medium" content={issueTitle} />
+
              <InlineMarkdown
+
                stripEmphasizedStyling
+
                fontSize="medium"
+
                content={issueTitle} />
            {:else}
              <span class="txt-missing">No title</span>
            {/if}
modified src/views/projects/Patch.svelte
@@ -585,6 +585,7 @@
    display: flex;
    align-items: center;
    gap: 0.5rem;
+
    font-weight: var(--font-weight-semibold);
    font-size: var(--font-size-large);
    height: 2.5rem;
  }
@@ -669,7 +670,10 @@
            <span class="txt-missing">No title</span>
          {:else}
            <div class="title">
-
              <InlineMarkdown fontSize="large" content={patch.title} />
+
              <InlineMarkdown
+
                stripEmphasizedStyling
+
                fontSize="large"
+
                content={patch.title} />
            </div>
          {/if}
          {#if session && role.isDelegateOrAuthor(session.publicKey, project.delegates, patch.author.id) && patchState === "read"}
modified src/views/projects/Source/ProjectNameHeader.svelte
@@ -76,6 +76,9 @@
  .description {
    padding: 0 1rem 1rem 1rem;
  }
+
  .project-name {
+
    font-weight: var(--font-weight-semibold);
+
  }
  .project-name:hover {
    color: inherit;
  }