UNPKG

@intility/bifrost-react

Version:

React library for Intility's design system, Bifrost.

38 lines (37 loc) 1.45 kB
"use client"; import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; import { forwardRef } from "react"; import classNames from "classnames"; import { faAngleLeft } from "@fortawesome/free-solid-svg-icons/faAngleLeft"; import Icon from "../Icon/Icon.js"; import Breadcrumbs from "../Breadcrumbs/Breadcrumbs.js"; import BreadcrumbsItem from "../Breadcrumbs/Breadcrumbs.Item.js"; import useLocale from "../../hooks/useLocale.js"; /** * Display a breadcrumb link that triggers history.back (can be overridden with onClick) */ const BackButton = /*#__PURE__*/ forwardRef(({ className, text, ...props }, ref)=>{ const locale = useLocale(); return /*#__PURE__*/ _jsx(Breadcrumbs, { children: /*#__PURE__*/ _jsx(BreadcrumbsItem, { children: /*#__PURE__*/ _jsxs("button", { type: "button", onClick: ()=>window.history.back(), ...props, className: classNames("bf-link", className), ref: ref, children: [ /*#__PURE__*/ _jsx(Icon, { icon: faAngleLeft, style: { marginRight: 8 }, widthAuto: true }), text ?? locale.back ] }) }) }); }); BackButton.displayName = "BackButton"; export default BackButton;