Gap in right margin of page won't go away - reactjs

I'm building a new project using reactJS, nodeJS, and react-bootstrap. When setting up my landing page. There is a gap in the margin on the right side of the page that won't go away, no matter what I try.
.I've tried including the meyer's reset css file in the index.html.
.I've tried setting margins, borders, and padding on the Body element to zero.
.I've tried setting my Container to width: 100%.
.I've tried resizing the background image.
.I've tried including the bootstrap 4 cdn in my index.html.
App.js
import React, { Component } from 'react';
import { BrowserRouter as Router, Route, Switch } from "react-router-dom";
import LandingPage from './components/landingpage';
import Header from './components/header';
import Footer from './components/footer';
import './App.css';
class App extends Component {
render() {
return (
<Router>
<Header/>
<Switch>
<Route exact path='/' component={LandingPage}/>
</Switch>
<Footer/>
</Router>
);
}
}
export default App;
App.css
/* {
box-sizing: border-box;
}*/
body {
background-image: url('./images/background.jpg');
background-repeat: no-repeat;
background-position: center center;
/*background-size: cover;*/
font-family: 'Courgette', cursive;
color: beige;
font-size: 28px;
text-align: center;
max-width: 100%;
margin: 0;
border: 0;
padding: 0;
}
.container {
margin: 0;
padding: 0;
width: 100%;
}
.courgette {
font-family: 'Courgette', cursive;
}
.lobster {
font-family: 'Lobster', cursive;
}
header.js
import React from "react";
import './header.css';
import { Container, Row, Col } from 'react-bootstrap';
import { Link } from "react-router-dom";
const Header = () => {
return(
<Container className='header'>
<Row>
<Col>
<Link href="#">
<img className='hamburgermenu' src={require('./../../images/navbaricon.png')} alt='Hamburger Menu Icon'/>
</Link>
</Col>
<Col>
<h1>MDNight</h1>
</Col>
<Col>
<p>Hello!</p>
</Col>
</Row>
</Container>
)
}
export default Header;
header.css
.header{
background-color: maroon;
margin: 0;
}
.hamburgermenu {
height: 80px;
width: auto;
}
The header is supposed to extend to the edge of the page, but it does not.

There is any margin gap in the application.

Related

Can't style #mui Avatar icon with styled-components

I'm playing around with styled-components and having troubles working with material-ui. So thats the code:
import React from "react";
import styled from "styled-components";
import ChatIcon from "#mui/icons-material/Chat";
import MoreVertIcon from "#mui/icons-material/MoreVert";
import { Avatar} from "#mui/material";
function Sidebar() {
return (
<Container>
<Header>
<UserAvatar className={"override"} />
<IconsContainer>
<IconButton>
<ChatIcon />
</IconButton>
<IconButton>
<MoreVertIcon />
</IconButton>
</IconsContainer>
</Header>
</Container>
);
}
export default Sidebar;
const Container = styled.div``;
const Header = styled.div`
display: flex;
position: sticky;
top: 0;
background-color: white;
z-index: 1;
justify-content: space-between;
align-items: center;
padding: 15px;
height: 80px;
border-bottom: 1px solid whitesmoke;
`;
const UserAvatar = styled(Avatar)`
height: 60px;
`;
const IconsContainer = styled.div`;
The styled div is working completely fine, but when I import 'Avatar' from #mui and try to add some styling named UserAvatar, it is completely ignoring what I'm writing down.
I think that with mui they have their own version of styled for styled components. https://mui.com/system/styled/
It appears they want you to use it rather than styled-components
import Button from '#mui/material/Button';
import { styled } from '#mui/material/styles';
const CustomButton = styled(Button)({
// your custom styles go here
}) as typeof Button;
see the import from import { styled } from '#mui/material/styles';;

Background image only shows up after reloading the page

I'm trying to import an image as I usually do on React and using that value as a background image for a styled component, the first page that renders seems to use the background fine, but then when navigating the application with Links from react-router it doesn't seem to load the background for any of the components inside the router. I have to reload each component to see the actual background.
import React from "react";
import MiningBackground from "assets/backgrounds/miningBackground.jpg";
import styled from "#emotion/styled";
const MiningPage = () => {
return <BackgroundContainer key="mining-background"></BackgroundContainer>;
};
const BackgroundContainer = styled.div`
background-image: url(${MiningBackground});
background-repeat: no-repeat;
background-size: cover;
opacity: 0.3;
min-height: 100vh;
min-width: 100vw;
background-color: "#0A2836";
color: "#0A2836";
`;
export default MiningPage;
After further checking, it looks like the router is not returning the components at all, I'll attach the router and the navigation.
The Drawer:
import {
faHome,
faGem,
faCoins,
faSpaceShuttle,
} from "#fortawesome/free-solid-svg-icons";
import { Divider, Drawer, List, Toolbar, Typography } from "#material-ui/core";
import React from "react";
import AMenuItem from "components/atoms/AMenuItem";
import styled from "#emotion/styled";
import MadeByCommunityBlack from "assets/MadeByTheCommunity_Black.png";
const SideMenu: React.FC = () => {
return (
<StyledDrawer variant="permanent" open>
<div>
<Toolbar />
<StyledList>
<AMenuItem link="/" icon={faHome} text="Home" />
<AMenuItem link="/mining" icon={faGem} text="Mining" />
<AMenuItem link="/trading" icon={faCoins} text="Trading" />
<AMenuItem link="/fleet" icon={faSpaceShuttle} text="Fleet" />
<Divider />
</StyledList>
</div>
<TradeMarkContainer>
<StyledImage
src={MadeByCommunityBlack}
alt="Made by the star citizen community official logo"
/>
<Typography variant="caption">
Star Citizen®, Roberts Space Industries® and Cloud Imperium ® are
registered trademarks of Cloud Imperium Rights LLC.
</Typography>
</TradeMarkContainer>
</StyledDrawer>
);
};
const StyledDrawer = styled(Drawer)`
.MuiDrawer-paper {
z-index: 980;
display: flex;
flex-direction: column;
justify-content: space-between;
height: 100%;
padding: 0px 10px 10px 10px;
width: 190px;
}
`;
const TradeMarkContainer = styled.div`
display: flex;
flex-direction: column;
align-items: center;
`;
const StyledList = styled(List)`
background-color: "#0A2836";
`;
const StyledImage = styled.img`
width: 150px;
`;
export default SideMenu;
The Router:
import FleetPage from "components/pages/FleetPage";
import MiningPage from "components/pages/MiningPage";
import TradingPage from "components/pages/TradingPage";
import React from "react";
import { Route, Router, Switch } from "react-router-dom";
import HomePage from "../components/pages/HomePage";
import { createBrowserHistory } from "history";
import SideMenu from "components/organisms/SideMenu";
import TopBar from "components/organisms/TopBar";
const Routes = () => {
const history = createBrowserHistory();
return (
<Router history={history}>
<TopBar />
<SideMenu />
<Switch>
<Route path="/fleet" component={FleetPage} />
<Route path="/trading" component={TradingPage} />
<Route path="/mining" component={MiningPage} />
<Route path="/" component={HomePage} />
</Switch>
</Router>
);
};
export default Routes;
The issue was I was importing Router and not BrowserRouter from react-router-dom. Changing that and removing the history prop did the trick.

Render Header or Title to ant design - Timepicker component

I would like to render some header/title for time picker to indicate this is HH, MM and SS (Which is Hour, Minute, Sec) but unable to do.
I can achieve it by only renderExtraFooter which renders at the bottom of the picker but I need it on the top of the time picker. You can check the code below:
https://stackblitz.com/edit/react-j1kksn-ef4m56?file=index.js
Some of the users feels hard to find which is hour, minute and seconds. It would be better to have that option.
import React from "react";
import ReactDOM from "react-dom";
import "antd/dist/antd.css";
import "./index.css";
import { TimePicker } from "antd";
const onChangeTime = time => {
console.log(time);
};
ReactDOM.render(
<TimePicker
onChange={onChangeTime}
renderExtraFooter={() => (
<div className="timePickerHeader">
<p>HH</p>
<p>MM</p>
<p>SS</p>
</div>
)}
/>,
document.getElementById("container")
);
.timePickerHeader {
position: float;
}
.timePickerHeader p {
display: inline-block;
width: 33%;
}
Looks like there is no header option, but you can change the style to make the footers align with their respective column. Use a grid column layout.
Avoid using <p> and position:float and display:inline-block in favor of <div> with display:grid and display:flex.
renderExtraFooter={() => (
<div className="timePickerHeader">
<div>HH</div>
<div>MM</div>
<div>SS</div>
</div>
)}
.ant-picker-footer-extra {
padding-left: 7px;
}
.timePickerHeader {
display: grid;
grid-auto-flow: column;
}
.timePickerHeader div {
padding-left: 14px;
text-align: left;
}
Note: The CSS above can be simplified to the following, if you just want to center the text within each column.
.ant-picker-footer-extra {
padding: 0;
}
.timePickerHeader {
display: grid;
grid-auto-flow: column;
}
.timePickerHeader div {
text-align: center;
}

Why my styled component not work with text-decoration?

I'm trying to remove underline for my Link in react by using styled-components
if I use style={{textDecoration: "none"}} it will work but when I use text-decoration: none; in my styled components it won't work:
here is my js code:
import React from "react";
import styled from "styled-components";
import { Link } from "#reach/router";
import { CSSTransition, TransitionGroup } from "react-transition-group";
const StyleNavbarContainer = styled.nav`
background-color: #333333;
width: 100%;
color: #d6d6d6;
position: fixed;
text-align: center;
top: 0;
`;
const AppleLogo = styled.div`
font-size: 20px;
display: inline-block;
`;
const StyleLinkList = styled.ul`
display: inline-block;
`;
const StyledLink = styled(Link)`
padding: 12px 10px;
color: #d6d6d6;
text-decoration: none;
`;
const Navbar = (props) => {
return (
<>
<StyleNavbarContainer>
<AppleLogo>
<i class="fab fa-apple"></i>
</AppleLogo>
<StyleLinkList>
<StyledLink to="/">Mac</StyledLink>
</StyleLinkList>
</StyleNavbarContainer>
</>
);
};
export default Navbar;
add my App.jsx file here is the code:
import React from "react";
import "bootstrap/dist/css/bootstrap.min.css";
import Navbar from "./components/Navbar";
function App() {
return (
<div className="App">
<Navbar />
</div>
);
}
export default App;
Need to remove import "bootstrap/dist/css/bootstrap.min.css"; from App.jsx

How to prevent Reach Router from disabling Scrolling in children component

Scrollbar and scrolling is disable in parent element (with "overflow-y" set to "scroll") inside the component in Router children , Why its behaving like this and how do i prevent it / make it work?
live demo here: https://codesandbox.io/s/priceless-johnson-1fkju
import React from "react";
import { Router } from "#reach/router";
import Chats from "./Chats";
import { TopBar, AndroidControls } from "../components/shared";
const Routing = () => {
return (
<div className="app-wrapper">
<TopBar />
{* <section className="content"> *} // So i tested this, the section element need to be outside of the router comp for it to work , why?
<Router>
<Chats path="/" />
</Router>
{/* </section> *}
<AndroidControls />
</div>
);
};
export default Routing;
The problem is with your CSS
Slightly modify you css
from this
.content {
width: 100%;
height: calc(100% - 22rem);
padding-bottom: 4.9rem;
background-color: #fff;
overflow-y: scroll;
}
to this
.content {
width: 100%;
height: 80vh; /*Changed the height value*/
padding-bottom: 4.9rem;
background-color: #fff;
overflow-y: auto; /*Changed to auto*/
}
CodeSandbox modified

Resources