[APP-611] Add nice date to expanded post view (#567)
* Add nice date to expanded post view * Fix styleszio/stable
parent
6f1c4ec9a9
commit
2eb0d8c095
|
@ -27,3 +27,15 @@ export function ago(date: number | string | Date): string {
|
||||||
return new Date(ts).toLocaleDateString()
|
return new Date(ts).toLocaleDateString()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function niceDate(date: number | string | Date) {
|
||||||
|
const d = new Date(date)
|
||||||
|
return `${d.toLocaleDateString('en-us', {
|
||||||
|
year: 'numeric',
|
||||||
|
month: 'short',
|
||||||
|
day: 'numeric',
|
||||||
|
})} at ${d.toLocaleTimeString(undefined, {
|
||||||
|
hour: 'numeric',
|
||||||
|
minute: '2-digit',
|
||||||
|
})}`
|
||||||
|
}
|
||||||
|
|
|
@ -122,12 +122,15 @@ export const s = StyleSheet.create({
|
||||||
ml2: {marginLeft: 2},
|
ml2: {marginLeft: 2},
|
||||||
ml5: {marginLeft: 5},
|
ml5: {marginLeft: 5},
|
||||||
ml10: {marginLeft: 10},
|
ml10: {marginLeft: 10},
|
||||||
|
ml20: {marginLeft: 20},
|
||||||
mt2: {marginTop: 2},
|
mt2: {marginTop: 2},
|
||||||
mt5: {marginTop: 5},
|
mt5: {marginTop: 5},
|
||||||
mt10: {marginTop: 10},
|
mt10: {marginTop: 10},
|
||||||
|
mt20: {marginTop: 20},
|
||||||
mb2: {marginBottom: 2},
|
mb2: {marginBottom: 2},
|
||||||
mb5: {marginBottom: 5},
|
mb5: {marginBottom: 5},
|
||||||
mb10: {marginBottom: 10},
|
mb10: {marginBottom: 10},
|
||||||
|
mb20: {marginBottom: 20},
|
||||||
|
|
||||||
// paddings
|
// paddings
|
||||||
p2: {padding: 2},
|
p2: {padding: 2},
|
||||||
|
|
|
@ -15,7 +15,7 @@ import {PostDropdownBtn} from '../util/forms/DropdownButton'
|
||||||
import * as Toast from '../util/Toast'
|
import * as Toast from '../util/Toast'
|
||||||
import {UserAvatar} from '../util/UserAvatar'
|
import {UserAvatar} from '../util/UserAvatar'
|
||||||
import {s} from 'lib/styles'
|
import {s} from 'lib/styles'
|
||||||
import {ago} from 'lib/strings/time'
|
import {ago, niceDate} from 'lib/strings/time'
|
||||||
import {sanitizeDisplayName} from 'lib/strings/display-names'
|
import {sanitizeDisplayName} from 'lib/strings/display-names'
|
||||||
import {pluralize} from 'lib/strings/helpers'
|
import {pluralize} from 'lib/strings/helpers'
|
||||||
import {useStores} from 'state/index'
|
import {useStores} from 'state/index'
|
||||||
|
@ -235,7 +235,10 @@ export const PostThreadItem = observer(function PostThreadItem({
|
||||||
) : undefined}
|
) : undefined}
|
||||||
<PostEmbeds embed={item.post.embed} style={s.mb10} />
|
<PostEmbeds embed={item.post.embed} style={s.mb10} />
|
||||||
</ContentHider>
|
</ContentHider>
|
||||||
{item._isHighlightedPost && hasEngagement ? (
|
<View style={[s.mt2, s.mb10]}>
|
||||||
|
<Text style={pal.textLight}>{niceDate(item.post.indexedAt)}</Text>
|
||||||
|
</View>
|
||||||
|
{hasEngagement ? (
|
||||||
<View style={[styles.expandedInfo, pal.border]}>
|
<View style={[styles.expandedInfo, pal.border]}>
|
||||||
{item.post.repostCount ? (
|
{item.post.repostCount ? (
|
||||||
<Link
|
<Link
|
||||||
|
|
Loading…
Reference in New Issue