Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.
Merged
26 changes: 11 additions & 15 deletions src/components/Hero/__tests__/__snapshots__/hero.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,22 @@ exports[`Hero component renders correctly 1`] = `
<div
className="download-lts-container"
>
<button
className="download-lts-cta t-body1"
type="button"
<a
href="https://nodejs.org/dist//node-.tar.gz"
>
Download Node (LTS)
</button>
<button
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

@giankotarola giankotarola May 3, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ooh yeaa 😕!

I tried it with:

<a className="download-lts-cta t-body1" href={ltsVersionUrl}>
  Download Node (LTS)
</a>

But styles change:

Screen Shot 2020-05-03 at 00 05 09

Also fixing Learn Node button too with:

<Link className="learn-cta t-body1" to="/learn">
  Learn Node
</Link>

And styles are not the same too 😕

Screen Shot 2020-05-03 at 00 06 39

Looking into CSS to could send a PR with the fix for it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @benhalverson! Just a quick question, in this link https://www.figma.com/proto/lOxAGGg5KXb6nwie7zXkz6/NJ---Design-System?scaling=min-zoom&node-id=1338%3A13127, is possible to could see design details as font sizes, color, size, etc?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes click on the figma icon in the top left and signup / signin
You can then see the artboard with those details. The colors fonts and size are already in tokens.scss

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nschonni @benhalverson I have sent a fix in #675

className="download-lts-cta t-body1"
type="button"
>
Download Node (LTS)
</button>
</a>
<p
className="links t-caption"
>
Version 10.15.3
-
<a
href="/download"
>
What’s new
</a>
/


<a
href="/download"
href="https://nodejs.org/dist//node-.tar.gz"
>
Get Current
</a>
Expand Down
93 changes: 71 additions & 22 deletions src/components/Hero/index.tsx
Original file line number Diff line number Diff line change
@@ -1,34 +1,83 @@
import React from 'react';
import { Link } from 'gatsby';

import { detectOS, UserOS } from '../../util/detectOS';
import { useReleaseHistory, ReleaseData } from '../../hooks/useReleaseHistory';

interface Props {
title: string;
subTitle: string;
}

const NodeVersion = 'Version 10.15.3';

const Hero = ({ title, subTitle }: Props): JSX.Element => (
<div className="home-page-hero">
<h1>{title}</h1>
<h2 className="sub-title t-subheading">{subTitle}</h2>
<div className="btn-ctas">
<div className="download-lts-container">
<button className="download-lts-cta t-body1" type="button">
Download Node (LTS)
</button>
<p className="links t-caption">
{NodeVersion} - <Link to="/download">What’s new</Link> /{' '}
<Link to="/download">Get Current</Link>
</p>
function downloadUrlByOS(userOS: UserOS, version: string): string {
const baseURL = `https://nodejs.org/dist/${version}`;

if (userOS === UserOS.MOBILE) {
return baseURL;
}

if (userOS === UserOS.MAC) {
return `${baseURL}/node-${version}.pkg`;
}

if (userOS === UserOS.WIN) {
if (
navigator.appVersion.indexOf('WOW64') !== -1 ||
navigator.appVersion.indexOf('Win64') !== -1
) {
return `${baseURL}/node-${version}-x64.msi`;
}

return `${baseURL}/node-${version}-x86.msi`;
}

return `${baseURL}/node-${version}.tar.gz`;
}

const Hero = ({ title, subTitle }: Props): JSX.Element => {
const userOS = detectOS();
const [currentRelease, ...releases] = useReleaseHistory();

// find first lts version (first found is last LTS)
const lastLTSRelease = releases.find(
(release: ReleaseData): boolean => release.lts
);

const ltsVersionUrl = downloadUrlByOS(
userOS,
lastLTSRelease ? lastLTSRelease.version : ''
);
const currentVersionUrl = downloadUrlByOS(
userOS,
currentRelease ? currentRelease.version : ''
);

return (
<div className="home-page-hero">
<h1>{title}</h1>
<h2 className="sub-title t-subheading">{subTitle}</h2>
<div className="btn-ctas">
<div className="download-lts-container">
<a href={ltsVersionUrl}>
<button className="download-lts-cta t-body1" type="button">
Download Node (LTS)
</button>
</a>
<p className="links t-caption">
{lastLTSRelease
? `Version ${lastLTSRelease.version.substr(1)} - `
: ''}
<a href={currentVersionUrl}>Get Current</a>
</p>
</div>
<Link to="/learn">
<button className="learn-cta t-body1" type="button">
Learn Node
</button>
</Link>
</div>
<Link to="/learn">
<button className="learn-cta t-body1" type="button">
Learn Node
</button>
</Link>
</div>
</div>
);
);
};

export default Hero;
15 changes: 9 additions & 6 deletions src/components/ReleaseCards/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ export default function ReleaseCards({ line }: Props): JSX.Element {
<i className="material-icons">cloud</i>
<p>Windows Installer</p>
<a
href={`https://nodejs.org/dist/${fileName}/node-${line &&
line.version}-x86.msi`}
href={`https://nodejs.org/dist/${fileName}/node-${
line && line.version
}-x86.msi`}
>
node-
{line && line.version}
Expand All @@ -25,8 +26,9 @@ export default function ReleaseCards({ line }: Props): JSX.Element {
<i className="material-icons">cloud</i>
<p>Mac Installer</p>
<a
href={`https://nodejs.org/dist/${fileName}/node-${line &&
line.version}.pkg`}
href={`https://nodejs.org/dist/${fileName}/node-${
line && line.version
}.pkg`}
>
node-
{line && line.version}
Expand All @@ -37,8 +39,9 @@ export default function ReleaseCards({ line }: Props): JSX.Element {
<i className="material-icons">cloud</i>
<p>Source Code</p>
<a
href={`https://nodejs.org/dist/${fileName}/node-${line &&
line.version}.tar.gz`}
href={`https://nodejs.org/dist/${fileName}/node-${
line && line.version
}.tar.gz`}
>
node-
{line && line.version}
Expand Down
4 changes: 1 addition & 3 deletions src/pages/docs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,7 @@ function renderArticleOverview(
</a>
{children.length ? (
<ul className="api-key__section">{children}</ul>
) : (
undefined
)}
) : undefined}
</li>
);

Expand Down
2 changes: 1 addition & 1 deletion src/styles/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
color: var(--color-text-secondary);
margin: var(--space-08) 0 0 0;
position: absolute;
left: calc(var(--space-16) * -1);
left: var(--space-16);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/util/detectOS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export function detectOS(): UserOS {
if (navigator.appVersion.indexOf('Mac') !== -1) OS = UserOS.MAC;
if (navigator.appVersion.indexOf('X11') !== -1) OS = UserOS.UNIX;
if (navigator.appVersion.indexOf('Linux') !== -1) OS = UserOS.LINUX;
// not currently checking for mobile devices
if (navigator.appVersion.indexOf('Mobi') !== -1) OS = UserOS.MOBILE;
}
return OS;
}