@lifesg/react-design-system 2.1.0-canary.3 → 2.1.0-canary.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/index.js +13 -12
- package/cjs/index.js.map +1 -1
- package/index.js +13 -12
- package/index.js.map +1 -1
- package/navbar/brand.d.ts +2 -1
- package/navbar/brand.styles.d.ts +0 -1
- package/navbar/index.js +13 -12
- package/navbar/index.js.map +1 -1
- package/navbar/navbar.styles.d.ts +1 -1
- package/navbar/types.d.ts +1 -0
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -3827,7 +3827,7 @@ object-assign
|
|
|
3827
3827
|
padding: 0;
|
|
3828
3828
|
}
|
|
3829
3829
|
`,Masthead=()=>{useEffect((()=>{e()||t()}),[]);const e=()=>document.getElementById(SCRIPT_ID),t=()=>{if(!document.getElementById(SCRIPT_ID)){const e=document.createElement("script");e.id=SCRIPT_ID,e.type="module",e.src=SCRIPT_SRC,document.head.appendChild(e)}};return jsx(Wrapper$e,{dangerouslySetInnerHTML:{__html:"<sgds-masthead></sgds-masthead>"}})},SCRIPT_ID="lifesg-ds-masthead-script",SCRIPT_SRC="https://cdn.jsdelivr.net/npm/@govtechsg/sgds-web-component/Masthead/index.js",Modal=Object.assign(Modal$1,{Box:ModalBox}),NAVBAR_HEIGHT={notCompress:6,compress:4},NAVBAR_MOBILE_HEIGHT=3.5,Wrapper$d=styled.div`
|
|
3830
|
-
position: ${e=>e.$fixed?"
|
|
3830
|
+
position: ${e=>e.$fixed?"sticky":"relative"};
|
|
3831
3831
|
background-color: white;
|
|
3832
3832
|
z-index: 30;
|
|
3833
3833
|
top: 0;
|
|
@@ -3871,36 +3871,37 @@ object-assign
|
|
|
3871
3871
|
color: ${Color.Neutral[1]};
|
|
3872
3872
|
`,NavBrandContainer=styled.div`
|
|
3873
3873
|
display: flex;
|
|
3874
|
-
height: 100%;
|
|
3875
3874
|
flex-direction: row;
|
|
3876
3875
|
align-items: center;
|
|
3877
3876
|
flex-shrink: 0;
|
|
3877
|
+
|
|
3878
|
+
height: ${e=>e.$compress?1.5:2}rem;
|
|
3879
|
+
|
|
3880
|
+
${MediaQuery.MaxWidth.tablet} {
|
|
3881
|
+
height: 1.5rem;
|
|
3882
|
+
}
|
|
3878
3883
|
`,NavSeparator=styled.div`
|
|
3879
3884
|
display: flex;
|
|
3880
3885
|
background-color: ${Color.Neutral[5]};
|
|
3881
|
-
height:
|
|
3886
|
+
height: 100%;
|
|
3882
3887
|
width: 1px;
|
|
3883
|
-
margin: 0 ${e=>e.$compress?1
|
|
3888
|
+
margin: 0 ${e=>e.$compress?1:1.5}rem;
|
|
3884
3889
|
|
|
3885
3890
|
${MediaQuery.MaxWidth.tablet} {
|
|
3886
|
-
height: 1.5rem;
|
|
3887
3891
|
margin: 0 1rem;
|
|
3888
3892
|
}
|
|
3889
3893
|
`,Clickable=styled.a`
|
|
3890
3894
|
display: flex;
|
|
3891
3895
|
justify-content: center;
|
|
3896
|
+
height: 100%;
|
|
3892
3897
|
|
|
3893
3898
|
img {
|
|
3894
3899
|
width: auto;
|
|
3895
|
-
height:
|
|
3900
|
+
height: 100%;
|
|
3896
3901
|
transition: ${Transition.Base};
|
|
3897
3902
|
object-fit: contain;
|
|
3898
|
-
|
|
3899
|
-
${MediaQuery.MaxWidth.tablet} {
|
|
3900
|
-
height: ${e=>"primary"===e.$type?1:1.5}rem;
|
|
3901
|
-
}
|
|
3902
3903
|
}
|
|
3903
|
-
`,Brand=({resources:e,
|
|
3904
|
+
`,Brand=({resources:e,onClick:t,"data-id":r,"data-testid":n="navbar-brand",type:i})=>jsx(Clickable,Object.assign({role:"link","aria-label":e.brandName+"-app-home-page",onClick:e=>{t&&t(e,i)},tabIndex:0,"data-id":r,"data-testid":n,$type:i},{children:jsx(ImageWithFallback,{src:e.logoSrc,alt:e.brandName+"-app-logo"})})),VISIBILITY_STYLE=e=>e?css`
|
|
3904
3905
|
right: 0;
|
|
3905
3906
|
transition: all 300ms cubic-bezier(0.21, 0.79, 0.53, 1);
|
|
3906
3907
|
transition-delay: 200ms;
|
|
@@ -4235,7 +4236,7 @@ object-assign
|
|
|
4235
4236
|
:hover {
|
|
4236
4237
|
color: ${Color.Neutral[1]};
|
|
4237
4238
|
}
|
|
4238
|
-
`,NavbarItems=({items:e,selectedId:t,mobile:r=!1,onItemClick:n})=>{const[i,a]=useState(-1),[o,s]=useState(!1),l=useRef(null);useEffect((()=>{const e=e=>{l.current&&!l.current.contains(e.target)&&c()};return document.addEventListener("click",e,!0),()=>{document.removeEventListener("click",e,!0)}}),[]);const c=()=>{s(!1)},p=(e,t)=>r=>{r.stopPropagation(),a(t),s(!0),n(r,e)},d=(e,t)=>{e.stopPropagation(),n(e,t),s(!1)},u=()=>e.map(((e,n)=>{if("component"===e.itemType){const t=e&&e.children||null;return jsx("li",{children:t},n)}{const a=(e=>{if(e.id===t)return!0;if((null==e?void 0:e.subMenu)&&e.subMenu.length>=1)return!!e.subMenu.find((e=>e.id===t));return!1})(e),{children:s,options:l}=e,c=__rest$1(e,["children","options"]),u=a?r?"bold":"semibold":"regular",h=r?`link__mobile-${n+1}`:`link__${n+1}`,f=i>=0&&i===n&&o;return jsxs(LinkItem,{children:[jsxs(Link,Object.assign({"data-testid":h,weight:u,$selected:a},c,{onClick:p(e,n)},l,{children:[jsx(LinkLabel,{children:s}),a&&jsx(LinkIndicator,{}),r&&e.subMenu&&jsx(LinkIconContainer,{children:jsx(ExpandCollapseButton,Object.assign({"data-testid":`${h}-expand-collapse-button`,$selected:f,focusHighlight:!1,focusOutline:"browser","aria-label":f?"Collapse":"Expand"},{children:jsx(ChevronIcon$1,{})}))})]})),f&&jsx(Menu,{items:e.subMenu,mobile:r,onItemClick:d})]},n)}}));if(e&&e.length>0){return jsx(r?MobileWrapper:Wrapper$9,Object.assign({ref:l},{children:u()}))}return jsx(Fragment,{})},Component$1=(e,t)=>{var{items:r,
|
|
4239
|
+
`,NavbarItems=({items:e,selectedId:t,mobile:r=!1,onItemClick:n})=>{const[i,a]=useState(-1),[o,s]=useState(!1),l=useRef(null);useEffect((()=>{const e=e=>{l.current&&!l.current.contains(e.target)&&c()};return document.addEventListener("click",e,!0),()=>{document.removeEventListener("click",e,!0)}}),[]);const c=()=>{s(!1)},p=(e,t)=>r=>{r.stopPropagation(),a(t),s(!0),n(r,e)},d=(e,t)=>{e.stopPropagation(),n(e,t),s(!1)},u=()=>e.map(((e,n)=>{if("component"===e.itemType){const t=e&&e.children||null;return jsx("li",{children:t},n)}{const a=(e=>{if(e.id===t)return!0;if((null==e?void 0:e.subMenu)&&e.subMenu.length>=1)return!!e.subMenu.find((e=>e.id===t));return!1})(e),{children:s,options:l}=e,c=__rest$1(e,["children","options"]),u=a?r?"bold":"semibold":"regular",h=r?`link__mobile-${n+1}`:`link__${n+1}`,f=i>=0&&i===n&&o;return jsxs(LinkItem,{children:[jsxs(Link,Object.assign({"data-testid":h,weight:u,$selected:a},c,{onClick:p(e,n)},l,{children:[jsx(LinkLabel,{children:s}),a&&jsx(LinkIndicator,{}),r&&e.subMenu&&jsx(LinkIconContainer,{children:jsx(ExpandCollapseButton,Object.assign({"data-testid":`${h}-expand-collapse-button`,$selected:f,focusHighlight:!1,focusOutline:"browser","aria-label":f?"Collapse":"Expand"},{children:jsx(ChevronIcon$1,{})}))})]})),f&&jsx(Menu,{items:e.subMenu,mobile:r,onItemClick:d})]},n)}}));if(e&&e.length>0){return jsx(r?MobileWrapper:Wrapper$9,Object.assign({ref:l},{children:u()}))}return jsx(Fragment,{})},Component$1=(e,t)=>{var{items:r,className:n,id:i,selectedId:a,compress:o=!1,fixed:s=!0,resources:l=DEFAULT_RESOURCES,hideNavElements:c=!1,drawerDismissalExclusions:p=[],actionButtons:d,onItemClick:u,onActionButtonClick:h,onBrandClick:f,masthead:m=!0,layout:y="default"}=e,g=__rest$1(e,["items","className","id","selectedId","compress","fixed","resources","hideNavElements","drawerDismissalExclusions","actionButtons","onItemClick","onActionButtonClick","onBrandClick","masthead","layout"]);const[b,v]=useState(!1),[_,x]=useState(!1),S="stretch"===y,C=useRef(),{primary:$=DEFAULT_RESOURCES.primary,secondary:w}=l;useImperativeHandle(t,(()=>Object.assign(C.current,{dismissDrawer:()=>{T()}})),[b]),useEffect((()=>(E(),window.addEventListener("resize",E),()=>{window.removeEventListener("resize",E)})),[]);const T=()=>{v(!1),setTimeout((()=>{x(!1)}),550)},k=e=>b&&-1===p.indexOf(e),E=()=>{window.innerWidth<=MediaWidths$1.tablet&&b&&T()},A=(e,t)=>{f&&(e.preventDefault(),f(t)),k("brand-click")&&T()},D=(e,t)=>{t.onClick?t.onClick(e):u&&(e.preventDefault(),u(t)),!(null==t?void 0:t.subMenu)&&k("item-click")&&T()},I=(e,t)=>{t.args&&t.args.onClick?t.args.onClick(e):h&&(e.preventDefault(),h(t)),k("item-click")&&T()},P=()=>{v(!0),x(!0)},M=()=>{k("close-button-click")&&T()};return jsxs(Wrapper$d,Object.assign({ref:C,$fixed:s,className:n,id:i||"navbar-wrapper","data-testid":g["data-testid"]||"navbar-wrapper"},{children:[m&&jsx(Masthead,{}),jsxs(Layout.Content,Object.assign({stretch:S},{children:[jsxs(Nav,Object.assign({$compress:o},{children:[jsxs(NavBrandContainer,Object.assign({$compress:o,"data-id":"brand-container"},{children:[jsx(Brand,{resources:$,onClick:A,"data-id":"brand-primary","data-testid":"main__brand",type:"primary"}),w&&jsxs(Fragment,{children:[jsx(NavSeparator,{$compress:o}),jsx(Brand,{resources:w,onClick:A,"data-id":"brand-secondary","data-testid":"main__brand-secondary",type:"secondary"})]})]})),!c&&jsxs(NavElementsContainer,{children:[jsx(NavbarItems,{items:r.desktop,onItemClick:D,selectedId:a}),jsx(NavbarActionButtons,{actionButtons:d,onActionButtonClick:I}),jsx(MobileMenuButton,Object.assign({"aria-label":"Open nav menu","data-testid":"button__mobile-menu",onClick:P,focusHighlight:!1},{children:jsx(MobileMenuIcon,{})}))]})]})),!c&&jsx(Overlay,Object.assign({show:_,enableOverlayClick:!0,onOverlayClick:M},{children:jsxs(Drawer,Object.assign({show:b,resources:{primary:$,secondary:w},onClose:M,onBrandClick:A,actionButtons:d},{children:[jsx(NavbarItems,{items:r.mobile||r.desktop,onItemClick:D,selectedId:a,mobile:!0}),jsx(NavbarActionButtons,{actionButtons:d,onActionButtonClick:I,mobile:!0})]}))}))]}))]}))},Navbar=forwardRef(Component$1),DEFAULT_RESOURCES={primary:{brandName:"LifeSG",logoSrc:"https://assets.life.gov.sg/lifesg/logo-lifesg.svg"}},NavbarHeight=NAVBAR_HEIGHT,NavbarMobileHeight=NAVBAR_MOBILE_HEIGHT,commonLinkStyle=css`
|
|
4239
4240
|
color: ${Color.Validation.Orange.Icon};
|
|
4240
4241
|
|
|
4241
4242
|
svg {
|