Add files for assignment 01
This commit is contained in:
parent
51d9be7063
commit
187b450f85
BIN
Tasks/Task 01/assignment_01.pdf
Normal file
BIN
Tasks/Task 01/assignment_01.pdf
Normal file
Binary file not shown.
BIN
Tasks/Task 01/navibar/imgs/coffee.png
Normal file
BIN
Tasks/Task 01/navibar/imgs/coffee.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
BIN
Tasks/Task 01/navibar/imgs/home.png
Normal file
BIN
Tasks/Task 01/navibar/imgs/home.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 876 B |
BIN
Tasks/Task 01/navibar/imgs/map.png
Normal file
BIN
Tasks/Task 01/navibar/imgs/map.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.6 KiB |
BIN
Tasks/Task 01/navibar/imgs/settings.png
Normal file
BIN
Tasks/Task 01/navibar/imgs/settings.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.6 KiB |
37
Tasks/Task 01/navibar/navibar.html
Normal file
37
Tasks/Task 01/navibar/navibar.html
Normal file
|
@ -0,0 +1,37 @@
|
|||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Navibar Demo</title>
|
||||
|
||||
<script src="navibar.js"></script>
|
||||
|
||||
<style>
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
navigation-bar {
|
||||
width: 100vw;
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
/* ... */
|
||||
}
|
||||
|
||||
navigation-bar a img {
|
||||
opacity: 0.3;
|
||||
/* ... */
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
26
Tasks/Task 01/navibar/navibar.js
Normal file
26
Tasks/Task 01/navibar/navibar.js
Normal file
|
@ -0,0 +1,26 @@
|
|||
class CustomNavigationBar extends HTMLElement {
|
||||
constructor() {
|
||||
super()
|
||||
const shadowRoot = this.attachShadow({mode: 'open'})
|
||||
shadowRoot.innerHTML = `
|
||||
<style>
|
||||
div.navibar {
|
||||
align-items: center;
|
||||
background-color: #ccc;
|
||||
margin: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
::slotted(a) {
|
||||
display: block;
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
<div class="navibar">
|
||||
<slot></slot>
|
||||
</div>`
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
customElements.define('navigation-bar', CustomNavigationBar)
|
25
Tasks/Task 01/progress/demo.html
Normal file
25
Tasks/Task 01/progress/demo.html
Normal file
|
@ -0,0 +1,25 @@
|
|||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Progress Bar Demo</title>
|
||||
|
||||
<script src="progress.js"></script>
|
||||
<script src="demo.js"></script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>
|
||||
<custom-progress-bar />
|
||||
</p>
|
||||
<p>
|
||||
<custom-progress-bar value="25" />
|
||||
</p>
|
||||
<p>
|
||||
<custom-progress-bar value="0" />
|
||||
</p>
|
||||
|
||||
</body>
|
||||
</html>
|
17
Tasks/Task 01/progress/demo.js
Normal file
17
Tasks/Task 01/progress/demo.js
Normal file
|
@ -0,0 +1,17 @@
|
|||
/*
|
||||
* Progress Bar Demo
|
||||
*/
|
||||
|
||||
window.onload = () => {
|
||||
document.querySelector('p:nth-child(1) custom-progress-bar').progress = 75;
|
||||
document.querySelector('p:nth-child(2) custom-progress-bar');
|
||||
|
||||
var pb = document.querySelector('p:nth-child(3) custom-progress-bar');
|
||||
setInterval(() => changePb(pb), 20);
|
||||
}
|
||||
|
||||
const changePb = (pb) => {
|
||||
if (Math.random()>0.85) {
|
||||
pb.progress = (parseInt(pb.progress)+1) % 101;
|
||||
}
|
||||
}
|
59
Tasks/Task 01/progress/progress.js
Normal file
59
Tasks/Task 01/progress/progress.js
Normal file
|
@ -0,0 +1,59 @@
|
|||
class CustomProgressBar extends HTMLElement {
|
||||
constructor() {
|
||||
super();
|
||||
const shadowRoot = this.attachShadow({mode: 'open'});
|
||||
shadowRoot.innerHTML = `
|
||||
<style>
|
||||
:host {
|
||||
display: inline-block;
|
||||
width: 5rem;
|
||||
height: 1rem;
|
||||
}
|
||||
.progress {
|
||||
display: inline-block;
|
||||
position: relative;
|
||||
border: solid 1px #000;
|
||||
padding: 1px;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
.progress > .bar {
|
||||
background: #9cf;
|
||||
height: 100%;
|
||||
}
|
||||
.progress > .label {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
font-size: 0.8rem;
|
||||
line-height: 1.1rem;
|
||||
}
|
||||
</style>
|
||||
<div class="progress" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100">
|
||||
<div class="bar" style="width: 0px;"></div>
|
||||
<div class="label">0%</div>
|
||||
</div>
|
||||
`;
|
||||
this._progressElement = shadowRoot.querySelector('.progress');
|
||||
this._label = shadowRoot.querySelector('.label');
|
||||
this._bar = shadowRoot.querySelector('.bar');
|
||||
}
|
||||
|
||||
static get observedAttributes() { return ['value']; }
|
||||
attributeChangedCallback(name, oldValue, newValue, namespaceURI) {
|
||||
if (name === 'value') {
|
||||
const newPercentage = newValue === null ? 0 : parseInt(newValue);
|
||||
this._progressElement.setAttribute('aria-valuenow', newPercentage);
|
||||
this._label.textContent = newPercentage + '%';
|
||||
this._bar.style.width = newPercentage + '%';
|
||||
}
|
||||
}
|
||||
|
||||
get progress() { return this.getAttribute('value'); }
|
||||
set progress(newValue) { this.setAttribute('value', newValue); }
|
||||
};
|
||||
|
||||
|
||||
customElements.define('custom-progress-bar', CustomProgressBar);
|
Loading…
Reference in a new issue