UNPKG

@musica-sacra/layout

Version:

Layout components for building easy web apps layouts

3 lines (2 loc) 3.68 kB
import{jsx as e,jsxs as n}from"react/jsx-runtime";import{createContext as i,useContext as t,useState as r}from"react";function c(e){return{bem:function(n){for(var i=[],t=1;t<arguments.length;t++)i[t-1]=arguments[t];var r=[],c=function(e){e&&!r.includes(e)&&r.push(e)},a=function(n,i){void 0===i&&(i=!0);for(var t=0,r=Object.entries(n);t<r.length;t++){var a=r[t],o=a[0];a[1]&&c(o===e?e:i?"".concat(e,"__").concat(o):o)}};n===e||void 0===n?c(e):("string"==typeof n&&""!==n&&c("".concat(e,"__").concat(n)),"object"==typeof n&&a(n));for(var o=0,l=i;o<l.length;o++){var s=l[o];s===e||("string"==typeof s&&""!==s&&c(s),"object"==typeof s&&a(s,!1)),c(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 i=n[0];return"".concat(e,"__").concat(i)}).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 i=n[0];return"".concat(e,"--").concat(i)}).join(" "):""},base:e}}function a(n){var i,t=n.classname,r=void 0===t?"":t,a=n.children,o=n.isPageContainer,l=void 0!==o&&o,s=c("ms-container"),d=s.bem,u=s.base;return e("div",{className:d(u,(i={},i[r]=!0,i["ms-container--page-container"]=l,i)),children:a})}function o(n){var i=n.children,t=n.classname,r=void 0===t?"":t,o=n.isPageLayout,l=void 0!==o&&o,s=c("ms-layout-basic"),d=s.bem,u=s.base;return e("div",{className:d(u,r),children:e(a,{isPageContainer:l,children:i})})}var l=i({closeSidebar:function(){}}),s=function(){return t(l)};function d(i){var t,a=i.className,o=void 0===a?"":a,s=i.sidebar,d=i.children,u=i.isPageLayout,h=void 0!==u&&u,v=c("ms-layout-with-sidebar"),f=v.bem,m=v.base,b=r(!1),g=b[0],p=b[1],w=function(){p(function(e){return!e})};return n("div",{className:f(m,(t={},t[o]=!0,t["ms-layout-with-sidebar--page-layout"]=h,t)),children:[e("div",{className:f("sidebar-expand"),children:e("button",{onClick:w,"aria-label":"Sidebar","aria-pressed":g,children:n("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:[n("g",{children:[e("rect",{fill:"none",height:"24",width:"24"}),e("rect",{fill:"none",height:"24",width:"24"})]}),e("g",{children:n("g",{children:[e("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("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"})]})})]})})}),g&&e("div",{className:f({overlay:!0,"overlay--active":g}),onClick:w}),n("aside",{className:f({sidebar:!0,"sidebar--expanded":g}),children:[g&&e("div",{className:f("sidebar-close"),children:e("button",{onClick:w,"aria-label":"Zatvoriť sidebar",children:e("svg",{xmlns:"http://www.w3.org/2000/svg",height:"24",viewBox:"0 0 24 24",width:"24",fill:"currentColor",children:e("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(l.Provider,{value:{closeSidebar:function(){return p(!1)}},children:e("div",{className:f("sidebar-content"),children:s})})]}),e("main",{className:f("content"),children:e("div",{className:f("content-inner"),children:d})})]})}export{a as Container,o as LayoutBasic,d as LayoutWithSidebar,s as useSidebar}; //# sourceMappingURL=index.mjs.map