Skip to content

Commit

Permalink
feat: add dates to Goodreads Last PR and GitHub Last Update (#274)
Browse files Browse the repository at this point in the history
This PR updates the Goodreads Last Pull Request and GitHub Last Update
cards to include the update date, matching the content provided for the
GitHub Pinned Items cards. This PR closes #152.

## Screenshots

### Goodreads Last Update

| Before | After |
|--------|-------|
|
![before](https://github.com/user-attachments/assets/c1996546-acb7-4dce-a841-b1c72232b275)
|
![after](https://github.com/user-attachments/assets/3e00dbdb-011d-4767-b296-4982ae2b9d6c)
|

### GitHub Pull Request

| Before | After |
|--------|-------|
| Unavailable |
![gh-after-optimized](https://github.com/user-attachments/assets/a9190010-a175-4658-a70a-8173ba626963)
|

> [!NOTE]
> I'm on an airplane and having trouble uploading the before photo so
I'm skipping that altogether.
  • Loading branch information
chrisvogt authored Dec 22, 2024
1 parent 40a094e commit 4d4608f
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 26 deletions.
2 changes: 1 addition & 1 deletion theme/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "gatsby-theme-chrisvogt",
"description": "My personal blog and website.",
"version": "0.33.1",
"version": "0.33.2",
"author": "Chris Vogt <[email protected]> (https://www.chrisvogt.me)",
"main": "index.js",
"license": "MIT",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ exports[`GitHub Widget matches the loading state snapshot 1`] = `
}
/>
<div
className="css-5cryjx"
className="css-b5lvlf"
>
<div
className="text-row show-loading-animation"
Expand All @@ -447,7 +447,7 @@ exports[`GitHub Widget matches the loading state snapshot 1`] = `
"height": "15px",
"marginTop": 0,
"maxHeight": undefined,
"width": "15px",
"width": "150px",
}
}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ exports[`Widget/GitHub/LastPullRequest snapshots matches the loading state snaps
}
/>
<div
className="css-1x5vc5t"
className="css-1c6hy0j"
>
<div
className="text-row show-loading-animation"
Expand All @@ -38,7 +38,7 @@ exports[`Widget/GitHub/LastPullRequest snapshots matches the loading state snaps
"height": "15px",
"marginTop": 0,
"maxHeight": undefined,
"width": "15px",
"width": "150px",
}
}
/>
Expand Down Expand Up @@ -66,21 +66,18 @@ exports[`Widget/GitHub/LastPullRequest snapshots matches the repository variant
>
<span>
Add fake information to the fake project's repository
(
<span
className="css-7f3d9a"
>
#
42
</span>
) – in
– in
<em>
Fake Project
</em>
</span>
<div
className="css-1x5vc5t"
className="css-1c6hy0j"
>
<span>
Merged
NaN years ago
</span>
<span>
<svg
aria-hidden="true"
Expand Down
10 changes: 6 additions & 4 deletions theme/src/components/widgets/github/last-pull-request.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ import { Themed } from '@theme-ui/mdx'
import { Box, Card, Heading } from '@theme-ui/components'
import Placeholder from 'react-placeholder'
import { TextRow } from 'react-placeholder/lib/placeholders'
import ago from 's-ago'

import CardFooter from '../card-footer'
import ViewExternal from '../view-external'

const LastPullRequest = ({ isLoading, pullRequest = {} }) => {
const { number, repository: { name: repositoryName } = {}, title, url } = pullRequest
const { closedAt, repository: { name: repositoryName } = {}, title, url } = pullRequest

return (
<Box>
Expand Down Expand Up @@ -41,17 +42,18 @@ const LastPullRequest = ({ isLoading, pullRequest = {} }) => {
showLoadingAnimation
>
<span>
{title} (<span sx={{ fontWeight: 600 }}>#{number}</span>) – in <em>{repositoryName}</em>
{title} – in <em>{repositoryName}</em>
</span>
</Placeholder>

<CardFooter customStyles={{ justifyContent: 'flex-end' }}>
<CardFooter>
<Placeholder
color='#efefef'
customPlaceholder={<TextRow color='#efefef' style={{ marginTop: 0, width: '15px', height: '15px' }} />}
customPlaceholder={<TextRow color='#efefef' style={{ marginTop: 0, width: '150px', height: '15px' }} />}
ready={!isLoading}
showLoadingAnimation
>
<span>Merged {ago(new Date(closedAt))}</span>
<ViewExternal platform='GitHub' />
</Placeholder>
</CardFooter>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -360,17 +360,17 @@ exports[`Goodreads Widget matches the loading state snapshot 1`] = `
}
/>
<div
className="css-5cryjx"
className="css-b5lvlf"
>
<div
className="text-row show-loading-animation"
style={
{
"backgroundColor": undefined,
"height": "1em",
"backgroundColor": "#efefef",
"height": "15px",
"marginTop": 0,
"maxHeight": undefined,
"width": "140px",
"width": "150px",
}
}
/>
Expand Down
10 changes: 6 additions & 4 deletions theme/src/components/widgets/goodreads/user-status.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const mapStatusToTemplate = {
}

const UserStatus = ({ isLoading, status, actorName }) => {
const { link, type, updated } = status
const { created, link, type } = status

const statusText = mapStatusToTemplate[type] ? mapStatusToTemplate[type](status) : 'Loading...'

Expand Down Expand Up @@ -56,16 +56,18 @@ const UserStatus = ({ isLoading, status, actorName }) => {
showLoadingAnimation
>
<span>
{actorName} {statusText} <em>{ago(new Date(updated))}</em>
{actorName} {statusText}
</span>
</Placeholder>
<CardFooter customStyles={{ justifyContent: 'flex-end' }}>

<CardFooter>
<Placeholder
color='#efefef'
customPlaceholder={<TextRow style={{ marginTop: 0, width: '140px' }} />}
customPlaceholder={<TextRow color='#efefef' style={{ marginTop: 0, width: '150px', height: '15px' }} />}
ready={!isLoading}
showLoadingAnimation
>
<span>Posted {ago(new Date(created))}</span>
<ViewExternal platform='Goodreads' />
</Placeholder>
</CardFooter>
Expand Down

0 comments on commit 4d4608f

Please sign in to comment.