Skip to content

Commit 6c099e5

Browse files
author
Rich Harris
committed
improve textarea example
1 parent f82de86 commit 6c099e5

File tree

4 files changed

+37
-12
lines changed

4 files changed

+37
-12
lines changed

content/tutorial/01-svelte/06-bindings/05-textarea-inputs/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ The `<textarea>` element behaves similarly to a text input in Svelte — use `bi
66

77
```svelte
88
/// file: App.svelte
9-
<textarea bind:value={value}></textarea>
9+
<textarea +++bind:value=+++{value}></textarea>
1010
```
1111

1212
In cases like these, where the names match, we can also use a shorthand form:
1313

1414
```svelte
1515
/// file: App.svelte
16-
<textarea bind:value></textarea>
16+
<textarea +++bind:value+++></textarea>
1717
```
1818

1919
This applies to all bindings, not just textareas.
Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,27 @@
11
<script>
22
import { marked } from 'marked';
3-
let value = `Some words are *italic*, some are **bold**`;
3+
let value = `Some words are *italic*, some are **bold**\n\n- lists\n- are\n- cool`;
44
</script>
55

6-
{@html marked(value)}
6+
<div class="grid">
7+
input
8+
<textarea {value}></textarea>
79

8-
<textarea {value}></textarea>
10+
output
11+
<div>{@html marked(value)}</div>
12+
</div>
913

1014
<style>
15+
.grid {
16+
display: grid;
17+
grid-template-columns: 5em 1fr;
18+
grid-template-rows: 1fr 1fr;
19+
grid-gap: 1em;
20+
height: 100%;
21+
}
22+
1123
textarea {
12-
width: 100%;
13-
height: 200px;
24+
flex: 1;
25+
resize: none;
1426
}
1527
</style>
Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,27 @@
11
<script>
22
import { marked } from 'marked';
3-
let value = `Some words are *italic*, some are **bold**`;
3+
let value = `Some words are *italic*, some are **bold**\n\n- lists\n- are\n- cool`;
44
</script>
55

6-
{@html marked(value)}
6+
<div class="grid">
7+
input
8+
<textarea bind:value></textarea>
79

8-
<textarea bind:value></textarea>
10+
output
11+
<div>{@html marked(value)}</div>
12+
</div>
913

1014
<style>
15+
.grid {
16+
display: grid;
17+
grid-template-columns: 5em 1fr;
18+
grid-template-rows: 1fr 1fr;
19+
grid-gap: 1em;
20+
height: 100%;
21+
}
22+
1123
textarea {
12-
width: 100%;
13-
height: 200px;
24+
flex: 1;
25+
resize: none;
1426
}
1527
</style>

content/tutorial/common/src/app.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
font-family: var(--font);
2424
line-height: 1.5;
2525
margin: 1rem;
26+
height: calc(100vh - 2rem);
2627
}
2728

2829
h1,

0 commit comments

Comments
 (0)