Skip to content

Commit 0331446

Browse files
committed
refactor: replace iframe with livecodes sdk
1 parent 66b316d commit 0331446

2 files changed

Lines changed: 102 additions & 84 deletions

File tree

docs/docs/tutorials/building-your-first-app.mdx

Lines changed: 48 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -2,45 +2,21 @@
22
title: Building Your First App
33
---
44

5-
# Building Your First App
6-
7-
Learn how to build a simple color generator app using LiveCodes. This app will let users click a button to generate random background colors.
8-
9-
Try the completed project below, or [open it in a new tab](https://livecodes.io/?x=id/v9dmx2p9z8w).
5+
import CodeBlock from '@theme/CodeBlock';
6+
import LiveCodes from '../../src/components/LiveCodes.tsx';
7+
import RunInLiveCodes from '../../src/components/RunInLiveCodes.tsx';
108

11-
<iframe src="https://livecodes.io/?x=id/v9dmx2p9z8w" width="100%" height="400px"></iframe>
12-
13-
## What We'll Build
14-
15-
A fun color generator with:
16-
- Random color generation
17-
- Display the color code
18-
- Simple, clean interface
19-
20-
## Project Setup
21-
22-
1. Open [LiveCodes](https://livecodes.io)
23-
2. We'll use HTML, CSS, and JavaScript
24-
25-
## Implementation
26-
27-
### HTML Structure
28-
29-
```html
30-
<div class="container">
9+
export const colorGeneratorParams = {
10+
html: `<div class="container">
3111
<h1>Color Generator</h1>
3212
<div class="color-display" id="colorDisplay">
3313
<span id="colorCode">#3498db</span>
3414
</div>
3515
<button id="generateBtn">Generate Color</button>
3616
<p class="hint">Click the button to generate a random color!</p>
3717
</div>
38-
```
39-
40-
### Styling
41-
42-
```css
43-
body {
18+
`,
19+
css: `body {
4420
margin: 0;
4521
font-family: Arial, sans-serif;
4622
display: flex;
@@ -102,12 +78,8 @@ h1 {
10278
color: #666;
10379
font-size: 0.9rem;
10480
}
105-
```
106-
107-
### JavaScript Logic
108-
109-
```javascript
110-
const colorDisplay = document.getElementById('colorDisplay');
81+
`,
82+
js: `const colorDisplay = document.getElementById('colorDisplay');
11183
const colorCode = document.getElementById('colorCode');
11284
const generateBtn = document.getElementById('generateBtn');
11385
@@ -130,7 +102,42 @@ generateBtn.addEventListener('click', updateColor);
130102
131103
// Generate a color on page load
132104
updateColor();
133-
```
105+
`,
106+
};
107+
108+
# Building Your First App
109+
110+
Learn how to build a simple color generator app using LiveCodes. This app will let users click a button to generate random background colors.
111+
112+
Try the completed project below, or <RunInLiveCodes linkText="open it in a new tab" params={colorGeneratorParams}></RunInLiveCodes>.
113+
114+
<LiveCodes params={colorGeneratorParams}></LiveCodes>
115+
116+
## What We'll Build
117+
118+
A fun color generator with:
119+
- Random color generation
120+
- Display the color code
121+
- Simple, clean interface
122+
123+
## Project Setup
124+
125+
1. Open [LiveCodes](https://livecodes.io)
126+
2. We'll use HTML, CSS, and JavaScript
127+
128+
## Implementation
129+
130+
### HTML Structure
131+
132+
<CodeBlock language="html">{colorGeneratorParams.html}</CodeBlock>
133+
134+
### Styling
135+
136+
<CodeBlock language="css">{colorGeneratorParams.css}</CodeBlock>
137+
138+
### JavaScript Logic
139+
140+
<CodeBlock language="js">{colorGeneratorParams.js}</CodeBlock>
134141

135142
## How It Works
136143

@@ -163,13 +170,15 @@ You've just built your color generator app with LiveCodes!
163170

164171
Compare your version with the completed project above. Did you add any personal touches?
165172

166-
**[View the completed project](https://livecodes.io/?x=id/v9dmx2p9z8w)**
173+
<RunInLiveCodes linkText="View the completed project" params={colorGeneratorParams}></RunInLiveCodes>
167174

168175
## Next Steps
169176

170177
- [External Resources](/docs/features/external-resources) - Add libraries like color manipulation tools
178+
- [Getting Started Guide](getting-started) - Review the basics
171179

172180
## Complete Code Summary
173181

174182
**Concepts Covered**: DOM manipulation, events, random generation, CSS transitions
183+
175184
**Time to Build**: 10-15 minutes

docs/docs/tutorials/getting-started-guide.mdx

Lines changed: 54 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -2,44 +2,18 @@
22
title: Getting Started Guide
33
---
44

5-
# Getting Started Guide
6-
7-
This guide will walk you through creating your first project in LiveCodes.
8-
9-
Try the completed project below, or [open it in a new tab](https://livecodes.io/?x=id/q6k8itvp2dv).
10-
11-
<iframe src="https://livecodes.io/?x=id/q6k8itvp2dv" width="100%" height="400px"></iframe>
12-
13-
## Prerequisites
14-
15-
- A web browser (Chrome, Firefox, Safari, or Edge)
16-
- Basic knowledge of HTML, CSS, and JavaScript
17-
18-
## Step 1: Open LiveCodes
19-
20-
1. Navigate to [livecodes.io](https://livecodes.io)
21-
2. You'll see the editor interface with three panels:
22-
- **HTML**
23-
- **CSS**
24-
- **JavaScript**
25-
- **Result**
26-
27-
## Step 2: Create a Simple Page
28-
29-
Let's create a simple interactive greeting card.
5+
import CodeBlock from '@theme/CodeBlock';
6+
import LiveCodes from '../../src/components/LiveCodes.tsx';
7+
import RunInLiveCodes from '../../src/components/RunInLiveCodes.tsx';
308

31-
### HTML Panel
32-
```html
33-
<div class="container">
9+
export const gettingStartedParams = {
10+
html: `<div class="container">
3411
<h1 id="greeting">Hello, World!</h1>
3512
<input type="text" id="nameInput" placeholder="Enter your name">
3613
<button id="greetBtn">Greet Me!</button>
3714
</div>
38-
```
39-
40-
### CSS Panel
41-
```css
42-
.container {
15+
`,
16+
css: `.container {
4317
max-width: 600px;
4418
margin: 50px auto;
4519
text-align: center;
@@ -72,23 +46,58 @@ button {
7246
button:hover {
7347
background-color: #0056b3;
7448
}
75-
```
76-
77-
### JavaScript Panel
78-
```javascript
79-
const greeting = document.getElementById('greeting');
49+
`,
50+
js: `const greeting = document.getElementById('greeting');
8051
const nameInput = document.getElementById('nameInput');
8152
const greetBtn = document.getElementById('greetBtn');
8253
8354
greetBtn.addEventListener('click', () => {
8455
const name = nameInput.value.trim();
8556
if (name) {
86-
greeting.textContent = `Hello, ${name}!`;
57+
greeting.textContent = \`Hello, \${name}!\`;
8758
} else {
8859
greeting.textContent = 'Hello, World!';
8960
}
9061
});
91-
```
62+
`,
63+
};
64+
65+
# Getting Started Guide
66+
67+
This guide will walk you through creating your first project in LiveCodes.
68+
69+
Try the completed project below, or <RunInLiveCodes linkText="open it in a new tab" params={gettingStartedParams}></RunInLiveCodes>.
70+
71+
<LiveCodes params={gettingStartedParams}></LiveCodes>
72+
73+
## Prerequisites
74+
75+
- A web browser (Chrome, Firefox, Safari, or Edge)
76+
- Basic knowledge of HTML, CSS, and JavaScript
77+
78+
## Step 1: Open LiveCodes
79+
80+
1. Navigate to [livecodes.io](https://livecodes.io)
81+
2. You'll see the editor interface with three panels:
82+
- **HTML**
83+
- **CSS**
84+
- **JavaScript**
85+
86+
## Step 2: Create a Simple Page
87+
88+
Let's create a simple interactive greeting card.
89+
90+
### HTML Panel
91+
92+
<CodeBlock language="html">{gettingStartedParams.html}</CodeBlock>
93+
94+
### CSS Panel
95+
96+
<CodeBlock language="css">{gettingStartedParams.css}</CodeBlock>
97+
98+
### JavaScript Panel
99+
100+
<CodeBlock language="js">{gettingStartedParams.js}</CodeBlock>
92101

93102
## Step 3: See Your Results
94103

@@ -99,18 +108,18 @@ The result panel automatically updates as you type. Try:
99108

100109
## Step 4: Save Your Project
101110

102-
1. Click on the "Project" menu button in the toolbar.
103-
2. Click Save to save the project (on this device).
104-
3. You can open it later from "Project menu > Open".
105-
4. Use "Project menu > Share" to get a permanent URL to your project that you can share.
111+
1. Click on the "**Project**" menu button in the toolbar
112+
2. Click "**Save**" to save the project (on this device)
113+
3. You can open it later from "**Project menu > Open**"
114+
4. Use "**Project menu > Share**" to get a permanent URL to your project that you can share
106115

107116
## Congratulations!
108117

109118
You've just built your first interactive app with LiveCodes!
110119

111120
Compare your version with the completed project above. Did you add any personal touches?
112121

113-
**[View the completed project](https://livecodes.io/?x=id/q6k8itvp2dv)**
122+
<RunInLiveCodes linkText="View the completed project" params={gettingStartedParams}></RunInLiveCodes>
114123

115124
## Next Steps
116125

0 commit comments

Comments
 (0)