Refactor #3922 - For ToggleButton

pull/3938/head
Tuğçe Küçükoğlu 2023-05-09 11:57:03 +03:00
parent 53b595a236
commit f624aa2b9f
3 changed files with 22 additions and 26 deletions

View File

@ -29,14 +29,6 @@ export interface ToggleButtonPassThroughOptions {
* Uses to pass attributes to the root's DOM element. * Uses to pass attributes to the root's DOM element.
*/ */
root?: ToggleButtonPassThroughOptionType; 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. * Uses to pass attributes to the icon's DOM element.
*/ */
@ -45,6 +37,14 @@ export interface ToggleButtonPassThroughOptions {
* Uses to pass attributes to the label's DOM element. * Uses to pass attributes to the label's DOM element.
*/ */
label?: ToggleButtonPassThroughOptionType; 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;
} }
/** /**

View File

@ -1,6 +1,6 @@
<template> <template>
<div ref="container" v-ripple :class="buttonClass" @click="onClick($event)" v-bind="ptm('root')"> <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 <input
:id="inputId" :id="inputId"
type="checkbox" type="checkbox"
@ -13,7 +13,7 @@
:aria-label="ariaLabel" :aria-label="ariaLabel"
@focus="onFocus($event)" @focus="onFocus($event)"
@blur="onBlur($event)" @blur="onBlur($event)"
v-bind="{ ...inputProps, ...ptm('input') }" v-bind="{ ...inputProps, ...ptm('hiddenInput') }"
/> />
</span> </span>
<slot name="icon" :value="modelValue" :class="iconClass"> <slot name="icon" :value="modelValue" :class="iconClass">

View File

@ -3,11 +3,10 @@
<div class="card flex justify-content-center"> <div class="card flex justify-content-center">
<ToggleButton <ToggleButton
v-model="checked" v-model="checked"
class="w-8rem"
:pt="{ :pt="{
root: () => ({ root: {
class: checked ? 'bg-green-500 border-white' : undefined class: ['w-8rem', { 'bg-teal-400 border-white': checked }]
}) }
}" }"
/> />
</div> </div>
@ -23,11 +22,10 @@ export default {
basic: ` basic: `
<ToggleButton <ToggleButton
v-model="checked" v-model="checked"
class="w-8rem"
:pt="{ :pt="{
root: () => ({ root: {
class: checked ? 'bg-green-500 border-white' : undefined class: ['w-8rem', { 'bg-teal-400 border-white': checked }]
}) }
}" }"
/>`, />`,
options: ` options: `
@ -35,11 +33,10 @@ export default {
<div class="card flex justify-content-center"> <div class="card flex justify-content-center">
<ToggleButton <ToggleButton
v-model="checked" v-model="checked"
class="w-8rem"
:pt="{ :pt="{
root: () => ({ root: {
class: checked ? 'bg-green-500 border-white' : undefined class: ['w-8rem', { 'bg-teal-400 border-white': checked }]
}) }
}" }"
/> />
</div> </div>
@ -59,11 +56,10 @@ export default {
<div class="card flex justify-content-center"> <div class="card flex justify-content-center">
<ToggleButton <ToggleButton
v-model="checked" v-model="checked"
class="w-8rem"
:pt="{ :pt="{
root: () => ({ root: {
class: checked ? 'bg-green-500 border-white' : undefined class: ['w-8rem', { 'bg-teal-400 border-white': checked }]
}) }
}" }"
/> />
</div> </div>