Skip to content

Commit 9f064b9

Browse files
committed
feat(stackblitz): revert to template
1 parent 41cfff1 commit 9f064b9

File tree

1 file changed

+15
-49
lines changed

1 file changed

+15
-49
lines changed

integrations/stackblitz/src/index.tsx

Lines changed: 15 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
RuntimeContext,
66
} from '@gitbook/runtime';
77

8-
const defaultContent = '';
8+
import { createProject } from './stackblitz';
99

1010
type IntegrationContext = {} & RuntimeContext;
1111

@@ -17,67 +17,33 @@ const handleFetchEvent: FetchEventCallback<IntegrationContext> = async (request,
1717
return new Response(JSON.stringify(user));
1818
};
1919

20-
const stackblitzBlock = createComponent<
21-
{
22-
content?: string;
23-
},
24-
{
25-
content: string;
26-
}
27-
>({
20+
const exampleBlock = createComponent({
2821
componentId: 'stackblitz',
2922
initialState: (props) => {
3023
return {
31-
content: props.content || defaultContent,
24+
message: 'Click Me',
3225
};
3326
},
34-
async render(element, { environment }) {
35-
const { editable } = element.context;
36-
const { content } = element.state;
37-
38-
element.setCache({
39-
maxAge: 86400,
40-
});
41-
42-
const output = (
43-
<webframe
44-
source={{
45-
// url: environment.integration.urls.publicEndpoint,
46-
// TODO: Remove hardcoded example
47-
url: 'https://stackblitz.com/edit/simple-search-filter?embed=1&file=src%2Fapp%2Fapp.component.ts',
48-
}}
49-
aspectRatio={16 / 9}
50-
data={{
51-
content: element.dynamicState('content'),
52-
}}
53-
/>
54-
);
55-
27+
action: async (element, action, context) => {
28+
switch (action.action) {
29+
case 'click':
30+
console.log('Button Clicked');
31+
return {};
32+
}
33+
},
34+
render: async (element, action, context) => {
35+
console.log('RENDER');
36+
await createProject();
5637
return (
5738
<block>
58-
{editable ? (
59-
<codeblock
60-
state="content"
61-
content={content}
62-
syntax="stackblitz"
63-
onContentChange={{
64-
action: '@editor.node.updateProps',
65-
props: {
66-
content: element.dynamicState('content'),
67-
},
68-
}}
69-
footer={[output]}
70-
/>
71-
) : (
72-
output
73-
)}
39+
<button label={element.state.message} onPress={{ action: 'click' }} />
7440
</block>
7541
);
7642
},
7743
});
7844

7945
export default createIntegration({
8046
fetch: handleFetchEvent,
81-
components: [stackblitzBlock],
47+
components: [exampleBlock],
8248
events: {},
8349
});

0 commit comments

Comments
 (0)