File tree 4 files changed +37
-12
lines changed
01-svelte/06-bindings/05-textarea-inputs
4 files changed +37
-12
lines changed Original file line number Diff line number Diff line change @@ -6,14 +6,14 @@ The `<textarea>` element behaves similarly to a text input in Svelte — use `bi
6
6
7
7
``` svelte
8
8
/// file: App.svelte
9
- <textarea bind:value={value}></textarea>
9
+ <textarea +++ bind:value=+++ {value}></textarea>
10
10
```
11
11
12
12
In cases like these, where the names match, we can also use a shorthand form:
13
13
14
14
``` svelte
15
15
/// file: App.svelte
16
- <textarea bind:value></textarea>
16
+ <textarea +++ bind:value+++ ></textarea>
17
17
```
18
18
19
19
This applies to all bindings, not just textareas.
Original file line number Diff line number Diff line change 1
1
<script >
2
2
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 ` ;
4
4
</script >
5
5
6
- {@html marked (value )}
6
+ <div class =" grid" >
7
+ input
8
+ <textarea {value }></textarea >
7
9
8
- <textarea {value }></textarea >
10
+ output
11
+ <div >{@html marked (value )}</div >
12
+ </div >
9
13
10
14
<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
+
11
23
textarea {
12
- width : 100 % ;
13
- height : 200 px ;
24
+ flex : 1 ;
25
+ resize : none ;
14
26
}
15
27
</style >
Original file line number Diff line number Diff line change 1
1
<script >
2
2
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 ` ;
4
4
</script >
5
5
6
- {@html marked (value )}
6
+ <div class =" grid" >
7
+ input
8
+ <textarea bind:value ></textarea >
7
9
8
- <textarea bind:value ></textarea >
10
+ output
11
+ <div >{@html marked (value )}</div >
12
+ </div >
9
13
10
14
<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
+
11
23
textarea {
12
- width : 100 % ;
13
- height : 200 px ;
24
+ flex : 1 ;
25
+ resize : none ;
14
26
}
15
27
</style >
Original file line number Diff line number Diff line change 23
23
font-family : var (--font );
24
24
line-height : 1.5 ;
25
25
margin : 1rem ;
26
+ height : calc (100vh - 2rem );
26
27
}
27
28
28
29
h1 ,
You can’t perform that action at this time.
0 commit comments