@avament-pub/navbar-ui

中文文档
0.6.5发布于 2026/10/30MITTypeScriptES Module近 30 天下载 2369

Self-contained Avament navbar UI for React / Next.js apps (includes embedded Support create report)

原始使用文档
文档目录14 节
  1. Table of contents
  2. 1. Install
  3. 2. Quick start
  4. 3. Layout structure
  5. 4. Feature flags
  6. 5. Project picker modes
  7. 6. Logo
  8. 7. Weather
  9. 8. Lang / theme
  10. 9. Host binding checklist
  11. 10. Host slots
  12. 11. RTL
  13. 12. Theming / CSS
  14. 13. Exports

@avament-pub/navbar-ui

Self-contained Avament navbar UI for React / Next.js apps — no @/ imports, no stores, no API calls. Host provides labels, routes, project data, and theme CSS.

Package@avament-pub/navbar-ui
React≥ 18 (peer)
Dependencylucide-react
LicenseMIT

Table of contents

  1. Install
  2. Quick start
  3. Layout structure
  4. Feature flags
  5. Project picker modes
  6. Logo
  7. Weather
  8. Lang / theme
  9. Host binding checklist
  10. Host slots
  11. RTL
  12. Theming / CSS
  13. Exports

1. Install

npm install @avament-pub/navbar-ui
yarn add @avament-pub/navbar-ui
pnpm add @avament-pub/navbar-ui

Requirements

  • React 18+ / React DOM 18+
  • Client component in Next.js App Router ("use client" is included in the bundle)

Optional (Next.js App Router):

transpilePackages: ["@avament-pub/navbar-ui"];

2. Quick start

import { Navbar } from "@avament-pub/navbar-ui";
import Link from "next/link";

<Navbar
  pathname={pathname}
  dir="ltr"
  labels={{ selectAProject: "Select a project", /* … */ }}
  routes={{
    home: "https://avament.com/home",
    settings: "/settings",
    support: "https://support.avament.com",
  }}
  logo={{ src: "/logos/main.svg", href: "https://avament.com/home" }}
  projectPicker={{
    mode: "interactive",
    selectedProjectId,
    selectedProjectName,
    projects,
    onSelect: handleProjectSelect,
  }}
  LinkComponent={Link}
/>

3. Layout structure

Main site and sub-sites share one bar structure. The package owns placement — hosts only wire props.

Desktop (fixed order):

LeftRight
Nav actions · optional beside picker · project pickertheme · language · trailingSlot · logo

Weather renders centered in the bar (desktop) when features.weather is enabled on the main home layout.

Nav actions depend on layout + page:

ModeLeft icons
Main home (layout="default", /home)Support · settings
Main inner pagesBack · settings · home
Sub-sites (layout="submodule")Back · settings · home
Submodule + features.support: trueBack · support · settings · home
Off home + supportCreate or onSupportClickSupport opens in-app create dialog; home keeps routes.support link

Optional beside project picker (left group, before picker):

  1. moduleLabel — pill tag (e.g. "AVAMENT-Intern")
  2. context — External / Internal segmented control
  3. projectPickerLeadingSlot — any custom UI
// Main website (home)
<Navbar
  pathname="/home"
  isHomeLayout
  features={{ weather: true, support: true }}
  projectPicker={{ mode: "interactive", … }}
  weather={forecast}
  logo={logo}
  /* … */
/>

// Sub-site (ticket, check, …)
<Navbar
  layout="submodule"
  pathname={pathname}
  moduleLabel="AVAMENT-Intern"
  context={{
    value: visibility,
    onChange: setVisibility,
    options: [
      { value: "external", label: "External" },
      { value: "internal", label: "Internal" },
    ],
  }}
  projectPicker={{ mode: "interactive", … }}
  features={{ langTheme: true }}
  langTheme={{ language, onLanguageChange, theme, onThemeChange, isDarkMode }}
  trailingSlot={<CreateTicketButton />}
  onBack={() => {
    if (pathname === "/") window.location.href = routes.landing ?? "https://avament.com";
    else router.back();
  }}
  /* …labels, routes, logo, LinkComponent */
/>

trailingSlot: app-only actions before the logo (Create batch, Create ticket).

Use contextSlot or projectPickerLeadingSlot only when built-in options are not enough.


4. Feature flags

PropDefaultEffect
features.weatherfalseCenter weather strip (desktop, home layout)
features.supportmain home: yes; submodule: no (set true to show)Headset support link in nav actions
features.supportCreatefalseOff home: embedded Support create dialog (API from NEXT_PUBLIC_BASE_URL / NEXT_PUBLIC_API_URL, SSO cookies; needs React Query + i18n)
supportCreate—Optional overrides (createDialogTitle, onOpenChange, …) when features.supportCreate is on
onSupportClick—Off home: manual headset handler (overrides supportCreate click when both set)
features.langThemefalseLanguage + theme pickers (desktop)
features.topicPillfalseRead-only topic pill
features.actionstrueSettings / home / back icons

5. Project picker modes

ModeUI
interactiveDropdown with chevron, clickable
readonlyLabel only — no chevron, not clickable
hiddenNot rendered
projectPicker={{
  mode: "readonly",
  selectedProjectId: "uuid",
  selectedProjectName: "Project Alpha",
}}

Static:

logo={{ src: "/logos/check.svg", href: "https://check.avament.com", alt: "Check" }}

Dynamic:

logo={{
  resolve: ({ pathname }) => ({
    src: pathname.startsWith("/check") ? "/logos/check.svg" : "/logos/main.svg",
    href: pathname === "/home" ? "https://avament.com/landing" : "https://avament.com/home",
  }),
}}

7. Weather

Host fetches data; UI only renders:

features={{ weather: true }}
weather={{
  days: forecast.days,
  locationLabel: forecast.locationLabel,
  timezone: forecast.timezone,
  locale: "de",
}}

8. Lang / theme

Controlled pickers — host persists changes:

features={{ langTheme: true }}
langTheme={{
  language: "de",
  onLanguageChange: (lang) => updateSettings({ language: lang }),
  theme: "dark",
  onThemeChange: (theme) => updateSettings({ theme }),
  isDarkMode: true,
}}

9. Host binding checklist

  1. Pass labels from your i18n (t() → object). See REQUIRED_NAVBAR_LABEL_KEYS / OPTIONAL_NAVBAR_LABEL_KEYS exports.
  2. Wire projectPicker.onSelect → your auth / project-switch flow.
  3. Pass navigationBlocked when unsaved/import/edit guards are active.
  4. Provide LinkComponent (Next.js Link) or use onNavigate with your router.
  5. Implement onBack for back-button behavior.
  6. Include theme CSS (see Theming / CSS).

10. Host slots

PropUse
moduleLabelBuilt-in pill beside project picker
contextBuilt-in External / Internal segmented control
projectPickerLeadingSlotCustom UI beside project picker
trailingSlotApp actions before logo (Create ticket, etc.)

11. RTL

Pass dir="rtl" when the app locale is Arabic (or any RTL language):

<Navbar dir={locale === "ar" ? "rtl" : "ltr"} /* … */ />

The package mirrors the bar automatically:

  • Left group (actions + project picker) → visual right
  • Right group (lang/theme + logo) → visual left
  • Weather stays centered
  • Dropdowns align to the trigger’s inline-start edge
  • Back arrow icon flips in RTL

Project picker text and menus inherit dir from the navbar. Weather temperatures stay dir="ltr" for numeric readability.


12. Theming / CSS

This package uses host-provided Tailwind theme utilities. Your app must define:

  • bg-theme, border-theme, surface-theme, text-theme-primary
  • hover:bg-input-theme, bg-theme-surface, border-theme-border
  • --input-border-color CSS variable
  • animate-project-picker-pulse keyframe animation
  • shadow-glass, shadow-glass-dark (optional, for dropdowns/popovers)

Without these classes the navbar will render but look unstyled.

Support create dialog (features.supportCreate): theme CSS is injected automatically when you import from @avament-pub/navbar-ui. Optional manual import: @avament-pub/navbar-ui/styles.css. Host apps should define --surface-color, --text-primary-color, --input-border-color, and related tokens (see protocol/ticket apps).


13. Exports

// Components
export { Navbar, NavDropdown, WeatherForecastWidget, ProjectPicker, LangPicker, ThemePicker, NavbarSegmentedControl };

// Constants
export { NAV_ICON_SIZE, navIconButtonClass, navIconButtonClassNoMargin, DEFAULT_LANGUAGE_OPTIONS };
export { REQUIRED_NAVBAR_LABEL_KEYS, OPTIONAL_NAVBAR_LABEL_KEYS };

// Types
export type {
  NavbarProps,
  NavbarLayout,
  NavbarContextControl,
  NavbarContextOption,
  NavbarFeatures,
  NavbarRoutes,
  NavbarLabels,
  NavbarLogoConfig,
  NavbarProject,
  NavbarProjectPicker,
  NavbarWeather,
  NavbarWeatherDay,
  NavbarLangTheme,
  NavbarTheme,
  NavbarLinkComponent,
  ProjectPickerMode,
};

版本与发布记录

@avament-pub/navbar-ui 共发布 18 个版本,首次发布于 2026/10/03;过去 12 个月发布了 18 个版本。

版本发布日期距今
0.6.5latest2026/10/308 天前
0.6.42026/10/309 天前
0.6.32026/10/2811 天前
0.6.22026/10/2811 天前
0.6.12026/10/2811 天前
0.6.02026/10/2811 天前

关于 @avament-pub/navbar-ui 的常见问题

@avament-pub/navbar-ui 是什么?

Self-contained Avament navbar UI for React / Next.js apps (includes embedded Support create report)

如何安装 @avament-pub/navbar-ui?

在项目目录运行 npm install @avament-pub/navbar-ui,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:clsx(>=2.0.0)、axios(>=1.6.0)、react(>=18)、i18next(>=23.0.0)、date-fns(>=3.0.0)、react-dom(>=18)、lucide-react(>=0.400.0)、react-i18next(>=14.0.0)、tailwind-merge(>=2.0.0)、react-day-picker(>=9.0.0)、@avament-pub/select(>=0.3.0)、@radix-ui/react-slot(>=1.2.0)、@radix-ui/react-label(>=2.1.0)、@tanstack/react-query(>=5.0.0)、@radix-ui/react-dialog(>=1.1.0)、@radix-ui/react-select(>=2.2.0)、@radix-ui/react-popover(>=1.1.0)、@radix-ui/react-checkbox(>=1.1.0)、class-variance-authority(>=0.7.0)、@avament-pub/color-picker(>=0.1.0)、@avament-pub/image-editor(>=0.1.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@avament-pub/navbar-ui 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@avament-pub/navbar-ui 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@avament-pub/navbar-ui 可以商用吗?

@avament-pub/navbar-ui 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@avament-pub/navbar-ui 的下载量有多少?

根据 npm 官方下载统计,@avament-pub/navbar-ui 在 2026/10/07 – 2026/11/05 这 30 天内被下载 2,369 次,日均约 79 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@avament-pub/navbar-ui 还在维护吗?

最新版本 0.6.5 发布于 2026/10/30(8 天前);至今共发布 18 个版本,其中过去 12 个月发布了 18 个;首次发布于 2026/10/03。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。