v2.15.0

ProgressGroup

Один индикатор выполнения, который несёт сразу несколько значений, каждое в виде отдельного цветного сегмента.

Использование

ProgressGroup показывает несколько значений как сегменты одного индикатора выполнения.

  • Система19%
  • Приложения6%
  • Документы9%
  • Мультимедиа33%
<script setup lang="ts">
import type { ProgressGroupItem } from '@bxshefby/b24ui-nuxt'

const items = ref<ProgressGroupItem[]>([
  {
    label: 'Система',
    value: 24,
    color: 'air-secondary'
  },
  {
    label: 'Приложения',
    value: 8,
    color: 'air-primary-alert'
  },
  {
    label: 'Документы',
    value: 12,
    color: 'air-primary-warning'
  },
  {
    label: 'Мультимедиа',
    value: 42,
    color: 'air-primary-success'
  }
])
</script>

<template>
  <B24ProgressGroup :max="128" :items="items" class="w-96" />
</template>
<script setup lang="ts">
import { ref } from 'vue'
import type { ProgressGroupItem } from '@bxshefby/b24ui-nuxt'

const items = ref<ProgressGroupItem[]>([
  {
    label: 'Система',
    value: 24,
    color: 'air-secondary'
  },
  {
    label: 'Приложения',
    value: 8,
    color: 'air-primary-alert'
  },
  {
    label: 'Документы',
    value: 12,
    color: 'air-primary-warning'
  },
  {
    label: 'Мультимедиа',
    value: 42,
    color: 'air-primary-success'
  }
])
</script>

<template>
  <B24ProgressGroup :max="128" :items="items" class="w-96" />
</template>

Элементы

Пропс items — массив объектов со свойствами:

  • label?: string
  • icon?: IconComponent
  • value?: number
  • color?: "air-primary" | "air-primary-success" | "air-primary-alert" | "air-primary-copilot" | "air-primary-warning" | "air-secondary"
  • slot?: string
  • class?: any
  • b24ui?: { segment?: ClassNameValue, indicator?: ClassNameValue, item?: ClassNameValue, itemLeadingIcon?: ClassNameValue, itemLeadingDot?: ClassNameValue, itemLabel?: ClassNameValue, itemTrailing?: ClassNameValue }
  • Вычисления42%
  • Хранилище18%
  • Пропускная способность9%
<script setup lang="ts">
import type { ProgressGroupItem } from '@bxshefby/b24ui-nuxt'

const items = ref<ProgressGroupItem[]>([
  {
    label: 'Вычисления',
    value: 42,
    color: 'air-primary'
  },
  {
    label: 'Хранилище',
    value: 18,
    color: 'air-secondary'
  },
  {
    label: 'Пропускная способность',
    value: 9,
    color: 'air-primary-warning'
  }
])
</script>

<template>
  <B24ProgressGroup :items="items" class="w-96" />
</template>
<script setup lang="ts">
import { ref } from 'vue'
import type { ProgressGroupItem } from '@bxshefby/b24ui-nuxt'

const items = ref<ProgressGroupItem[]>([
  {
    label: 'Вычисления',
    value: 42,
    color: 'air-primary'
  },
  {
    label: 'Хранилище',
    value: 18,
    color: 'air-secondary'
  },
  {
    label: 'Пропускная способность',
    value: 9,
    color: 'air-primary-warning'
  }
])
</script>

<template>
  <B24ProgressGroup :items="items" class="w-96" />
</template>
Элементы без icon получают в списке цветную точку.

Максимум

Пропс max задаёт значение, которое составляют все элементы вместе. По умолчанию 100.

  • Система19%
  • Приложения6%
<script setup lang="ts">
import type { ProgressGroupItem } from '@bxshefby/b24ui-nuxt'

const items = ref<ProgressGroupItem[]>([
  {
    label: 'Система',
    value: 24
  },
  {
    label: 'Приложения',
    value: 8
  }
])
</script>

<template>
  <B24ProgressGroup :max="128" :items="items" class="w-96" />
</template>
<script setup lang="ts">
import { ref } from 'vue'
import type { ProgressGroupItem } from '@bxshefby/b24ui-nuxt'

const items = ref<ProgressGroupItem[]>([
  {
    label: 'Система',
    value: 24
  },
  {
    label: 'Приложения',
    value: 8
  }
])
</script>

<template>
  <B24ProgressGroup :max="128" :items="items" class="w-96" />
</template>
Если max не положительное число, используется 100, и сегменты сохраняют пропорции, а не схлопываются.

Статус

Пропс status показывает суммарное значение прогресса.

25%
  • Система19%
  • Приложения6%
<script setup lang="ts">
import type { ProgressGroupItem } from '@bxshefby/b24ui-nuxt'

const items = ref<ProgressGroupItem[]>([
  {
    label: 'Система',
    value: 24,
    color: 'air-secondary'
  },
  {
    label: 'Приложения',
    value: 8,
    color: 'air-primary-alert'
  }
])
</script>

<template>
  <B24ProgressGroup :max="128" status :items="items" class="w-96" />
</template>
<script setup lang="ts">
import { ref } from 'vue'
import type { ProgressGroupItem } from '@bxshefby/b24ui-nuxt'

const items = ref<ProgressGroupItem[]>([
  {
    label: 'Система',
    value: 24,
    color: 'air-secondary'
  },
  {
    label: 'Приложения',
    value: 8,
    color: 'air-primary-alert'
  }
])
</script>

<template>
  <B24ProgressGroup :max="128" status :items="items" class="w-96" />
</template>
Статус следует за концом полосы; чтобы растянуть его на всю ширину, используйте :b24ui="{ status: 'w-full' }".

Цвет

Пропс color задаёт цвет, который берут элементы без своего цвета.

  • Система19%
  • Приложения6%
<script setup lang="ts">
import type { ProgressGroupItem } from '@bxshefby/b24ui-nuxt'

const items = ref<ProgressGroupItem[]>([
  {
    label: 'Система',
    value: 24
  },
  {
    label: 'Приложения',
    value: 8
  }
])
</script>

<template>
  <B24ProgressGroup color="air-secondary" :max="128" :items="items" class="w-96" />
</template>
<script setup lang="ts">
import { ref } from 'vue'
import type { ProgressGroupItem } from '@bxshefby/b24ui-nuxt'

const items = ref<ProgressGroupItem[]>([
  {
    label: 'Система',
    value: 24
  },
  {
    label: 'Приложения',
    value: 8
  }
])
</script>

<template>
  <B24ProgressGroup color="air-secondary" :max="128" :items="items" class="w-96" />
</template>

Размер

Пропс size меняет толщину полосы.

  • Система19%
  • Приложения6%
<script setup lang="ts">
import type { ProgressGroupItem } from '@bxshefby/b24ui-nuxt'

const items = ref<ProgressGroupItem[]>([
  {
    label: 'Система',
    value: 24
  },
  {
    label: 'Приложения',
    value: 8
  }
])
</script>

<template>
  <B24ProgressGroup size="lg" :max="128" :items="items" class="w-96" />
</template>
<script setup lang="ts">
import { ref } from 'vue'
import type { ProgressGroupItem } from '@bxshefby/b24ui-nuxt'

const items = ref<ProgressGroupItem[]>([
  {
    label: 'Система',
    value: 24
  },
  {
    label: 'Приложения',
    value: 8
  }
])
</script>

<template>
  <B24ProgressGroup size="lg" :max="128" :items="items" class="w-96" />
</template>

Ориентация

Пропс orientation меняет направление полосы. По умолчанию horizontal.

  • Система19%
  • Приложения6%
<script setup lang="ts">
import type { ProgressGroupItem } from '@bxshefby/b24ui-nuxt'

const items = ref<ProgressGroupItem[]>([
  {
    label: 'Система',
    value: 24
  },
  {
    label: 'Приложения',
    value: 8
  }
])
</script>

<template>
  <B24ProgressGroup orientation="vertical" :max="128" :items="items" class="h-96" />
</template>
<script setup lang="ts">
import { ref } from 'vue'
import type { ProgressGroupItem } from '@bxshefby/b24ui-nuxt'

const items = ref<ProgressGroupItem[]>([
  {
    label: 'Система',
    value: 24
  },
  {
    label: 'Приложения',
    value: 8
  }
])
</script>

<template>
  <B24ProgressGroup orientation="vertical" :max="128" :items="items" class="h-96" />
</template>

Примеры

Со слотом status

Слот status заменяет суммарное значение вашим содержимым.

86GB used

42GB remaining

  • Системная19%
  • Приложения6%
  • Документы9%
  • Мультимедиа33%
<script setup lang="ts">
import type { ProgressGroupItem } from '@bxshefby/b24ui-nuxt'
import SettingsIcon from '@bitrix24/b24icons-vue/main/SettingsIcon'
import AppsIcon from '@bitrix24/b24icons-vue/outline/AppsIcon'
import FileIcon from '@bitrix24/b24icons-vue/main/FileIcon'
import PlayCircleIcon from '@bitrix24/b24icons-vue/main/PlayCircleIcon'

const max = 128

const items: ProgressGroupItem[] = [
  { label: 'Системная', value: 24, color: 'air-secondary', icon: SettingsIcon },
  { label: 'Приложения', value: 8, color: 'air-primary-alert', icon: AppsIcon },
  { label: 'Документы', value: 12, color: 'air-primary-warning', icon: FileIcon },
  { label: 'Мультимедиа', value: 42, color: 'air-primary-success', icon: PlayCircleIcon }
]

const used = items.reduce((total, item) => total + (item.value ?? 0), 0)
</script>

<template>
  <B24ProgressGroup :items="items" :max="max" status class="w-96" :b24ui="{ status: 'w-full justify-between' }">
    <template #status>
      <p>{{ used }}GB used</p>
      <p class="text-description">
        {{ max - used }}GB remaining
      </p>
    </template>
  </B24ProgressGroup>
</template>

Со слотами элементов

Слоты item-label и item-trailing меняют то, что легенда показывает для каждого элемента.

  • Системная24GB
  • Приложения8GB
  • Документы12GB
  • Мультимедиа42GB
<script setup lang="ts">
import type { ProgressGroupItem } from '@bxshefby/b24ui-nuxt'

const items: ProgressGroupItem[] = [
  { label: 'Системная', value: 24, color: 'air-secondary' },
  { label: 'Приложения', value: 8, color: 'air-primary-alert' },
  { label: 'Документы', value: 12, color: 'air-primary-warning' },
  { label: 'Мультимедиа', value: 42, color: 'air-primary-success' }
]
</script>

<template>
  <B24ProgressGroup :items="items" :max="128" class="w-96">
    <template #item-label="{ item }">
      <span class="font-(--ui-font-weight-medium)">{{ item.label }}</span>
    </template>

    <template #item-trailing="{ item }">
      {{ item.value }}GB
    </template>
  </B24ProgressGroup>
</template>

API

Пропсы

Prop Default Type
as'div'any

The element or component this component should render as.

items T[]
max100 number

The value all items add up to, used to compute each segment's share of the track.

statusboolean

Display the summed progress value.

size'md' "xs" | "sm" | "md" | "lg"
color'air-primary'"air-primary" | "air-primary-success" | "air-primary-alert" | "air-primary-warning" | "air-primary-copilot" | "air-secondary"
orientation'horizontal' "horizontal" | "vertical"

The orientation of the progress bar.

b24ui { root?: SlotClass; base?: SlotClass; segment?: SlotClass; indicator?: SlotClass; status?: SlotClass; list?: SlotClass; item?: SlotClass; itemLeadingIcon?: SlotClass; itemLeadingDot?: SlotClass; itemLabel?: SlotClass; itemTrailing?: SlotClass; }

Слоты

Slot Type
status{ percent: number; }
item{ item: T; index: number; percent: number; }
item-leading{ item: T; index: number; percent: number; }
item-label{ item: T; index: number; percent: number; }
item-trailing{ item: T; index: number; percent: number; }

Тема

https://github.com/bx-shef/b24-ui/tree/main/src/theme/progress-group.ts
export default {
  slots: {
    root: 'gap-2',
    base: 'flex overflow-hidden rounded-(--ui-border-radius-pill) bg-(--ui-color-base-5)',
    segment: 'duration-200 ease-out motion-reduce:transition-none',
    indicator: 'size-full bg-(--b24ui-background)',
    status: 'flex justify-end text-legend duration-200 ease-out motion-reduce:transition-none',
    list: 'flex flex-col gap-1',
    item: 'flex items-center gap-1.5 min-w-0',
    itemLeadingIcon: 'shrink-0',
    itemLeadingDot: 'shrink-0 rounded-(--ui-border-radius-pill)',
    itemLabel: 'truncate text-label',
    itemTrailing: 'ms-auto shrink-0 text-legend'
  },
  variants: {
    color: {
      'air-primary': {
        segment: 'style-filled',
        itemLeadingIcon: 'style-filled text-(--b24ui-background)',
        itemLeadingDot: 'style-filled bg-(--b24ui-background)'
      },
      'air-primary-success': {
        segment: 'style-filled-success',
        itemLeadingIcon: 'style-filled-success text-(--b24ui-background)',
        itemLeadingDot: 'style-filled-success bg-(--b24ui-background)'
      },
      'air-primary-alert': {
        segment: 'style-filled-alert',
        itemLeadingIcon: 'style-filled-alert text-(--b24ui-background)',
        itemLeadingDot: 'style-filled-alert bg-(--b24ui-background)'
      },
      'air-primary-copilot': {
        segment: 'style-filled-copilot',
        itemLeadingIcon: 'style-filled-copilot text-(--b24ui-background)',
        itemLeadingDot: 'style-filled-copilot bg-(--b24ui-background)'
      },
      'air-primary-warning': {
        segment: 'style-filled-warning',
        itemLeadingIcon: 'style-filled-warning text-(--b24ui-background)',
        itemLeadingDot: 'style-filled-warning bg-(--b24ui-background)'
      },
      'air-secondary': {
        segment: 'style-tinted',
        itemLeadingIcon: 'style-tinted text-(--b24ui-background)',
        itemLeadingDot: 'style-tinted bg-(--b24ui-background)'
      }
    },
    size: {
      xs: {
        status: 'text-(length:--ui-font-size-xs)/(--ui-font-line-height-sm)',
        list: 'text-(length:--ui-font-size-xs)/(--ui-font-line-height-sm)',
        itemLeadingIcon: 'size-3',
        itemLeadingDot: 'size-1.5'
      },
      sm: {
        status: 'text-(length:--ui-font-size-sm)/(--ui-font-line-height-sm)',
        list: 'text-(length:--ui-font-size-sm)/(--ui-font-line-height-sm)',
        itemLeadingIcon: 'size-4',
        itemLeadingDot: 'size-2'
      },
      md: {
        status: 'text-(length:--ui-font-size-sm)/(--ui-font-line-height-sm)',
        list: 'text-(length:--ui-font-size-sm)/(--ui-font-line-height-sm)',
        itemLeadingIcon: 'size-4',
        itemLeadingDot: 'size-2'
      },
      lg: {
        status: 'text-(length:--ui-font-size-sm)/(--ui-font-line-height-sm)',
        list: 'text-(length:--ui-font-size-sm)/(--ui-font-line-height-sm)',
        itemLeadingIcon: 'size-5',
        itemLeadingDot: 'size-2.5'
      }
    },
    orientation: {
      horizontal: {
        root: 'w-full flex flex-col',
        base: 'w-full flex-row',
        status: 'flex-row w-(--percent) transition-[width]'
      },
      vertical: {
        root: 'h-full flex flex-row-reverse',
        base: 'h-full flex-col',
        status: 'flex-col min-w-[32px] h-(--percent) transition-[height]'
      }
    }
  },
  compoundVariants: [
    {
      orientation: 'horizontal',
      size: 'xs',
      class: {
        base: 'h-[2px]'
      }
    },
    {
      orientation: 'horizontal',
      size: 'sm',
      class: {
        base: 'h-[4px]'
      }
    },
    {
      orientation: 'horizontal',
      size: 'md',
      class: {
        base: 'h-2'
      }
    },
    {
      orientation: 'horizontal',
      size: 'lg',
      class: {
        base: 'h-[12px]'
      }
    },
    {
      orientation: 'vertical',
      size: 'xs',
      class: {
        base: 'w-[2px]'
      }
    },
    {
      orientation: 'vertical',
      size: 'sm',
      class: {
        base: 'w-[4px]'
      }
    },
    {
      orientation: 'vertical',
      size: 'md',
      class: {
        base: 'w-2'
      }
    },
    {
      orientation: 'vertical',
      size: 'lg',
      class: {
        base: 'w-[12px]'
      }
    }
  ],
  defaultVariants: {
    color: 'air-primary',
    size: 'md'
  }
}

История изменений