Create new
Bindings
Transitions
Animations
Easing
Component composition
Context API
Special elements
Module context
Debugging
Miscellaneous
App.svelte
runes
This component is not in runes mode.
To enable runes mode, either start using runes in your code, or add the following to the top of your component:
<svelte:options runes />
99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
›
⌄
⌄
⌄
⌄
⌄
⌄
⌄
⌄
<script>
import { MaterialApp, AppBar, Divider, Button } from "svelte-materialify";
let theme = 'light';
function toggleTheme() {
if (theme === 'light') theme = 'dark';
else theme = 'light';
}
</script>
<MaterialApp {theme}>
<AppBar>
<span slot="title">Title</span>
</AppBar>
<br />
<h2 class="mb-4">
Svelte Materialify
</h2>
<Divider />
<br>
<div class="text-center">
<a href="//github.com/TheComputerM/svelte-materialify/stargazers">
<Button class="primary-color">
Star on GitHub
</Button>
</a>
<Button on:click={toggleTheme}>Toggle Theme</Button>
</div>
<br />
</MaterialApp>
bundling https://unpkg.com/clsx@2.1.1/dist/clsx.mjs
99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
›
⌄
⌄
⌄
⌄
⌄
⌄
⌄
⌄
import 'svelte/internal/disclose-version';
import 'svelte/internal/flags/legacy';
import * as $ from 'svelte/internal/client';
import { MaterialApp, AppBar, Divider, Button } from "svelte-materialify";
var root_2 = $.template(`<span slot="title">Title</span>`);
var root_1 = $.template(`<!> <br> <h2 class="mb-4">Svelte Materialify</h2> <!> <br> <div class="text-center"><a href="//github.com/TheComputerM/svelte-materialify/stargazers"><!></a> <!></div> <br>`, 1);
export default function App($$anchor) {
let theme = $.mutable_state('light');
function toggleTheme() {
if ($.get(theme) === 'light') $.set(theme, 'dark'); else $.set(theme, 'light');
}
MaterialApp($$anchor, {
get theme() {
return $.get(theme);
},
children: ($$anchor, $$slotProps) => {
var fragment_1 = root_1();
var node = $.first_child(fragment_1);
AppBar(node, {
$$slots: {
title: ($$anchor, $$slotProps) => {
var span = root_2();
$.append($$anchor, span);
}
}
});
var node_1 = $.sibling(node, 6);
Divider(node_1, {});
result = svelte.compile(source, {
generate: ,
});9
1
›
/* Add a <style> tag to see the CSS output */
Root {
- css: null
- js: []
- start: 216
- end: 621
- type: "Root"
fragment: Fragment {...}
- type: "Fragment"
nodes: [...] (2)
Text {...}
- type: "Text"
- start: 214
- end: 216
- raw: "\n\n"
- data: "\n\n"
} Component {...}
- type: "Component"
- start: 216
- end: 621
- name: "MaterialApp"
attributes: [...] (1)
Attribute {...}
- type: "Attribute"
- start: 229
- end: 236
- name: "theme"
value: ExpressionTag {...}
- type: "ExpressionTag"
- start: 230
- end: 235
expression: Identifier {...}
- start: 230
- end: 235
- type: "Identifier"
- name: "theme"
}
}
}
]fragment: Fragment {...}
- type: "Fragment"
nodes: [...] (15)
Text {...}
- type: "Text"
- start: 237
- end: 239
- raw: "\n\t"
- data: "\n\t"
} Component {...}
- type: "Component"
- start: 239
- end: 292
- name: "AppBar"
- attributes: []
fragment: Fragment {...}
- type: "Fragment"
nodes: [...] (3)
Text {...}
- type: "Text"
- start: 247
- end: 250
- raw: "\n\t\t"
- data: "\n\t\t"
} RegularElement {...}
- type: "RegularElement"
- start: 250
- end: 281
- name: "span"
attributes: [...] (1)
Attribute {...}
- type: "Attribute"
- start: 256
- end: 268
- name: "slot"
value: [...] (1)
Text {...}
- start: 262
- end: 267
- type: "Text"
- raw: "title"
- data: "title"
}
]
}
]fragment: Fragment {...}
- type: "Fragment"
nodes: [...] (1)
Text {...}
- type: "Text"
- start: 269
- end: 274
- raw: "Title"
- data: "Title"
}
]
}
} Text {...}
- type: "Text"
- start: 281
- end: 283
- raw: "\n\t"
- data: "\n\t"
}
]
}
} Text {...}
- type: "Text"
- start: 292
- end: 294
- raw: " "
- data: " "
} RegularElement {...}
- type: "RegularElement"
- start: 294
- end: 300
- name: "br"
- attributes: []
fragment: Fragment {...}
- type: "Fragment"
- nodes: []
}
} Text {...}
- type: "Text"
- start: 300
- end: 302
- raw: " "
- data: " "
} RegularElement {...}
- type: "RegularElement"
- start: 302
- end: 347
- name: "h2"
attributes: [...] (1)
Attribute {...}
- type: "Attribute"
- start: 306
- end: 318
- name: "class"
value: [...] (1)
Text {...}
- start: 313
- end: 317
- type: "Text"
- raw: "mb-4"
- data: "mb-4"
}
]
}
]fragment: Fragment {...}
- type: "Fragment"
nodes: [...] (1)
Text {...}
- type: "Text"
- start: 319
- end: 342
- raw: "Svelte Materialify"
- data: "Svelte Materialify"
}
]
}
} Text {...}
- type: "Text"
- start: 347
- end: 349
- raw: " "
- data: " "
} Component {...}
- type: "Component"
- start: 349
- end: 360
- name: "Divider"
- attributes: []
fragment: Fragment {...}
- type: "Fragment"
- nodes: []
}
} Text {...}
- type: "Text"
- start: 360
- end: 362
- raw: " "
- data: " "
} RegularElement {...}
- type: "RegularElement"
- start: 362
- end: 366
- name: "br"
- attributes: []
fragment: Fragment {...}
- type: "Fragment"
- nodes: []
}
} Text {...}
- type: "Text"
- start: 366
- end: 368
- raw: " "
- data: " "
} RegularElement {...}
- type: "RegularElement"
- start: 368
- end: 598
- name: "div"
attributes: [...] (1)
Attribute {...}
- type: "Attribute"
- start: 373
- end: 392
- name: "class"
value: [...] (1)
Text {...}
- start: 380
- end: 391
- type: "Text"
- raw: "text-center"
- data: "text-center"
}
]
}
]fragment: Fragment {...}
- type: "Fragment"
nodes: [...] (5)
Text {...}
- type: "Text"
- start: 393
- end: 396
- raw: "\n\t\t"
- data: "\n\t\t"
} RegularElement {...}
- type: "RegularElement"
- start: 396
- end: 535
- name: "a"
attributes: [...] (1)
Attribute {...}
- type: "Attribute"
- start: 399
- end: 461
- name: "href"
value: [...] (1)
Text {...}
- start: 405
- end: 460
- type: "Text"
- raw: "//github.com/TheComputerM/svelte-materialify/stargazers"
- data: "//github.com/TheComputerM/svelte-materialify/stargazers"
}
]
}
]fragment: Fragment {...}
- type: "Fragment"
nodes: [...] (3)
Text {...}
- type: "Text"
- start: 462
- end: 466
- raw: "\n\t\t\t"
- data: "\n\t\t\t"
} Component {...}
- type: "Component"
- start: 466
- end: 528
- name: "Button"
attributes: [...] (1)
Attribute {...}
- type: "Attribute"
- start: 474
- end: 495
- name: "class"
value: [...] (1)
Text {...}
- start: 481
- end: 494
- type: "Text"
- raw: "primary-color"
- data: "primary-color"
}
]
}
]fragment: Fragment {...}
- type: "Fragment"
nodes: [...] (1)
Text {...}
- type: "Text"
- start: 496
- end: 519
- raw: "Star on GitHub"
- data: "Star on GitHub"
}
]
}
} Text {...}
- type: "Text"
- start: 528
- end: 531
- raw: "\n\t\t"
- data: "\n\t\t"
}
]
}
} Text {...}
- type: "Text"
- start: 535
- end: 538
- raw: " "
- data: " "
} Component {...}
- type: "Component"
- start: 538
- end: 590
- name: "Button"
attributes: [...] (1)
OnDirective {...}
- start: 546
- end: 568
- type: "OnDirective"
- name: "click"
expression: Identifier {...}
- type: "Identifier"
- start: 556
- end: 567
loc: {...}
start: {...}
- line: 28
- column: 20
}end: {...}
- line: 28
- column: 31
}
}- name: "toggleTheme"
}- modifiers: []
}
]fragment: Fragment {...}
- type: "Fragment"
nodes: [...] (1)
Text {...}
- type: "Text"
- start: 569
- end: 581
- raw: "Toggle Theme"
- data: "Toggle Theme"
}
]
}
} Text {...}
- type: "Text"
- start: 590
- end: 592
- raw: "\n\t"
- data: "\n\t"
}
]
}
} Text {...}
- type: "Text"
- start: 598
- end: 600
- raw: " "
- data: " "
} RegularElement {...}
- type: "RegularElement"
- start: 600
- end: 606
- name: "br"
- attributes: []
fragment: Fragment {...}
- type: "Fragment"
- nodes: []
}
} Text {...}
- type: "Text"
- start: 606
- end: 607
- raw: "\n"
- data: "\n"
}
]
}
}
]
}- options: null
instance: Script {...}
- type: "Script"
- start: 0
- end: 214
- context: "default"
content: Program {...}
- type: "Program"
- start: 8
- end: 205
loc: {...}
start: {...}
- line: 1
- column: 0
}end: {...}
- line: 10
- column: 0
}
}body: [...] (3)
ImportDeclaration {...}
- type: "ImportDeclaration"
- start: 10
- end: 84
loc: {...}
start: {...}
- line: 2
- column: 1
}end: {...}
- line: 2
- column: 75
}
}specifiers: [...] (4)
ImportSpecifier {...}
- type: "ImportSpecifier"
- start: 19
- end: 30
loc: {...}
start: {...}
- line: 2
- column: 10
}end: {...}
- line: 2
- column: 21
}
}imported: Identifier {...}
- type: "Identifier"
- start: 19
- end: 30
loc: {...}
start: {...}
- line: 2
- column: 10
}end: {...}
- line: 2
- column: 21
}
}- name: "MaterialApp"
}local: Identifier {...}
- type: "Identifier"
- start: 19
- end: 30
loc: {...}
start: {...}
- line: 2
- column: 10
}end: {...}
- line: 2
- column: 21
}
}- name: "MaterialApp"
}
} ImportSpecifier {...}
- type: "ImportSpecifier"
- start: 32
- end: 38
loc: {...}
start: {...}
- line: 2
- column: 23
}end: {...}
- line: 2
- column: 29
}
}imported: Identifier {...}
- type: "Identifier"
- start: 32
- end: 38
loc: {...}
start: {...}
- line: 2
- column: 23
}end: {...}
- line: 2
- column: 29
}
}- name: "AppBar"
}local: Identifier {...}
- type: "Identifier"
- start: 32
- end: 38
loc: {...}
start: {...}
- line: 2
- column: 23
}end: {...}
- line: 2
- column: 29
}
}- name: "AppBar"
}
} ImportSpecifier {...}
- type: "ImportSpecifier"
- start: 40
- end: 47
loc: {...}
start: {...}
- line: 2
- column: 31
}end: {...}
- line: 2
- column: 38
}
}imported: Identifier {...}
- type: "Identifier"
- start: 40
- end: 47
loc: {...}
start: {...}
- line: 2
- column: 31
}end: {...}
- line: 2
- column: 38
}
}- name: "Divider"
}local: Identifier {...}
- type: "Identifier"
- start: 40
- end: 47
loc: {...}
start: {...}
- line: 2
- column: 31
}end: {...}
- line: 2
- column: 38
}
}- name: "Divider"
}
} ImportSpecifier {...}
- type: "ImportSpecifier"
- start: 49
- end: 55
loc: {...}
start: {...}
- line: 2
- column: 40
}end: {...}
- line: 2
- column: 46
}
}imported: Identifier {...}
- type: "Identifier"
- start: 49
- end: 55
loc: {...}
start: {...}
- line: 2
- column: 40
}end: {...}
- line: 2
- column: 46
}
}- name: "Button"
}local: Identifier {...}
- type: "Identifier"
- start: 49
- end: 55
loc: {...}
start: {...}
- line: 2
- column: 40
}end: {...}
- line: 2
- column: 46
}
}- name: "Button"
}
}
]source: Literal {...}
- type: "Literal"
- start: 63
- end: 83
loc: {...}
start: {...}
- line: 2
- column: 54
}end: {...}
- line: 2
- column: 74
}
}- value: "svelte-materialify"
- raw: "\"svelte-materialify\""
}
} VariableDeclaration {...}
- type: "VariableDeclaration"
- start: 88
- end: 108
loc: {...}
start: {...}
- line: 4
- column: 1
}end: {...}
- line: 4
- column: 21
}
}declarations: [...] (1)
VariableDeclarator {...}
- type: "VariableDeclarator"
- start: 92
- end: 107
loc: {...}
start: {...}
- line: 4
- column: 5
}end: {...}
- line: 4
- column: 20
}
}id: Identifier {...}
- type: "Identifier"
- start: 92
- end: 97
loc: {...}
start: {...}
- line: 4
- column: 5
}end: {...}
- line: 4
- column: 10
}
}- name: "theme"
}init: Literal {...}
- type: "Literal"
- start: 100
- end: 107
loc: {...}
start: {...}
- line: 4
- column: 13
}end: {...}
- line: 4
- column: 20
}
}- value: "light"
- raw: "'light'"
}
}
]- kind: "let"
} FunctionDeclaration {...}
- type: "FunctionDeclaration"
- start: 112
- end: 204
loc: {...}
start: {...}
- line: 6
- column: 1
}end: {...}
- line: 9
- column: 2
}
}id: Identifier {...}
- type: "Identifier"
- start: 121
- end: 132
loc: {...}
start: {...}
- line: 6
- column: 10
}end: {...}
- line: 6
- column: 21
}
}- name: "toggleTheme"
}- expression: false
- generator: false
- async: false
- params: []
body: BlockStatement {...}
- type: "BlockStatement"
- start: 135
- end: 204
loc: {...}
start: {...}
- line: 6
- column: 24
}end: {...}
- line: 9
- column: 2
}
}body: [...] (1)
IfStatement {...}
- type: "IfStatement"
- start: 139
- end: 201
loc: {...}
start: {...}
- line: 7
- column: 2
}end: {...}
- line: 8
- column: 23
}
}test: BinaryExpression {...}
- type: "BinaryExpression"
- start: 143
- end: 160
loc: {...}
start: {...}
- line: 7
- column: 6
}end: {...}
- line: 7
- column: 23
}
}left: Identifier {...}
- type: "Identifier"
- start: 143
- end: 148
loc: {...}
start: {...}
- line: 7
- column: 6
}end: {...}
- line: 7
- column: 11
}
}- name: "theme"
}- operator: "==="
right: Literal {...}
- type: "Literal"
- start: 153
- end: 160
loc: {...}
start: {...}
- line: 7
- column: 16
}end: {...}
- line: 7
- column: 23
}
}- value: "light"
- raw: "'light'"
}
}consequent: ExpressionStatement {...}
- type: "ExpressionStatement"
- start: 162
- end: 177
loc: {...}
start: {...}
- line: 7
- column: 25
}end: {...}
- line: 7
- column: 40
}
}expression: AssignmentExpression {...}
- type: "AssignmentExpression"
- start: 162
- end: 176
loc: {...}
start: {...}
- line: 7
- column: 25
}end: {...}
- line: 7
- column: 39
}
}- operator: "="
left: Identifier {...}
- type: "Identifier"
- start: 162
- end: 167
loc: {...}
start: {...}
- line: 7
- column: 25
}end: {...}
- line: 7
- column: 30
}
}- name: "theme"
}right: Literal {...}
- type: "Literal"
- start: 170
- end: 176
loc: {...}
start: {...}
- line: 7
- column: 33
}end: {...}
- line: 7
- column: 39
}
}- value: "dark"
- raw: "'dark'"
}
}
}alternate: ExpressionStatement {...}
- type: "ExpressionStatement"
- start: 185
- end: 201
loc: {...}
start: {...}
- line: 8
- column: 7
}end: {...}
- line: 8
- column: 23
}
}expression: AssignmentExpression {...}
- type: "AssignmentExpression"
- start: 185
- end: 200
loc: {...}
start: {...}
- line: 8
- column: 7
}end: {...}
- line: 8
- column: 22
}
}- operator: "="
left: Identifier {...}
- type: "Identifier"
- start: 185
- end: 190
loc: {...}
start: {...}
- line: 8
- column: 7
}end: {...}
- line: 8
- column: 12
}
}- name: "theme"
}right: Literal {...}
- type: "Literal"
- start: 193
- end: 200
loc: {...}
start: {...}
- line: 8
- column: 15
}end: {...}
- line: 8
- column: 22
}
}- value: "light"
- raw: "'light'"
}
}
}
}
]
}
}
]- sourceType: "module"
}- attributes: []
}
}
The AST is not public API and may change at any point in time