v2.15.0

Progress

Индикатор выполнения, показывающий, насколько завершена задача.

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

Директива v-model управляет значением Progress.

<script setup lang="ts">
const value = ref(24)
</script>

<template>
  <B24Progress v-model="value" />
</template>
<script setup lang="ts">
import { ref } from 'vue'

const value = ref(24)
</script>

<template>
  <B24Progress v-model="value" />
</template>
Компонент ProgressGroup делит одну полосу на несколько сегментов, которые в сумме дают общее значение.

Максимум

Пропс max задаёт максимальное значение Progress.

<script setup lang="ts">
const value = ref(2)
</script>

<template>
  <B24Progress v-model="value" :max="4" />
</template>
<script setup lang="ts">
import { ref } from 'vue'

const value = ref(2)
</script>

<template>
  <B24Progress v-model="value" :max="4" />
</template>

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

Поиск клиентов...
Квалификация...
Презентация...
Переговоры...
Сделка закрыта!
<script setup lang="ts">
const value = ref(3)
</script>

<template>
  <B24Progress
    v-model="value"
    :max="{
      '0': 'Поиск клиентов...',
      '1': 'Квалификация...',
      '2': 'Презентация...',
      '3': 'Переговоры...',
      '4': 'Сделка закрыта!'
    }"
  />
</template>
<script setup lang="ts">
import { ref } from 'vue'

const value = ref(3)
</script>

<template>
  <B24Progress
    v-model="value"
    :max="{
      '0': 'Поиск клиентов...',
      '1': 'Квалификация...',
      '2': 'Презентация...',
      '3': 'Переговоры...',
      '4': 'Сделка закрыта!'
    }"
  />
</template>

Статус

Пропс status показывает текущее значение Progress над полосой.

24%
<script setup lang="ts">
const value = ref(24)
</script>

<template>
  <B24Progress v-model="value" status />
</template>
<script setup lang="ts">
import { ref } from 'vue'

const value = ref(24)
</script>

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

Неопределённое состояние

Когда v-model не задан или значение равно null, Progress переходит в неопределённое состояние: полоса анимируется как loading; анимацию можно сменить пропсом animation.

<script setup lang="ts">
const value = ref(null)
</script>

<template>
  <B24Progress v-model="value" />
</template>
<script setup lang="ts">
import { ref } from 'vue'

const value = ref(null)
</script>

<template>
  <B24Progress v-model="value" />
</template>
Если пользователь предпочитает уменьшенное движение, анимация отключается, и полоса неопределённого состояния показывается как пульсация на всю ширину.

Анимация

Пропс animation меняет анимацию Progress на обратную карусель, качающуюся полосу или упругую полосу. По умолчанию loading.

<template>
  <B24Progress animation="swing" />
</template>

Ориентация

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

<template>
  <B24Progress orientation="vertical" class="h-48 justify-center" />
</template>

Цвет

Пропс color меняет цвет Progress.

<template>
  <B24Progress color="air-primary-copilot" />
</template>

Размер

Пропс size меняет размер Progress.

<template>
  <B24Progress size="lg" />
</template>

Инверсия

Пропс inverted визуально инвертирует Progress.

<template>
  <B24Progress inverted v-model="value" />
</template>

API

Пропсы

Prop Default Type
as'div'any

The element or component this component should render as.

max number | any[]

The maximum progress value

statusboolean

Display the current progress value

invertedfalseboolean

Whether the progress is visually inverted

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.

animation'loading' "carousel" | "loading" | "carousel-inverse" | "swing" | "elastic"
getValueLabel (value: number | null , max: number): string | undefined

A function to get the accessible label text in a human-readable format.

If not provided, the value label will be read as the numeric value as a percentage of the max value.

getValueText (value: number | null , max: number): string | undefined

A function to get the accessible value text representing the current value in a human-readable format.

modelValuenull null | number

The progress value. Can be bind as v-model.

b24ui { root?: SlotClass; base?: SlotClass; indicator?: SlotClass; status?: SlotClass; steps?: SlotClass; step?: SlotClass; }

Слоты

Slot Type
status{ percent?: number | undefined; }

События

Event Type
update:modelValue[value: string[] | undefined]
update:max[value: number]

Тема

https://github.com/bx-shef/b24-ui/tree/main/src/theme/progress.ts
export default {
  slots: {
    root: 'gap-2',
    base: 'relative overflow-hidden rounded-(--ui-border-radius-pill) bg-(--ui-color-base-5)',
    indicator: 'rounded-(--ui-border-radius-pill) size-full transition-transform duration-200 ease-out motion-reduce:transition-none motion-reduce:data-[state=indeterminate]:animate-pulse bg-(--b24ui-background)',
    status: 'flex justify-end text-legend duration-200 ease-out motion-reduce:transition-none',
    steps: 'grid items-end text-legend',
    step: 'truncate text-end row-start-1 col-start-1 transition-opacity ease-out'
  },
  variants: {
    animation: {
      loading: '',
      carousel: '',
      'carousel-inverse': '',
      swing: '',
      elastic: ''
    },
    color: {
      'air-primary': {
        root: 'style-filled'
      },
      'air-primary-success': {
        root: 'style-filled-success'
      },
      'air-primary-alert': {
        root: 'style-filled-alert'
      },
      'air-primary-copilot': {
        root: 'style-filled-copilot'
      },
      'air-primary-warning': {
        root: 'style-filled-warning'
      },
      'air-secondary': {
        root: 'style-tinted'
      },
      default: {
        root: 'style-old-default'
      },
      danger: {
        root: 'style-old-danger'
      },
      success: {
        root: 'style-old-success'
      },
      warning: {
        root: 'style-old-warning'
      },
      primary: {
        root: 'style-old-primary'
      },
      secondary: {
        root: 'style-old-secondary'
      },
      collab: {
        root: 'style-old-collab'
      },
      ai: {
        root: 'style-old-ai'
      }
    },
    size: {
      xs: {
        status: 'text-(length:--ui-font-size-xs)/(--ui-font-line-height-sm)',
        steps: 'text-(length:--ui-font-size-xs)/(--ui-font-line-height-sm)'
      },
      sm: {
        status: 'text-(length:--ui-font-size-sm)/(--ui-font-line-height-sm)',
        steps: 'text-(length:--ui-font-size-sm)/(--ui-font-line-height-sm)'
      },
      md: {
        status: 'text-(length:--ui-font-size-sm)/(--ui-font-line-height-sm)',
        steps: 'text-(length:--ui-font-size-sm)/(--ui-font-line-height-sm)'
      },
      lg: {
        status: 'text-(length:--ui-font-size-sm)/(--ui-font-line-height-sm)',
        steps: 'text-(length:--ui-font-size-sm)/(--ui-font-line-height-sm)'
      }
    },
    step: {
      active: {
        step: 'opacity-100'
      },
      first: {
        step: 'opacity-100 text-legend'
      },
      other: {
        step: 'opacity-0'
      },
      last: {
        step: ''
      }
    },
    orientation: {
      horizontal: {
        root: 'w-full flex flex-col',
        base: 'w-full',
        status: 'flex-row w-(--percent) transition-[width]'
      },
      vertical: {
        root: 'h-full flex flex-row-reverse',
        base: 'h-full',
        status: 'flex-col min-w-[32px] h-(--percent) transition-[height]'
      }
    },
    inverted: {
      true: {
        status: 'self-end'
      }
    }
  },
  compoundVariants: [
    {
      inverted: true,
      orientation: 'horizontal',
      class: {
        step: 'text-start',
        status: 'flex-row-reverse'
      }
    },
    {
      inverted: true,
      orientation: 'vertical',
      class: {
        steps: 'items-start',
        status: 'flex-col-reverse'
      }
    },
    {
      orientation: 'horizontal',
      size: 'xs',
      class: 'h-[2px]'
    },
    {
      orientation: 'horizontal',
      size: 'sm',
      class: 'h-[4px]'
    },
    {
      orientation: 'horizontal',
      size: 'md',
      class: 'h-2'
    },
    {
      orientation: 'horizontal',
      size: 'lg',
      class: 'h-[12px]'
    },
    {
      orientation: 'vertical',
      size: 'xs',
      class: 'w-[2px]'
    },
    {
      orientation: 'vertical',
      size: 'sm',
      class: 'w-[4px]'
    },
    {
      orientation: 'vertical',
      size: 'md',
      class: 'w-2'
    },
    {
      orientation: 'vertical',
      size: 'lg',
      class: 'w-[12px]'
    },
    {
      orientation: 'horizontal',
      animation: 'carousel',
      class: {
        indicator: 'motion-safe:data-[state=indeterminate]:animate-[carousel_2s_linear_infinite] motion-safe:data-[state=indeterminate]:rtl:animate-[carousel-rtl_2s_linear_infinite]'
      }
    },
    {
      orientation: 'vertical',
      animation: 'carousel',
      class: {
        indicator: 'motion-safe:data-[state=indeterminate]:animate-[carousel-vertical_2s_linear_infinite]'
      }
    },
    {
      orientation: 'horizontal',
      animation: 'carousel-inverse',
      class: {
        indicator: 'motion-safe:data-[state=indeterminate]:animate-[carousel-inverse_2s_linear_infinite] motion-safe:data-[state=indeterminate]:rtl:animate-[carousel-inverse-rtl_2s_linear_infinite]'
      }
    },
    {
      orientation: 'vertical',
      animation: 'carousel-inverse',
      class: {
        indicator: 'motion-safe:data-[state=indeterminate]:animate-[carousel-inverse-vertical_2s_linear_infinite]'
      }
    },
    {
      orientation: 'horizontal',
      animation: 'swing',
      class: {
        indicator: 'motion-safe:data-[state=indeterminate]:animate-[swing_2s_var(--ease-in-out)_infinite]'
      }
    },
    {
      orientation: 'vertical',
      animation: 'swing',
      class: {
        indicator: 'motion-safe:data-[state=indeterminate]:animate-[swing-vertical_2s_var(--ease-in-out)_infinite]'
      }
    },
    {
      orientation: 'horizontal',
      animation: 'elastic',
      class: {
        indicator: 'motion-safe:data-[state=indeterminate]:animate-[elastic_2s_var(--ease-in-out)_infinite]'
      }
    },
    {
      orientation: 'vertical',
      animation: 'elastic',
      class: {
        indicator: 'motion-safe:data-[state=indeterminate]:animate-[elastic-vertical_2s_var(--ease-in-out)_infinite]'
      }
    },
    {
      orientation: 'horizontal',
      animation: 'loading',
      class: {
        indicator: 'motion-safe:data-[state=indeterminate]:animate-[progressbar-loading_2s_infinite]'
      }
    },
    {
      orientation: 'vertical',
      animation: 'loading',
      class: {
        indicator: 'motion-safe:data-[state=indeterminate]:animate-[progressbar-loading-vertical_2s_infinite]'
      }
    }
  ],
  defaultVariants: {
    color: 'air-primary',
    animation: 'loading',
    size: 'md'
  }
}