Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Support description markdown and longer length #385

Merged
merged 6 commits into from
Jan 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
"keyword-mark-element": "^0.2.0",
"lit": "3.1.1",
"marked": "^4.0.10",
"micromark": "^4.0.1",
"micromark-extension-gfm-strikethrough": "^2.1.0",
"mime-types": "^2.1.32",
"minimist": "^1.2.5",
"node-fetch": "^3.3.0",
Expand Down
3 changes: 2 additions & 1 deletion src/appmain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,8 @@ export class ReplayWebApp extends LitElement {
flex-direction: column;
}
wr-item {
height: 100%;
flex: 1 1 auto;
overflow: hidden;
}
.navbar {
padding: 0 0.5em;
Expand Down
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, {
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
49 changes: 37 additions & 12 deletions src/pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,8 @@ class Pages extends LitElement {
return wrapCss(css`
:host {
width: 100%;
height: 100%;
flex: 1 1 auto;
overflow: hidden;
display: flex;
min-width: 0px;
flex-direction: column;
Expand Down Expand Up @@ -396,10 +397,19 @@ class Pages extends LitElement {
position: relative;
}

.index-bar-title {
font-size: 1.25rem;
.index-bar-label {
text-transform: uppercase;
margin-bottom: 1rem;
font-size: var(--sl-font-size-x-small);
font-weight: var(--sl-font-weight-semibold);
color: var(--sl-color-neutral-500);
margin-bottom: var(--sl-spacing-2x-small);
line-height: 1;
}

.index-bar-title {
font-size: var(--sl-font-size-large);
font-weight: var(--sl-font-weight-semibold);
margin-bottom: var(--sl-spacing-large);
word-break: break-word;
}

Expand Down Expand Up @@ -528,8 +538,11 @@ class Pages extends LitElement {
}

.index-bar-description {
margin-bottom: 20px;
font-style: italic;
margin-bottom: var(--sl-spacing-x-small);
line-height: var(--sl-line-height-normal);
flex: 1 1 auto;
overflow: auto;
border-bottom: 1px solid var(--sl-panel-border-color);
}
`);
}
Expand Down Expand Up @@ -638,18 +651,30 @@ class Pages extends LitElement {
</form>
`
: html` <div
class="index-bar-label ${this.collInfo!.description
? "is-hidden-mobile"
: "is-sr-only"}"
>
Collection Name
</div>
<div
class="index-bar-title"
@dblclick="${() => (this.editing = true)}"
>
${this.collInfo!.name || this.collInfo!.title}
</div>
${this.collInfo!.description
? html`<div
class="index-bar-description"
@dblclick="${() => (this.editing = true)}"
>
${this.collInfo!.description}
</div>`
? html` <div class="index-bar-label is-hidden-mobile">
About This Collection
</div>
<div
class="index-bar-description is-hidden-mobile"
@dblclick="${() => (this.editing = true)}"
>
<wr-coll-description
value=${this.collInfo!.description}
></wr-coll-description>
</div>`
: html``}`}
${this.editable
? html`<fa-icon class="editIcon" .svg="${fasEdit}"></fa-icon>`
Expand Down
Loading
Loading