You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/editor/public/_docs/Live coding tutorial.md
+30-23Lines changed: 30 additions & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,9 +1,11 @@
1
-
# Introduction to TypeCell
1
+
# TypeCell Live Coding tutorial
2
2
3
-
Welcome to TypeCell. A TypeCell document is a live, interactive programming environment for Javascript / Typescript
3
+
TypeCell documents contain a live, interactive programming environment for Javascript / Typescript
4
4
running in your browser.
5
5
6
-
In this introduction, we will go through the basics of using TypeCell.
6
+
In this introduction, we will go through the basics of coding in TypeCell.
7
+
8
+
__This document is completely editable. Follow the steps below!__
7
9
8
10
## Cats
9
11
@@ -56,10 +58,12 @@ export default (
56
58
);
57
59
```
58
60
59
-
Uh oh, what's this? I forgot to add a cell defining our friend. Can you do it for me?
61
+
Uh oh, what's this? I forgot to add a code block defining a friend for our cat. Can you do it for me?
62
+
63
+
Add a code block by clicking on the + next to a block when hovering it (or type "/"), and select "code block".
60
64
61
-
A cell is a container for code & output. To add one, click on the + above or below another cell.
62
-
You can do it wherever you like.
65
+
_**Hint:** Our friend only needs a name for now. Use the same structure as you already
66
+
used for your cat (first code block), but only include the "name" field and export it as the variable named "friend"._
63
67
64
68
```typescript
65
69
// @default-collapsed
@@ -74,17 +78,16 @@ export default (
74
78
);
75
79
```
76
80
77
-
<small><strong>Hint:</strong> Our friend only needs a name for now. Use the same structure as you already
78
-
used for your cat, but only include the `name` field.</small>
79
81
80
-
Notice how we use `$.friend.name` in the cell above. Whenever you `export` a variable, you can access it across
81
-
the document by using the `$` symbol. In other words, `$` is a store for all variables that you want
82
+
83
+
Notice how we use _$.friend.name_ in the cell above. Whenever you _export_ a variable, you can access it across
84
+
the document by using the _$_ symbol. In other words, _$_ is a store for all variables that you want
82
85
to access across cells! Exported variables are also displayed below the cell.
83
86
84
87
Code cells automatically run when:
85
88
86
89
- You change the code of a cell
87
-
- Any of the reactive variables the cell references (from `$`) are changed
90
+
- Any of the reactive variables the cell references (from _$_) are changed
88
91
89
92
## Feeding neighbors
90
93
@@ -172,16 +175,17 @@ export default (
172
175
);
173
176
```
174
177
175
-
We have now stored the number of dry & wet food required (we exported variables `dryFoodToPrepare` and `wetFoodToPrepare`).
178
+
We have now stored the number of dry & wet food required (we exported variables "dryFoodToPrepare" and "wetFoodToPrepare").
176
179
We also visualize them nicely with a friendly message and emojis using React & JSX.
177
-
See the default `export` at the end of the cell above.
180
+
See the default "export" at the end of the cell above.
178
181
179
-
<small>React? JSX? What's this now? React is a Javascript framework that's used
182
+
_React? JSX? What's this now? React is a Javascript framework that's used
180
183
to create user interfaces. We won't go too in depth on it here, but you can
181
-
check out the documentation at https://reactjs.org/docs/getting-started.html.
184
+
check out the documentation at https://reactjs.org/docs/getting-started.html._
182
185
183
-
JSX is part of React, and makes it easy to create type-safe HTML elements. In TypeCell, just `export` JSX elements to create user interfaces or visualize data in your notebook.</small>
186
+
_JSX is part of React, and makes it easy to create type-safe HTML elements. In TypeCell, just "export" JSX elements to create user interfaces or visualize data in your notebook._
184
187
188
+
### Input fields
185
189
Next, we'll create some user input fields to indicate how much food we have prepared.
186
190
The built-in TypeCell Input library makes this easy:
187
191
@@ -293,22 +297,25 @@ export default (
293
297
);
294
298
```
295
299
296
-
<strong>Go ahead, play with the inputs above to adjust how much food to prepare!</strong>
300
+
**Go ahead, play with the inputs above to adjust how much food to prepare!**
297
301
298
302
These are just 2 of the many input types that TypeCell supports. To see the
299
303
other choices, make sure to try the TypeCell inputs tutorial.
300
304
301
-
_<strong>Tip:</strong> expand the 3 cells above to see how they work._
305
+
_**Tip:** expand the 3 cells above to see how they work._
302
306
303
307
## Final notes
304
308
305
-
We hope this introduction has given you a sense of how TypeCell and reactive notebooks work.
309
+
We hope this introduction has given you a sense of how TypeCell interactive documents work.
306
310
307
311
The live feedback and Reactive programming model should be pretty powerful.
308
-
There are a lot more features to discover, for example,
309
-
did you know you can import any NPM package you like, or even compose different notebooks?
310
-
Try creating your own notebook to give it a try, or have a look at the other examples.
312
+
313
+
There are a lot more features to discover. For example,
314
+
did you know you can import any NPM package you like, or even compose different documents?
315
+
316
+
Try signup up and create your own documents to give it a try, or have a look at the other examples.
311
317
312
318
**Have fun using TypeCell!**
313
319
314
-
<small>This tutorial is inspired by [pluto.jl](https://github.com/fonsp/Pluto.jl), thanks Fons & Nicholas!</small>
320
+
321
+
_This tutorial is inspired by [pluto.jl](https://github.com/fonsp/Pluto.jl), thanks Fons & Nicholas!_
Copy file name to clipboardExpand all lines: packages/editor/public/_docs/demos.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,4 +11,4 @@ To showcase some of TypeCell's features, explore these demos from our community:
11
11
12
12
## Built something exciting?
13
13
14
-
Let us know [on discord](https://discord.gg/TcJ9TRC3SV)or [Matrix](https://matrix.to/#/#typecell-space:matrix.org)if you'd like to feature your own demo on this page!
14
+
Let us know [on discord](https://discord.gg/TcJ9TRC3SV) if you'd like to feature your own demo on this page!
The page you're looking at is called a _notebook_.
4
-
It's basically an interactive document that mixes _code_ and _text_ (documentation).
3
+
The page you're looking at is an interactive document that mixes _code_ and _text_. A document consists of different blocks, highlighted when you hover over them. TypeCell supports all kind of blocks, like _headings_, _paragraphs_, _lists_, or more advanced _code blocks_.
5
4
6
-
## Creating and reordering cells
5
+
## Creating and reordering Blocks
7
6
8
-
When you hover over a cell, click the `+` sign to insert a new cell above or below.
7
+
When you hover over a block, click the `+` sign to insert a new block. You can also type "/" anywhere to open the slash-menu that allows you to add a new block.
9
8
10
-
To reorder a cell, hover next to it (try it out on the left of this text), and simply drag and drop the cell.
9
+
To reorder a block, hover next to it (try it out on the left of this text), and simply drag and drop the block via the drag handle (⋮⋮).
11
10
12
-
To view the source code of a cell, hover over the cell and click the caret <svgstroke="currentColor"fill="currentColor"stroke-width="0"viewBox="0 0 16 16"class="notebookCell-sideIcon"height="1em"width="1em"xmlns="http://www.w3.org/2000/svg"><title>Show / hide code</title><pathfill-rule="evenodd"clip-rule="evenodd"d="M10.072 8.024L5.715 3.667l.618-.62L11 7.716v.618L6.333 13l-.618-.619 4.357-4.357z"></path></svg> on the top left.
13
-
You'll notice the text you're reading now is written in Markdown.
11
+
## Code blocks
14
12
15
-
## Cell types
16
-
17
-
TypeCell currently supports a number of languages. You can view / change the language of a cell in the bottom-right of the cell's editor.
18
-
19
-
### Markdown
20
-
21
-
Useful for writing text / documentation. Markdown cells are collapsed by default (code cells are expanded by default).
13
+
TypeCell Code Blocks currently supports Typescript and CSS. You can view / change the language of a code block in the bottom-right of the code block editor.
22
14
23
15
### CSS
24
16
25
-
Use CSS to easily style the output of other cells (those written in Markdown or TypeScript).
17
+
Use CSS to easily style the output of other code blocks (those written in Markdown or TypeScript).
26
18
27
19
```css
28
20
.redText {
@@ -32,16 +24,18 @@ Use CSS to easily style the output of other cells (those written in Markdown or
Copy file name to clipboardExpand all lines: packages/editor/public/_docs/manual/2. TypeScript and exports.md
+10-8Lines changed: 10 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,15 +1,17 @@
1
1
# TypeScript and exports
2
2
3
-
TypeScript cells are the main way to write code in TypeCell.
3
+
TypeScript code blocks are the main way to write code in TypeCell.
4
4
5
5
You'll get all the benefits of the [Monaco Editor](https://microsoft.github.io/monaco-editor/) while writing code, the same editor that powers VS Code!
6
6
7
-
Note that TypeScript code still executes, even if there are type errors.
7
+
## Plain JavaScript
8
+
9
+
Note that TypeScript code always executes, even if there are type errors.
8
10
This allows you to quickly write and test code, but still get hints about possible bugs.
9
11
10
-
<small>Note that this means that any <strong>JavaScript</strong> code works in TypeCell as well (i.e.: you don't <em>need</em> to type everything if you don't want to).</small>
12
+
_This means that any **plain JavaScript** code works in TypeCell as well (you're not forced add types for everything)._
11
13
12
-
In the example below, you'll notice that we get an error because we assign a `number` to a `string` variable, but the code still executes regardless.
14
+
In the example below, you'll notice that we get an error because we assign a "number" to a "string" variable, but the code still executes regardless.
13
15
14
16
```typescript
15
17
exportlet message ="hello";
@@ -18,7 +20,7 @@ message = 4;
18
20
19
21
## Exports
20
22
21
-
You can export variables from your code, and they'll show up as _output_ of the cell. Above, we've exported a single `message` variable.
23
+
You can export variables from your code, and they'll show up as _output_ of the cell. Above, we've exported a single "message" variable.
22
24
23
25
You can also export multiple variables from a cell, and the _inspector_ will help you to view the output:
24
26
@@ -54,7 +56,7 @@ export let reactElement = (
54
56
55
57
## The `default` export
56
58
57
-
You use a `default` export to indicate which variable should be displayed in the output.
59
+
You use a "default" export to indicate which variable should be displayed in the output.
58
60
59
61
The following cell exports 2 variables, but only one is displayed in the output:
60
62
@@ -64,8 +66,8 @@ export let myNum = 42;
64
66
export default <div>The number is: {myNum}</div>;
65
67
```
66
68
67
-
Now you might ask; what's the use of exporting `myNum` if you don't see it in the output?
69
+
Now you might ask; what's the use of exporting "myNum" if you don't see it in the output?
68
70
69
-
This is because exported variables can be reused across cells and notebooks; one of most powerful features of TypeCell!
71
+
This is because exported variables can be reused across blocks and documents; one of most powerful features of TypeCell!
70
72
71
73
Continue to learn more about exported variables and Reactivity.
This is where things get interesting! Your code can reference variables exported by other cells.
3
+
This is where things get interesting! Your code can reference variables exported by other blocks.
4
4
5
-
Code cells in TypeCell (re)evaluate when:
5
+
Code blocks in TypeCell (re)evaluate when:
6
6
7
7
- The code of the cell changes (i.e.: you're editing the code)
8
-
- A variable the cell depends upon updates
8
+
- A variable the block depends upon updates
9
9
10
10
## The `$` variable
11
11
12
-
Exports of cells are available under the `$` variable. Have a look at the example below, and change the `name` variable to your own name. Notice how the greeting in the cell below updates automatically.
12
+
Exports of cells are available under the "$" variable. Have a look at the example below, and change the "name" variable to your own name. Notice how the greeting in the cell below updates automatically.
13
13
14
14
```typescript
15
15
exportlet name ="Anonymous coder";
@@ -23,8 +23,8 @@ export let greeting = (
23
23
);
24
24
```
25
25
26
-
<small>Tip: type `$.` in a TypeScript cell, and the editor (Intellisense) will display a list of all exported variables you can reference.</small>
26
+
_Tip: type "$." in a TypeScript cell, and the editor (Intellisense) will display a list of all exported variables you can reference._
27
27
28
28
## Interactive Tutorial
29
29
30
-
The Reactive model of TypeCell is quite powerful. If you haven't already, follow the [interactive introduction](/docs/interactive-introduction.md) or have a look at the [demos](/docs/demos.md) to get some hands-on experience.
30
+
The Reactive model of TypeCell is quite powerful. If you haven't already, follow the [live coding tutorial](/docs/Live%20coding%20tutorial.md) or have a look at the [demos](/docs/Demos.md) to get some hands-on experience.
Copy file name to clipboardExpand all lines: packages/editor/public/_docs/manual/4. Inputs.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# Working with user inputs
2
2
3
-
In your notebook, you'll often want the viewer to be able to control input variables, without changing code.
3
+
In your interactive document, you'll often want the viewer to be able to control input variables, without changing code.
4
4
5
5
Of course, you can create input elements using HTML / React. For example, like this:
6
6
@@ -130,7 +130,7 @@ export default $.select;
130
130
131
131
### Numbers & Ranges
132
132
133
-
You can user *number* and *range* input types to allow the user to enter numbers. Make sure to explicitly pass `<number>` to guide the type system that the edited variable is a number.
133
+
You can user *number* and *range* input types to allow the user to enter numbers. Make sure to explicitly pass "<number>" to guide the type system that the edited variable is a number.
0 commit comments