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-stats
component
- Loading branch information
Showing
8 changed files
with
123 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
@use "~@conversionxl/cxl-lumo-styles/scss/mq"; | ||
|
||
:host { | ||
display: grid; | ||
grid-template-columns: repeat(2, 1fr); | ||
gap: var(--lumo-space-m); | ||
padding: var(--lumo-space-xl) var(--lumo-space-m) var(--lumo-space-m); | ||
border-bottom: 1px solid var(--cxl-color-light-gray); | ||
|
||
@media #{mq.$small} { | ||
padding: var(--lumo-space-xl) var(--lumo-space-l) var(--lumo-space-l); | ||
} | ||
|
||
@media #{mq.$medium} { | ||
grid-template-columns: repeat(4, 1fr); | ||
} | ||
} |
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,16 @@ | ||
cxl-stats { | ||
.stats-title { | ||
margin-top: 0; | ||
font-size: var(--lumo-font-size-xs); | ||
font-weight: 400; | ||
line-height: 1; | ||
color: var(--cxl-color-black-50pct); | ||
text-transform: uppercase; | ||
} | ||
|
||
.stats-count { | ||
margin: 0; | ||
font-size: var(--lumo-font-size-xxl); | ||
font-weight: 700; | ||
} | ||
} |
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,28 @@ | ||
// eslint-disable-next-line import/no-extraneous-dependencies | ||
import { LitElement, html } from 'lit'; | ||
// eslint-disable-next-line import/no-extraneous-dependencies | ||
import { customElement } from 'lit/decorators.js'; | ||
import { registerGlobalStyles } from '@conversionxl/cxl-lumo-styles/src/utils'; | ||
import '@conversionxl/cxl-lumo-styles'; | ||
import cxlStatsStyles from '../styles/cxl-stats-css.js'; | ||
import cxlStatsGlobalStyles from '../styles/global/cxl-stats-css.js'; | ||
|
||
@customElement('cxl-stats') | ||
export class CXLStatsElement extends LitElement { | ||
static get styles() { | ||
return [cxlStatsStyles]; | ||
} | ||
|
||
render() { | ||
return html`<slot></slot>`; | ||
} | ||
|
||
firstUpdated(_changedProperties) { | ||
super.firstUpdated(_changedProperties); | ||
|
||
// Global styles. | ||
registerGlobalStyles(cxlStatsGlobalStyles, { | ||
moduleId: 'cxl-stats', | ||
}); | ||
} | ||
} |
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,18 @@ | ||
[ | ||
{ | ||
"title": "Categories<br>completed", | ||
"count": "1" | ||
}, | ||
{ | ||
"title": "Courses<br>completed", | ||
"count": "30" | ||
}, | ||
{ | ||
"title": "Lessons<br>completed", | ||
"count": "95" | ||
}, | ||
{ | ||
"title": "Complete<br>library", | ||
"count": "12%" | ||
} | ||
] |
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,40 @@ | ||
import { html } from 'lit'; | ||
import { unsafeHTML } from 'lit/directives/unsafe-html.js'; | ||
import '@conversionxl/cxl-lumo-styles'; | ||
import '@conversionxl/cxl-ui/src/components/cxl-stats.js'; | ||
import statsData from './cxl-stats.data.json'; | ||
|
||
export default { | ||
title: 'CXL UI/cxl-stats', | ||
}; | ||
|
||
export const CXLStats = ({ statsCount }) => { | ||
for (let i = 0; i < statsCount; i += 1) { | ||
const newItem = { | ||
title: 'Complete<br>library', | ||
count: '12%', | ||
}; | ||
|
||
statsData.push(newItem); | ||
} | ||
|
||
return html` | ||
<cxl-stats class="stats"> | ||
${statsData.slice(0, statsCount).map( | ||
(el) => html` | ||
<div> | ||
<h4 class="stats-title">${unsafeHTML(el.title)}</h4> | ||
<p class="stats-count">${el.count}</p> | ||
</div> | ||
` | ||
)} | ||
</cxl-stats> | ||
`; | ||
}; | ||
|
||
Object.assign(CXLStats, { | ||
args: { | ||
statsCount: 4, | ||
}, | ||
storyName: 'CXL Stats', | ||
}); |