UNPKG

@carbon/react

Version:

React components for the Carbon Design System

54 lines (52 loc) 1.93 kB
/** * Copyright IBM Corp. 2016, 2026 * * This source code is licensed under the Apache-2.0 license found in the * LICENSE file in the root directory of this source tree. */ import { usePrefix } from "../../internal/usePrefix.js"; import classNames from "classnames"; import "react"; import PropTypes from "prop-types"; import { jsx, jsxs } from "react/jsx-runtime"; import { ChevronRight, Close } from "@carbon/icons-react"; //#region src/components/UIShell/SideNavFooter.tsx /** * Copyright IBM Corp. 2016, 2023 * * This source code is licensed under the Apache-2.0 license found in the * LICENSE file in the root directory of this source tree. */ /** * SideNavFooter is used for rendering the button at the bottom of the side * navigation that is a part of the UI Shell. It is responsible for handling the * user interaction to expand or collapse the side navigation. */ function SideNavFooter({ assistiveText = "Toggle opening or closing the side navigation", className: customClassName, expanded, onToggle }) { const prefix = usePrefix(); return /* @__PURE__ */ jsx("footer", { className: classNames(`${prefix}--side-nav__footer`, customClassName), children: /* @__PURE__ */ jsxs("button", { className: `${prefix}--side-nav__toggle`, type: "button", onClick: (evt) => onToggle(evt), title: assistiveText, children: [/* @__PURE__ */ jsx("div", { className: `${prefix}--side-nav__icon`, children: expanded ? /* @__PURE__ */ jsx(Close, { size: 20 }) : /* @__PURE__ */ jsx(ChevronRight, { size: 20 }) }), /* @__PURE__ */ jsx("span", { className: `${prefix}--assistive-text`, children: assistiveText })] }) }); } SideNavFooter.displayName = "SideNavFooter"; SideNavFooter.propTypes = { assistiveText: PropTypes.string, className: PropTypes.string, expanded: PropTypes.bool.isRequired, onToggle: PropTypes.func.isRequired }; //#endregion export { SideNavFooter as default };