Skip to content

Commit

Permalink
render markdown
Browse files Browse the repository at this point in the history
  • Loading branch information
SuaYoo authored and emma-sg committed Dec 23, 2024
1 parent b7937ea commit 52b3cf6
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 3 deletions.
7 changes: 7 additions & 0 deletions src/assets/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ $modal-card-title-size: 1.2rem;
// Set placeholder contrast to ~4.5:1 for WCAG AA compliance
$input-placeholder-color: #757575;
$input-disabled-placeholder-color: #707070;

.input::placeholder, .textarea::placeholder, .select select::placeholder {
opacity: 1;
}
Expand Down Expand Up @@ -115,6 +116,11 @@ a:focus {

// Add html and body styles to :host for webcomponents
:host {
--primary: #{$wr-green};
--info: #{$wr-light-bg};
--warning: #{$wr-yellow};
--link: #{$wr-dark-blue};

//background-color: $body-background-color;
font-size: $body-size;
-moz-osx-font-smoothing: grayscale;
Expand All @@ -130,6 +136,7 @@ a:focus {
line-height: $body-line-height;

box-sizing: border-box;

}

// Make available to screen readers while hiding element visually:
Expand Down
61 changes: 61 additions & 0 deletions src/coll-description.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import { css, LitElement } from "lit";
import { customElement, property } from "lit/decorators.js";
import { html as staticHtml, unsafeStatic } from "lit/static-html.js";
import { micromark } from "micromark";
import {
gfmStrikethrough,
gfmStrikethroughHtml,
} from "micromark-extension-gfm-strikethrough";

@customElement("wr-coll-description")
export class CollectionDescription extends LitElement {
static styles = [
css`
h1,
h2,
h3,
h4,
h5,
h6 {
font-size: 1rem;
}
a {
color: var(--link);
}
a:hover,
a:active {
text-decoration: none;
}
img {
max-width: 100%;
}
p {
line-height: inherit;
}
p:first-child {
margin-top: 0;
}
p:last-child {
margin-bottom: 0;
}
`,
];

@property({ type: String })
value = "";

render() {
return staticHtml`${unsafeStatic(
micromark(this.value, {

Check warning on line 55 in src/coll-description.ts

View workflow job for this annotation

GitHub Actions / lint

Unsafe argument of type `any` assigned to a parameter of type `string`
extensions: [gfmStrikethrough()],
htmlExtensions: [gfmStrikethroughHtml()],
}),
)}`;
}
}
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { Sorter } from "./sorter";
import { SWManager } from "./swmanager";
import { URLResources } from "./url-resources";
import { Embed } from "./embed";
import "./coll-description";
import "./shoelace";

export {
Expand Down
9 changes: 6 additions & 3 deletions src/pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -539,9 +539,10 @@ class Pages extends LitElement {
.index-bar-description {
margin-bottom: var(--sl-spacing-x-small);
line-height: var(--sl-line-height-normal);
flex: 1 1 auto;
overflow: auto;
line-height: var(--sl-line-height-normal);
border-bottom: 1px solid var(--sl-panel-border-color);
}
`);
}
Expand Down Expand Up @@ -654,7 +655,7 @@ class Pages extends LitElement {
? "is-hidden-mobile"
: "is-sr-only"}"
>
Collection Title
Collection Name
</div>
<div
class="index-bar-title"
Expand All @@ -670,7 +671,9 @@ class Pages extends LitElement {
class="index-bar-description is-hidden-mobile"
@dblclick="${() => (this.editing = true)}"
>
${this.collInfo!.description}
<wr-coll-description
value=${this.collInfo!.description}
></wr-coll-description>
</div>`
: html``}`}
${this.editable
Expand Down

0 comments on commit 52b3cf6

Please sign in to comment.