v2.15.0

ContentSurround

Пара кнопок «Назад» и «Вперёд» для последовательной навигации по страницам.
Компонент доступен, только если установлен модуль @nuxt/content.

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

Пропс surround принимает значение surround, которое возвращается при получении соседних страниц.

<script setup lang="ts">
import { withoutTrailingSlash, withTrailingSlash } from 'ufo'

const route = useRoute()

const { data: surround } = await useAsyncData(`${route.path}-surround`, async () => {
  const surround = await queryCollectionItemSurroundings('docs', withoutTrailingSlash(route.path), {
    fields: ['description']
  })
  if (surround[0]) {
    surround[0].path = withTrailingSlash(surround[0].path)
  }
  if (surround[1]) {
    surround[1].path = withTrailingSlash(surround[1].path)
  }

  return surround
})
</script>

<template>
  <B24ContentSurround :surround="(surround as any)" />
</template>

Назад / Вперёд

Пропсы prev-icon и next-icon задают иконки кнопок.

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

const surround = ref<ContentSurroundLink[]>([
  {
    title: 'ContentSearchButton',
    path: '/docs/components/content-search-button/',
    stem: '3.components/content-search-button',
    description: 'Готовая кнопка Button, которая открывает модальное окно ContentSearch.'
  },
  {
    title: 'ContentToc',
    path: '/docs/components/content-toc/',
    stem: '3.components/content-toc',
    description: 'Закреплённое оглавление с настраиваемыми слотами.'
  }
])
</script>

<template>
  <B24ContentSurround :prev-icon="RocketIcon" :next-icon="RocketIcon" :surround="surround" />
</template>
<script setup lang="ts">
import { ref } from 'vue'
import RocketIcon from '@bitrix24/b24icons-vue/main/RocketIcon'
import type { ContentSurroundLink } from '@bxshefby/b24ui-nuxt'

const surround = ref<ContentSurroundLink[]>([
  {
    title: 'ContentSearchButton',
    path: '/docs/components/content-search-button/',
    stem: '3.components/content-search-button',
    description: 'Готовая кнопка Button, которая открывает модальное окно ContentSearch.'
  },
  {
    title: 'ContentToc',
    path: '/docs/components/content-toc/',
    stem: '3.components/content-toc',
    description: 'Закреплённое оглавление с настраиваемыми слотами.'
  }
])
</script>

<template>
  <B24ContentSurround :prev-icon="RocketIcon" :next-icon="RocketIcon" :surround="surround" />
</template>

Примеры

На странице

Компонент ContentSurround на странице показывает ссылки на предыдущую и следующую страницы:

pages/[...slug].vue
<script setup lang="ts">
const route = useRoute()

const { data: page } = await useAsyncData(route.path, () => queryCollection('docs').path(route.path).first())
if (!page.value) {
  throw createError({ status: 404, statusText: 'Page not found', fatal: true })
}
</script>

<template>
  <template v-if="page">
    <ProseH1>{{ page.title }}</ProseH1>

    <template v-if="page?.body?.toc?.links?.length">
      <B24ContentToc :links="page.body.toc.links" />
    </template>

    <div>
      <ContentRenderer v-if="page.body" :value="page" />

      <B24Separator v-if="surround?.filter(Boolean).length" class="my-4" />

      <B24ContentSurround :surround="(surround as any)" />
    </div>
  </template>
</template>

API

Пропсы

Prop Default Type
as'div'any

The element or component this component should render as.

prevIconicons.arrowLeftIconComponent

The icon displayed in the prev link.

nextIconicons.arrowRightIconComponent

The icon displayed in the next link.

surround T[]
b24ui { root?: SlotClass; link?: SlotClass; linkLeading?: SlotClass; linkLeadingIcon?: SlotClass; linkTitle?: SlotClass; linkDescription?: SlotClass; }

Слоты

Slot Type
link{ link: T; b24ui: object; }
link-leading{ link: T; b24ui: object; }
link-title{ link: T; b24ui: object; }
link-description{ link: T; b24ui: object; }

Тема

https://github.com/bx-shef/b24-ui/tree/main/src/theme/content/content-surround.ts
export default {
  slots: {
    root: 'grid grid-cols-1 sm:grid-cols-2 gap-[32px]',
    link: 'group block backdrop-blur-md rounded-(--ui-border-radius-md) px-[24px] py-[32px] bg-(--ui-color-design-outline-bg) border border-(--ui-color-design-outline-stroke) border-(length:--ui-design-outline-stroke-weight) cursor-pointer focus-visible:outline-(--ui-color-accent-main-primary) transition-colors',
    linkLeading: 'inline-flex items-center rounded-full select-none mb-[16px] p-[6px] bg-(--ui-color-design-outline-bg) group-hover:bg-[color-mix(in_srgb,_var(--ui-color-design-selection-bg)_100%,_var(--ui-color-bg-state-hover-default-hex)_var(--ui-color-bg-state-hover-default-opacity))] ring-(--ui-color-design-outline-stroke) ring-(length:--ui-design-outline-stroke-weight) group-hover:ring-[color-mix(in_srgb,_var(--ui-color-design-selection-stroke)_100%,_var(--ui-color-bg-state-hover-default-hex)_var(--ui-color-bg-state-hover-default-opacity))] transition',
    linkLeadingIcon: 'size-[20px] shrink-0 text-(--ui-color-design-outline-content-icon) group-hover:text-(--ui-color-design-outline-content-icon-alt) transition-[color,translate] motion-reduce:transition-none',
    linkTitle: 'font-(--ui-font-weight-bold) text-(length:--ui-font-size-lg)/(--ui-font-line-height-lg) text-(--ui-color-design-outline-content) mb-[4px] truncate',
    linkDescription: 'text-(length:--ui-font-size-sm)/(--ui-font-line-height-sm) text-(--ui-color-design-outline-content-secondary) text-pretty line-clamp-2'
  },
  variants: {
    direction: {
      left: {
        linkLeadingIcon: 'group-active:-translate-x-0.5'
      },
      right: {
        link: 'text-end',
        linkLeadingIcon: 'group-active:translate-x-0.5'
      }
    }
  }
}