refactor: use padZero function for numbers
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
import { seenLocations } from '$utils/stores'
|
||||
import { photoFields } from '$utils/api'
|
||||
import { PUBLIC_LIST_INCREMENT } from '$env/static/public'
|
||||
import { padZero } from 'utils/string'
|
||||
// Components
|
||||
import Metas from '$components/Metas.svelte'
|
||||
import Image from '$components/atoms/Image.svelte'
|
||||
@@ -294,7 +295,7 @@
|
||||
location={location.name}
|
||||
ratio={width / height}
|
||||
date={date_taken}
|
||||
index="{(totalPhotos - index < 10) ? '0' : ''}{totalPhotos - index}"
|
||||
index={padZero(totalPhotos - index)}
|
||||
/>
|
||||
{/each}
|
||||
</section>
|
||||
|
||||
@@ -13,8 +13,9 @@
|
||||
import { getAssetUrlKey } from '$utils/api'
|
||||
import { previousPage } from '$utils/stores'
|
||||
import { DELAY } from '$utils/constants'
|
||||
import { throttle } from 'utils/actions'
|
||||
import { swipe } from '$utils/interactions/swipe'
|
||||
import { throttle } from 'utils/actions'
|
||||
import { padZero } from 'utils/string'
|
||||
// Components
|
||||
import Metas from '$components/Metas.svelte'
|
||||
import SplitText from '$components/SplitText.svelte'
|
||||
@@ -354,7 +355,8 @@
|
||||
|
||||
|
||||
<div class="photo-page__index title-index">
|
||||
<SplitText text="{(currentPhotoIndex < 10) ? '0' : ''}{currentPhotoIndex}" mode="chars" />
|
||||
<div class="index title-index">
|
||||
<SplitText text={padZero(currentPhotoIndex)} mode="chars" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -4,3 +4,11 @@
|
||||
export const capitalizeFirstLetter = (string: string) => {
|
||||
return string[0].toUpperCase() + string.slice(1)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Pad string or number with zero
|
||||
*/
|
||||
export const padZero = (value: string | number) => {
|
||||
return ('0' + Number(value)).slice(-2)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user