Skip to content

Commit 7ec1910

Browse files
committed
Fix server components warning in examples page
1 parent 509c342 commit 7ec1910

File tree

2 files changed

+84
-77
lines changed

2 files changed

+84
-77
lines changed
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
'use client';
2+
3+
import { useState } from 'react';
4+
5+
export function LiveDemo() {
6+
const [exampleRepo, setExampleRepo] = useState('json-schema-example');
7+
return (
8+
<div className="min-h-[calc(100vh-var(--nextra-navbar-height))] flex flex-col">
9+
<div className="flex items-center justify-center gap-2 py-8">
10+
Choose Live Example:
11+
<select
12+
value={exampleRepo}
13+
onChange={e => {
14+
setExampleRepo(e.target.value);
15+
}}
16+
className="border rounded-md py-1.5"
17+
>
18+
{Object.entries(EXAMPLES).map(([groupName, group]) => (
19+
<optgroup key={groupName} label={groupName}>
20+
{Object.entries(group).map(([exampleName, value]) => (
21+
<option key={exampleName} label={exampleName} value={value}>
22+
{exampleName}
23+
</option>
24+
))}
25+
</optgroup>
26+
))}
27+
</select>
28+
</div>
29+
<iframe
30+
loading="lazy"
31+
src={`https://codesandbox.io/embed/github/ardatan/graphql-mesh/tree/master/examples/${exampleRepo}?fontsize=14&hidenavigation=1&theme=dark&module=%2F.meshrc.yml`}
32+
className="grow"
33+
title={exampleRepo}
34+
allow="geolocation; microphone; camera; midi; vr; accelerometer; gyroscope; payment; ambient-light-sensor; encrypted-media; usb"
35+
sandbox="allow-modals allow-forms allow-popups allow-scripts allow-same-origin"
36+
/>
37+
</div>
38+
);
39+
}
40+
41+
export const EXAMPLES = {
42+
OpenAPI: {
43+
'JavaScript Wiki': 'openapi-javascript-wiki',
44+
'Location Weather': 'openapi-location-weather',
45+
YouTrack: 'openapi-youtrack',
46+
Stripe: 'openapi-stripe',
47+
StackExchange: 'openapi-stackexchange',
48+
'WeatherBit on React App': 'openapi-react-weatherbit',
49+
'NextJS with Apollo': 'nextjs-apollo-example',
50+
},
51+
'JSON Schema': {
52+
'Fake API': 'json-schema-example',
53+
'Covid-19 Statistics': 'json-schema-covid',
54+
'Subscriptions, Webhooks & Live Queries': 'json-schema-subscriptions',
55+
},
56+
OData: {
57+
TripPin: 'odata-trippin',
58+
'Microsoft Graph': 'odata-microsoft',
59+
},
60+
SOAP: {
61+
'Country Info': 'soap-country-info',
62+
},
63+
MySQL: {
64+
Rfam: 'mysql-rfam',
65+
},
66+
SQLite: {
67+
Chinook: 'sqlite-chinook',
68+
},
69+
'Apollo Federation': {
70+
'Apollo Federation Example': 'federation-example',
71+
},
72+
'Apache Thrift': {
73+
Calculator: 'thrift-calculator',
74+
},
75+
gRPC: {
76+
'Movies Example': 'grpc-example',
77+
},
78+
Neo4J: {
79+
'Movies Example': 'neo4j-example',
80+
},
81+
};
Lines changed: 3 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,84 +1,10 @@
1-
import { useState } from 'react';
1+
import { LiveDemo } from './live-demo';
22

33
export const metadata = {
44
title: 'Examples',
55
description: 'Examples of Mesh usage',
66
};
77

8-
export default function LiveDemo() {
9-
const [exampleRepo, setExampleRepo] = useState('json-schema-example');
10-
return (
11-
<div className="min-h-[calc(100vh-var(--nextra-navbar-height))] flex flex-col">
12-
<div className="flex items-center justify-center gap-2 py-8">
13-
Choose Live Example:
14-
<select
15-
value={exampleRepo}
16-
onChange={e => {
17-
setExampleRepo(e.target.value);
18-
}}
19-
className="border rounded-md py-1.5"
20-
>
21-
{Object.entries(EXAMPLES).map(([groupName, group]) => (
22-
<optgroup key={groupName} label={groupName}>
23-
{Object.entries(group).map(([exampleName, value]) => (
24-
<option key={exampleName} label={exampleName} value={value}>
25-
{exampleName}
26-
</option>
27-
))}
28-
</optgroup>
29-
))}
30-
</select>
31-
</div>
32-
<iframe
33-
loading="lazy"
34-
src={`https://codesandbox.io/embed/github/ardatan/graphql-mesh/tree/master/examples/${exampleRepo}?fontsize=14&hidenavigation=1&theme=dark&module=%2F.meshrc.yml`}
35-
className="grow"
36-
title={exampleRepo}
37-
allow="geolocation; microphone; camera; midi; vr; accelerometer; gyroscope; payment; ambient-light-sensor; encrypted-media; usb"
38-
sandbox="allow-modals allow-forms allow-popups allow-scripts allow-same-origin"
39-
/>
40-
</div>
41-
);
8+
export default function ExamplesPage() {
9+
return <LiveDemo />;
4210
}
43-
44-
export const EXAMPLES = {
45-
OpenAPI: {
46-
'JavaScript Wiki': 'openapi-javascript-wiki',
47-
'Location Weather': 'openapi-location-weather',
48-
YouTrack: 'openapi-youtrack',
49-
Stripe: 'openapi-stripe',
50-
StackExchange: 'openapi-stackexchange',
51-
'WeatherBit on React App': 'openapi-react-weatherbit',
52-
'NextJS with Apollo': 'nextjs-apollo-example',
53-
},
54-
'JSON Schema': {
55-
'Fake API': 'json-schema-example',
56-
'Covid-19 Statistics': 'json-schema-covid',
57-
'Subscriptions, Webhooks & Live Queries': 'json-schema-subscriptions',
58-
},
59-
OData: {
60-
TripPin: 'odata-trippin',
61-
'Microsoft Graph': 'odata-microsoft',
62-
},
63-
SOAP: {
64-
'Country Info': 'soap-country-info',
65-
},
66-
MySQL: {
67-
Rfam: 'mysql-rfam',
68-
},
69-
SQLite: {
70-
Chinook: 'sqlite-chinook',
71-
},
72-
'Apollo Federation': {
73-
'Apollo Federation Example': 'federation-example',
74-
},
75-
'Apache Thrift': {
76-
Calculator: 'thrift-calculator',
77-
},
78-
gRPC: {
79-
'Movies Example': 'grpc-example',
80-
},
81-
Neo4J: {
82-
'Movies Example': 'neo4j-example',
83-
},
84-
};

0 commit comments

Comments
 (0)