-
-
Notifications
You must be signed in to change notification settings - Fork 496
[FEAT] Show Genres and Release date on Game Page #3330
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 18 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
a919be3
feat: get genre and release date from pcgw
flavioislima dea803a
chore: do not upload snaps
flavioislima 2446b95
fix: genres spaces
flavioislima e30e9ff
Merge branch 'main' of github.com:Heroic-Games-Launcher/HeroicGamesLa…
flavioislima 5b17c15
[FEAT] Show Genres and Release date on Game Page
flavioislima 1e8acbe
i18n: updated keys
flavioislima 19b72d0
feat: add info to new design as well
flavioislima 9310269
fix: lint
flavioislima 363342d
fix: tests
flavioislima 3caec0f
Merge branch 'main' into feat/pcgw_improvements
flavioislima 9fb5caa
fix: PR comments
flavioislima 6ce509c
fix: check if valid date before showing
flavioislima a6a99ce
fix: double padding
flavioislima 368d79e
fix: lint
flavioislima 4b44a3f
Merge branch 'main' of github.com:Heroic-Games-Launcher/HeroicGamesLa…
flavioislima f398859
i18n: updated keys
flavioislima 8ff7fbb
Merge branch 'feat/pcgw_improvements' of github.com:Heroic-Games-Laun…
flavioislima 8e4605a
Merge branch 'main' into feat/pcgw_improvements
flavioislima f080921
Update public/locales/en/translation.json
flavioislima File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,23 @@ | ||
import React from 'react' | ||
|
||
type GenresProps = { | ||
genres: string[] | ||
} | ||
|
||
const Genres: React.FC<GenresProps> = ({ genres }) => { | ||
if (genres[0] === '' || genres.length === 0) { | ||
return null | ||
} | ||
|
||
return ( | ||
<span className="genres"> | ||
{genres.map((genre) => ( | ||
<span key={genre} className="genre"> | ||
{genre} | ||
</span> | ||
))} | ||
</span> | ||
) | ||
} | ||
|
||
export default Genres |
74 changes: 74 additions & 0 deletions
74
src/frontend/screens/Game/GamePage/components/ReleaseDate.tsx
This file contains hidden or 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,74 @@ | ||
import React, { useContext } from 'react' | ||
import { useTranslation } from 'react-i18next' | ||
import GameContext from '../../GameContext' | ||
|
||
type ReleaseDateProps = { | ||
date: string[] | undefined | ||
} | ||
|
||
// convert date to current locale using Intl module | ||
function convertDate(date: string) { | ||
// Extract only the date part if the string contains extra information | ||
const match = date.match(/(\w+ \d{1,2}, \d{4})/) | ||
if (match) { | ||
date = match[1] | ||
} | ||
|
||
const options: Intl.DateTimeFormatOptions = { | ||
year: 'numeric', | ||
month: 'long', | ||
day: 'numeric' | ||
} | ||
|
||
const dateObj = new Date(date) | ||
|
||
// Check if dateObj is a valid date | ||
if (isNaN(dateObj.getTime())) { | ||
return null | ||
} | ||
|
||
return dateObj.toLocaleDateString(undefined, options) | ||
arielj marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
const ReleaseDate: React.FC<ReleaseDateProps> = ({ date }) => { | ||
const { is } = useContext(GameContext) | ||
|
||
const { t } = useTranslation() | ||
|
||
if (!date || date[0] === '' || date.length === 0) { | ||
return null | ||
} | ||
|
||
const getReleaseDate = () => { | ||
let windowsReleaseDate = '' | ||
|
||
for (let i = 0; i < date.length; i++) { | ||
const [platformName, releaseDate] = date[i].split(': ') | ||
|
||
if (platformName === 'Windows') { | ||
windowsReleaseDate = releaseDate | ||
} | ||
|
||
if ( | ||
(platformName === 'Linux' && is.linuxNative && is.linux) || | ||
(platformName === 'OS X' && is.macNative && is.mac) | ||
) { | ||
return convertDate(releaseDate) | ||
} | ||
} | ||
|
||
return convertDate(windowsReleaseDate) | ||
} | ||
|
||
if (!getReleaseDate()) { | ||
return null | ||
} | ||
|
||
return ( | ||
<div className="releaseDate"> | ||
{t('label.releaseDate', 'Release Date')}: {getReleaseDate()} | ||
</div> | ||
) | ||
} | ||
|
||
export default ReleaseDate |
This file contains hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.