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

feat: render markdown in gv-card-full description #675

Merged
merged 1 commit into from
Feb 27, 2024
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: 1 addition & 1 deletion src/lib/item.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export function getEntrypoints(item) {
}

export function getDescription(item) {
if (item) {
if (item && item.description) {
return item.description;
}
return '';
Expand Down
28 changes: 20 additions & 8 deletions src/molecules/gv-card-full/gv-card-full.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,17 @@ export class GvCardFull extends ItemResource(LitElement) {
.description {
padding: 0 16px;
margin: 6px 0;
flex: 1;
flex-grow: 1;
max-height: 150px;
flex: 1;
overflow: hidden;
text-overflow: ellipsis;
}

.description * {
a-cordier marked this conversation as resolved.
Show resolved Hide resolved
display: contents;
font-size: var(--gv-theme-font-size-m, 14px);
}

.infos {
display: flex;
border-bottom: 1px solid var(--gv-theme-neutral-color-dark, #d9d9d9);
Expand Down Expand Up @@ -184,6 +188,16 @@ export class GvCardFull extends ItemResource(LitElement) {
}
}

_getDescription() {
if (this._error) {
return i18n('gv-card-full.error');
}
if (this._empty) {
return i18n('gv-card-full.empty');
}
return getDescription(this._item);
}

render() {
const title = getTitle(this._item);
const owner = getOwner(this._item);
Expand All @@ -200,12 +214,10 @@ export class GvCardFull extends ItemResource(LitElement) {
</div>
<div class="version"><span class="${classMap({ skeleton: this._skeleton })}">${getVersion(this._item)}</span></div>
</div>
<div class="${classMap({ skeleton: this._skeleton, description: true })}">
${truncate(
this._error ? i18n('gv-card-full.error') : this._empty ? i18n('gv-card-full.empty') : getDescription(this._item),
this.limit,
)}
</div>
<div
class="${classMap({ skeleton: this._skeleton, description: true })}"
.innerHTML="${truncate(this._getDescription(), this.limit)}"
a-cordier marked this conversation as resolved.
Show resolved Hide resolved
></div>
<span class="${classMap({ skeleton: this._skeleton })}">
<div class="infos">${this._renderMetricsWithRating()}</div>

Expand Down
2 changes: 1 addition & 1 deletion src/molecules/gv-card-full/gv-card-full.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { makeStory, storyWait } from '../../../testing/lib/make-story';

const name = 'Supernova';
const description =
'Tempore quo primis auspiciis in mundanum fulgorem surgeret victura dum erunt homines Roma, ' +
'<h1>Tempore</h1> <h2>quo primis</h2> <h3>auspiciis</h3> <h4>in</h4> mundanum <a href="">fulgorem surgeret</a> victura dum erunt homines Roma, ' +
'ut augeretur sublimibus incrementis, foedere pacis aeternae Virtus convenit atque plerumque dissidentes,';

const version = 'v.1.1';
Expand Down
Loading