svelte-parse
Version:
An increidbly relaxed svelte-parser
587 lines (586 loc) • 12.6 kB
JSON
{
"type": "root",
"children": [
{
"type": "svelteScript",
"tagName": "script",
"properties": [],
"selfClosing": false,
"children": [
{
"type": "text",
"value": "\n import { classnames } from '../../helpers/classnames';\n import Spinner from '../Spinner/Spinner.svelte';\n\n export let isActive = false;\n export let isDisabled = false;\n export let isWaiting = false;\n\n export let ClassNames;\n $: {\n ClassNames = classnames(\n {\n isActive,\n isDisabled,\n isWaiting\n }\n );\n }\n\n function onClick() {\n if (!isDisabled && !isWaiting) {\n isActive = !isActive;\n }\n }\n",
"position": {
"start": {
"line": 1,
"column": 9,
"offset": 8
},
"end": {
"line": 25,
"column": 1,
"offset": 458
}
}
}
],
"position": {
"start": {
"line": 1,
"column": 1,
"offset": 0
},
"end": {
"line": 25,
"column": 10,
"offset": 467
}
}
},
{
"type": "text",
"value": "\n\n",
"position": {
"start": {
"line": 25,
"column": 10,
"offset": 467
},
"end": {
"line": 27,
"column": 1,
"offset": 469
}
}
},
{
"type": "svelteStyle",
"tagName": "style",
"properties": [],
"selfClosing": false,
"children": [
{
"type": "text",
"value": "\n .switch {\n background: #b2b8bf;\n color: #b2b8bf;\n border-radius: 12px;\n cursor: pointer;\n height: 22px;\n width: 44px;\n position: relative;\n transition: background 0.2s ease-in;\n }\n\n .isDisabled {\n background: #d8dbdf;\n color: #d8dbdf;\n cursor: default;\n }\n\n .isActive {\n background: #007aff;\n color: #007aff;\n }\n\n .isDisabled.isActive {\n background: #b9daff;\n color: #b9daff;\n }\n\n .isWaiting {\n cursor: default;\n }\n\n .handle {\n box-shadow: 1px 1px 1px 0 rgba(44, 62, 80, 0.64);\n background: #fff;\n border-radius: 18px;\n display: block;\n height: 18px;\n width: 18px;\n position: absolute;\n left: 2px;\n top: 2px;\n transition: all 0.15s ease-out;\n z-index: 2;\n }\n\n .isActive .handle {\n left: 24px;\n }\n\n .spinner {\n display: block;\n width: 12px;\n height: 12px;\n position: absolute;\n top: 50%;\n left: 50%;\n margin: -6px 0 0 -6px;\n animation: spinnerEnter 1s ease-out;\n }\n\n @keyframes spinnerEnter {\n from {\n opacity: 0;\n transform: scale(0.5);\n }\n }\n",
"position": {
"start": {
"line": 27,
"column": 8,
"offset": 476
},
"end": {
"line": 94,
"column": 1,
"offset": 1563
}
}
}
],
"position": {
"start": {
"line": 27,
"column": 1,
"offset": 469
},
"end": {
"line": 94,
"column": 9,
"offset": 1571
}
}
},
{
"type": "text",
"value": "\n\n\n",
"position": {
"start": {
"line": 94,
"column": 9,
"offset": 1571
},
"end": {
"line": 97,
"column": 1,
"offset": 1574
}
}
},
{
"type": "svelteElement",
"tagName": "div",
"properties": [
{
"type": "svelteProperty",
"name": "class",
"value": [
{
"type": "text",
"value": "switch",
"position": {
"start": {
"line": 97,
"column": 13,
"offset": 1586
},
"end": {}
}
},
{
"type": "text",
"value": " ",
"position": {
"start": {
"line": 97,
"column": 19,
"offset": 1592
},
"end": {
"line": 97,
"column": 20,
"offset": 1593
}
}
},
{
"type": "svelteDynamicContent",
"position": {
"start": {
"line": 97,
"column": 20,
"offset": 1593
},
"end": {
"line": 97,
"column": 32,
"offset": 1605
}
},
"expression": {
"type": "svelteExpression",
"value": "ClassNames",
"position": {
"start": {
"line": 97,
"column": 21,
"offset": 1594
},
"end": {
"line": 97,
"column": 31,
"offset": 1604
}
}
}
}
],
"modifiers": [],
"shorthand": "none",
"position": {
"start": {
"line": 97,
"column": 6,
"offset": 1579
},
"end": {
"line": 97,
"column": 33,
"offset": 1606
}
}
},
{
"type": "svelteDirective",
"name": "on",
"value": [
{
"type": "svelteDynamicContent",
"position": {
"start": {
"line": 97,
"column": 44,
"offset": 1617
},
"end": {
"line": 97,
"column": 53,
"offset": 1626
}
},
"expression": {
"type": "svelteExpression",
"value": "onClick",
"position": {
"start": {
"line": 97,
"column": 45,
"offset": 1618
},
"end": {
"line": 97,
"column": 52,
"offset": 1625
}
}
}
}
],
"modifiers": [],
"shorthand": "none",
"position": {
"start": {
"line": 97,
"column": 34,
"offset": 1607
},
"end": {
"line": 97,
"column": 54,
"offset": 1627
}
},
"specifier": "click"
}
],
"selfClosing": false,
"children": [
{
"type": "text",
"value": "\n ",
"position": {
"start": {
"line": 97,
"column": 55,
"offset": 1628
},
"end": {
"line": 98,
"column": 3,
"offset": 1631
}
}
},
{
"type": "svelteElement",
"tagName": "span",
"properties": [
{
"type": "svelteProperty",
"name": "class",
"value": [
{
"type": "text",
"value": "handle",
"position": {
"start": {
"line": 98,
"column": 16,
"offset": 1644
},
"end": {
"line": 98,
"column": 23,
"offset": 1651
}
}
}
],
"modifiers": [],
"shorthand": "none",
"position": {
"start": {
"line": 98,
"column": 9,
"offset": 1637
},
"end": {
"line": 98,
"column": 23,
"offset": 1651
}
}
}
],
"selfClosing": false,
"children": [
{
"type": "text",
"value": "\n ",
"position": {
"start": {
"line": 98,
"column": 24,
"offset": 1652
},
"end": {
"line": 99,
"column": 5,
"offset": 1657
}
}
},
{
"type": "svelteBranchingBlock",
"name": "if",
"branches": [
{
"type": "svelteBranch",
"name": "if",
"expression": {
"type": "svelteExpression",
"value": "isWaiting ",
"position": {
"start": {
"line": 99,
"column": 11,
"offset": 1663
},
"end": {
"line": 99,
"column": 21,
"offset": 1673
}
}
},
"children": [
{
"type": "text",
"value": "\n ",
"position": {
"start": {
"line": 99,
"column": 22,
"offset": 1674
},
"end": {
"line": 100,
"column": 5,
"offset": 1679
}
}
},
{
"type": "svelteElement",
"tagName": "span",
"properties": [
{
"type": "svelteProperty",
"name": "class",
"value": [
{
"type": "text",
"value": "spinner",
"position": {
"start": {
"line": 100,
"column": 18,
"offset": 1692
},
"end": {
"line": 100,
"column": 26,
"offset": 1700
}
}
}
],
"modifiers": [],
"shorthand": "none",
"position": {
"start": {
"line": 100,
"column": 11,
"offset": 1685
},
"end": {
"line": 100,
"column": 26,
"offset": 1700
}
}
}
],
"selfClosing": false,
"children": [
{
"type": "text",
"value": "\n ",
"position": {
"start": {
"line": 100,
"column": 27,
"offset": 1701
},
"end": {
"line": 101,
"column": 7,
"offset": 1708
}
}
},
{
"type": "svelteComponent",
"tagName": "Spinner",
"properties": [],
"selfClosing": false,
"children": [],
"position": {
"start": {
"line": 101,
"column": 7,
"offset": 1708
},
"end": {
"line": 101,
"column": 26,
"offset": 1727
}
}
},
{
"type": "text",
"value": "\n ",
"position": {
"start": {
"line": 101,
"column": 26,
"offset": 1727
},
"end": {
"line": 102,
"column": 5,
"offset": 1732
}
}
}
],
"position": {
"start": {
"line": 100,
"column": 5,
"offset": 1679
},
"end": {
"line": 102,
"column": 12,
"offset": 1739
}
}
},
{
"type": "text",
"value": "\n ",
"position": {
"start": {
"line": 102,
"column": 12,
"offset": 1739
},
"end": {
"line": 103,
"column": 5,
"offset": 1744
}
}
}
],
"position": {
"start": {
"line": 99,
"column": 5,
"offset": 1657
},
"end": {
"line": 103,
"column": 5,
"offset": 1744
}
}
}
],
"position": {
"start": {
"line": 99,
"column": 5,
"offset": 1657
},
"end": {
"line": 103,
"column": 12,
"offset": 1751
}
}
},
{
"type": "text",
"value": "\n ",
"position": {
"start": {
"line": 103,
"column": 12,
"offset": 1751
},
"end": {
"line": 104,
"column": 3,
"offset": 1754
}
}
}
],
"position": {
"start": {
"line": 98,
"column": 3,
"offset": 1631
},
"end": {
"line": 104,
"column": 10,
"offset": 1761
}
}
},
{
"type": "text",
"value": "\n",
"position": {
"start": {
"line": 104,
"column": 10,
"offset": 1761
},
"end": {
"line": 105,
"column": 1,
"offset": 1762
}
}
}
],
"position": {
"start": {
"line": 97,
"column": 1,
"offset": 1574
},
"end": {
"line": 105,
"column": 7,
"offset": 1768
}
}
}
],
"position": {
"start": {
"column": 1,
"line": 1,
"offset": 0
},
"end": {
"line": 105,
"column": 7,
"offset": 1768
}
}
}