Skip to content

Commit 8e7e2cf

Browse files
committed
refactor(components): use formkit notation for icons
1 parent 4f4f640 commit 8e7e2cf

18 files changed

+142
-52
lines changed

dev/pages/outputs/OutputBoolean.vue

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,32 @@
11
<script setup lang='ts'>
22
const primeAttributes = ''
3-
const customAttributes = 'icon, iconPosition (left, right)'
3+
const customAttributes = 'prefixIcon, prefix, suffix, suffixIcon'
44
55
const schema
66
= [
77
{
88
$formkit: 'primeOutputBoolean',
99
name: 'trueValue',
10-
label: 'True',
10+
label: 'True Example',
11+
prefix: 'MyValue',
12+
prefixIcon: 'pi pi-check',
13+
14+
},
15+
{
16+
$formkit: 'primeOutputBoolean',
17+
name: 'falseValue',
18+
label: 'False',
19+
suffix: 'MyValue',
20+
suffixIcon: 'pi pi-check',
1121
},
1222
{
1323
$formkit: 'primeOutputBoolean',
1424
name: 'falseValue',
1525
label: 'False',
26+
prefix: 'prefix',
27+
prefixIcon: 'pi pi-check',
28+
suffix: 'suffix',
29+
suffixIcon: 'pi pi-times',
1630
},
1731
1832
]

dev/pages/outputs/OutputDate.vue

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script setup lang='ts'>
22
const primeAttributes = ''
3-
const customAttributes = 'icon, iconPosition (left, right)'
3+
const customAttributes = 'prefixIcon, prefix, suffix, suffixIcon'
44
55
const schema
66
= [
@@ -15,16 +15,14 @@ const schema
1515
name: 'date2',
1616
label: 'Icon Left',
1717
help: '',
18-
icon: 'pi pi-check',
19-
iconPosition: 'left',
18+
prefixIcon: 'pi pi-check',
2019
},
2120
{
2221
$formkit: 'primeOutputDate',
2322
name: 'date3',
2423
label: 'Icon Right',
2524
help: 'Right Icon Demo',
26-
icon: 'pi pi-check text-yellow-500',
27-
iconPosition: 'right',
25+
suffixIcon: 'pi pi-check text-yellow-500',
2826
},
2927
3028
]

dev/pages/outputs/OutputDuration.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script setup lang='ts'>
22
const primeAttributes = ''
3-
const customAttributes = 'icon, iconPosition (left, right)'
3+
const customAttributes = 'prefixIcon, prefix, suffix, suffixIcon'
44
55
const schema
66
= [

dev/pages/outputs/OutputLink.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script setup lang='ts'>
22
const primeAttributes = ''
3-
const customAttributes = 'icon, iconPosition (left, right)'
3+
const customAttributes = 'prefixIcon, prefix, suffix, suffixIcon'
44
55
const schema
66
= [

dev/pages/outputs/OutputList.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script setup lang='ts'>
22
const primeAttributes = ''
3-
const customAttributes = 'icon, iconPosition (left, right)'
3+
const customAttributes = 'prefixIcon, prefix, suffix, suffixIcon'
44
55
const schema
66
= [

dev/pages/outputs/OutputNumber.vue

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script setup lang='ts'>
22
const primeAttributes = ''
3-
const customAttributes = 'icon, iconPosition (left, right)'
3+
const customAttributes = 'prefixIcon, prefix, suffix, suffixIcon'
44
55
const schema
66
= [
@@ -15,15 +15,16 @@ const schema
1515
name: 'number2',
1616
label: 'Icon Left',
1717
help: '',
18-
icon: 'pi pi-check',
19-
iconPosition: 'left',
18+
prefixIcon: 'pi pi-check',
2019
},
2120
{
2221
$formkit: 'primeOutputNumber',
2322
name: 'number3',
2423
format: 'currency',
2524
label: 'Icon Right',
2625
help: 'Right Icon Demo',
26+
suffixIcon: 'pi pi-check',
27+
2728
},
2829
2930
]

dev/pages/outputs/OutputText.vue

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script setup lang='ts'>
22
const primeAttributes = ''
3-
const customAttributes = 'icon, iconPosition (left, right)'
3+
const customAttributes = 'prefixIcon, prefix, suffix, suffixIcon'
44
55
const schema
66
= [
@@ -15,16 +15,14 @@ const schema
1515
name: 'iconLeft',
1616
label: 'Icon Left',
1717
help: '',
18-
icon: 'pi pi-check',
19-
iconPosition: 'left',
18+
prefixIcon: 'pi pi-check',
2019
},
2120
{
2221
$formkit: 'primeOutputText',
2322
name: 'iconRight',
2423
label: 'Icon Right',
2524
help: 'Right Icon Demo',
26-
icon: 'pi pi-check text-yellow-500',
27-
iconPosition: 'right',
25+
suffixIcon: 'pi pi-check text-yellow-500',
2826
},
2927
3028
]

src/components/PrimeOutputBoolean.vue

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<script setup lang='ts'>
22
import { useI18n } from 'vue-i18n'
33
import { computed } from 'vue'
4-
import { useFormKitIcon } from '../composables'
4+
import { useFormKitSection } from '../composables'
55
66
const props = defineProps({
77
context: Object,
88
})
9-
const { hasIcon, icon, iconPosition } = useFormKitIcon(props.context)
9+
const { hasPrefix, hasPrefixIcon, hasSuffix, hasSuffixIcon } = useFormKitSection(props.context)
1010
1111
const { t } = useI18n()
1212
@@ -20,10 +20,16 @@ const translated = computed(() => {
2020

2121
<template>
2222
<div class="p-formkit p-output-boolean">
23-
<i v-if="hasIcon && iconPosition === 'left'" :class="icon" class="p-formkit-icon-left" />
23+
<i v-if="hasPrefixIcon" class="formkit-prefix-icon" :class="context?.prefixIcon" />
24+
<span v-if="hasPrefix" class="formkit-prefix">
25+
{{ context?.attrs?.prefix }}
26+
</span>
2427
<span :id="context?.id" :style="context?.attrs?.style" :class="context?.attrs?.class">
2528
{{ translated }}
2629
</span>
27-
<i v-if="hasIcon && iconPosition === 'right'" :class="icon" class="p-formkit-icon-right" />
30+
<span v-if="hasSuffix" class="formkit-suffix">
31+
{{ context?.attrs?.suffix }}
32+
</span>
33+
<i v-if="hasSuffixIcon" class="formkit-suffix-icon" :class="context?.suffixIcon" />
2834
</div>
2935
</template>

src/components/PrimeOutputDate.vue

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<script setup lang='ts'>
22
import { useI18n } from 'vue-i18n'
33
import { computed } from 'vue'
4-
import { useFormKitIcon } from '../composables'
4+
import { useFormKitSection } from '../composables'
55
66
const props = defineProps({
77
context: Object,
88
})
9-
const { hasIcon, icon, iconPosition } = useFormKitIcon(props.context)
9+
const { hasPrefix, hasPrefixIcon, hasSuffix, hasSuffixIcon } = useFormKitSection(props.context)
1010
1111
const { d } = useI18n()
1212
@@ -30,10 +30,16 @@ const converted = computed(() => {
3030

3131
<template>
3232
<div class="p-formkit p-output-date">
33-
<i v-if="hasIcon && iconPosition === 'left'" :class="icon" class="p-formkit-icon-left" />
33+
<i v-if="hasPrefixIcon" class="formkit-prefix-icon" :class="context?.prefixIcon" />
34+
<span v-if="hasPrefix" class="formkit-prefix">
35+
{{ context?.attrs?.prefix }}
36+
</span>
3437
<span :id="context?.id" :style="context?.attrs?.style" :class="context?.attrs?.class">
3538
{{ converted }}
3639
</span>
37-
<i v-if="hasIcon && iconPosition === 'right'" :class="icon" class="p-formkit-icon-right" />
40+
<span v-if="hasSuffix" class="formkit-suffix">
41+
{{ context?.attrs?.suffix }}
42+
</span>
43+
<i v-if="hasSuffixIcon" class="formkit-suffix-icon" :class="context?.suffixIcon" />
3844
</div>
3945
</template>
Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,27 @@
11
<script setup lang='ts'>
2-
import { useFormKitIcon, useOutputDuration } from '../composables'
2+
import { useFormKitSection, useOutputDuration } from '../composables'
33
44
const props = defineProps({
55
context: Object,
66
})
77
8-
const { hasIcon, icon, iconPosition } = useFormKitIcon(props.context)
8+
const { hasPrefix, hasPrefixIcon, hasSuffix, hasSuffixIcon } = useFormKitSection(props.context)
99
1010
const { formattedDuration } = useOutputDuration()
1111
</script>
1212

1313
<template>
1414
<div class="p-formkit p-output-duration">
15-
<i v-if="hasIcon && iconPosition === 'left'" :class="icon" class="p-formkit-icon-left" />
15+
<i v-if="hasPrefixIcon" class="formkit-prefix-icon" :class="context?.prefixIcon" />
16+
<span v-if="hasPrefix" class="formkit-prefix">
17+
{{ context?.attrs?.prefix }}
18+
</span>
1619
<span :id="context?.id" :style="context?.attrs?.style" :class="context?.attrs?.class">
1720
{{ formattedDuration(context?._value) }}
1821
</span>
19-
<i v-if="hasIcon && iconPosition === 'right'" :class="icon" class="p-formkit-icon-right" />
22+
<span v-if="hasSuffix" class="formkit-suffix">
23+
{{ context?.attrs?.suffix }}
24+
</span>
25+
<i v-if="hasSuffixIcon" class="formkit-suffix-icon" :class="context?.suffixIcon" />
2026
</div>
2127
</template>

0 commit comments

Comments
 (0)