@musica-sacra/layout
Version:
Layout components for building easy web apps layouts
3 lines (2 loc) • 3.76 kB
JavaScript
"use strict";var e=require("react/jsx-runtime"),n=require("react");function t(e){return{bem:function(n){for(var t=[],i=1;i<arguments.length;i++)t[i-1]=arguments[i];var r=[],a=function(e){e&&!r.includes(e)&&r.push(e)},c=function(n,t){void 0===t&&(t=!0);for(var i=0,r=Object.entries(n);i<r.length;i++){var c=r[i],s=c[0];c[1]&&a(s===e?e:t?"".concat(e,"__").concat(s):s)}};n===e||void 0===n?a(e):("string"==typeof n&&""!==n&&a("".concat(e,"__").concat(n)),"object"==typeof n&&c(n));for(var s=0,o=t;s<o.length;s++){var l=o[s];l===e||("string"==typeof l&&""!==l&&a(l),"object"==typeof l&&c(l,!1)),a(e)}return r.join(" ")},element:function(n){return"string"==typeof n&&""!==n?"".concat(e,"__").concat(n):"object"==typeof n?Object.entries(n).filter(function(e){return e[1]}).map(function(n){var t=n[0];return"".concat(e,"__").concat(t)}).join(" "):e},modifier:function(n){return"string"==typeof n&&""!==n?"".concat(e,"--").concat(n):"object"==typeof n?Object.entries(n).filter(function(e){return e[1]}).map(function(n){var t=n[0];return"".concat(e,"--").concat(t)}).join(" "):""},base:e}}function i(n){var i,r=n.classname,a=void 0===r?"":r,c=n.children,s=n.isPageContainer,o=void 0!==s&&s,l=t("ms-container"),d=l.bem,u=l.base;return e.jsx("div",{className:d(u,(i={},i[a]=!0,i["ms-container--page-container"]=o,i)),children:c})}var r=n.createContext({closeSidebar:function(){}});exports.Container=i,exports.LayoutBasic=function(n){var r=n.children,a=n.classname,c=void 0===a?"":a,s=n.isPageLayout,o=void 0!==s&&s,l=t("ms-layout-basic"),d=l.bem,u=l.base;return e.jsx("div",{className:d(u,c),children:e.jsx(i,{isPageContainer:o,children:r})})},exports.LayoutWithSidebar=function(i){var a,c=i.className,s=void 0===c?"":c,o=i.sidebar,l=i.children,d=i.isPageLayout,u=void 0!==d&&d,h=t("ms-layout-with-sidebar"),v=h.bem,x=h.base,f=n.useState(!1),b=f[0],j=f[1],m=function(){j(function(e){return!e})};return e.jsxs("div",{className:v(x,(a={},a[s]=!0,a["ms-layout-with-sidebar--page-layout"]=u,a)),children:[e.jsx("div",{className:v("sidebar-expand"),children:e.jsx("button",{onClick:m,"aria-label":"Sidebar","aria-pressed":b,children:e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",enableBackground:"new 0 0 24 24",height:"24px",viewBox:"0 0 24 24",width:"24px",fill:"currentColor",children:[e.jsxs("g",{children:[e.jsx("rect",{fill:"none",height:"24",width:"24"}),e.jsx("rect",{fill:"none",height:"24",width:"24"})]}),e.jsx("g",{children:e.jsxs("g",{children:[e.jsx("path",{d:"M5.7,6.71L5.7,6.71c-0.39,0.39-0.39,1.02,0,1.41L9.58,12L5.7,15.88c-0.39,0.39-0.39,1.02,0,1.41l0,0 c0.39,0.39,1.02,0.39,1.41,0l4.59-4.59c0.39-0.39,0.39-1.02,0-1.41L7.12,6.71C6.73,6.32,6.09,6.32,5.7,6.71z"}),e.jsx("path",{d:"M12.29,6.71L12.29,6.71c-0.39,0.39-0.39,1.02,0,1.41L16.17,12l-3.88,3.88c-0.39,0.39-0.39,1.02,0,1.41l0,0 c0.39,0.39,1.02,0.39,1.41,0l4.59-4.59c0.39-0.39,0.39-1.02,0-1.41l-4.59-4.59C13.32,6.32,12.68,6.32,12.29,6.71z"})]})})]})})}),b&&e.jsx("div",{className:v({overlay:!0,"overlay--active":b}),onClick:m}),e.jsxs("aside",{className:v({sidebar:!0,"sidebar--expanded":b}),children:[b&&e.jsx("div",{className:v("sidebar-close"),children:e.jsx("button",{onClick:m,"aria-label":"Zatvoriť sidebar",children:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",height:"24",viewBox:"0 0 24 24",width:"24",fill:"currentColor",children:e.jsx("path",{d:"M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"})})})}),e.jsx(r.Provider,{value:{closeSidebar:function(){return j(!1)}},children:e.jsx("div",{className:v("sidebar-content"),children:o})})]}),e.jsx("main",{className:v("content"),children:e.jsx("div",{className:v("content-inner"),children:l})})]})},exports.useSidebar=function(){return n.useContext(r)};
//# sourceMappingURL=index.js.map