Skip to content

Commit

Permalink
Refactor #3922 - For ToggleButton
Browse files Browse the repository at this point in the history
  • Loading branch information
tugcekucukoglu committed May 9, 2023
1 parent 53b595a commit f624aa2
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 26 deletions.
16 changes: 8 additions & 8 deletions components/lib/togglebutton/ToggleButton.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,6 @@ export interface ToggleButtonPassThroughOptions {
* Uses to pass attributes to the root's DOM element.
*/
root?: ToggleButtonPassThroughOptionType;
/**
* Uses to pass attributes to the input aria's DOM element.
*/
inputAria?: ToggleButtonPassThroughOptionType;
/**
* Uses to pass attributes to the input's DOM element.
*/
input?: ToggleButtonPassThroughOptionType;
/**
* Uses to pass attributes to the icon's DOM element.
*/
Expand All @@ -45,6 +37,14 @@ export interface ToggleButtonPassThroughOptions {
* Uses to pass attributes to the label's DOM element.
*/
label?: ToggleButtonPassThroughOptionType;
/**
* Uses to pass attributes to the hidden input wrapper's DOM element.
*/
hiddenInputWrapper?: ToggleButtonPassThroughOptionType;
/**
* Uses to pass attributes to the hidden input's DOM element.
*/
hiddenInput?: ToggleButtonPassThroughOptionType;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions components/lib/togglebutton/ToggleButton.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<div ref="container" v-ripple :class="buttonClass" @click="onClick($event)" v-bind="ptm('root')">
<span class="p-hidden-accessible" v-bind="ptm('inputAria')">
<span class="p-hidden-accessible" v-bind="ptm('hiddenInputWrapper')">
<input
:id="inputId"
type="checkbox"
Expand All @@ -13,7 +13,7 @@
:aria-label="ariaLabel"
@focus="onFocus($event)"
@blur="onBlur($event)"
v-bind="{ ...inputProps, ...ptm('input') }"
v-bind="{ ...inputProps, ...ptm('hiddenInput') }"
/>
</span>
<slot name="icon" :value="modelValue" :class="iconClass">
Expand Down
28 changes: 12 additions & 16 deletions doc/togglebutton/pt/PTDoc.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
<div class="card flex justify-content-center">
<ToggleButton
v-model="checked"
class="w-8rem"
:pt="{
root: () => ({
class: checked ? 'bg-green-500 border-white' : undefined
})
root: {
class: ['w-8rem', { 'bg-teal-400 border-white': checked }]
}
}"
/>
</div>
Expand All @@ -23,23 +22,21 @@ export default {
basic: `
<ToggleButton
v-model="checked"
class="w-8rem"
:pt="{
root: () => ({
class: checked ? 'bg-green-500 border-white' : undefined
})
root: {
class: ['w-8rem', { 'bg-teal-400 border-white': checked }]
}
}"
/>`,
options: `
<template>
<div class="card flex justify-content-center">
<ToggleButton
v-model="checked"
class="w-8rem"
:pt="{
root: () => ({
class: checked ? 'bg-green-500 border-white' : undefined
})
root: {
class: ['w-8rem', { 'bg-teal-400 border-white': checked }]
}
}"
/>
</div>
Expand All @@ -59,11 +56,10 @@ export default {
<div class="card flex justify-content-center">
<ToggleButton
v-model="checked"
class="w-8rem"
:pt="{
root: () => ({
class: checked ? 'bg-green-500 border-white' : undefined
})
root: {
class: ['w-8rem', { 'bg-teal-400 border-white': checked }]
}
}"
/>
</div>
Expand Down

0 comments on commit f624aa2

Please sign in to comment.