Skip to content

Commit

Permalink
feat: add loading placeholder
Browse files Browse the repository at this point in the history
  • Loading branch information
crymis committed Jun 24, 2024
1 parent c23e305 commit fc9e1a5
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 9 deletions.
8 changes: 7 additions & 1 deletion condensing/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,15 @@ <h1>Order History</h1>
<li class="list-header">
<div></div>
<div class="name">Name</div>
<div class="info">Order n° </div>
<div class="info">Order n°</div>
<div class="quantity">Quantity</div>
</li>
<li class="placeholder">
<div></div>
<div class="name">Loading...</div>
<div class="info"></div>
<div class="quantity"></div>
</li>
</ul>
<aside>
<p>Please select an item.</p>
Expand Down
3 changes: 2 additions & 1 deletion condensing/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ class CondensingSidebar {
item.addEventListener('click', highlightItemAndOpenSidebar);
item.addEventListener('keypress', highlightItemAndOpenSidebar);
});
const loadingPlaceholder = document.querySelector('li.placeholder');
loadingPlaceholder.remove();
}

highlightActiveListItem(event) {
Expand Down Expand Up @@ -88,7 +90,6 @@ function safeStartViewTransition(updateDom) {

async function init() {
new CondensingSidebar(coffeeList);
// TODO, add other demos here
}

init();
12 changes: 6 additions & 6 deletions condensing/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,21 @@ a {

/* element swap */
::view-transition-old(details) {
animation: slide-down 0.2s both ease-in-out;
animation: slide-start 0.24s both ease-in-out;
}

::view-transition-new(details) {
animation: slide-up 0.2s both ease-in-out;
animation: slide-end 0.24s both ease-in-out;
}

/* element leave */
::view-transition-old(details):only-child {
animation: slide-in 0.2s both ease-in reverse;
animation: slide-in 0.24s both ease-in reverse;
}

/* element enter */
::view-transition-new(details):only-child {
animation: slide-in 0.2s both ease-out;
animation: slide-in 0.24s both ease-out;
}

@container list (max-width: 400px) {
Expand Down Expand Up @@ -362,7 +362,7 @@ a {
}
}

@keyframes slide-up {
@keyframes slide-end {
from {
transform: translateX(100%);
opacity: 0;
Expand All @@ -374,7 +374,7 @@ a {
}
}

@keyframes slide-down {
@keyframes slide-start {
from {
transform: translateX(0);
opacity: 1;
Expand Down
6 changes: 6 additions & 0 deletions overlapping/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ <h1>Order History</h1>
<div class="info">Order n° </div>
<div class="quantity">Quantity</div>
</li>
<li class="placeholder">
<div></div>
<div class="name">Loading...</div>
<div class="info"></div>
<div class="quantity"></div>
</li>
</ul>
<dialog></dialog>
</main>
Expand Down
2 changes: 2 additions & 0 deletions overlapping/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ class OverlappingSidebar {
item.addEventListener('click', highlightItemAndOpenSidebar);
item.addEventListener('keypress', highlightItemAndOpenSidebar);
});
const loadingPlaceholder = document.querySelector('li.placeholder');
loadingPlaceholder.remove();
}

highlightActiveListItem(event) {
Expand Down
6 changes: 6 additions & 0 deletions reserved/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ <h1>Order History</h1>
<div class="info">Order n° </div>
<div class="quantity">Quantity</div>
</li>
<li class="placeholder">
<div></div>
<div class="name">Loading...</div>
<div class="info"></div>
<div class="quantity"></div>
</li>
</ul>
<aside>
<p class="placeholder">Please select an item.</p>
Expand Down
4 changes: 3 additions & 1 deletion reserved/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ class ReservedSidebar {
item.addEventListener('click', highlightItemAndReplaceSidebarContent);
item.addEventListener('keypress', highlightItemAndReplaceSidebarContent);
});
const loadingPlaceholder = document.querySelector('li.placeholder');
loadingPlaceholder.remove();
}

highlightActiveListItem(event) {
Expand Down Expand Up @@ -42,7 +44,7 @@ class ReservedSidebar {
detailsTempCloneDesc.textContent = description;
detailsTempClonePaymentBadge.textContent = paymentType;
detailsEl.replaceChildren(detailsTempClone);
animateBorderOnImgLoad(detailsTempCloneImg);
this.animateBorderOnImgLoad(detailsTempCloneImg);
}

addItemToList({ name, quantity, info, imgSrc }) {
Expand Down

0 comments on commit fc9e1a5

Please sign in to comment.