Skip to content

Commit

Permalink
Fixed navbar responsive and dynamic height of navbar (#146)
Browse files Browse the repository at this point in the history
* fixed navbar responsive issue

* temp fixed iframe height

* fixed dynamic height

* removed create new button
  • Loading branch information
shuhaib-aot authored Feb 16, 2024
1 parent 0a7c932 commit 52aa460
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const ConnectedApps = React.memo((props: any) => {
return (
<>
{connectedApps ? <iframe width="100%"
height="500"
height="700"
src={connectedApps}
title="connected apps" >
</iframe> : <Alert message="No urls found"/> }
Expand Down
2 changes: 1 addition & 1 deletion forms-flow-integration/src/components/Library/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const Library = React.memo((props: any) => {

return (
<> {libraryUrl ? <iframe width="100%"
height="500"
height="700"
src={libraryUrl}
title="Library" >
</iframe> : <Alert message="No urls found"/> }</>
Expand Down
2 changes: 1 addition & 1 deletion forms-flow-integration/src/components/Recipes/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const Recipes = React.memo((props: any) => {

return (
<> {recipesUrl ? <iframe width="100%"
height="500"
height="700"
src={recipesUrl}
title="Recipes" >
</iframe> : <Alert message="No urls found"/> }</>
Expand Down
6 changes: 1 addition & 5 deletions forms-flow-integration/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,7 @@ const Integration = React.memo(({ props }: any) => {
<div className="main-container " tabIndex={0}>
<div className="container mt-5">
<div className="min-container-height ps-md-3">
<div className="d-flex align-items-center justify-content-between">
<Head hideLine={true} items={headerList()} page={page} />
<button className="btn btn-primary"><i className="fa-solid fa-plus me-2"></i>Create new</button>
</div>
<hr className="head-rule " data-testid="head-rule" />
<Head items={headerList()} page={page} />
<ToastContainer theme="colored" />
<Switch>
<Route
Expand Down
40 changes: 34 additions & 6 deletions forms-flow-nav/src/Navbar.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect, useMemo, useState } from "react";
import React, { useEffect, useMemo, useRef, useState } from "react";
import { Navbar, Container, Nav, NavDropdown } from "react-bootstrap";
import { Link, BrowserRouter, useHistory } from "react-router-dom";
import { getUserRoleName, getUserRolePermission } from "./helper/user";
Expand Down Expand Up @@ -97,6 +97,33 @@ const NavBar = React.memo(({ props }) => {
const tenantKey = tenant?.tenantId;
const formTenant = form?.tenantKey;
const baseUrl = MULTITENANCY_ENABLED ? `/tenant/${tenantKey}/` : "/";
const navbarRef = useRef(null);

const onResize = React.useCallback(() => {
if (navbarRef?.current) {
const isMediumScreen = window.matchMedia('(min-width: 992px)').matches;
if(isMediumScreen){
document.documentElement.style.setProperty('--navbar-height', `${navbarRef.current.offsetHeight}px`);
}else{
document.documentElement.style.setProperty('--navbar-height', `${52}px`);
}
}
}, [navbarRef?.current]);

// to set the navbar height
useEffect(()=>{
onResize()
},[navbarRef?.current,navbarRef?.current?.offsetHeight])


useEffect(() => {
window.addEventListener("resize", onResize);
onResize();
return () => {
window.removeEventListener("resize", onResize);
};
}, []);


/**
* For anonymous forms the only way to identify the tenant is through the
Expand Down Expand Up @@ -179,9 +206,8 @@ const NavBar = React.memo(({ props }) => {
<link rel="icon" type="image/png" href={MULTITENANCY_ENABLED ? tenantLogo : null} />
</Helmet>
<BrowserRouter>
<header className="navbar-background shadow">
<Container>
<Navbar collapseOnSelect expand="lg" className={`navbar-background p-0 m-0 ${!isAuthenticated ? 'justify-content-between':''}`}>
<Navbar ref={navbarRef} collapseOnSelect fixed="top" expand="lg" className={`navbar-background py-0 shadow px-3 m-0 ${!isAuthenticated ? 'justify-content-between':''}`}>
<Container className="d-flex justify-content-between" >
<Navbar.Brand href={`${baseUrl}`} className="d-flex col-3 px-0">
<img
className="custom-logo"
Expand All @@ -198,6 +224,7 @@ const NavBar = React.memo(({ props }) => {
className="d-lg-flex justify-content-between h-100"
>
<Nav

id="main-menu-nav"
className="align-items-lg-center justify-content-start w-100"
data-testid="main-menu-nav"
Expand Down Expand Up @@ -422,9 +449,10 @@ const NavBar = React.memo(({ props }) => {
</Link>
)
)}
</Container>
</Navbar>
</Container>
</header>


</BrowserRouter>
</>
);
Expand Down
3 changes: 2 additions & 1 deletion forms-flow-theme/src/baseStyle.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ body {
}

.main-container{
max-height: calc(100vh - 52px);
max-height: calc(100vh - var(--navbar-height));
margin-top: var(--navbar-height);
overflow-y: auto;

}
Expand Down
1 change: 1 addition & 0 deletions forms-flow-theme/src/global.scss
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
--navbar-items-font-weight: 400;

--navbar-background: var(--color-white);
--navbar-height: 52px;
--navbar-items: var(--color-black);
--navbar-active: var(--color-primary);
--button-primary-background: var(--color-primary);
Expand Down

0 comments on commit 52aa460

Please sign in to comment.