메뉴
메뉴 (Menu)
메뉴는 사용자가 액션을 실행하거나 다른 페이지로 이동할 수 있도록 항목(item)들을 나열하는 탐색 컴포넌트 모음이에요. 버튼 항목, 링크 항목, 커스텀 항목, 그룹, 섹션, 로딩 스켈레톤 등 다양한 종류의 항목을 제공한답니다.
출처: 문서
본문
ButtonItem 컴포넌트
클릭하면 액션을 실행하는 메뉴 항목이에요. Copy, Delete, Create 같은 액션에 사용해요.
- 키워드: menu, button, item, action
- 카테고리: navigation
- 상태: general-availability
예시
/**
* @jsxRuntime classic
* @jsx jsx
*/
import { cssMap, jsx } from '@compiled/react';
import ButtonItem from '@atlaskit/menu/button-item';
import { token } from '@atlaskit/tokens';
import ImgIcon from '../common/img-icon';
import Yeti from '../icons/yeti.png';
// Mimics overrides in side-navigation
const styles = cssMap({
root: {
paddingBlockStart: token('space.100'),
paddingInlineEnd: token('space.300'),
paddingBlockEnd: token('space.100'),
paddingInlineStart: token('space.300'),
borderRadius: token('radius.small'),
backgroundColor: '#FAFBFC',
color: '#42526E',
'&:hover': {
backgroundColor: '#EBECF0',
textDecoration: 'none',
color: '#42526E',
},
'&:active': {
color: '#0052CC',
backgroundColor: '#DEEBFF',
boxShadow: 'none',
},
'[data-item-elem-before]': {
display: 'flex',
height: 8 * 1.25,
width: 8 * 1.25,
alignItems: 'center',
justifyContent: 'center',
marginInlineEnd: token('space.200'),
},
},
disabled: {
color: token('color.text.disabled'),
backgroundColor: '#FAFBFC',
'&:hover, &:active': {
backgroundColor: '#FAFBFC',
color: token('color.text.disabled'),
},
},
});
const _default: () => JSX.Element = () => (
<div >
<ButtonItem isSelected>Activate</ButtonItem>
<ButtonItem isDisabled>Activate</ButtonItem>
<ButtonItem>Activate</ButtonItem>
<ButtonItem description="Next-gen software project">Activate</ButtonItem>
<ButtonItem description="Legacy software project" isDisabled>
Activate
</ButtonItem>
<ButtonItem iconBefore={<ImgIcon src={Yeti} alt="" />} description="Next-gen software project">
Activate
</ButtonItem>
<ButtonItem css={styles.root} description="Style overrides">
Activate
</ButtonItem>
<ButtonItem isDisabled css={[styles.root, styles.disabled]} description="Style overrides">
Activate
</ButtonItem>
<ButtonItem css={styles.root} description="Style overrides">
Activate
</ButtonItem>
</div>
);
export default _default;
Props
| Prop | Type | Description |
|---|---|---|
children |
string | number | boolean | ReactElement<any, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal |
Primary content for the item |
description |
string | global.JSX.Element |
Description of the item |
iconAfter |
string | number | boolean | ReactElement<any, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal |
Element to render after the item text |
iconBefore |
string | number | boolean | ReactElement<any, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal |
Element to render before the item text |
id |
string |
Unique identifier for the element |
isDisabled |
boolean |
Makes the element appear disabled as well as removing interactivity |
isSelected |
boolean |
Makes the element appear selected |
onClick |
(e: MouseEvent<HTMLElement, globalThis.MouseEvent> | KeyboardEvent<HTMLElement>) => void |
Event that's triggered when the element is clicked |
onMouseDown |
(event: MouseEvent<Element, globalThis.MouseEvent>) => void |
Event that's triggered when the element has been pressed |
role |
string |
Use this to override the accessibility role for the element |
shouldDescriptionWrap |
boolean |
When true, the description of the item will wrap multiple lines if it's long enough |
shouldTitleWrap |
boolean |
When true, the title of the item will wrap multiple lines if it's long enough |
사용 지침
- 이동(navigation)이 아닌 액션에 사용해요 (예: Copy, Create article)
- 의미를 더할 때는 아이콘과 함께 사용해요
- 도움이 될 때 보조 텍스트로 맥락을 제공해요 (예: 프로젝트 유형)
콘텐츠 지침
- 명확하고 액션 지향적인 라벨을 사용해요
- 메뉴 전체에서 일관된 용어를 사용해요
CustomItem 컴포넌트
ButtonItem이나 LinkItem이 요구사항을 충족하지 못할 때 고급 사용을 위해 커스텀 컴포넌트를 받는 메뉴 항목이에요.
- 키워드: menu, custom, item, component
- 카테고리: navigation
- 상태: general-availability
예시
/**
* @jsxRuntime classic
* @jsx jsx
*/
import { cssMap, jsx } from '@compiled/react';
import CustomItem from '@atlaskit/menu/custom-item';
import { type CustomItemComponentProps } from '@atlaskit/menu/types';
import { Box } from '@atlaskit/primitives/compiled/box';
import Slack from '../icons/slack';
type CustomComponentWithHrefProps = CustomItemComponentProps & {
href: string;
};
const CustomComponent = ({ children, href, ...props }: CustomComponentWithHrefProps) => {
return (
<a href={href} {...props}>
{children}
</a>
);
};
const styles = cssMap({
root: {
position: 'relative',
overflow: 'hidden',
userSelect: 'none',
},
interactive: {
'&::before': {
content: '""',
position: 'absolute',
insetInlineStart: 0,
insetBlockStart: 0,
insetBlockEnd: 0,
width: 3,
transform: 'translateX(-1px)',
transition: 'transform 70ms ease-in-out',
backgroundColor: '#4C9AFF',
},
'&:hover::before': {
transform: 'translateX(0)',
},
},
});
const _default: () => JSX.Element = () => (
/**
* It is not normally acceptable to add click handlers to non-interactive elements
* as this is an accessibility anti-pattern. However, because this instance is
* for performance reasons (to avoid multiple click handlers) and not creating an
* inaccessible custom element, we can add role="presentation" so that there is
* no negative impacts to assistive technologies.
*/
<Box onClick={(e: React.MouseEvent) => e.preventDefault()} role="presentation">
<CustomItem
href="/navigation-system"
component={CustomComponent}
css={[styles.root, styles.interactive]}
>
CustomItem
</CustomItem>
<CustomItem
href="/navigation-system-1"
isSelected
component={CustomComponent}
css={[styles.root, styles.interactive]}
>
isSelected CustomItem
</CustomItem>
<CustomItem
href="/navigation-system-2"
isDisabled
component={CustomComponent}
css={styles.root}
>
isDisabled CustomItem
</CustomItem>
<CustomItem
href="/navigation-system-3"
component={CustomComponent}
iconBefore={<Slack />}
css={[styles.root, styles.interactive]}
>
iconBefore CustomItem
</CustomItem>
<CustomItem
href="/navigation-system-4"
component={CustomComponent}
iconBefore={<Slack />}
description="Next-gen software project"
css={[styles.root, styles.interactive]}
>
iconBefore and description CustomItem
</CustomItem>
</Box>
);
export default _default;
Props
| Prop | Type | Description |
|---|---|---|
children |
string | number | boolean | React.ReactElement<any, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | React.ReactPortal |
Primary content for the item |
component |
React.ComponentClass<React.PropsWithChildren<TComponentProps>, any> | React.FunctionComponent<React.PropsWithChildren<TComponentProps>> |
Custom component to render as an item |
description |
string | JSX.Element |
Description of the item |
iconAfter |
string | number | boolean | React.ReactElement<any, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | React.ReactPortal |
Element to render after the item text |
iconBefore |
string | number | boolean | React.ReactElement<any, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | React.ReactPortal |
Element to render before the item text |
isDisabled |
boolean |
Makes the element appear disabled as well as removing interactivity |
isSelected |
boolean |
Makes the element appear selected |
onClick |
(e: React.MouseEvent<HTMLElement, MouseEvent> | React.KeyboardEvent<HTMLElement>) => void |
Event that's triggered when the element is clicked |
onMouseDown |
(event: React.MouseEvent<Element, MouseEvent>) => void |
Event that's triggered when the element has been pressed |
shouldDescriptionWrap |
boolean |
When true, the description of the item will wrap multiple lines if it's long enough |
shouldTitleWrap |
boolean |
When true, the title of the item will wrap multiple lines if it's long enough |
사용 지침
- ButtonItem이나 LinkItem이 요구사항을 충족하지 못할 때 사용해요
- 커스텀 구현에서도 메뉴 항목의 스타일과 동작을 유지해요
콘텐츠 지침
- 커스텀 컴포넌트가 접근성을 유지하도록 해요
- 커스텀 구현을 최소한으로 유지해요
HeadingItem 컴포넌트
메뉴 섹션 내의 비(非)상호작용 제목이에요. Section 제목을 사용하지 않을 때 항목 그룹을 라벨링하는 데 사용해요.
- 키워드: menu, heading, item, label
- 카테고리: navigation
- 상태: general-availability
예시
import ButtonItem from '@atlaskit/menu/button-item';
import MenuGroup from '@atlaskit/menu/menu-group';
import Section from '@atlaskit/menu/section';
import MenuGroupContainer from '../common/menu-group-container';
export default (): React.JSX.Element => (
<MenuGroupContainer>
<MenuGroup>
<Section title="Actions">
<ButtonItem>Create article</ButtonItem>
</Section>
<Section>
<ButtonItem>Create article</ButtonItem>
</Section>
</MenuGroup>
</MenuGroupContainer>
);
Props
| Prop | Type | Description |
|---|---|---|
children |
string | number | boolean | ReactElement<any, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal |
The text of the heading (required) |
headingLevel |
1 | 2 | 3 | 4 | 5 | 6 |
Specifies the heading level in the document structure |
id |
string |
A unique identifier that can be referenced in the labelledby prop of a |
| section to allow assistive technology to announce the name of groups |
사용 지침
- 섹션 제목만으로 충분하지 않을 때 섹션 그룹을 라벨링하는 데 사용해요
- 상호작용 콘텐츠에는 사용하지 마세요 — 제목은 표시 전용이에요
콘텐츠 지침
- 명확하고 설명적인 제목을 사용해요
- 제목을 간결하게 유지해요
LinkItem 컴포넌트
클릭하면 URL로 이동하는 메뉴 항목이에요. Dashboard나 Settings 같은 이동 링크에 사용해요.
- 키워드: menu, link, item, navigation
- 카테고리: navigation
- 상태: general-availability
예시
import React, { type MouseEvent, useState } from 'react';
import LinkItem from '@atlaskit/menu/link-item';
import { type LinkItemProps } from '@atlaskit/menu/types';
import { Box } from '@atlaskit/primitives/compiled/box';
import ImgIcon from '../common/img-icon';
import koala from '../icons/koala.png';
const useLinkItemComputedProps = (initialSelectedHref?: string) => {
const [currentHref, setCurrentHref] = useState<string | undefined>(initialSelectedHref);
const getComputedProps = ({ href, ...restProps }: LinkItemProps) => ({
href,
...restProps,
isSelected: currentHref === href,
onClick: () => setCurrentHref(href),
});
return getComputedProps;
};
export default (): React.JSX.Element => {
const getComputedProps = useLinkItemComputedProps('#link-item2');
return (
/**
* It is not normally acceptable to add click handlers to non-interactive elements
* as this is an accessibility anti-pattern. However, because this instance is
* for performance reasons (to avoid multiple click handlers) and not creating an
* inaccessible custom element, we can add role="presentation" so that there is
* no negative impacts to assistive technologies.
*/
<Box onClick={(e: MouseEvent) => e.preventDefault()} role="presentation">
<LinkItem {...getComputedProps({ href: '#link-item1' })}>Customer Feedback</LinkItem>
<LinkItem {...getComputedProps({ href: '#link-item2' })}>Customer Feedback</LinkItem>
<LinkItem {...getComputedProps({ href: '#link-item3' })} isDisabled>
Customer Feedback
</LinkItem>
<LinkItem {...getComputedProps({ href: '#link-item4' })} description="Classic service desk">
Customer Feedback
</LinkItem>
<LinkItem
{...getComputedProps({ href: '#link-item5' })}
iconBefore={<ImgIcon src={koala} alt={'A koala'} />}
description="Classic service desk"
>
Customer Feedback
</LinkItem>
<LinkItem {...getComputedProps({ href: 'https://atlassian.design' })} testId="link-item">
Atlassian Design
</LinkItem>
</Box>
);
};
Props
| Prop | Type | Description |
|---|---|---|
children |
string | number | boolean | ReactElement<any, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal |
Primary content for the item |
description |
string | global.JSX.Element |
Description of the item |
href |
string |
Link to another page |
iconAfter |
string | number | boolean | ReactElement<any, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal |
Element to render after the item text |
iconBefore |
string | number | boolean | ReactElement<any, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal |
Element to render before the item text |
isDisabled |
boolean |
Makes the element appear disabled as well as removing interactivity |
isSelected |
boolean |
Makes the element appear selected |
onClick |
(e: MouseEvent<HTMLElement, globalThis.MouseEvent> | KeyboardEvent<HTMLElement>) => void |
Event that's triggered when the element is clicked |
onMouseDown |
(event: MouseEvent<Element, globalThis.MouseEvent>) => void |
Event that's triggered when the element has been pressed |
rel |
string |
The relationship of the linked URL as space-separated link types |
role |
string |
Use this to override the accessibility role for the element |
shouldDescriptionWrap |
boolean |
When true, the description of the item will wrap multiple lines if it's long enough |
shouldTitleWrap |
boolean |
When true, the title of the item will wrap multiple lines if it's long enough |
target |
string |
Where to display the linked URL, |
| see [anchor information](https://developer |
사용 지침
- 탐색에 사용해요 (예: Team Spaces, Settings)
- 해당되는 경우 현재 페이지를 표시해요
- 의미를 더할 때는 맥락을 위한 아이콘과 함께 사용해요
콘텐츠 지침
- 이동 대상에 대해 명확하고 설명적인 라벨을 사용해요
- 라벨을 간결하게 유지해요
MenuGroup 컴포넌트
액션을 실행하거나 이동할 수 있는 옵션 목록이에요.
- 키워드: menu, group, navigation, section, items
- 카테고리: navigation
- 상태: general-availability
예시
import ButtonItem from '@atlaskit/menu/button-item';
import LinkItem from '@atlaskit/menu/link-item';
import MenuGroup from '@atlaskit/menu/menu-group';
import Section from '@atlaskit/menu/section';
const Examples = (): React.JSX.Element => (
<>
<MenuGroup spacing="cozy">
<Section title="Navigation">
<LinkItem href="/dashboard">Dashboard</LinkItem>
<LinkItem href="/projects">Projects</LinkItem>
<LinkItem href="/settings">Settings</LinkItem>
</Section>
</MenuGroup>
<MenuGroup spacing="compact">
<Section title="Actions">
<ButtonItem>Create New</ButtonItem>
<ButtonItem>Import</ButtonItem>
<ButtonItem>Export</ButtonItem>
</Section>
<Section title="Help">
<LinkItem href="/docs">Documentation</LinkItem>
<LinkItem href="/support">Support</LinkItem>
</Section>
</MenuGroup>
</>
);
export default Examples;
Props
| Prop | Type | Description |
|---|---|---|
children |
string | number | boolean | React.ReactElement<any, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | React.ReactPortal |
Children of the menu group (required) |
isLoading |
boolean |
Used this to tell assistive technologies that the menu group is loading |
maxHeight |
string | number |
Use this to constrain the menu group's height to a specific value |
maxWidth |
string | number |
Use this to constrain the menu group's maximum width to a specific value |
menuLabel |
string |
Provide an accessible label via aria-label for the menu element for assistive technology |
minHeight |
string | number |
Use this to constrain the menu group's minimum height to a specific value |
minWidth |
string | number |
Use this to constrain the menu group's minimum width to a specific value |
onClick |
(event: React.MouseEvent<Element, MouseEvent> | React.KeyboardEvent<Element>) => void |
Handler called when clicking on this element, |
| or any children elements | ||
role |
string |
Use this to override the accessibility role for the element |
spacing |
"compact" | "cozy" |
Configure the density of the menu group content |
사용 지침
- 액션을 실행하거나 이동할 수 있는 옵션 목록에 사용해요
- 버튼 항목 = 액션 (예: Copy), 링크 항목 = 이동 (예: Team Spaces)
- 관련 있는 메뉴 항목들을 함께 그룹화해요
- 명확한 섹션 제목을 사용해요
콘텐츠 지침
- 명확하고 설명적인 메뉴 항목 라벨을 사용해요
- 관련 항목을 논리적으로 그룹화해요
- 일관된 용어를 사용해요
- 메뉴 구조를 단순하게 유지해요
접근성 지침
- 명확한 메뉴 항목 라벨을 제공해요
- 적절한 ARIA 속성을 사용해요
- 화살표 키로 키보드 탐색이 가능하도록 해요
- 명확한 섹션 제목을 제공해요
Section 컴포넌트
관련 메뉴 항목들을 선택적인 제목이나 헤딩과 함께 그룹으로 묶어줘요.
- 키워드: menu, section, group, items
- 카테고리: navigation
- 상태: general-availability
예시
import ButtonItem from '@atlaskit/menu/button-item';
import HeadingItem from '@atlaskit/menu/heading-item';
import MenuGroup from '@atlaskit/menu/menu-group';
import Section from '@atlaskit/menu/section';
import MenuGroupContainer from '../common/menu-group-container';
export default (): React.JSX.Element => (
<MenuGroupContainer>
<MenuGroup>
<Section title="Actions">
<ButtonItem>Create article</ButtonItem>
</Section>
<Section aria-labelledby="settings" hasSeparator>
<HeadingItem id="settings">Settings</HeadingItem>
<ButtonItem>Manage account</ButtonItem>
</Section>
</MenuGroup>
</MenuGroupContainer>
);
Props
| Prop | Type | Description |
|---|---|---|
children |
string | number | boolean | ReactElement<any, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal |
Children of the section (required) |
hasSeparator |
boolean |
Use this to render a border at the top of the section |
id |
string |
Unique identifier for the element |
isList |
boolean |
If your menu contains a list, use this to add <ul> and <li> tags around the items |
isScrollable |
boolean |
Enables scrolling within the section |
label |
string |
Provide an accessible label for the section via aria-label for assistive technology |
title |
string |
The text passed into the internal HeadingItem |
titleId |
string |
ID referenced by the menu group wrapper's aria-labelledby attribute |
사용 지침
- 관련 메뉴 항목을 그룹으로 묶을 때 사용해요 (예: Actions, Settings)
- 그룹화할 때 명확한 섹션 제목을 사용해요
- 필요할 때 섹션 사이에 시각적 구분선을 사용해요
콘텐츠 지침
- 명확한 섹션 제목을 사용해요
- 항목을 논리적으로 그룹화해요
SkeletonHeadingItem 컴포넌트
로딩 상태에서 메뉴 헤딩을 위한 스켈레톤 자리 표시자(placeholder)예요.
- 키워드: menu, skeleton, heading, loading
- 카테고리: loading
- 상태: general-availability
예시
/**
* @jsxRuntime classic
* @jsx jsx
*/
import React, { useEffect, useState } from 'react';
import { cssMap, jsx } from '@compiled/react';
import Button from '@atlaskit/button/default/button';
import StarStarredIcon from '@atlaskit/icon/core/star-starred';
import StarUnstarredIcon from '@atlaskit/icon/core/star-unstarred';
import ButtonItem from '@atlaskit/menu/button-item';
import HeadingItem from '@atlaskit/menu/heading-item';
import MenuGroup from '@atlaskit/menu/menu-group';
import Section from '@atlaskit/menu/section';
import SkeletonHeadingItem from '@atlaskit/menu/skeleton-heading-item';
import SkeletonItem from '@atlaskit/menu/skeleton-item';
import { type ButtonItemProps } from '@atlaskit/menu/types';
import { Box } from '@atlaskit/primitives/compiled/box';
import { Stack } from '@atlaskit/primitives/compiled/stack';
import { token } from '@atlaskit/tokens';
import MenuGroupContainer from '../common/menu-group-container';
import Invision from '../icons/invision';
import Portfolio from '../icons/portfolio';
import Slack from '../icons/slack';
import Tempo from '../icons/tempo';
const styles = cssMap({
iconContainer: {
height: token('space.200'),
width: token('space.200'),
background: 'linear-gradient(180deg, #4E86EE 0%, #3562C1 100%), #4E86EE',
borderRadius: token('radius.small'),
},
buttonContainer: {
display: 'flex',
justifyContent: 'center',
},
});
const Item = ({ isLoading, ...props }: ButtonItemProps & { isLoading?: boolean }) => {
if (isLoading) {
return <SkeletonItem hasIcon isShimmering />;
}
return <ButtonItem {...props} />;
};
const Heading = ({ isLoading, ...props }: any) => {
if (isLoading) {
return <SkeletonHeadingItem isShimmering />;
}
return <HeadingItem {...props} />;
};
export default (): React.JSX.Element => {
const [isLoading, setIsLoading] = useState(true);
const [retryLoading, setRetryLoading] = useState(true);
useEffect(() => {
if (!retryLoading) {
return;
}
setIsLoading(true);
setTimeout(() => {
setRetryLoading(false);
setIsLoading(false);
}, 1500);
}, [retryLoading]);
return (
<Stack space="space.200">
<MenuGroupContainer>
<MenuGroup>
<Section aria-labelledby={isLoading ? '' : 'apps'}>
<Heading aria-hidden id="apps" isLoading={isLoading}>
Apps
</Heading>
<Item
isLoading={isLoading}
iconBefore={
<span css={styles.iconContainer}>
<Portfolio color={token('color.icon.brand')} />
</span>
}
iconAfter={<StarStarredIcon color={token('color.icon.accent.orange')} label="" />}
>
Portfolio
</Item>
<Item
isLoading={isLoading}
iconBefore={<Tempo />}
iconAfter={<StarStarredIcon color={token('color.icon.accent.orange')} label="" />}
>
Tempo timesheets
</Item>
<Item
isLoading={isLoading}
iconBefore={<Invision />}
iconAfter={<StarUnstarredIcon label="" />}
>
Invision
</Item>
<Item isLoading={isLoading} iconBefore={<Slack />}>
Slack
</Item>
</Section>
<Section hasSeparator>
<Item>Find new apps</Item>
<Item>Manage your apps</Item>
</Section>
</MenuGroup>
</MenuGroupContainer>
<Box xcss={styles.buttonContainer}>
<Button testId="toggle-loading" onClick={() => setRetryLoading(true)}>
Reload
</Button>
</Box>
</Stack>
);
};
Props
| Prop | Type | Description |
|---|---|---|
isShimmering |
boolean |
Causes to the skeleton to have a slight horizontal shimmer |
width |
string | number |
Width of the skeleton heading item |
xcss |
false | (XCSSValue<"paddingBlockEnd" | "paddingBlockStart" | "paddingInlineEnd" | "paddingInlineStart" | "paddingBlock" | "paddingInline", DesignTokenStyles, ""> & ... 4 more ... & { ...; }) |
Bounded style overrides |
사용 지침
- 섹션 헤딩이 나타날 로딩 중에 사용해요
SkeletonItem 컴포넌트
로딩 상태에서 메뉴 항목을 위한 스켈레톤 자리 표시자(placeholder)예요.
- 키워드: menu, skeleton, loading, placeholder
- 카테고리: loading
- 상태: general-availability
예시
/**
* @jsxRuntime classic
* @jsx jsx
*/
import React, { useEffect, useState } from 'react';
import { cssMap, jsx } from '@compiled/react';
import Button from '@atlaskit/button/default/button';
import StarStarredIcon from '@atlaskit/icon/core/star-starred';
import StarUnstarredIcon from '@atlaskit/icon/core/star-unstarred';
import ButtonItem from '@atlaskit/menu/button-item';
import HeadingItem from '@atlaskit/menu/heading-item';
import MenuGroup from '@atlaskit/menu/menu-group';
import Section from '@atlaskit/menu/section';
import SkeletonHeadingItem from '@atlaskit/menu/skeleton-heading-item';
import SkeletonItem from '@atlaskit/menu/skeleton-item';
import { type ButtonItemProps } from '@atlaskit/menu/types';
import { Box } from '@atlaskit/primitives/compiled/box';
import { Stack } from '@atlaskit/primitives/compiled/stack';
import { token } from '@atlaskit/tokens';
import MenuGroupContainer from '../common/menu-group-container';
import Invision from '../icons/invision';
import Portfolio from '../icons/portfolio';
import Slack from '../icons/slack';
import Tempo from '../icons/tempo';
const styles = cssMap({
iconContainer: {
height: token('space.200'),
width: token('space.200'),
background: 'linear-gradient(180deg, #4E86EE 0%, #3562C1 100%), #4E86EE',
borderRadius: token('radius.small'),
},
buttonContainer: {
display: 'flex',
justifyContent: 'center',
},
});
const Item = ({ isLoading, ...props }: ButtonItemProps & { isLoading?: boolean }) => {
if (isLoading) {
return <SkeletonItem hasIcon isShimmering />;
}
return <ButtonItem {...props} />;
};
const Heading = ({ isLoading, ...props }: any) => {
if (isLoading) {
return <SkeletonHeadingItem isShimmering />;
}
return <HeadingItem {...props} />;
};
export default (): React.JSX.Element => {
const [isLoading, setIsLoading] = useState(true);
const [retryLoading, setRetryLoading] = useState(true);
useEffect(() => {
if (!retryLoading) {
return;
}
setIsLoading(true);
setTimeout(() => {
setRetryLoading(false);
setIsLoading(false);
}, 1500);
}, [retryLoading]);
return (
<Stack space="space.200">
<MenuGroupContainer>
<MenuGroup>
<Section aria-labelledby={isLoading ? '' : 'apps'}>
<Heading aria-hidden id="apps" isLoading={isLoading}>
Apps
</Heading>
<Item
isLoading={isLoading}
iconBefore={
<span css={styles.iconContainer}>
<Portfolio color={token('color.icon.brand')} />
</span>
}
iconAfter={<StarStarredIcon color={token('color.icon.accent.orange')} label="" />}
>
Portfolio
</Item>
<Item
isLoading={isLoading}
iconBefore={<Tempo />}
iconAfter={<StarStarredIcon color={token('color.icon.accent.orange')} label="" />}
>
Tempo timesheets
</Item>
<Item
isLoading={isLoading}
iconBefore={<Invision />}
iconAfter={<StarUnstarredIcon label="" />}
>
Invision
</Item>
<Item isLoading={isLoading} iconBefore={<Slack />}>
Slack
</Item>
</Section>
<Section hasSeparator>
<Item>Find new apps</Item>
<Item>Manage your apps</Item>
</Section>
</MenuGroup>
</MenuGroupContainer>
<Box xcss={styles.buttonContainer}>
<Button testId="toggle-loading" onClick={() => setRetryLoading(true)}>
Reload
</Button>
</Box>
</Stack>
);
};
Props
| Prop | Type | Description |
|---|---|---|
hasAvatar |
boolean |
Renders a skeleton circle in the iconBefore location |
hasIcon |
boolean |
Renders a skeleton square in the iconBefore location |
isShimmering |
boolean |
Causes to the skeleton to have a slight horizontal shimmer |
width |
string | number |
Width of the skeleton item |
xcss |
false | (XCSSValue<"minHeight" | "paddingBlockEnd" | "paddingBlockStart" | "paddingInlineEnd" | "paddingInlineStart" | "paddingBlock" | "paddingInline", DesignTokenStyles, ""> & ... 4 more ... & { ...; }) |
Bounded style overrides |
사용 지침
- 레이아웃 안정성을 유지하기 위해 로딩 중에 사용해요
- 로딩될 항목의 모양에 맞춰요 (아이콘 유무 등)