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: add locked state to cards #431

Merged
merged 1 commit into from
Aug 19, 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
3 changes: 2 additions & 1 deletion packages/cxl-lumo-styles/src/icons.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions packages/cxl-ui/scss/cxl-base-card.scss
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,15 @@ header {
display: none;
}

.icon-lock {
color: var(--lumo-body-text-color);

:host([theme~="category"]) &,
:host([theme~="minidegree"]) & {
color: var(--lumo-tint);
}
}

:host([new]) {
.icon-new {
position: absolute;
Expand Down Expand Up @@ -249,3 +258,10 @@ vaadin-button {
}
}
}

:host([locked]) {
header, .content-wrapper {
opacity: 0.6;
}

}
9 changes: 9 additions & 0 deletions packages/cxl-ui/scss/cxl-light-card.scss
Original file line number Diff line number Diff line change
Expand Up @@ -177,3 +177,12 @@
}
}
}

.icon-lock {
position: absolute;
top: var(--lumo-space-s);
right: var(--lumo-space-s);
z-index: 2;
width: var(--lumo-icon-size-s);
height: var(--lumo-icon-size-s);
}
5 changes: 5 additions & 0 deletions packages/cxl-ui/src/components/cxl-base-card.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ export class CXLBaseCardElement extends LitElement {

@property({ type: String }) id = '';

@property({ type: Boolean, reflect: true }) locked;

@property({ type: String, attribute: 'locked-message' }) lockedMessage = 'Purchase an All-Access subscription to unlock this course.';

@property({ type: String }) theme = '';

@property({ type: String }) name = '';
Expand Down Expand Up @@ -50,6 +54,7 @@ export class CXLBaseCardElement extends LitElement {
${this.theme && this._tagsHasChildren ? this.separator : ''}
<slot name="tags" @slotchange=${this._slotHasChildren}></slot>
${this.new ? html`${this.theme ? this.separator : ''}<span class="tag new">NEW</span>` : ''}
${this.locked ? html`${this.theme ? this.separator : ''}<span><vaadin-icon class="icon-lock" icon="vaadin:lock"><vaadin-tooltip slot="tooltip" text="${this.lockedMessage}"></vaadin-tooltip></vaadin-icon></span>` : ''}
</div>
`;
}
Expand Down
7 changes: 4 additions & 3 deletions packages/cxl-ui/src/components/cxl-light-card.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,10 @@ export class CXLLightCardElement extends CXLBaseCardElement {
_renderHeaderName() {
return html`
<h3 class="name" title=${this.name}>
${unsafeHTML(this.name)}${
this.completed ? html`<vaadin-icon icon="lumo:checkmark"></vaadin-icon>` : nothing
}
${unsafeHTML(this.name)}${
this.completed ? html`<vaadin-icon icon="lumo:checkmark"></vaadin-icon>` : nothing
}
${this.locked ? html`<vaadin-icon class="icon-lock" icon="vaadin:lock"><vaadin-tooltip slot="tooltip" text="${this.lockedMessage}"></vaadin-tooltip></vaadin-icon>` : ''}
</h3>
`;
}
Expand Down
2 changes: 2 additions & 0 deletions packages/storybook/cxl-ui/cxl-course-card/template.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export const CourseCardTemplate = (course) => html`
<cxl-course-card
id=${course.id}
class=${course.classes || ''}
?locked=${course.locked}
theme=${course.theme}
name=${course.name}
time=${course.time}
Expand All @@ -26,6 +27,7 @@ export const CourseCardTemplate = (course) => html`

export const args = {
id: 'cxl-course-1',
locked: false,
name: 'Account based marketing',
time: '3h 00min',
instructor: 'Tom Wesseling',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export const CXLLightCardMinidegree = Template.bind({});
export const CXLLightCardFooter = Template.bind({});

CXLLightCard.args = {
locked: false,
theme: 'light-card',
new: false,
completed: false,
Expand Down
1 change: 1 addition & 0 deletions packages/storybook/cxl-ui/cxl-light-card/template.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { unsafeHTML } from 'lit/directives/unsafe-html.js';

export const Template = (card) => html`
<cxl-light-card
?locked="${card.locked}"
theme="${card.theme}"
name="${card.name}"
time="${card.time}"
Expand Down
Loading