-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c83fa0f
commit 7066a85
Showing
13 changed files
with
110 additions
and
45,273 deletions.
There are no files selected for viewing
This file contains 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 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 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 |
---|---|---|
@@ -1 +1 @@ | ||
18 | ||
20 |
58 changes: 32 additions & 26 deletions
58
components/legacy-components/src/article-card/article-card.js
This file contains 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 |
---|---|---|
@@ -1,47 +1,53 @@ | ||
import { Link } from "@reach/router" | ||
import { format as formatDate } from 'date-fns' | ||
import React from "react" | ||
import ResponsiveImage from '../responsive-image' | ||
|
||
export default function articleCard({ article, linkImplementation = Link, withBody = true, withImage = true, withDate = true }) { | ||
|
||
const date = new Date(article.date) | ||
const LinkImplementation = linkImplementation | ||
import { Link } from "@reach/router"; | ||
import { format as formatDate } from "date-fns"; | ||
import React from "react"; | ||
import ResponsiveImage from "../responsive-image"; | ||
|
||
export function ArticleCard({ | ||
article, | ||
linkImplementation = Link, | ||
withBody = true, | ||
withImage = true, | ||
withDate = true, | ||
}) { | ||
const date = new Date(article.date); | ||
const LinkImplementation = linkImplementation; | ||
|
||
return ( | ||
<div className="alex-card"> | ||
|
||
<div className="alex-card__content--container"> | ||
|
||
<div className="alex-card__title"> | ||
<h3><LinkImplementation to={article.slug}>{article.title}</LinkImplementation></h3> | ||
<h3> | ||
<LinkImplementation to={article.slug}> | ||
{article.title} | ||
</LinkImplementation> | ||
</h3> | ||
</div> | ||
|
||
{(withBody !== false) ? | ||
{withBody !== false ? ( | ||
<div className="alex-card__abstract"> | ||
<p> | ||
{article.content.excerpt} | ||
</p> | ||
<p>{article.content.excerpt}</p> | ||
</div> | ||
: null} | ||
) : null} | ||
|
||
{(withDate !== false) ? | ||
{withDate !== false ? ( | ||
<div className="alex-card__timetamp"> | ||
<span className="dateline"> | ||
<time dateTime={date.toISOString()}>{formatDate(date, "d MMM yyyy")}</time> | ||
<time dateTime={date.toISOString()}> | ||
{formatDate(date, "d MMM yyyy")} | ||
</time> | ||
</span> | ||
</div> | ||
: null} | ||
|
||
) : null} | ||
</div> | ||
|
||
{(withImage !== false && article.image && article.image.thumbnail) ? | ||
{withImage !== false && article.image && article.image.thumbnail ? ( | ||
<div className="alex-card__image"> | ||
<ResponsiveImage src={article.image.thumbnail} width={400} /> | ||
</div> | ||
: null} | ||
|
||
) : null} | ||
</div> | ||
) | ||
|
||
); | ||
} | ||
|
||
export default ArticleCard; |
This file contains 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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import './responsive-image.scss' | ||
import ResponsiveImage from './responsive-image' | ||
export {ResponsiveImage} | ||
export default ResponsiveImage | ||
import "./responsive-image.scss"; | ||
import ResponsiveImage from "./responsive-image"; | ||
export { ResponsiveImage }; | ||
export default ResponsiveImage; |
33 changes: 21 additions & 12 deletions
33
components/legacy-components/src/responsive-image/responsive-image.js
This file contains 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 |
---|---|---|
@@ -1,24 +1,33 @@ | ||
import React from 'react' | ||
import React from "react"; | ||
|
||
export default function responsiveImage({src, alt, width, height, quality, format, className}) { | ||
|
||
const queryParams = [] | ||
if (Number.isInteger(width)) queryParams.push(`width=${width}`) | ||
if (Number.isInteger(height)) queryParams.push(`height=${height}`) | ||
export function ResponsiveImage({ | ||
src, | ||
alt, | ||
width, | ||
height, | ||
quality, | ||
format, | ||
className, | ||
}) { | ||
const queryParams = []; | ||
if (Number.isInteger(width)) queryParams.push(`width=${width}`); | ||
if (Number.isInteger(height)) queryParams.push(`height=${height}`); | ||
|
||
if (quality) { | ||
queryParams.push(`quality=${quality}`) | ||
queryParams.push(`quality=${quality}`); | ||
} | ||
|
||
if (format) { | ||
queryParams.push(`format=${format}`) | ||
queryParams.push(`format=${format}`); | ||
} | ||
|
||
return ( | ||
<img | ||
src={`https://imagecdn.app/v2/image/${encodeURIComponent(src)}?${queryParams.join('&')}`} | ||
className={`responsive-image ${className}`} | ||
alt={alt} | ||
src={`https://imagecdn.app/v2/image/${encodeURIComponent(src)}?${queryParams.join("&")}`} | ||
className={`responsive-image ${className}`} | ||
alt={alt} | ||
/> | ||
) | ||
); | ||
} | ||
|
||
export default ResponsiveImage; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.