Skip to content

Commit

Permalink
Migrate: Source-link (#5364)
Browse files Browse the repository at this point in the history
* Migrate: Source-link

* Fix: JSON key moved to the end of the file

* Test: Storybook snapshot test

---------

Signed-off-by: Claudio Wunder <cwunder@gnome.org>
Co-authored-by: Claudio Wunder <cwunder@gnome.org>
  • Loading branch information
yossipoli and ovflowd committed May 24, 2023
1 parent c114d02 commit 862d056
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 1 deletion.
10 changes: 10 additions & 0 deletions components/Api/SourceLink/__snapshots__/index.stories.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Api/SourceLink Default smoke-test 1`] = `
<p class="SourceLink_sourceLinkComponent__1vzdY">
Source Code:
<a href="https://github.com/nodejs/node/blob/1.0.0/http://nodejs.org/version/1.0.0">
http://nodejs.org/version/1.0.0
</a>
</p>
`;
5 changes: 5 additions & 0 deletions components/Api/SourceLink/index.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.sourceLinkComponent {
font-size: var(--font-size-body3);
font-weight: var(--font-weight-semibold);
text-transform: uppercase;
}
14 changes: 14 additions & 0 deletions components/Api/SourceLink/index.stories.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import SourceLink from './index';
import type { Meta as MetaObj, StoryObj } from '@storybook/react';

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

export const Default: Story = {
args: {
version: '1.0.0',
link: 'http://nodejs.org/version/1.0.0',
},
};

export default { component: SourceLink } as Meta;
20 changes: 20 additions & 0 deletions components/Api/SourceLink/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { FormattedMessage } from 'react-intl';

import styles from './index.module.scss';
import type { FC } from 'react';

type SourceLinkProps = {
link: string;
version: string;
};

const SourceLink: FC<SourceLinkProps> = ({ version, link }) => (
<p className={styles.sourceLinkComponent}>
<FormattedMessage id="components.api.sourceLink" />{' '}
<a href={`https://github.com/nodejs/node/blob/${version}/${link}`}>
{link}
</a>
</p>
);

export default SourceLink;
3 changes: 2 additions & 1 deletion i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,6 @@
"components.common.shellBox.copy": "{copied, select, true {copied}other {copy}}",
"components.codeBox.copy": "{copied, select, true {copied}other {copy}}",
"components.api.stability": "Stability: {level} - ",
"components.api.jsonLink.title": "View as JSON"
"components.api.jsonLink.title": "View as JSON",
"components.api.sourceLink": "Source Code:"
}

0 comments on commit 862d056

Please sign in to comment.