-
-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added
landroid-linear-progress
element to avoid issue with import `…
…mwc-linear-progress` #269
- Loading branch information
Showing
6 changed files
with
106 additions
and
22 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
"es6": true | ||
}, | ||
"parserOptions": { | ||
"ecmaVersion": 2020, | ||
"ecmaVersion": "latest", | ||
"sourceType": "module" | ||
} | ||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,48 @@ | ||
class LandroidLinearProgress extends HTMLElement { | ||
constructor() { | ||
super(); | ||
|
||
this.attachShadow({ mode: 'open' }); | ||
|
||
this.shadowRoot.innerHTML = ` | ||
<style> | ||
:host { | ||
display: block; | ||
width: 100%; | ||
height: 4px; | ||
overflow: hidden; | ||
} | ||
#progress { | ||
width: 0; | ||
height: 100%; | ||
background-color: var(--mdc-theme-primary, #6200ee); | ||
transition: width 0.3s ease; | ||
} | ||
</style> | ||
<div id="progress"></div> | ||
`; | ||
|
||
this.progressElement = this.shadowRoot.getElementById('progress'); | ||
} | ||
|
||
static get observedAttributes() { | ||
return ['progress']; | ||
} | ||
|
||
attributeChangedCallback(name, oldValue, newValue) { | ||
if (name === 'progress') { | ||
this.setProgressBarWidth(newValue); | ||
} | ||
} | ||
|
||
setProgressBarWidth(progress) { | ||
const parsedProgress = parseFloat(progress); | ||
const clampedProgress = isNaN(parsedProgress) | ||
? 0 | ||
: Math.min(100, Math.max(0, parsedProgress)); | ||
this.progressElement.style.width = `${clampedProgress}%`; | ||
} | ||
} | ||
|
||
customElements.define('landroid-linear-progress', LandroidLinearProgress); |
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