@@ -50,13 +50,61 @@ export default {
50
50
```
51
51
</docs>
52
52
53
+ <script setup lang="ts">
54
+ import { computed } from 'vue'
55
+
56
+ const props = withDefaults(defineProps<{
57
+ /**
58
+ * Specify the size of the saving icon.
59
+ */
60
+ size?: number
61
+
62
+ /**
63
+ * Specify what is saved.
64
+ * If not set the element will be hidden from accessibility tree.
65
+ */
66
+ name?: string
67
+
68
+ /**
69
+ * Set to true when saving is in progress.
70
+ */
71
+ saving?: boolean
72
+
73
+ /**
74
+ * Set to true if an error occured while saving.
75
+ */
76
+ error?: boolean
77
+ }>(), {
78
+ error: false,
79
+ name: '',
80
+ saving: false,
81
+ size: 20,
82
+ })
83
+
84
+ defineEmits<{
85
+ /**
86
+ * Click event on the icon.
87
+ */
88
+ click: [MouseEvent]
89
+ }>()
90
+
91
+ const indicatorColor = computed(() => {
92
+ if (props.error) {
93
+ return 'var(--color-error)'
94
+ }
95
+ if (props.saving) {
96
+ return 'var(--color-primary-element)'
97
+ }
98
+ return 'none'
99
+ })
100
+ </script>
101
+
53
102
<template>
54
103
<span :aria-label="name"
55
104
class="material-design-icon"
56
105
role="img"
57
106
@click="$emit('click', $event)">
58
- <svg :fill="fillColor"
59
- class="material-design-icon__svg"
107
+ <svg class="material-design-icon__svg"
60
108
:width="size"
61
109
:height="size"
62
110
viewBox="0 0 24 24">
@@ -67,49 +115,3 @@ export default {
67
115
</svg>
68
116
</span>
69
117
</template>
70
-
71
- <script>
72
- import { defineComponent } from 'vue'
73
-
74
- export default defineComponent({
75
- name: 'NcSavingIndicatorIcon',
76
- props: {
77
- /**
78
- * Specify the size of the saving icon.
79
- */
80
- size: {
81
- type: Number,
82
- default: 20,
83
- },
84
- /**
85
- * Specify what is saved.
86
- */
87
- name: {
88
- type: String,
89
- default: '',
90
- },
91
- /**
92
- * Set to true when saving is in progress.
93
- */
94
- saving: {
95
- type: Boolean,
96
- default: false,
97
- required: false,
98
- },
99
- /**
100
- * Set to true if an error occured while saving.
101
- */
102
- error: {
103
- type: Boolean,
104
- default: false,
105
- required: false,
106
- },
107
- },
108
- emits: ['click'],
109
- computed: {
110
- indicatorColor() {
111
- return this.error ? 'var(--color-error)' : (this.saving ? 'var(--color-primary-element)' : 'none')
112
- },
113
- },
114
- })
115
- </script>
0 commit comments