Skip to content

Commit bda95b0

Browse files
Merge pull request #9 from appwrite/feat-route-transition
draft: route transition and global cover component
2 parents f573024 + 06f333b commit bda95b0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+705
-703
lines changed

package-lock.json

Lines changed: 14 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
"e2e": "playwright test tests/e2e"
2020
},
2121
"dependencies": {
22-
"@aw-labs/ui": "*"
22+
"@aw-labs/ui": "^0.0.0-4",
23+
"@aw-labs/icons": "^0.0.0-4"
2324
},
2425
"devDependencies": {
2526
"@playwright/test": "^1.22.1",

src/lib/components/card.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
<article class="card">
1+
<article class="card common-section">
22
<slot />
33
</article>

src/lib/components/empty.svelte

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
<script>
2-
import { Card } from '.';
2+
export let dashed = false;
3+
export let centered = false;
34
</script>
45

5-
<Card>
6-
<b>
7-
<slot name="header" />
8-
</b>
9-
<p>
10-
<slot />
11-
</p>
12-
</Card>
6+
<article
7+
class="card common-section u-flex u-flex-vertical"
8+
class:is-border-dashed={dashed}
9+
class:u-cross-center={centered}>
10+
<slot />
11+
</article>

src/lib/components/modal.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,14 @@
4848
aria-label="Close Modal"
4949
title="Close Modal"
5050
on:click={closeModal}>
51-
<span class="icon-cancel" aria-hidden="true" />
51+
<span class="icon-x" aria-hidden="true" />
5252
</button>
5353
</header>
5454
<div class="modal-content">
5555
<slot />
5656
</div>
5757
<div class="modal-footer">
58-
<div class="u-flex u-gap-10">
58+
<div class="u-flex u-main-space-end u-gap-12">
5959
<slot name="footer" />
6060
</div>
6161
</div>

src/lib/components/pagination.svelte

Lines changed: 36 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
offset = limit * (page - 1);
1414
currentPage = page;
1515
dispatch('change');
16+
pages = pagination(currentPage, totalPages);
1617
}
1718
}
1819
@@ -21,36 +22,32 @@
2122
currentPage += 1;
2223
offset = limit * (currentPage - 1);
2324
dispatch('change');
25+
pages = pagination(currentPage, totalPages);
2426
} else if (direction === 'prev' && currentPage > 1) {
2527
currentPage -= 1;
2628
offset = limit * (currentPage - 1);
2729
dispatch('change');
30+
pages = pagination(currentPage, totalPages);
2831
}
2932
}
3033
3134
let pages = pagination(currentPage, totalPages);
3235
33-
function pagination(current: number, total: number) {
34-
let delta = 2,
35-
left = current - delta,
36-
right = current + delta + 1,
37-
range = [],
38-
rangeWithDots = [];
39-
40-
for (let i = 1; i <= total; i++) {
41-
if (i == 1 || i == total || (i >= left && i < right)) {
42-
range.push(i);
43-
}
44-
}
45-
46-
rangeWithDots = range.reduce((prev, current, index) => {
47-
if (current - prev[index - 1] > delta) {
48-
prev.push('...');
49-
}
50-
prev.push(current);
51-
return prev;
52-
}, []);
53-
return rangeWithDots;
36+
function pagination(page: number, total: number) {
37+
const pagesShown = 5;
38+
const start = Math.max(
39+
1,
40+
Math.min(page - Math.floor((pagesShown - 3) / 2), total - pagesShown + 2)
41+
);
42+
const end = Math.min(
43+
total,
44+
Math.max(page + Math.floor((pagesShown - 2) / 2), pagesShown - 1)
45+
);
46+
return [
47+
...(start > 2 ? [1, '...'] : start > 1 ? [1] : []),
48+
...Array.from({ length: end + 1 - start }, (_, i) => i + start),
49+
...(end < total - 1 ? ['...', total] : end < total ? [total] : [])
50+
];
5451
}
5552
</script>
5653

@@ -93,4 +90,22 @@
9390
<span class="icon-cheveron-right" aria-hidden="true" />
9491
</button>
9592
</nav>
93+
{:else}
94+
<nav class="pagination">
95+
<button class="button is-text is-disabled" aria-label="prev page">
96+
<span class="icon-cheveron-left" aria-hidden="true" />
97+
<span class="text">Prev</span>
98+
</button>
99+
<ol class="pagination-list is-only-desktop">
100+
<li class="pagination-item">
101+
<button class="button is-disabled" aria-label="page">
102+
<span class="text">1</span>
103+
</button>
104+
</li>
105+
</ol>
106+
<button class="button is-text is-disabled" aria-label="next page">
107+
<span class="text">Next</span>
108+
<span class="icon-cheveron-right" aria-hidden="true" />
109+
</button>
110+
</nav>
96111
{/if}

src/lib/elements/forms/button.svelte

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
export let outline = false;
55
export let danger = false;
66
export let disabled = false;
7+
export let round = false;
78
export let href: string = null;
89
</script>
910

@@ -12,6 +13,7 @@
1213
{disabled}
1314
{href}
1415
class="button"
16+
class:is-only-icon={round}
1517
class:is-secondary={secondary}
1618
class:is-outline={outline}
1719
class:is-danger={danger}>
@@ -22,6 +24,7 @@
2224
on:click
2325
{disabled}
2426
class="button"
27+
class:is-only-icon={round}
2528
class:is-secondary={secondary}
2629
class:is-outline={outline}
2730
class:is-danger={danger}

src/lib/elements/table/cellHead.svelte

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,9 @@
77
<slot />
88
</span>
99
</th>
10+
11+
<style>
12+
th {
13+
text-transform: uppercase;
14+
}
15+
</style>

src/lib/helpers/date.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,16 @@ export const toLocaleDate = (timestamp: number) => {
44

55
return date.toLocaleDateString('en', options);
66
};
7+
8+
export const toLocaleDateTime = (timestamp: number) => {
9+
const date = new Date(timestamp * 1000);
10+
const options: Intl.DateTimeFormatOptions = {
11+
year: 'numeric',
12+
month: 'long',
13+
day: 'numeric',
14+
hour: 'numeric',
15+
minute: 'numeric'
16+
};
17+
18+
return date.toLocaleDateString('en', options);
19+
};

src/lib/layout/cover.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<div class="top-cover" class:is-adjust-content-to-cover={adjustContentToCover}>
66
<div class="container">
7-
<h1 class="heading-level-1">
7+
<h1 class="heading-level-2">
88
<slot name="title" />
99
</h1>
1010
<slot />

0 commit comments

Comments
 (0)