Skip to content

Commit

Permalink
chore: updates main with latest major/website-redesign (#5382)
Browse files Browse the repository at this point in the history
* test(snapshot): Migrate snapshot tests to storybook (#5340)

Co-authored-by: Manish Kumar ⛄ <manishprivet@protonmail.com>
Co-authored-by: Wai.Tung <maledong_public@foxmail.com>
Co-authored-by: Shanmughapriyan S <priyanshan03@gmail.com>
Co-authored-by: Michael Esteban <mickel13@gmail.com>
Co-authored-by: Claudio Wunder <cwunder@gnome.org>
Co-authored-by: Teja Sai Sandeep Reddy Konala <sandeep.konala@knacksystems.com>
Co-authored-by: Claudio Wunder <cwunder@hubspot.com>
Co-authored-by: vasanth9 <cheepurupalli.vasanthkumar.com>
Co-authored-by: Aymen Naghmouchi <aymenadvance@gmail.com>
Co-authored-by: Teja Sai Sandeep Reddy Konala <tejasaisandeepreddykonala@MacBook-Pro.local>
Co-authored-by: Augustin Mauroy <97875033+AugustinMauroy@users.noreply.github.com>
Co-authored-by: Guilherme Araújo <guilherme.araujo@maxxidata.com>
Co-authored-by: Augustin Mauroy <augustin.mauroy@outlook.fr>
Co-authored-by: HinataKah0 <128208841+HinataKah0@users.noreply.github.com>
Co-authored-by: Olaleye Blessing <Olayinkablexxy@gmail.com>
Co-authored-by: ktssr <31731919+ktssr@users.noreply.github.com>
Co-authored-by: vasanthkumar <42891954+vasanth9@users.noreply.github.com>
Co-authored-by: Floran Hachez <floran.hachez@gmail.com>
Co-authored-by: Jatin <96469998+JatinSharma32@users.noreply.github.com>
fixed styleling misconfig and fixed storybooks (#5281)
fix storybook styles, imports, typescript config and dependencies (#5319
fix(package.json) Lint command is missing slashes (#5321
fix storybook local development mode (#5335)
fix(i18n): translation key (#5347)

* chore: no-unused-vars ignores pattern starting with _ (#5363)

* Contributing Guidelines Update - Add clarity to step 4 based on clone method (#5369)

Add clarity to step 4 based on clone method

Signed-off-by: Vessy Shestorkina <46304479+Ve33y@users.noreply.github.com>

* fix(test): dir name (#5354)

* feat(stability): migrate component (#5339)

* Migrate JsonLink component (#5370)

* Migrate JsonLink component

Signed-off-by: Vessy Shestorkina <46304479+Ve33y@users.noreply.github.com>

* Add storybook snap and robot icon

Signed-off-by: Vessy Shestorkina <46304479+Ve33y@users.noreply.github.com>

* Remove IconContext provider

Signed-off-by: Vessy Shestorkina <46304479+Ve33y@users.noreply.github.com>

---------

Signed-off-by: Vessy Shestorkina <46304479+Ve33y@users.noreply.github.com>
Signed-off-by: Claudio Wunder <cwunder@gnome.org>
Co-authored-by: Claudio Wunder <cwunder@gnome.org>

* refactor(useDownloadLink): Move useDetectOs to useDownloadLink (#5376)

* refactor(useDownloadLink): Move useDetectOs to useDownloadLink

* refactor(useDownloadLink): rename file

* refactor(useDownloadLink): rename file

* Apply suggestions from code review

Signed-off-by: Claudio Wunder <cwunder@gnome.org>

* refactor(useDownloadLink): undo deleted file

---------

Signed-off-by: Claudio Wunder <cwunder@gnome.org>
Co-authored-by: Claudio Wunder <cwunder@gnome.org>

* feat: Add MUI Config and Theme Provider (#5368)

* feat: Add MUI Config and Theme Provider

* added createTheme

* refactor themeConfig

* feat(theme): Fix linting and package-lock

* feat(theme): Add emotion styled and emtion react

---------

Co-authored-by: Harkunwar Kochar <10580591+Harkunwar@users.noreply.github.com>

* refactor(delete): duplicate test file (#5377)

refactor(test): Delete duplicate test file

Co-authored-by: Claudio Wunder <cwunder@gnome.org>

* feat(useClickOutside): introduce (#5359)

* feat(useClickOutside): introduce

* Update hooks/useClickOutside.ts

Co-authored-by: Claudio Wunder <cwunder@gnome.org>
Signed-off-by: Augustin Mauroy <augustin.mauroy@outlook.fr>

* feat(useClickOutside): fix and twix

* feat(dropdown): remove useless ref

* feat(useClickOutside): update unit test

* feat(UseClickOutside): update type

* fix: usage of type

* Update hooks/useClickOutside.ts

Co-authored-by: Claudio Wunder <cwunder@gnome.org>
Signed-off-by: Augustin Mauroy <augustin.mauroy@outlook.fr>

* update listener

* Update components/Common/LanguageSelector/index.tsx

Co-authored-by: Shanmughapriyan S <priyanshan03@gmail.com>
Signed-off-by: Augustin Mauroy <augustin.mauroy@outlook.fr>

* fix: languageSelector

* update with feedback

* better unit test

* Update hooks/useClickOutside.ts

Co-authored-by: Harkunwar Kochar <10580591+Harkunwar@users.noreply.github.com>
Signed-off-by: Augustin Mauroy <augustin.mauroy@outlook.fr>

* feat(useClickOutside): update with feedback

* Update hooks/useClickOutside.ts

Co-authored-by: Shanmughapriyan S <priyanshan03@gmail.com>
Signed-off-by: Augustin Mauroy <augustin.mauroy@outlook.fr>

* Update hooks/useClickOutside.ts

Co-authored-by: Shanmughapriyan S <priyanshan03@gmail.com>
Signed-off-by: Augustin Mauroy <augustin.mauroy@outlook.fr>

* fix: if click on modal

* Update hooks/useClickOutside.ts

Co-authored-by: Harkunwar Kochar <10580591+Harkunwar@users.noreply.github.com>
Signed-off-by: Augustin Mauroy <augustin.mauroy@outlook.fr>

* Update hooks/useClickOutside.ts

Signed-off-by: Harkunwar Kochar <10580591+Harkunwar@users.noreply.github.com>

* Update hooks/useClickOutside.ts

Co-authored-by: Harkunwar Kochar <10580591+Harkunwar@users.noreply.github.com>
Signed-off-by: Augustin Mauroy <augustin.mauroy@outlook.fr>

* Update useClickOutside.ts

* Update hooks/useClickOutside.ts

Co-authored-by: Shanmughapriyan S <priyanshan03@gmail.com>
Signed-off-by: Augustin Mauroy <augustin.mauroy@outlook.fr>

* Update useClickOutside.ts

* Apply suggestions from code review

Signed-off-by: Claudio Wunder <cwunder@gnome.org>

* Update hooks/useClickOutside.ts

Co-authored-by: Claudio Wunder <cwunder@gnome.org>
Signed-off-by: Augustin Mauroy <augustin.mauroy@outlook.fr>

* Update hooks/useClickOutside.ts

Co-authored-by: Claudio Wunder <cwunder@gnome.org>
Signed-off-by: Augustin Mauroy <augustin.mauroy@outlook.fr>

* fix: build

---------

Signed-off-by: Augustin Mauroy <augustin.mauroy@outlook.fr>
Signed-off-by: Harkunwar Kochar <10580591+Harkunwar@users.noreply.github.com>
Signed-off-by: Claudio Wunder <cwunder@gnome.org>
Co-authored-by: Claudio Wunder <cwunder@gnome.org>
Co-authored-by: Shanmughapriyan S <priyanshan03@gmail.com>
Co-authored-by: Harkunwar Kochar <10580591+Harkunwar@users.noreply.github.com>

---------

Signed-off-by: Vessy Shestorkina <46304479+Ve33y@users.noreply.github.com>
Signed-off-by: Claudio Wunder <cwunder@gnome.org>
Signed-off-by: Augustin Mauroy <augustin.mauroy@outlook.fr>
Signed-off-by: Harkunwar Kochar <10580591+Harkunwar@users.noreply.github.com>
Co-authored-by: Harkunwar Kochar <10580591+Harkunwar@users.noreply.github.com>
Co-authored-by: Manish Kumar ⛄ <manishprivet@protonmail.com>
Co-authored-by: Wai.Tung <maledong_public@foxmail.com>
Co-authored-by: Shanmughapriyan S <priyanshan03@gmail.com>
Co-authored-by: Michael Esteban <mickel13@gmail.com>
Co-authored-by: Teja Sai Sandeep Reddy Konala <sandeep.konala@knacksystems.com>
Co-authored-by: Aymen Naghmouchi <aymenadvance@gmail.com>
Co-authored-by: Teja Sai Sandeep Reddy Konala <tejasaisandeepreddykonala@MacBook-Pro.local>
Co-authored-by: Augustin Mauroy <97875033+AugustinMauroy@users.noreply.github.com>
Co-authored-by: Guilherme Araújo <guilherme.araujo@maxxidata.com>
Co-authored-by: Augustin Mauroy <augustin.mauroy@outlook.fr>
Co-authored-by: HinataKah0 <128208841+HinataKah0@users.noreply.github.com>
Co-authored-by: Olaleye Blessing <Olayinkablexxy@gmail.com>
Co-authored-by: ktssr <31731919+ktssr@users.noreply.github.com>
Co-authored-by: vasanthkumar <42891954+vasanth9@users.noreply.github.com>
Co-authored-by: Floran Hachez <floran.hachez@gmail.com>
Co-authored-by: Jatin <96469998+JatinSharma32@users.noreply.github.com>
Co-authored-by: Vessy <46304479+Ve33y@users.noreply.github.com>
Co-authored-by: Mert Can Altın <mertgold60@gmail.com>
  • Loading branch information
20 people authored May 17, 2023
1 parent b97fb2a commit 2065bf7
Show file tree
Hide file tree
Showing 74 changed files with 5,951 additions and 3,169 deletions.
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"plugins": ["@typescript-eslint"],
"globals": { "globalThis": false },
"rules": {
"no-unused-vars": ["error", { "argsIgnorePattern": "^_" }],
"@typescript-eslint/consistent-type-imports": "error"
}
},
Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,13 @@ jobs:
enableCrossOsArchive: true

- name: Run Unit Tests
run: npx turbo test:ci
run: npx turbo test:unit -- --coverage
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}

- name: Run Storybook Tests
run: npx turbo test:storybook
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}
Expand Down
4 changes: 3 additions & 1 deletion .storybook/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ export const decorators = [
}
`}
</style>
<Story />
<div data-test-id="story-root">
<Story />
</div>
</NodeDataProvider>
</LocaleProvider>
</SiteProvider>
Expand Down
14 changes: 14 additions & 0 deletions .storybook/test-runner.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// TODO: Convert this to ESM once the bug is resolved
// https://github.com/storybookjs/test-runner/issues/293

const config = {
async postRender(page, _context) {
const rootElementId = '[data-test-id="story-root"]';
const rootElement = await page.locator(rootElementId);
const content = await rootElement.innerHTML();
expect(content).toBeDefined();
expect(content).toMatchSnapshot();
},
};

module.exports = config;
15 changes: 11 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ Thank you for your interest in contributing to the Node.js Website. Before you p

```bash
git clone git@github.com:<GITHUB_ID>/nodejs.org.git # SSH
gh repo clone <GITHUB_ID>/nodejs.org # GitHub CLI
git clone https://github.com/<GITHUB_ID>/nodejs.org.git # HTTPS
gh repo clone <GITHUB_ID>/nodejs.org # GitHub CLI
```

3. Change into the nodejs.org directory.
Expand All @@ -36,7 +36,9 @@ cd nodejs.org
4. Create a remote for keeping your fork as well as your local clone up-to-date.

```bash
git remote add upstream git@github.com:nodejs/nodejs.org.git
git remote add upstream git@github.com:nodejs/nodejs.org.git # SSH
git remote add upstream https://github.com/nodejs/nodejs.org.git # HTTPS
gh repo sync nodejs/nodejs.org # GitHub CLI
```

5. Create a new branch for your work.
Expand Down Expand Up @@ -102,7 +104,10 @@ We also offer other commands that offer you assistance during your local develop
- **Usage:** `npx turbo scripts:release-post -- --version=vXX.X.X --force`
- `npx turbo storybook` starts Storybook's local server
- `npx turbo storybook:build` builds Storybook as a static web application for publishing
- `npx turbo test` runs jest (unit-tests) locally
- `npx turbo test` runs all tests locally
- `npx turbo test:unit` runs jest (unit-tests) locally
- `npx turbo test:storybook` runs storybook test-runner tests
- `npx turbo test:storybook:snapshot` generates and updates snapshots for all storybook components.

## Creating Components

Expand Down Expand Up @@ -178,7 +183,7 @@ Commits should be signed. You can read more about [Commit Signing][] here.

Each new feature or bug fix should be accompanied by a unit test (when deemed valuable). We use [Jest][] as our test runner and [React Testing Library][] for our React unit tests.

We also use [Storybook][] to document our components. Each component should have a storybook story that documents the component's usage.
We also use [Storybook][] to document our components. Each component should have a storybook story that documents the component's usage. Snapshot testing of our components is directly done by taking snapshot of all Storybook stories, using [Storybook Test Runner][] and [Playwright][].

### General Guidelines for Unit Tests

Expand Down Expand Up @@ -299,6 +304,8 @@ If something is missing here, or you feel something is not well described, feel
[Jest]: https://jestjs.io/
[React Testing Library]: https://testing-library.com/docs/react-testing-library/intro/
[Storybook]: https://storybook.js.org/
[Storybook Test Runner]: https://storybook.js.org/addons/@storybook/test-runner#dom-snapshot-recipe
[Playwright]: https://playwright.dev/
[`react-intl`]: https://formatjs.io/docs/react-intl/
[Next.js]: https://nextjs.org/
[MDX]: https://mdxjs.com/
Expand Down
25 changes: 25 additions & 0 deletions components/Api/DataTag/__snapshots__/index.stories.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Api/DataTag Blue smoke-test 1`] = `
<span class="DataTag_dataTag__xyqF4"
data-tag="M"
>
M
</span>
`;

exports[`Api/DataTag Red smoke-test 1`] = `
<span class="DataTag_dataTag__xyqF4"
data-tag="E"
>
E
</span>
`;

exports[`Api/DataTag Yellow smoke-test 1`] = `
<span class="DataTag_dataTag__xyqF4"
data-tag="C"
>
C
</span>
`;
34 changes: 0 additions & 34 deletions components/Api/DataTag/__tests__/__snapshots__/index.test.tsx.snap

This file was deleted.

25 changes: 0 additions & 25 deletions components/Api/DataTag/__tests__/index.test.tsx

This file was deleted.

23 changes: 23 additions & 0 deletions components/Api/JsonLink/__snapshots__/index.stories.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Api/JsonLink Default smoke-test 1`] = `
<div class="JsonLink_json__0XIkR">
<a href="https://nodejs.org/docs/latest-v18.x/api/documentation.json">
<span>
View as JSON
</span>
<svg stroke="currentColor"
fill="currentColor"
stroke-width="0"
viewbox="0 0 640 512"
class="JsonLink_FaRobotIcon__KvHGw"
height="1em"
width="1em"
xmlns="http://www.w3.org/2000/svg"
>
<path d="M32,224H64V416H32A31.96166,31.96166,0,0,1,0,384V256A31.96166,31.96166,0,0,1,32,224Zm512-48V448a64.06328,64.06328,0,0,1-64,64H160a64.06328,64.06328,0,0,1-64-64V176a79.974,79.974,0,0,1,80-80H288V32a32,32,0,0,1,64,0V96H464A79.974,79.974,0,0,1,544,176ZM264,256a40,40,0,1,0-40,40A39.997,39.997,0,0,0,264,256Zm-8,128H192v32h64Zm96,0H288v32h64ZM456,256a40,40,0,1,0-40,40A39.997,39.997,0,0,0,456,256Zm-8,128H384v32h64ZM640,256V384a31.96166,31.96166,0,0,1-32,32H576V224h32A31.96166,31.96166,0,0,1,640,256Z">
</path>
</svg>
</a>
</div>
`;
29 changes: 29 additions & 0 deletions components/Api/JsonLink/index.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
.json {
display: flex;
flex-wrap: wrap;

a {
color: var(--color-text-secondary);
font-family: var(--sans-serif);
font-size: 1.4rem;
font-weight: var(--font-weight-regular);
margin-left: 0;
text-decoration: none !important;
text-transform: uppercase;
vertical-align: middle;

span {
font-weight: var(--font-weight-regular);
vertical-align: middle;
}

&:hover {
color: var(--brand-light);
}

.FaRobotIcon {
margin-left: 0.5rem;
vertical-align: middle;
}
}
}
14 changes: 14 additions & 0 deletions components/Api/JsonLink/index.stories.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import JsonLink from './index';
import type { Meta as MetaObj, StoryObj } from '@storybook/react';

type Story = StoryObj<typeof JsonLink>;
type Meta = MetaObj<typeof JsonLink>;

export const Default: Story = {
args: {
version: 'v18',
fileName: 'documentation',
},
};

export default { component: JsonLink } as Meta;
22 changes: 22 additions & 0 deletions components/Api/JsonLink/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { FormattedMessage } from 'react-intl';
import { FaRobot } from 'react-icons/fa';
import styles from './index.module.scss';
import type { FC } from 'react';

type JsonLinkProps = {
fileName: string;
version: string;
};

const JsonLink: FC<JsonLinkProps> = ({ fileName, version }) => (
<div className={styles.json}>
<a
href={`https://nodejs.org/docs/latest-${version}.x/api/${fileName}.json`}
>
<FormattedMessage id="components.api.jsonLink.title" tagName="span" />
<FaRobot className={styles.FaRobotIcon} />
</a>
</div>
);

export default JsonLink;
7 changes: 7 additions & 0 deletions components/Api/Stability/__snapshots__/index.stories.tsx.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Api/Stability Default smoke-test 1`] = `
<div class="Stability_stability__U0Zm0 Stability_stabilityLevel0__ygvXd">
Stability: 0 - Insert the text of your Alert here
</div>
`;
36 changes: 36 additions & 0 deletions components/Api/Stability/index.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
.stability {
border-radius: 4px;
color: #fff;
line-height: 1.5;
margin: 0 0 1rem;
padding: 1rem;

p {
display: inline;
margin: 0;
}

a {
color: #fff;

code {
color: #fff !important;
}
}

&Level0 {
background-color: var(--danger5);
}

&Level1 {
background-color: var(--warning4);
}

&Level2 {
background-color: var(--brand5);
}

&Level3 {
background-color: var(--info5);
}
}
24 changes: 24 additions & 0 deletions components/Api/Stability/index.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import Stability from './index';
import type { Meta as MetaObj, StoryObj } from '@storybook/react';

type Story = StoryObj<typeof Stability>;
type Meta = MetaObj<typeof Stability>;

export const Default: Story = {
args: {
stability: 0,
children: 'Insert the text of your Alert here',
},
argTypes: {
stability: {
control: {
type: 'range',
min: 0,
max: 3,
step: 1,
},
},
},
};

export default { component: Stability } as Meta;
23 changes: 23 additions & 0 deletions components/Api/Stability/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { FormattedMessage } from 'react-intl';
import styles from './index.module.scss';
import type { PropsWithChildren, FC } from 'react';

type StabilityProps = PropsWithChildren<{ stability: number }>;

const getStabilityClass = (stability: number) => {
const style = styles[`stabilityLevel${stability}`];
if (!style) throw new Error(`Unknown stability level: ${stability}`);
return style;
};

const Stability: FC<StabilityProps> = ({ stability, children }) => (
<div className={`${styles.stability} ${getStabilityClass(stability)}`}>
<FormattedMessage
id="components.api.stability"
values={{ level: stability }}
/>
{children}
</div>
);

export default Stability;
7 changes: 7 additions & 0 deletions components/Article/Alert/__snapshots__/index.stories.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Article/Alert Default smoke-test 1`] = `
<div class="Alert_alert__qjYPQ">
This is an alert
</div>
`;
Loading

2 comments on commit 2065bf7

@vercel
Copy link

@vercel vercel bot commented on 2065bf7 May 17, 2023

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

nodejs-org-stories – ./

nodejs-org-stories-git-main-openjs.vercel.app
nodejs-org-storybook.vercel.app
nodejs-org-stories-openjs.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 2065bf7 May 17, 2023

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

nodejs-org – ./

node-js-org.vercel.app
nodejs-org-git-main-openjs.vercel.app
nodejs-org-openjs.vercel.app

Please sign in to comment.