create-coralite 0.33.0 → 0.34.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-coralite",
3
- "version": "0.33.0",
3
+ "version": "0.34.0",
4
4
  "description": "Coralite scaffolding script",
5
5
  "bin": {
6
6
  "create-coralite": "bin/index.js",
@@ -8,7 +8,7 @@
8
8
  "build": "coralite-scripts build"
9
9
  },
10
10
  "devDependencies": {
11
- "coralite-scripts": "^0.33.0",
11
+ "coralite-scripts": "^0.34.0",
12
12
  "cross-env": "^10.1.0"
13
13
  }
14
14
  }
@@ -1,6 +1,6 @@
1
1
  <template id="coralite-counter">
2
2
  <button ref="count-button" type="button" class="btn">
3
- Count is 0
3
+ Count is {{ count }}
4
4
  </button>
5
5
  </template>
6
6
 
@@ -27,29 +27,30 @@
27
27
  import { defineComponent } from 'coralite'
28
28
 
29
29
  export default defineComponent({
30
- client: {
31
- imports: [
32
- {
33
- specifier: 'https://esm.sh/canvas-confetti@latest',
34
- defaultExport: 'confetti'
35
- }
36
- ],
37
- script ({ values, helpers, imports }) {
38
- const button = helpers.refs('count-button')
39
- const step = values.step ? parseInt(values.step) : 1
40
- let count = 0
41
-
42
- button.addEventListener('click', () => {
43
- // increment the counter by the specified step value
44
- count += step
45
-
46
- // update the button's text content to reflect the new count value
47
- button.textContent = `Count is ${count}`
48
-
49
- // Explode confetti :)
50
- imports.confetti()
51
- })
30
+ attributes: {
31
+ step: {
32
+ type: Number,
33
+ default: 1
52
34
  }
35
+ },
36
+
37
+ async data () {
38
+ return {
39
+ count: 0
40
+ }
41
+ },
42
+
43
+ async script ({ state, refs }) {
44
+ const { default: confetti } = await import('https://esm.sh/canvas-confetti@latest')
45
+ const button = refs('count-button')
46
+
47
+ button.addEventListener('click', () => {
48
+ // Coralite automatically patches the {{ count }} token in the template.
49
+ state.count += state.step
50
+
51
+ // Explode confetti :)
52
+ confetti()
53
+ })
53
54
  }
54
55
  })
55
56
  </script>
@@ -8,13 +8,16 @@
8
8
  import { defineComponent } from 'coralite'
9
9
 
10
10
  export default defineComponent({
11
- tokens: {
12
- capitaliseName ({ name }) {
13
- if (name) {
14
- return name[0].toUpperCase() + name.slice(1)
15
- }
11
+ attributes: {
12
+ name: {
13
+ type: String,
14
+ default: 'coralite'
15
+ }
16
+ },
16
17
 
17
- return 'Coralite'
18
+ getters: {
19
+ capitaliseName: (state) => {
20
+ return state.name[0].toUpperCase() + state.name.slice(1)
18
21
  }
19
22
  }
20
23
  })
@@ -8,7 +8,7 @@
8
8
  "build": "coralite-scripts build"
9
9
  },
10
10
  "devDependencies": {
11
- "coralite-scripts": "^0.33.0",
11
+ "coralite-scripts": "^0.34.0",
12
12
  "cross-env": "^10.1.0"
13
13
  }
14
14
  }
@@ -1,6 +1,6 @@
1
1
  <template id="coralite-counter">
2
2
  <button ref="count-button" type="button" class="btn">
3
- Count is 0
3
+ Count is {{ count }}
4
4
  </button>
5
5
  </template>
6
6
 
@@ -27,29 +27,30 @@
27
27
  import { defineComponent } from 'coralite'
28
28
 
29
29
  export default defineComponent({
30
- client: {
31
- imports: [
32
- {
33
- specifier: 'https://esm.sh/canvas-confetti@latest',
34
- defaultExport: 'confetti'
35
- }
36
- ],
37
- script ({ values, helpers, imports }) {
38
- const button = helpers.refs('count-button')
39
- const step = values.step ? parseInt(values.step) : 1
40
- let count = 0
41
-
42
- button.addEventListener('click', () => {
43
- // increment the counter by the specified step value
44
- count += step
45
-
46
- // update the button's text content to reflect the new count value
47
- button.textContent = `Count is ${count}`
48
-
49
- // Explode confetti :)
50
- imports.confetti()
51
- })
30
+ attributes: {
31
+ step: {
32
+ type: Number,
33
+ default: 1
52
34
  }
35
+ },
36
+
37
+ async data () {
38
+ return {
39
+ count: 0
40
+ }
41
+ },
42
+
43
+ async script ({ state, refs }) {
44
+ const { default: confetti } = await import('https://esm.sh/canvas-confetti@latest')
45
+ const button = refs('count-button')
46
+
47
+ button.addEventListener('click', () => {
48
+ // Coralite automatically patches the {{ count }} token in the template.
49
+ state.count += state.step
50
+
51
+ // Explode confetti :)
52
+ confetti()
53
+ })
53
54
  }
54
55
  })
55
56
  </script>
@@ -8,12 +8,19 @@
8
8
  import { defineComponent } from 'coralite'
9
9
 
10
10
  export default defineComponent({
11
- tokens: {
12
- capitaliseName ({ name }) {
13
- if (name) {
14
- return name[0].toUpperCase() + name.slice(1)
15
- }
11
+ attributes: {
12
+ name: {
13
+ type: String,
14
+ default: ''
15
+ }
16
+ },
16
17
 
18
+ getters: {
19
+ capitaliseName: (state) => {
20
+ if (state.name) {
21
+ return state.name[0].toUpperCase() + state.name.slice(1)
22
+ }
23
+
17
24
  return 'Coralite'
18
25
  }
19
26
  }