Skip to content

Commit fba0dc5

Browse files
committed
refactor: typescript
1 parent 0d98502 commit fba0dc5

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

docs/app/components/BadgeGenerator.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
<script setup>
1+
<script lang="ts" setup>
22
import { useClipboard } from '@vueuse/core'
33
44
const pkg = useState('badge-pkg', () => 'nuxt')
5-
const type = useState('badge-type', () => 'version')
5+
const type = useState<BadgeType>('badge-type', () => 'version')
66
const isValid = ref(true)
77
88
const { copy, copied } = useClipboard({ copiedDuring: 2000 })
@@ -11,7 +11,7 @@ watch([pkg, type], () => {
1111
isValid.value = true
1212
})
1313
14-
const formatLabel = str => {
14+
const formatLabel = (str: string) => {
1515
if (!str || typeof str !== 'string') return ''
1616
return str
1717
.split('-')

docs/app/components/BadgeGeneratorParameters.vue

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
<script setup>
1+
<script lang="ts" setup>
22
import { useClipboard } from '@vueuse/core'
33
44
const pkg = useState('badge-pkg', () => 'nuxt')
5-
const type = useState('badge-type', () => 'version')
5+
const type = useState<BadgeType>('badge-type', () => 'version')
66
const isValid = ref(true)
77
88
const { copy, copied } = useClipboard({ copiedDuring: 2000 })
@@ -16,7 +16,7 @@ const badgeStyle = useState('badge-style', () => 'default')
1616
1717
const styles = ['default', 'shieldsio']
1818
19-
const validateHex = hex => {
19+
const validateHex = (hex: string) => {
2020
if (!hex) return true
2121
const clean = hex.replace('#', '')
2222
return /^[0-9A-F]{3}$/i.test(clean) || /^[0-9A-F]{6}$/i.test(clean)
@@ -28,7 +28,7 @@ const isInputValid = computed(
2828
() => isLabelHexValid.value && isBadgeHexValid.value && pkg.value.length > 0,
2929
)
3030
31-
const cleanHex = hex => hex?.replace('#', '') || ''
31+
const cleanHex = (hex: string) => hex?.replace('#', '') || ''
3232
3333
const queryParams = computed(() => {
3434
if (!isInputValid.value) return ''
@@ -58,7 +58,7 @@ watch([pkg, type, queryParams], () => {
5858
isValid.value = true
5959
})
6060
61-
const formatLabel = str => {
61+
const formatLabel = (str: string) => {
6262
if (!str || typeof str !== 'string') return ''
6363
return str
6464
.split('-')

0 commit comments

Comments
 (0)