@atlaskit/side-navigation
Version:
A highly composable side navigation component that supports nested views.
44 lines (43 loc) • 1.42 kB
JavaScript
import _extends from "@babel/runtime/helpers/extends";
import React, { forwardRef, useCallback, useState } from 'react';
import ArrowLeftIcon from '@atlaskit/icon/core/arrow-left';
import { ButtonItem } from './button-item';
/**
* __Go back item__
*
* A go back item is used to provide a customized "go back" button in nested
* navigations.
*
* - [Examples](https://atlassian.design/components/side-navigation/examples#go-back-item)
* - [Code](https://atlassian.design/components/side-navigation/code)
*
* @deprecated `@atlaskit/side-navigation` is deprecated. Use `@atlaskit/navigation-system` instead.
*/
export const GoBackItem = /*#__PURE__*/forwardRef(({
className,
iconBefore = /*#__PURE__*/React.createElement(ArrowLeftIcon, {
color: "currentColor",
label: ""
}),
onClick,
isSelected,
...rest
}, ref) => {
const [isInteracted, setIsInteracted] = useState(false);
const onClickHandler = useCallback(e => {
if (isInteracted) {
return;
}
setIsInteracted(true);
onClick && onClick(e);
}, [onClick, isInteracted]);
return /*#__PURE__*/React.createElement(ButtonItem, _extends({
isSelected: isSelected
// eslint-disable-next-line @atlaskit/design-system/no-unsafe-style-overrides, @atlaskit/ui-styling-standard/no-classname-prop
,
className: className,
iconBefore: iconBefore,
onClick: onClickHandler,
ref: ref
}, rest));
});