Skip to content

Commit 2d41bcc

Browse files
committed
refactor(NcSavingIndicatorIcon): migrate component to vue
Signed-off-by: Ferdinand Thiessen <[email protected]>
1 parent f457776 commit 2d41bcc

File tree

3 files changed

+51
-49
lines changed

3 files changed

+51
-49
lines changed

src/components/NcSavingIndicatorIcon/NcSavingIndicatorIcon.vue

+50-48
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,61 @@ export default {
5050
```
5151
</docs>
5252

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+
53102
<template>
54103
<span :aria-label="name"
55104
class="material-design-icon"
56105
role="img"
57106
@click="$emit('click', $event)">
58-
<svg :fill="fillColor"
59-
class="material-design-icon__svg"
107+
<svg class="material-design-icon__svg"
60108
:width="size"
61109
:height="size"
62110
viewBox="0 0 24 24">
@@ -67,49 +115,3 @@ export default {
67115
</svg>
68116
</span>
69117
</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>

src/components/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export { default as NcProgressBar } from './NcProgressBar/index.js'
7171
export { default as NcRelatedResourcesPanel } from './NcRelatedResourcesPanel/index.js'
7272
export { default as NcRichContenteditable, NcAutoCompleteResult, NcMentionBubble } from './NcRichContenteditable/index.js'
7373
export { default as NcRichText } from './NcRichText/index.js'
74-
export { default as NcSavingIndicatorIcon } from './NcSavingIndicatorIcon/index.js'
74+
export { default as NcSavingIndicatorIcon } from './NcSavingIndicatorIcon/index.ts'
7575
export { default as NcSelect } from './NcSelect/index.js'
7676
export { default as NcSelectTags } from './NcSelectTags/index.js'
7777
export { default as NcSettingsInputText } from './NcSettingsInputText/index.js'

0 commit comments

Comments
 (0)