From 631fd839caddd189a347a98c127bea998c4bc406 Mon Sep 17 00:00:00 2001 From: mertsincan Date: Sun, 14 Jan 2024 15:21:43 +0000 Subject: [PATCH] Refactor #5071 --- components/lib/togglebutton/ToggleButton.d.ts | 4 +++ components/lib/togglebutton/ToggleButton.vue | 12 ++++---- .../togglebutton/style/ToggleButtonStyle.js | 30 ++++++------------- 3 files changed, 20 insertions(+), 26 deletions(-) diff --git a/components/lib/togglebutton/ToggleButton.d.ts b/components/lib/togglebutton/ToggleButton.d.ts index 51ff88584..62080a7da 100755 --- a/components/lib/togglebutton/ToggleButton.d.ts +++ b/components/lib/togglebutton/ToggleButton.d.ts @@ -61,6 +61,10 @@ export interface ToggleButtonPassThroughOptions { * Used to pass attributes to the input's DOM element. */ input?: ToggleButtonPassThroughOptionType; + /** + * Used to pass attributes to the box's DOM element. + */ + box?: ToggleButtonPassThroughOptionType; /** * Used to pass attributes to the icon's DOM element. */ diff --git a/components/lib/togglebutton/ToggleButton.vue b/components/lib/togglebutton/ToggleButton.vue index 30e39299f..dffae4f4f 100755 --- a/components/lib/togglebutton/ToggleButton.vue +++ b/components/lib/togglebutton/ToggleButton.vue @@ -1,5 +1,5 @@ diff --git a/components/lib/togglebutton/style/ToggleButtonStyle.js b/components/lib/togglebutton/style/ToggleButtonStyle.js index c90f7ecf0..1c4ed4e22 100644 --- a/components/lib/togglebutton/style/ToggleButtonStyle.js +++ b/components/lib/togglebutton/style/ToggleButtonStyle.js @@ -3,49 +3,37 @@ import BaseStyle from 'primevue/base/style'; const css = ` @layer primevue { .p-togglebutton { + position: relative; display: inline-flex; user-select: none; - align-items: center; vertical-align: bottom; - text-align: center; - overflow: hidden; - position: relative; } .p-togglebutton-input { cursor: pointer; } - .p-button-label { + .p-togglebutton .p-button { flex: 1 1 auto; } - - .p-button-icon-right { - order: 1; - } - - .p-button-icon-only { - justify-content: center; - } - - .p-button-icon-only .p-button-label { - visibility: hidden; - width: 0; - flex: 0 0 auto; - } } `; const classes = { root: ({ instance, props }) => [ - 'p-togglebutton p-button p-component', + 'p-togglebutton p-component', { - 'p-button-icon-only': instance.hasIcon && !instance.hasLabel, 'p-disabled': props.disabled, 'p-highlight': instance.active } ], input: 'p-togglebutton-input', + box: ({ instance }) => [ + 'p-button p-component', + { + 'p-button-icon-only': instance.hasIcon && !instance.hasLabel + } + ], icon: ({ instance, props }) => [ 'p-button-icon', {