forked from web-padawan/aybolit
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cxl-ui): add cxl-certificate-header component
- Loading branch information
Hener Hoop
committed
Dec 8, 2023
1 parent
e25fb2e
commit 51996f3
Showing
15 changed files
with
366 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
@use "~@conversionxl/cxl-lumo-styles/scss/mq"; | ||
@use "./mixins"; | ||
|
||
:host { | ||
color: var(--lumo-tint); | ||
background-color: var(--lumo-shade); | ||
overflow: hidden; | ||
@include mixins.pesudo-element-full-width(var(--lumo-shade)); | ||
|
||
@media #{mq.$medium} { | ||
overflow: visible; | ||
} | ||
|
||
.container { | ||
position: relative; | ||
box-sizing: border-box; | ||
width: 100%; | ||
max-width: var(--cxl-content-max-width-wide); | ||
padding: var(--lumo-space-l) 0; | ||
|
||
@media #{mq.$small} { | ||
display: flex; | ||
justify-content: space-between; | ||
gap: var(--lumo-space-m); | ||
} | ||
|
||
@media #{mq.$large} { | ||
padding: var(--lumo-space-xl) 0; | ||
} | ||
} | ||
|
||
.content { | ||
max-width: var(--cxl-hero-content-max-width); | ||
} | ||
|
||
.title { | ||
margin: 0; | ||
font-family: var(--cxl-lumo-font-secondary); | ||
} | ||
|
||
.completed { | ||
display: flex; | ||
margin-top: var(--lumo-space-l); | ||
font-size: var(--lumo-font-size-xl); | ||
font-weight: 700; | ||
color: var(--lumo-primary-color); | ||
} | ||
|
||
.completed-icon { | ||
display: inline-flex; | ||
width: 32px; | ||
height: 32px; | ||
align-items: center; | ||
justify-content: center; | ||
margin-right: var(--lumo-space-m); | ||
color: var(--lumo-primary-color); | ||
background-color: var(--lumo-primary-color-10pct); | ||
border-radius: 100%; | ||
} | ||
|
||
.description { | ||
margin-top: var(--lumo-space-l); | ||
font-family: var(--cxl-lumo-font-secondary); | ||
line-height: var(--lumo-line-height-m); | ||
} | ||
|
||
.stats { | ||
margin-top: var(--lumo-space-l); | ||
|
||
@media #{mq.$medium} { | ||
margin-top: calc(4 * var(--lumo-space-m)); | ||
} | ||
} | ||
|
||
.actions { | ||
display: flex; | ||
flex-direction: column; | ||
gap: var(--lumo-space-s); | ||
margin-top: var(--lumo-space-m); | ||
|
||
@media #{mq.$medium} { | ||
flex-direction: row; | ||
gap: var(--lumo-space-m); | ||
margin-top: var(--lumo-space-xl); | ||
} | ||
} | ||
|
||
.credential { | ||
width: 100%; | ||
max-width: 100%; | ||
margin-top: var(--lumo-space-l); | ||
padding-top: var(--lumo-space-l); | ||
border-top: solid 1px var(--cxl-color-dark-gray); | ||
|
||
@media #{mq.$medium} { | ||
max-width: var(--cxl-hero-certificate-max-width); | ||
margin-top: 0; | ||
padding-top: 0; | ||
border-top: none; | ||
} | ||
} | ||
} | ||
|
||
:host([theme~="completed"]) { | ||
color: var(--lumo-shade); | ||
background-color: var(--lumo-tint); | ||
|
||
@media #{mq.$medium} { | ||
@include mixins.pesudo-element-full-width(var(--lumo-tint)); | ||
} | ||
|
||
.credential { | ||
padding-top: 0; | ||
border-top: none; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
cxl-certificate-header { | ||
position: relative; | ||
display: block; | ||
z-index: 1; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
/* eslint-disable import/no-extraneous-dependencies */ | ||
import { LitElement, html, nothing } from 'lit'; | ||
import { unsafeHTML } from 'lit/directives/unsafe-html.js'; | ||
import { customElement, property } from 'lit/decorators.js'; | ||
import '@conversionxl/cxl-lumo-styles'; | ||
import '@conversionxl/cxl-ui/src/components/cxl-section.js'; | ||
import { registerGlobalStyles } from '@conversionxl/cxl-lumo-styles/src/utils'; | ||
|
||
import cxlCertificateHeaderStyles from '../styles/cxl-certificate-header-css.js'; | ||
import cxlCertificateHeaderGlobalStyles from '../styles/global/cxl-certificate-header-css.js'; | ||
|
||
@customElement('cxl-certificate-header') | ||
export class CXLCertificateHeaderElement extends LitElement { | ||
static get styles() { | ||
return [cxlCertificateHeaderStyles]; | ||
} | ||
|
||
@property({ type: String }) theme = ''; | ||
@property({ type: String }) title = ''; | ||
@property({ type: String }) description = ''; | ||
@property({ type: Boolean, attribute: 'hide-actions' }) hideActions = false; | ||
@property({ type: Boolean, attribute: 'hide-stats' }) hideStats = false; | ||
@property({ type: Boolean, attribute: 'hide-credential' }) hideCredential = false; | ||
// eslint-disable-next-line class-methods-use-this | ||
_renderCompletedEmblem() { | ||
if (!this.theme.includes('completed')) { | ||
return nothing; | ||
} | ||
return html`<div class="completed"> | ||
<span class="completed-icon"><vaadin-icon icon="lumo:checkmark"></vaadin-icon></span> | ||
Course completed | ||
</div>`; | ||
} | ||
// eslint-disable-next-line class-methods-use-this | ||
_renderActions() { | ||
if (this.hideActions) { | ||
return nothing; | ||
} | ||
return html`<div class="actions"><slot name="actions"></slot></div>`; | ||
} | ||
// eslint-disable-next-line class-methods-use-this | ||
_renderStats() { | ||
if (this.hideStats) { | ||
return nothing; | ||
} | ||
return html`<div class="stats"><slot name="stats"></slot></div>`; | ||
} | ||
// eslint-disable-next-line class-methods-use-this | ||
_renderCredential() { | ||
if (this.hideCredential) { | ||
return nothing; | ||
} | ||
return html`<div class="credential"><slot name="credential"></slot>`; | ||
} | ||
render() { | ||
return html` | ||
<cxl-section class="alignfull" theme="cxl-certificate-header"> | ||
<div class="container"> | ||
<div class="content"> | ||
<h1 class="title">${this.title}</h1> | ||
${this._renderCompletedEmblem()} | ||
<div class="description">${unsafeHTML(this.description)}</div> | ||
${this._renderStats()} | ||
${this._renderActions()} | ||
</div> | ||
${this._renderCredential()} | ||
</div> | ||
</cxl-section> | ||
`; | ||
} | ||
firstUpdated(_changedProperties) { | ||
super.firstUpdated(_changedProperties); | ||
// Global styles. | ||
registerGlobalStyles(cxlCertificateHeaderGlobalStyles, { | ||
moduleId: 'cxl-certificate-header-global', | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.