create-coralite 0.33.1 → 0.35.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.1",
3
+ "version": "0.35.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.1",
11
+ "coralite-scripts": "^0.35.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,18 +27,26 @@
27
27
  import { defineComponent } from 'coralite'
28
28
 
29
29
  export default defineComponent({
30
- async script ({ properties, refs }) {
30
+ attributes: {
31
+ step: {
32
+ type: Number,
33
+ default: 1
34
+ }
35
+ },
36
+
37
+ async data () {
38
+ return {
39
+ count: 0
40
+ }
41
+ },
42
+
43
+ async script ({ state, refs }) {
31
44
  const { default: confetti } = await import('https://esm.sh/canvas-confetti@latest')
32
45
  const button = refs('count-button')
33
- const step = properties.step ? parseInt(properties.step) : 1
34
- let count = 0
35
46
 
36
47
  button.addEventListener('click', () => {
37
- // increment the counter by the specified step value
38
- count += step
39
-
40
- // update the button's text content to reflect the new count value
41
- button.textContent = `Count is ${count}`
48
+ // Coralite automatically patches the {{ count }} token in the template.
49
+ state.count += state.step
42
50
 
43
51
  // Explode confetti :)
44
52
  confetti()
@@ -8,13 +8,16 @@
8
8
  import { defineComponent } from 'coralite'
9
9
 
10
10
  export default defineComponent({
11
- properties: {
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.1",
11
+ "coralite-scripts": "^0.35.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,18 +27,26 @@
27
27
  import { defineComponent } from 'coralite'
28
28
 
29
29
  export default defineComponent({
30
- async script ({ properties, refs }) {
30
+ attributes: {
31
+ step: {
32
+ type: Number,
33
+ default: 1
34
+ }
35
+ },
36
+
37
+ async data () {
38
+ return {
39
+ count: 0
40
+ }
41
+ },
42
+
43
+ async script ({ state, refs }) {
31
44
  const { default: confetti } = await import('https://esm.sh/canvas-confetti@latest')
32
45
  const button = refs('count-button')
33
- const step = properties.step ? parseInt(properties.step) : 1
34
- let count = 0
35
46
 
36
47
  button.addEventListener('click', () => {
37
- // increment the counter by the specified step value
38
- count += step
39
-
40
- // update the button's text content to reflect the new count value
41
- button.textContent = `Count is ${count}`
48
+ // Coralite automatically patches the {{ count }} token in the template.
49
+ state.count += state.step
42
50
 
43
51
  // Explode confetti :)
44
52
  confetti()
@@ -8,12 +8,19 @@
8
8
  import { defineComponent } from 'coralite'
9
9
 
10
10
  export default defineComponent({
11
- properties: {
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
  }