forked from nodejs/nodejs.org
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.stories.tsx
More file actions
74 lines (59 loc) · 1.79 KB
/
index.stories.tsx
File metadata and controls
74 lines (59 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import * as TabsPrimitive from '@radix-ui/react-tabs';
import BaseCodeBox from '#ui/Common/BaseCodeBox';
import CodeTabs from '#ui/Common/CodeTabs';
import type { Meta as MetaObj, StoryObj } from '@storybook/react-webpack5';
import type { FC } from 'react';
type Story = StoryObj<typeof CodeTabs>;
type Meta = MetaObj<typeof CodeTabs>;
const mjsContent = `import * as http from 'http';
const hostname = '127.0.0.1';
const port = 3000;
const server = http.createServer((req, res) => {
res.statusCode = 200;
res.setHeader('Content-Type', 'text/plain');
res.end('Hello World');
});
server.listen(port, hostname, () => {
console.log(\`Server running at http://\${hostname}:\${port}/\`);
});`;
const cjsContent = `const http = require('http');
const hostname = '127.0.0.1';
const port = 3000;
const server = http.createServer((req, res) => {
res.statusCode = 200;
res.setHeader('Content-Type', 'text/plain');
res.end('Hello World');
});
server.listen(port, hostname, () => {
console.log(\`Server running at http://\${hostname}:\${port}/\`);
});`;
const boxProps = {
onCopy: console.log,
buttonContent: '[Button Text]',
};
const TabsContent: FC = () => (
<>
<TabsPrimitive.Content key="mjs" value="mjs">
<BaseCodeBox language="JavaScript (MJS)" {...boxProps}>
<code>{mjsContent}</code>
</BaseCodeBox>
</TabsPrimitive.Content>
<TabsPrimitive.Content key="cjs" value="cjs">
<BaseCodeBox language="JavaScript (CJS)" {...boxProps}>
<code>{cjsContent}</code>
</BaseCodeBox>
</TabsPrimitive.Content>
</>
);
export const Default: Story = {};
export default {
component: CodeTabs,
args: {
children: <TabsContent />,
defaultValue: 'mjs',
tabs: [
{ key: 'mjs', label: 'MJS' },
{ key: 'cjs', label: 'CJS' },
],
},
} as Meta;