From 3454ad0efd8066090fafb450bd352cf36774c489 Mon Sep 17 00:00:00 2001 From: tugcekucukoglu Date: Thu, 18 Jan 2024 15:53:33 +0300 Subject: [PATCH] Refactor #5066 --- components/lib/metergroup/MeterGroup.d.ts | 30 ++++++--- components/lib/metergroup/MeterGroup.vue | 67 +++++++++---------- components/lib/metergroup/MeterGroupLabel.vue | 36 ++++++++++ .../lib/metergroup/style/MeterGroupStyle.js | 17 ++--- 4 files changed, 96 insertions(+), 54 deletions(-) create mode 100644 components/lib/metergroup/MeterGroupLabel.vue diff --git a/components/lib/metergroup/MeterGroup.d.ts b/components/lib/metergroup/MeterGroup.d.ts index ddf934e7c..4f18ab53e 100644 --- a/components/lib/metergroup/MeterGroup.d.ts +++ b/components/lib/metergroup/MeterGroup.d.ts @@ -116,6 +116,10 @@ export interface MeterItemOptions { * Current color of the meter item. */ color: string; + /** + * Current icon of the meter item. + */ + icon: string; /** * Optional keys. */ @@ -187,7 +191,11 @@ export interface MeterGroupSlots { /** * Total percent of the metergroup items */ - totalPercent: string; + totalPercent: number; + /** + * Array of sequential sum of values of metergroup items + */ + percentages: number[]; }): VNode[]; /** * Custom meter template. @@ -212,15 +220,11 @@ export interface MeterGroupSlots { /** * Current width of the meter item */ - width: string; - /** - * Current height of the meter item - */ - height: string; + size: string; /** * Total percent of the metergroup items */ - totalPercent: string; + totalPercent: number; }): VNode[]; /** * Custom icon template. @@ -246,7 +250,11 @@ export interface MeterGroupSlots { /** * Total percent of the metergroup items */ - totalPercent: string; + totalPercent: number; + /** + * Array of sequential sum of values of metergroup items + */ + percentages: number[]; }): VNode[]; /** * Custom end template. @@ -259,7 +267,11 @@ export interface MeterGroupSlots { /** * Total percent of the metergroup items */ - totalPercent: string; + totalPercent: number; + /** + * Array of sequential sum of values of metergroup items + */ + percentages: number[]; }): VNode[]; } diff --git a/components/lib/metergroup/MeterGroup.vue b/components/lib/metergroup/MeterGroup.vue index 47b95e5cb..6ddd51c94 100644 --- a/components/lib/metergroup/MeterGroup.vue +++ b/components/lib/metergroup/MeterGroup.vue @@ -1,51 +1,26 @@ diff --git a/components/lib/metergroup/MeterGroupLabel.vue b/components/lib/metergroup/MeterGroupLabel.vue new file mode 100644 index 000000000..f48ca85e2 --- /dev/null +++ b/components/lib/metergroup/MeterGroupLabel.vue @@ -0,0 +1,36 @@ + + + diff --git a/components/lib/metergroup/style/MeterGroupStyle.js b/components/lib/metergroup/style/MeterGroupStyle.js index ff7d5f1b0..a7abe3a76 100644 --- a/components/lib/metergroup/style/MeterGroupStyle.js +++ b/components/lib/metergroup/style/MeterGroupStyle.js @@ -50,22 +50,23 @@ const css = ` `; const classes = { - root: ({ instance }) => [ + root: ({ props }) => [ 'p-metergroup p-component', { - 'p-metergroup-horizontal': instance.orientation === 'horizontal', - 'p-metergroup-vertical': instance.orientation === 'vertical' + 'p-metergroup-horizontal': props.orientation === 'horizontal', + 'p-metergroup-vertical': props.orientation === 'vertical' } ], metercontainer: 'p-metergroup-meter-container', meter: 'p-metergroup-meter', - labellist: ({ instance }) => [ + labellist: ({ props }) => [ 'p-metergroup-label-list', + { - 'p-metergroup-label-list-start': instance.labelPosition === 'start', - 'p-metergroup-label-list-end': instance.labelPosition === 'end', - 'p-metergroup-label-list-vertical': instance.labelOrientation === 'vertical', - 'p-metergroup-label-list-horizontal': instance.labelOrientation === 'horizontal' + 'p-metergroup-label-list-start': props.labelPosition === 'start', + 'p-metergroup-label-list-end': props.labelPosition === 'end', + 'p-metergroup-label-list-vertical': props.labelOrientation === 'vertical', + 'p-metergroup-label-list-horizontal': props.labelOrientation === 'horizontal' } ], labellistitem: 'p-metergroup-label-list-item',