v2.15.0

Banner

Верхний баннер для важных сообщений пользователю.

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

Заголовок

Пропс title показывает заголовок на Banner.

<template>
  <B24Banner
    title="Пробный период подписки закончился. Оформите подписку, чтобы продолжить работу со всеми приложениями."
  />
</template>

Иконка

Пропс icon показывает иконку на Banner.

<script setup lang="ts">
import RocketIcon from '@bitrix24/b24icons-vue/main/RocketIcon'
</script>

<template>
  <B24Banner
    :icon="RocketIcon"
    title="Пробный период подписки закончился. Оформите подписку, чтобы продолжить работу со всеми приложениями."
  />
</template>

Цвет

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

<script setup lang="ts">
import RocketIcon from '@bitrix24/b24icons-vue/main/RocketIcon'
</script>

<template>
  <B24Banner
    color="air-secondary-alert"
    :icon="RocketIcon"
    title="Пробный период подписки закончился. Оформите подписку, чтобы продолжить работу со всеми приложениями."
  />
</template>

Закрытие

Пропс close показывает кнопку, которой закрывают Banner. По умолчанию — false.

По нажатию на кнопку закрытия возникает событие close.
<template>
  <B24Banner id="example" title="The subscription trial has ended. Subscribe to continue using all apps." close />
</template>
После закрытия в локальное хранилище записывается banner-${id}, чтобы баннер больше не показывался.
В примере выше это banner-example.
Чтобы закрытие сохранялось после перезагрузки страницы, укажите пропс id. Без явного id баннер скрывается только на время текущей сессии и снова появляется после перезагрузки.

Иконка закрытия

Пропс close-icon задаёт иконку кнопки закрытия.

<script setup lang="ts">
import CircleCrossIcon from '@bitrix24/b24icons-vue/outline/CircleCrossIcon'
</script>

<template>
  <B24Banner
    title="The subscription trial has ended. Subscribe to continue using all apps."
    close
    :close-icon="CircleCrossIcon"
  />
</template>

Действия

Пропс actions добавляет в Banner действия — кнопки.

<script setup lang="ts">
import { RocketIcon } from '@bitrix24/b24icons-vue/main/RocketIcon'
import type { ButtonProps } from '@bxshefby/b24ui-nuxt'

const actions = ref<ButtonProps[]>([
  {
    label: 'Оформить подписку',
    color: 'air-primary'
  },
  {
    label: 'Открыть сканер',
    color: 'air-secondary-accent-2'
  }
])
</script>

<template>
  <B24Banner
    title="Пробный период подписки закончился. Оформите подписку, чтобы продолжить работу со всеми приложениями."
    :actions="actions"
  />
</template>
<script setup lang="ts">
import { ref } from 'vue'
import { RocketIcon } from '@bitrix24/b24icons-vue/main/RocketIcon'
import type { ButtonProps } from '@bxshefby/b24ui-nuxt'

const actions = ref<ButtonProps[]>([
  {
    label: 'Оформить подписку',
    color: 'air-primary'
  },
  {
    label: 'Открыть сканер',
    color: 'air-secondary-accent-2'
  }
])
</script>

<template>
  <B24Banner
    title="Пробный период подписки закончился. Оформите подписку, чтобы продолжить работу со всеми приложениями."
    :actions="actions"
  />
</template>
У кнопок действий по умолчанию color="air-secondary-no-accen" и size="xs". Эти значения можно переопределить в каждой кнопке.

Можно передать любое свойство компонента <NuxtLink>: to, target, rel и другие.

<template>
  <B24Banner
    to="https://apidocs.bitrix24.com/"
    target="_blank"
    title="Изучите REST API Битрикс24"
    color="air-primary"
  />
</template>
NuxtLink наследует остальные атрибуты, переданные компоненту Banner.

Примеры

В app.vue

Banner можно разместить в app.vue или в раскладке:

app.vue
<template>
  <B24App>
    <B24Banner
      :icon="Bitrix24Icon"
      title="Explore the Bitrix24 REST API"
      to="https://apidocs.bitrix24.com/"
    />
    <NuxtLayout>
      <NuxtPage />
    </NuxtLayout>
  </B24App>
</template>

API

Пропсы

Prop Default Type
as'div'any

The element or component this component should render as.

id string

A unique id saved to local storage to remember if the banner has been dismissed. Without an explicit id, the banner will not be persisted and will reappear on page reload.

iconIconComponent

The icon displayed next to the title.

title string
actions ButtonProps[]

Display a list of actions next to the title. { color: 'air-secondary-no-accent', size: 'xs' }

to string | J | W
target null | "_blank" | "_parent" | "_self" | "_top" | string & {}
color'air-primary-alert'"air-primary" | "air-primary-success" | "air-primary-alert" | "air-primary-warning" | "air-primary-copilot" | "air-secondary" | "air-secondary-alert" | "air-secondary-accent" | "air-secondary-accent-1" | "air-secondary-accent-2" | "air-tertiary"
closefalseboolean | Omit<ButtonProps, LinkPropsKeys>

Display a close button to dismiss the banner. { size: 'md', color: 'air-tertiary-no-accent' }

closeIconicons.closeIconComponent

The icon displayed in the close button.

b24ui { root?: SlotClass; container?: SlotClass; left?: SlotClass; center?: SlotClass; right?: SlotClass; icon?: SlotClass; title?: SlotClass; actions?: SlotClass; close?: SlotClass; }

Слоты

Slot Type
leading{ b24ui: object; }
title{}
actions{}
close{ b24ui: object; }

События

Event Type
close[]

Тема

https://github.com/bx-shef/b24-ui/tree/main/src/theme/banner.ts
export default {
  slots: {
    root: 'relative z-50 w-full bg-(--b24ui-background) transition-colors',
    container: 'flex items-center justify-between gap-3 h-12',
    left: 'hidden lg:flex-1 lg:flex lg:items-center',
    center: 'flex items-center gap-1.5 min-w-0',
    right: 'lg:flex-1 flex items-center justify-end',
    icon: 'size-5 shrink-0 text-(--b24ui-color) pointer-events-none',
    title: 'text-(length:--ui-font-size-sm)/(--ui-font-line-height-sm) text-(--b24ui-color) font-(--ui-font-weight-medium) truncate',
    actions: 'flex gap-1.5 shrink-0 isolate',
    close: '[--ui-btn-color:var(--b24ui-color)] hover:bg-(--ui-color-base-white-fixed)/10 focus-visible:bg-(--ui-color-base-white-fixed)/10 -me-1.5 lg:me-0'
  },
  variants: {
    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'
      },
      'air-secondary-alert': {
        root: 'style-tinted-alert'
      },
      'air-secondary-accent': {
        root: 'style-outline'
      },
      'air-secondary-accent-1': {
        root: 'style-outline-accent-1'
      },
      'air-secondary-accent-2': {
        root: 'style-outline-accent-2'
      },
      'air-tertiary': {
        root: 'style-outline-no-accent'
      }
    },
    to: {
      true: ''
    }
  },
  compoundVariants: [
    {
      to: true,
      class: {
        root: 'hover:bg-(--b24ui-background)/90'
      }
    }
  ],
  defaultVariants: {
    color: 'air-primary-alert'
  }
}