UNPKG

@tmnrp/react-sidebar

Version:

React sidebar is a component that can be used to display sidebar.

33 lines 1.91 kB
var __rest = (this && this.__rest) || function (s, e) { var t = {}; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; } return t; }; import React from "react"; import { useState } from "react"; // export const Sidebar = (_a) => { var { children, style = {}, isExpanded, isExpandedWidth = 200, isExpandedTransitionduration = 0.5 } = _a, props = __rest(_a, ["children", "style", "isExpanded", "isExpandedWidth", "isExpandedTransitionduration"]); return (React.createElement("aside", Object.assign({ style: Object.assign({ overflow: "hidden", transition: `width ${isExpandedTransitionduration}s ease-in-out`, width: isExpanded ? isExpandedWidth : 0 }, style) }, props), children)); }; // export const SidebarToggler = (_a) => { var { style = {}, isExpanded, toggle, isExpandedIcon, isCollapsedIcon } = _a, props = __rest(_a, ["style", "isExpanded", "toggle", "isExpandedIcon", "isCollapsedIcon"]); return (React.createElement("aside", Object.assign({ style: Object.assign({ cursor: "pointer", display: "inline-flex", justifyContent: "center", alignItems: "center" }, style), onClick: toggle }, props), isExpanded ? isExpandedIcon : isCollapsedIcon)); }; // export const useSidebar = (props) => { // const [isExpanded, setIsExpanded] = useState((props === null || props === void 0 ? void 0 : props.defaultIsExpanded) || false); // const toggle = () => setIsExpanded((isExpanded) => !isExpanded); // return { isExpanded, setIsExpanded, toggle }; }; //# sourceMappingURL=index.js.map