diff --git a/src/common/playlists/PlayHeaderInfo.jsx b/src/common/playlists/PlayHeaderInfo.jsx index 4646a07cbe..869c6dc24f 100644 --- a/src/common/playlists/PlayHeaderInfo.jsx +++ b/src/common/playlists/PlayHeaderInfo.jsx @@ -1,9 +1,25 @@ import { IoMdArrowBack } from 'react-icons/io'; import { Link } from 'react-router-dom'; import LevelBadge from 'common/components/LevelBadge'; +import { format } from 'date-fns'; +import * as allLocales from 'date-fns/locale'; +import { useState } from 'react'; import { email2Slug } from 'common/services/string'; -const Author = ({ user }) => { +const Author = ({ playCreatedAt, user }) => { + const [formattedPlayDate] = useState(() => { + // Get the locale from the local browser + const locale = navigator.language.split('-').join(''); + + // Get matching locale from date-fns + const dnsLocale = allLocales[locale] ?? allLocales.enUS; + + // Return formatted date with the browser locale + return format(new Date(playCreatedAt), 'MMM dd, yyyy', { + locale: dnsLocale + }); + }); + const getHostName = () => { var url = window.location.href; var arr = url.split('/'); @@ -13,16 +29,21 @@ const Author = ({ user }) => { }; return ( -
+
avatar - - {user?.displayName} - +
+ + {user?.displayName} + + + + {/* Formatted date goes here */} + {formattedPlayDate} +
); }; @@ -41,7 +62,7 @@ const Tags = ({ tags }) => { const PlayHeaderInfo = ({ play }) => { return ( -
+
@@ -56,8 +77,10 @@ const PlayHeaderInfo = ({ play }) => { {!!play.play_tags.length && }
-
- {play.user && } +
+ {play.user && ( + + )}
diff --git a/src/common/playlists/playlist.css b/src/common/playlists/playlist.css index f78bec3a2d..6622a8d60f 100644 --- a/src/common/playlists/playlist.css +++ b/src/common/playlists/playlist.css @@ -414,10 +414,12 @@ .play-details .play-details-header .header-secondary { display: flex; - flex-direction: row; + /* flex-direction: row; */ + flex-direction: column; flex-wrap: wrap; grid-gap: 0.2rem 0.6rem; - align-items: center; + /* align-items: center; */ + align-items: start; } @media screen and (max-width: 768px) {