-
Notifications
You must be signed in to change notification settings - Fork 218
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into chart-ssr-loading-state
- Loading branch information
Showing
9 changed files
with
90 additions
and
5 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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@evidence-dev/component-utilities': patch | ||
--- | ||
|
||
Explicitly set font family for chart theme |
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,6 @@ | ||
--- | ||
'@evidence-dev/core-components': patch | ||
'@evidence-dev/components': patch | ||
--- | ||
|
||
Add LastRefreshed component |
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,5 @@ | ||
--- | ||
'@evidence-dev/evidence': patch | ||
--- | ||
|
||
fix hard refresh on first project boot |
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
43 changes: 43 additions & 0 deletions
43
packages/core-components/src/lib/unsorted/ui/LastRefreshed.svelte
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,43 @@ | ||
<script context="module"> | ||
export const evidenceInclude = true; | ||
</script> | ||
|
||
<script> | ||
import { version } from '$app/environment'; | ||
const timestamp = Number(version); | ||
export let prefix = 'Last refreshed'; | ||
function timeAgo(startTimestamp, endTimestamp) { | ||
const secondsAgo = Math.floor((endTimestamp - startTimestamp) / 1000); | ||
if (secondsAgo < 60) { | ||
return secondsAgo === 1 ? '1 second ago' : `${secondsAgo} seconds ago`; | ||
} else if (secondsAgo < 3600) { | ||
const minutesAgo = Math.round(secondsAgo / 60); | ||
return minutesAgo === 1 ? '1 min ago' : `${minutesAgo} mins ago`; | ||
} else if (secondsAgo < 86400) { | ||
const hoursAgo = (secondsAgo / 3600).toFixed(1); | ||
return hoursAgo === '1' ? '1 hour ago' : `${hoursAgo} hours ago`; | ||
} else if (secondsAgo < 604800) { | ||
const daysAgo = Math.round(secondsAgo / 86400); | ||
return daysAgo === 1 ? '1 day ago' : `${daysAgo} days ago`; | ||
} else if (secondsAgo < 2592000) { | ||
const weeksAgo = Math.round(secondsAgo / 604800); | ||
return weeksAgo === 1 ? '1 week ago' : `${weeksAgo} weeks ago`; | ||
} else if (secondsAgo < 31536000) { | ||
const monthsAgo = Math.round(secondsAgo / 2592000); | ||
return monthsAgo === 1 ? '1 month ago' : `${monthsAgo} months ago`; | ||
} else { | ||
const yearsAgo = Math.round(secondsAgo / 31536000); | ||
return yearsAgo === 1 ? '1 year ago' : `${yearsAgo} years ago`; | ||
} | ||
} | ||
const varTimeAgo = timeAgo(timestamp, Date.now()); | ||
</script> | ||
|
||
<p class="text-sm py-1 cursor-text" title={new Date(timestamp).toLocaleString()}> | ||
{prefix} | ||
{varTimeAgo} | ||
</p> |
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
17 changes: 17 additions & 0 deletions
17
sites/example-project/src/pages/ui-components/last-refreshed/+page.md
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 @@ | ||
# Last Refreshed | ||
|
||
### Default | ||
|
||
```svelte | ||
<LastRefreshed/> | ||
``` | ||
|
||
<LastRefreshed/> | ||
|
||
### Custom Prefix | ||
|
||
```svelte | ||
<LastRefreshed prefix="Updated"/> | ||
``` | ||
|
||
<LastRefreshed prefix="Updated"/> |