Перейти к содержимому

Интеграции ​

Вкладки настроек, объявление об обновлении и подключённые приложения с поиском и переключателями.

Состав: Avatar, AvatarLabelGroup, Badge, Button, DropdownMenu, EmptyState, IconButton, InlineCta, InputGroup, Kbd, PageHeader, QueryContainer, SectionHeader, Select, Sidebar, Slideout, Switch, Tabs.

vue
<script setup lang="ts">
import {
  PageHeader,
  PageHeaderContent,
  PageHeaderHeading,
  PageHeaderTitle,
} from '@prosper/ui'

import SettingsIntegrationsSections from './SettingsIntegrationsSections.vue'
import ShellLayout from './ShellLayout.vue'
</script>

<template>
  <ShellLayout current="Настройки">
    <div class="page">
      <PageHeader>
        <PageHeaderContent>
          <PageHeaderHeading>
            <PageHeaderTitle>Настройки</PageHeaderTitle>
          </PageHeaderHeading>
        </PageHeaderContent>
      </PageHeader>
      <SettingsIntegrationsSections />
    </div>
  </ShellLayout>
</template>

<style scoped>
.page {
  display: flex;
  flex-direction: column;
  gap: var(--prosper-spacing-2xl);
}
</style>
vue
<script setup lang="ts">
import {
  EmptyState,
  EmptyStateDescription,
  EmptyStateTitle,
  InputGroup,
  InputGroupAddon,
  InputGroupInput,
  SectionHeader,
  SectionHeaderContent,
  SectionHeaderDescription,
  SectionHeaderHeading,
  SectionHeaderTitle,
} from '@prosper/ui'
import { SearchLg } from '@prosper/ui/icons'
import { computed, ref } from 'vue'

import { connectedApps } from '../data/settings-integrations'
import SettingsIntegrationsRow from './SettingsIntegrationsRow.vue'

const query = ref('')

const apps = ref(connectedApps.map((app) => ({ ...app })))

const shown = computed(() => {
  const needle = query.value.trim().toLocaleLowerCase('ru')

  return apps.value.filter((app) =>
    `${app.name} ${app.description}`.toLocaleLowerCase('ru').includes(needle),
  )
})
</script>

<template>
  <section class="apps" aria-labelledby="connected-apps-title">
    <SectionHeader>
      <SectionHeaderContent>
        <SectionHeaderHeading>
          <SectionHeaderTitle id="connected-apps-title" as="h2">
            Подключённые приложения
          </SectionHeaderTitle>
          <SectionHeaderDescription>
            Подключите сервисы, с которыми команда работает каждый день.
          </SectionHeaderDescription>
        </SectionHeaderHeading>
        <InputGroup size="sm" class="search">
          <InputGroupAddon><SearchLg /></InputGroupAddon>
          <InputGroupInput
            v-model="query"
            type="search"
            aria-label="Поиск приложений"
            placeholder="Поиск"
          />
        </InputGroup>
      </SectionHeaderContent>
    </SectionHeader>
    <ul v-if="shown.length > 0" class="list">
      <SettingsIntegrationsRow
        v-for="app in shown"
        :key="app.id"
        v-model:connected="app.connected"
        :app="app"
      />
    </ul>
    <EmptyState v-else size="sm">
      <EmptyStateTitle>Ничего не найдено</EmptyStateTitle>
      <EmptyStateDescription>
        Измените запрос, чтобы увидеть приложения.
      </EmptyStateDescription>
    </EmptyState>
  </section>
</template>

<style scoped>
.apps {
  display: flex;
  flex-direction: column;
  gap: var(--prosper-spacing-3xl);
}

.search {
  flex: 0 1 calc(var(--prosper-space-80) - var(--prosper-space-10));
}

@media (width < 40rem) {
  .search {
    flex-basis: 100%;
  }
}

.list {
  margin: 0;
  padding: 0;
  list-style: none;
}
</style>
vue
<script setup lang="ts">
import {
  Button,
  InlineCta,
  InlineCtaActions,
  InlineCtaContent,
  InlineCtaDescription,
  InlineCtaHeading,
  InlineCtaMedia,
  InlineCtaTitle,
} from '@prosper/ui'
import { ref } from 'vue'

import SettingsIntegrationsApps from './SettingsIntegrationsApps.vue'

const announced = ref(true)

const photo =
  "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 240 150'%3E%3Cdefs%3E%3ClinearGradient id='g' x2='1' y2='1'%3E%3Cstop offset='0' stop-color='%23d9d6fe'/%3E%3Cstop offset='1' stop-color='%237a5af8'/%3E%3C/linearGradient%3E%3C/defs%3E%3Cpath fill='url(%23g)' d='M0 0h240v150H0z'/%3E%3C/svg%3E"
</script>

<template>
  <div class="panel">
    <InlineCta v-if="announced">
      <InlineCtaMedia><img :src="photo" alt="" /></InlineCtaMedia>
      <InlineCtaContent>
        <InlineCtaHeading>
          <InlineCtaTitle as="h2">Мы выпустили обновление</InlineCtaTitle>
          <InlineCtaDescription>
            Новый вид панели: страницы теперь открываются быстрее.
          </InlineCtaDescription>
        </InlineCtaHeading>
        <InlineCtaActions>
          <Button size="sm" variant="secondary" @click="announced = false">
            Скрыть
          </Button>
          <Button size="sm">Что нового</Button>
        </InlineCtaActions>
      </InlineCtaContent>
    </InlineCta>
    <SettingsIntegrationsApps />
  </div>
</template>

<style scoped>
.panel {
  display: flex;
  flex-direction: column;
  gap: var(--prosper-spacing-4xl);
}
</style>
vue
<script setup lang="ts">
import { Button, Switch } from '@prosper/ui'
import {
  CheckSquareBroken,
  GitBranch01,
  LayersThree01,
  MessageChatCircle,
  File06,
  Zap,
} from '@prosper/ui/icons'
import type { Component } from 'vue'

import type { AppIcon, ConnectedApp } from '../data/settings-integrations'

defineProps<{ app: ConnectedApp }>()

const connected = defineModel<boolean>('connected', { required: true })

const icons: Record<AppIcon, Component> = {
  tracker: CheckSquareBroken,
  code: GitBranch01,
  layouts: LayersThree01,
  automation: Zap,
  notes: File06,
  chat: MessageChatCircle,
}
</script>

<template>
  <li class="row">
    <span class="logo" aria-hidden="true">
      <component :is="icons[app.icon]" size="100%" />
    </span>
    <div class="text">
      <h3 class="name">{{ app.name }}</h3>
      <p class="description">{{ app.description }}</p>
    </div>
    <Button
      variant="link-gray"
      class="more"
      :aria-label="`Подробнее: ${app.name}`"
    >
      Подробнее
    </Button>
    <Switch
      v-model:checked="connected"
      size="md"
      :aria-label="`Подключить ${app.name}`"
      class="toggle"
    />
  </li>
</template>

<style scoped>
.row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: var(--prosper-spacing-xl);
  padding-block: var(--prosper-spacing-xl);
  border-block-end: 1px solid var(--prosper-color-border-secondary);
}

.row:last-child {
  border-block-end: 0;
}

.logo {
  display: inline-flex;
  box-sizing: border-box;
  inline-size: calc(var(--prosper-space-12) + 2 * var(--prosper-spacing-xxs));
  block-size: calc(var(--prosper-space-12) + 2 * var(--prosper-spacing-xxs));
  padding: var(--prosper-spacing-md);
  border: 1px solid var(--prosper-color-border-secondary);
  border-radius: var(--prosper-radius-md);
  color: var(--prosper-color-fg-brand-primary);
}

.name {
  margin: 0;
  color: var(--prosper-color-text-primary);
  font-size: var(--prosper-text-md-size);
  font-weight: var(--prosper-font-weight-semibold);
  line-height: var(--prosper-text-md-line-height);
}

.description {
  margin: 0;
  color: var(--prosper-color-text-tertiary);
  font-size: var(--prosper-text-sm-size);
  line-height: var(--prosper-text-sm-line-height);
  overflow-wrap: anywhere;
}

@media (width < 40rem) {
  .row {
    grid-template-columns: auto 1fr auto;
    grid-template-areas: 'logo . toggle' 'text text text' 'more more more';
    align-items: start;
  }

  .logo {
    grid-area: logo;
  }

  .text {
    grid-area: text;
  }

  .more {
    grid-area: more;
    justify-self: start;
  }

  .toggle {
    grid-area: toggle;
    align-self: center;
  }
}
</style>
vue
<script setup lang="ts">
import {
  Badge,
  EmptyState,
  EmptyStateDescription,
  EmptyStateTitle,
  Select,
  SelectItem,
  Tabs,
  TabsContent,
  TabsList,
  TabsTrigger,
} from '@prosper/ui'
import { ref } from 'vue'

import { integrationSections } from '../data/settings-integrations'
import SettingsIntegrationsPanel from './SettingsIntegrationsPanel.vue'

const section = ref<string | number>('integrations')
</script>

<template>
  <div class="sections">
    <Select v-model="section" aria-label="Раздел настроек" class="narrow">
      <SelectItem
        v-for="item in integrationSections"
        :key="item.value"
        :value="item.value"
      >
        {{ item.label }}
      </SelectItem>
    </Select>
    <Tabs v-model="section" variant="underline" size="sm">
      <TabsList aria-label="Разделы настроек" class="wide">
        <TabsTrigger
          v-for="item in integrationSections"
          :key="item.value"
          :value="item.value"
        >
          {{ item.label }}
          <template v-if="'count' in item" #trailing>
            <Badge size="sm">{{ item.count }}</Badge>
          </template>
        </TabsTrigger>
      </TabsList>
      <TabsContent
        v-for="item in integrationSections"
        :key="item.value"
        :value="item.value"
      >
        <div class="panel">
          <SettingsIntegrationsPanel v-if="item.value === 'integrations'" />
          <EmptyState v-else size="sm">
            <EmptyStateTitle>{{ item.label }}</EmptyStateTitle>
            <EmptyStateDescription>
              Раздел не входит в пример.
            </EmptyStateDescription>
          </EmptyState>
        </div>
      </TabsContent>
    </Tabs>
  </div>
</template>

<style scoped>
.sections {
  display: flex;
  flex-direction: column;
}

.panel {
  margin-block-start: var(--prosper-spacing-4xl);
}

@media (width < 80rem) {
  .wide {
    display: none;
  }
}

@media (width >= 80rem) {
  .narrow {
    display: none;
  }
}
</style>
ts
export const integrationSections = [
  { value: 'details', label: 'Мои данные' },
  { value: 'profile', label: 'Профиль' },
  { value: 'password', label: 'Пароль' },
  { value: 'team', label: 'Команда' },
  { value: 'plan', label: 'Тариф' },
  { value: 'billing', label: 'Оплата' },
  { value: 'email', label: 'Почта' },
  { value: 'notifications', label: 'Уведомления', count: 2 },
  { value: 'integrations', label: 'Интеграции' },
  { value: 'api', label: 'API' },
] as const

export type AppIcon =
  'tracker' | 'code' | 'layouts' | 'automation' | 'notes' | 'chat'

export interface ConnectedApp {
  id: string
  name: string
  description: string
  icon: AppIcon
  connected: boolean
}

export const connectedApps: readonly ConnectedApp[] = [
  {
    id: 'tracker',
    name: 'Трекер',
    description: 'Ведите проекты, спринты и учёт задач.',
    icon: 'tracker',
    connected: true,
  },
  {
    id: 'code',
    name: 'Репозиторий',
    description: 'Связывайте запросы на слияние и автоматизируйте сборки.',
    icon: 'code',
    connected: true,
  },
  {
    id: 'layouts',
    name: 'Макеты',
    description: 'Показывайте превью макетов прямо в проектах.',
    icon: 'layouts',
    connected: true,
  },
  {
    id: 'automation',
    name: 'Автоматизация',
    description: 'Собирайте свои сценарии и связки с другими сервисами.',
    icon: 'automation',
    connected: true,
  },
  {
    id: 'notes',
    name: 'Заметки',
    description: 'Встраивайте страницы и заметки в проекты.',
    icon: 'notes',
    connected: true,
  },
  {
    id: 'chat',
    name: 'Чат',
    description: 'Отправляйте уведомления в каналы и создавайте проекты.',
    icon: 'chat',
    connected: false,
  },
]