Lynx

App Bar

화면 상단에서 현재 화면의 제목과 탐색 액션을 보여주는 내비게이션 바 컴포넌트입니다.

Engine ≥ 3.6
사용 가능 버전@seed-design/[email protected], @seed-design/[email protected]
Lynx 예제를 불러오는 중입니다.

Installation

npx @seed-design/cli add ui:app-bar

Props

AppBar

Prop

Type

AppBarLeft

고유 prop이 없습니다. className, style, children, bindlayoutchange를 받습니다.

AppBarMain

Prop

Type

AppBarRight

고유 prop이 없습니다. className, style, children, bindlayoutchange를 받습니다.

AppBarSlot

고유 prop이 없습니다. className, style, children을 받습니다.

AppBarIconButton

Prop

Type

icon?ReactElement<LynxIconElementProps, string | JSXElementConstructor<any>> | undefined

AppBarBackButton

Prop

Type

icon?ReactElement<LynxIconElementProps, string | JSXElementConstructor<any>> | undefined

AppBarCloseButton

Prop

Type

icon?ReactElement<LynxIconElementProps, string | JSXElementConstructor<any>> | undefined

Usage

AppBarBackButton과 AppBarCloseButton에는 이동 동작이 없습니다. bindtap으로 앱의 탐색 함수를 연결하세요.

import {
  AppBar,
  AppBarBackButton,
  AppBarLeft,
  AppBarMain,
  AppBarRight,
} from "@/components/ui/app-bar";

export function Header({ goBack }: { goBack: () => void }) {
  return (
    <AppBar>
      <AppBarLeft>
        <AppBarBackButton bindtap={goBack} />
      </AppBarLeft>
      <AppBarMain title="동네생활" />
      <AppBarRight />
    </AppBar>
  );
}

Title / Subtitle

AppBarMain에 subtitle을 전달하면 layout="withSubtitle"가 자동으로 적용됩니다.

Lynx 예제를 불러오는 중입니다.

Left / Right Action

왼쪽과 오른쪽에는 아이콘 버튼이나 직접 만든 슬롯을 배치할 수 있습니다. Cupertino theme에서는 좌우 슬롯 너비를 기준으로 제목이 가운데에 오도록 여백을 보정합니다.

각 슬롯의 가장자리 아이콘 버튼에만 보정이 적용됩니다. 직접 만든 레이아웃 박스 안의 버튼은 edge="leading", "trailing", "both" 중 하나를 지정하세요.

Lynx 예제를 불러오는 중입니다.

다른 아이콘을 쓰려면 AppBarIconButton의 icon prop에 Lynx 아이콘을 전달합니다.

import IconBellLine from "@karrotmarket/lynx-monochrome-icon/IconBellLine";
import {
  AppBar,
  AppBarBackButton,
  AppBarIconButton,
  AppBarLeft,
  AppBarMain,
  AppBarRight,
} from "@/components/ui/app-bar";

export function Header({ goBack }: { goBack: () => void }) {
  return (
    <AppBar>
      <AppBarLeft>
        <AppBarBackButton bindtap={goBack} />
      </AppBarLeft>
      <AppBarMain title="동네생활" />
      <AppBarRight>
        <AppBarIconButton accessibility-label="알림" icon={<IconBellLine />} />
      </AppBarRight>
    </AppBar>
  );
}

Multiple / Conditional Actions

여러 버튼 중 가장자리에 있는 버튼만 여백을 보정합니다. 조건부 렌더링으로 버튼 수가 바뀌어도 제목은 가운데에 유지됩니다.

Lynx 예제를 불러오는 중입니다.

Custom Slot / Explicit Edge

직접 만든 레이아웃 박스나 AppBarSlot 안의 버튼에는 edge를 지정하세요. 일반적인 AppBarLeft와 AppBarRight의 직계 아이콘 버튼에는 필요하지 않습니다.

<AppBarRight>
  <AppBarSlot>
    <AppBarCloseButton edge="trailing" bindtap={close} />
  </AppBarSlot>
</AppBarRight>

Tone

기본값인 tone="layer"는 레이어 배경을 표시합니다. tone="transparent"는 배경을 투명하게 하고 제목과 아이콘에 밝은 색상을 적용하므로 사진이나 어두운 배경 위에서 사용하세요. 배경과 스크롤에 따른 tone 전환은 호출부에서 관리합니다.

Lynx 예제를 불러오는 중입니다.

Accessibility

Lynx에서는 HTML ARIA 속성 대신 Lynx native 접근성 속성을 사용합니다. AppBarIconButton은 기본적으로 accessibility-element={true}와 accessibility-traits="button"을 적용하며, 아이콘만으로 의미를 알 수 없는 버튼에는 accessibility-label을 전달해야 합니다.

import IconBellLine from "@karrotmarket/lynx-monochrome-icon/IconBellLine";

<AppBarIconButton accessibility-label="알림" icon={<IconBellLine />} />

AppBarBackButton, AppBarCloseButton은 각각 "뒤로", "닫기" 라벨을 기본값으로 제공합니다.

Theme

theme은 "cupertino"와 "android"를 지원합니다. 지정하지 않으면 플랫폼에 맞는 값을 사용합니다.

<AppBar>
  <AppBarMain title="자동 theme" />
</AppBar>
Lynx 예제를 불러오는 중입니다.

Web Version Differences

  • 클릭 이벤트는 onClick 대신 bindtap으로 받습니다.
  • 아이콘 버튼의 접근성 이름은 aria-label 대신 accessibility-label로 지정합니다.
  • theme과 tone으로 플랫폼별 디자인과 배경을 지정합니다.
  • 뒤로 가기와 닫기 버튼에는 앱의 탐색 함수를 직접 연결해야 합니다.

Unsupported Lynx Features

  • Stackflow activity와 자동으로 연동하지 않습니다.
  • swipe-back 전환 애니메이션은 화면 탐색 계층에서 처리해야 합니다.

Last updated on

목차