I want to add animation to the sidedrawer I made in reactjs. And I am not sure how to do that should i use react transition group or anything else which would be good ?
sidedrawer.js
import React from 'react'
import './sidedrawer.scss'
export default function SideDrawer() {
return (
<aside className="menu is-dark sidedrawer__wrapper">
<ul className="menu-list">
<li><a>Home</a></li>
<li><a>Contact</a></li>
<li><a>About</a></li>
</ul>
</aside>
)
}
sidedrawer.scss
.sidedrawer__wrapper{
background-color: #363636;
right: 0;
width: 80%;
height: 100%;
top: 0;
box-shadow: 1px 0px 7px rgba(0, 0, 0, 0.5);
position: fixed;
overflow-y: hidden;
z-index: 200;
.menu-list {
padding: 5rem 2rem 0rem 3rem;
li {
padding-top: 2rem;
a {
text-decoration: none;
color: white;
font-size: 30px;
}
}
}
}
navbar.js
import React,{Component} from 'react'
import './navbar.scss';
import Backdrop from './backdrop/backdrop';
import SideDrawer from './sidedrawer/sidedrawer';
class Navbar extends Component {
render() {
let backdrop;
let sidedrawer;
if(this.props.sideDrawerOpen) {
backdrop = <Backdrop click={this.props.backdropClickHandler}/>
sidedrawer= <SideDrawer/>
}
return (
<nav style={{width: '85%', margin:'0 auto'}} className="navbar is-dark" role="navigation" aria-label="main navigation">
<div className="navbar-brand">
<a className="navbar-item" href="/">ADI</a>
<a onClick={this.props.drawerToggleClickHandler} role="button" className="navbar-burger burger" aria-label="menu" aria-expanded="false" data-target="navbarBasicExample">
<span aria-hidden="true"></span>
<span aria-hidden="true"></span>
<span aria-hidden="true"></span>
</a>
</div>
<div className="navbar-menu">
<div className="navbar-end">
HOME
CONTACT
ABOUT
</div>
</div>
{sidedrawer}
{backdrop}
</nav>
)
}
}
export default Navbar
In navbar.js there is hamburger icon which activate the side drawer. Here i want to add animation to the component when it will appear.
The simplest way is to just do that by setting the original margin to -sidedrawerwidth and adding a CSS class on state-change when you click the icon. And giving it {transition: margin transition-time}.
Related
I'm working on a site built on bootstrap and have a column down the right side that contains a search module and some other things. it gets hidden on smaller screens. I'm hoping to restore just the search module (and hide everything else but the footer) when pressing a button that gets displayed in the menu.
It sounded simple, but I can't seem to figure out how to override it being hidden. The visibility is set in the style sheet but I also tried setting the visibility on the div itself with d-none d-lg-block - no go.
With below code, when hitting the button, the main container hides (though sometimes only when pressing it twice) but it doesn't restore the sidebar. Which, based on the different things I've tried appears to be as intended, just not what I'm trying to do with it..
I'm sure it's something simple, but I've been staring at this for far too long and I'm not doing well with googling. Thanks in advance for any help/suggestions.
Update: The comment confirming it was out of the realm of bootstrap helped a lot. Updated code below to use javascript to handle activating the search module and hiding the main content. a simple function only goes one way, so I am also hiding the search button itself on click and displaying a close button that reverses the actions. The next step was to reset everything if the page width changes (as this function is only intended to be for smaller screens/mobile, and if you action any of the buttons and then increase page width things stay hidden that shouldn't) so I added a third function that listens for page width changes and resets the visibility of the impacted divs when the size becomes large enough to properly display. it's working in testing, but I'm open to feedback, tips, etc. to make it better.
My sincere thanks to all who have helped me get here!
```
/* Set gray background color and 100% height */
.sidebar {
padding-bottom: 10px;
background-color: #f1f1f1;
text-align: center;
justify-content: center;
}
/* this adds padding to bottom of main container in order to account for footer image */
.pb-6 {
padding-bottom: 5rem !important;
}
/* hides this div on small size */
#media screen and (max-width: 768px) {
div.sidebar {
display: none;
}
div.footerimage {
display: none;
}
}
#media (min-width: 768px) {
/* hides hamburger on bigger screens */
.navbar-brand{
display: none;
}
.navbar-search{
display: none;
}
.navbar-pressed{
display: none;
}
}
/* Set black background color, white text and some padding */
footer {
background-color: #000;
color: #fff;
padding: 15px;
margin:0;
}
body {
margin: 0px;
}
html {
font-family: "Lucida Sans", sans-serif;
}
/* images scales */
img {
max-width: 100%;
height: auto;
}
h1, h2, h3, h4, h5, h6 {
padding: 0px;
margin: 0px;
}
.header {
background-image: url();
background-size: cover;
background-color: #ffffff;
color: #000000;
padding:0;
margin:0;
text-align: center;
width: auto;
height: 100%;
line-height:0;
}
.navbar-pressed {
display: none;
}
.footerimage {
position: relative;
}
.footerpic {
background-image: url();
background-size: contain;
content: '';
height: 200px;
pointer-events: none;
position: absolute;
left: 50%;
top: 0;
transform: translate(-50%, -50%);
width: 200px;
}
/* change the background color */
.navbar-custom {
background-color: #1e73be;
margin-bottom: 0;
border-radius: 0;
padding: 0;
}
/* change the brand and text color */
.navbar-custom .navbar-brand,
.navbar-custom .navbar-text {
color: #ffffff;
}
/* change the link color */
.navbar-custom .navbar-nav .nav-link {
color: #ffffff;
}
/* change the color of navbar title when collapsed */
.navbar-toggler {
color: #ffffff;
}
/* change the color of active or hovered links */
.navbar-custom .nav-item.active .nav-link,
.navbar-custom .nav-item:focus .nav-link,
.navbar-custom .nav-item:hover .nav-link {
color: #ffffff;
background-color: #035a9e;
}
/* for dropdowns only */
.navbar-custom .navbar-nav .dropdown-menu {
background-color: #1e73be;
}
/* dropdown item text color */
.navbar-custom .navbar-nav .dropdown-item {
color: #ffffff;
}
/* dropdown item hover or focus */
.navbar-custom .navbar-nav .dropdown-item:hover,
.navbar-custom .navbar-nav .dropdown-item:focus {
color: #ffffff;
background-color: #035a9e;
}
.navbar-brand img {
height: 30px;
float: left;
margin-left: 20px;
padding: 0;
}
```
```
<!DOCTYPE html><html lang='en'><head><title>menu test</title><meta charset='utf-8'><meta name='viewport' content='width=device-width, initial-scale=1'><META HTTP-EQUIV='Content-Type' CONTENT='text/html; charset=iso-8859-1'>
<link rel='stylesheet' href='https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css'><link rel='stylesheet' href='https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.2.1/css/all.min.css'><link rel='preconnect' href='https://fonts.gstatic.com'><link href='https://fonts.googleapis.com/css2?family=Atma:wght#600&display=swap' rel='stylesheet'><script src='https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js'></script><script src='https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js'></script><script src='https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js'></script>
<script>
function myFunction() {
document.getElementById("maincontainer").style.display = 'none';
document.getElementById("sidebar").style.display = 'block';
document.getElementById("sidecontentdiv").style.display = 'none';
document.getElementById("navbar-search").style.display = 'none';
document.getElementById("navbar-pressed").style.display = 'block';
}
</script>
<script>
function myCloseFunction() {
document.getElementById("maincontainer").style.display = 'block';
document.getElementById("sidebar").style.display = 'none';
document.getElementById("sidecontentdiv").style.display = 'block';
document.getElementById("navbar-search").style.display = 'block';
document.getElementById("navbar-pressed").style.display = 'none';
}
</script>
<script>
function doSomething(matches) {
if (matches) {
// media query matches
} else {
// media query does not match
document.getElementById("maincontainer").style.display = "";
document.getElementById("sidebar").style.display = "";
document.getElementById("sidecontentdiv").style.display = "";
document.getElementById("navbar-search").style.display = "";
document.getElementById("navbar-pressed").style.display = "";
}
}
const query = window.matchMedia("(max-width: 767px)");
query.addEventListener("change", ({ matches }) => doSomething(matches));
doSomething(query.matches);
</script>
</head>
<body>
<div class='header'></div>
<nav class='navbar navbar-expand-md navbar-custom sticky-top'><div class='navbar-brand'><a href='https://www.url.com'><img src='/images/menu.png' alt='Logo'></a></div><div id='navbar-pressed' class='navbar-pressed ml-auto'><button class='navbar-toggler' type='button' onclick="myCloseFunction()"><i class='fa fa-circle-xmark fa-flip-horizontal' style='color:#ffffff'></i></button></div><div id='navbar-search' class='navbar-search ml-auto'><button class='navbar-toggler' type='button' onclick="myFunction()"><i class='fa-solid fa-magnifying-glass fa-flip-horizontal' style='color:#ffffff'></i></button></div><button class='navbar-toggler' type='button' data-toggle='collapse' data-target='#navbarCollapse'><span class='ml-auto' role='button'><i class='fa fa-bars' style='color:#ffffff'></i> Menu</span></button><div class='collapse navbar-collapse justify-content-between' id='navbarCollapse'><div class='navbar-nav'>
<div class='nav-item'><a href='index.php' class='nav-link'>Home</a></div>
<div class='nav-item'><a href='index.php' class='nav-link'>Home</a></div>
<div class='nav-item'><a href='index.php' class='nav-link'>Home</a></div></div>
</div></nav>
<div class='container-fluid text-center'>
<div class='row content'>
<div class='col-md-9 text-left pb-6' id='maincontainer'>
main body of page
</div>
<div id='sidebar' class='col-md-3 sidebar'>
<div id='searchdiv'>
<div class='sidebarheader rounded'><h4>Search:</h4></div>
<div class='searchbox rounded'>search module</div>
</div>
<div id='sidecontentdiv'>
<div class='sidebarheader rounded'><h4></h4></div>
<div class='searchbox rounded'>unimportant module</div>
</div></div>
<footer class='container-fluid text-center'>
<div class='row'>footer text</div>
</footer>
</div></div>
</body></html>
```
If it's simply hide/show div, why not use JavaScript / jQuery? Like,
<button onclick="myFunction()">src</button>
<div id="attid"></div>
<script>
function myFunction() {
document.getElementById("attid").style.display = 'none';
// or to show
// document.getElementById("attid").style.display = 'block';
}
</script>
Couldn't comment because lack of reputation :)
I think this will help you! Joe
const opener = document.getElementById('opener');
const sidebar = document.getElementById('sidebar');
const closer = document.getElementById('closer');
opener.onclick = function(){
sidebar.style.marginRight = 0
}
closer.onclick = function(){
sidebar.style.marginRight = 'calc(var(--length) * -1)'
}
body{
overflow:hidden;
}
#sidebar{
--length:280px;
margin-right:calc(var(--length) * -1);
width:var(--length);
transition:all .2s linear;
}
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.3.0-alpha1/dist/js/bootstrap.bundle.min.js" integrity="sha384-w76AqPfDkMBDXo30jS1Sgez6pr3x5MlQ1ZAGC+nuZB+EYdgRZgiwxhTBTkF7CXvN" crossorigin="anonymous"></script>
<button class="btn btn-primary" id='opener'>opener</button>
<div id = 'sidebar' class="d-flex d-md-none float-end flex-column flex-shrink-0 p-3 bg-light">
<div class="d-flex">
<button class="btn btn-primary" id='closer'>x</button>
<a href="/" class="d-flex align-items-center mb-3 mb-md-0 me-md-auto link-dark text-decoration-none">
<svg class="bi pe-none me-2" width="40" height="32"><use xlink:href="#bootstrap"></use></svg>
<span class="fs-4">Sidebar</span>
</a>
</div>
<hr>
<ul class="nav nav-pills flex-column mb-auto">
<li class="nav-item">
<a href="#" class="nav-link active" aria-current="page">
<svg class="bi pe-none me-2" width="16" height="16"><use xlink:href="#home"></use></svg>
Home
</a>
</li>
<li>
<a href="#" class="nav-link link-dark">
<svg class="bi pe-none me-2" width="16" height="16"><use xlink:href="#speedometer2"></use></svg>
Dashboard
</a>
</li>
<li>
<a href="#" class="nav-link link-dark">
<svg class="bi pe-none me-2" width="16" height="16"><use xlink:href="#table"></use></svg>
Orders
</a>
</li>
<li>
<a href="#" class="nav-link link-dark">
<svg class="bi pe-none me-2" width="16" height="16"><use xlink:href="#grid"></use></svg>
Products
</a>
</li>
<li>
<a href="#" class="nav-link link-dark">
<svg class="bi pe-none me-2" width="16" height="16"><use xlink:href="#people-circle"></use></svg>
Customers
</a>
</li>
</ul>
<hr>
<div class="dropdown">
<a href="#" class="d-flex align-items-center link-dark text-decoration-none dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">
<img src="https://github.com/mdo.png" alt="" width="32" height="32" class="rounded-circle me-2">
<strong>mdo</strong>
</a>
<ul class="dropdown-menu text-small shadow">
<li><a class="dropdown-item" href="#">New project...</a></li>
<li><a class="dropdown-item" href="#">Settings</a></li>
<li><a class="dropdown-item" href="#">Profile</a></li>
<li><hr class="dropdown-divider"></li>
<li><a class="dropdown-item" href="#">Sign out</a></li>
</ul>
</div>
</div>
I don't really know why transforming the X position while appending an additional class to make the slide effect isn't working as expected in React, as it does while using vanilla javascript.
This is the code example
.inputModal {
position: absolute;
width: 500px;
height: 150px;
display: inline-flex;
justify-content: center;
align-items: center;
padding: 10px 20px;
background-color: rgba(25, 26, 26, 0.74);
left: -8px;
top: 30%;
box-shadow: 10px 15px 20px rgba(0, 0, 0, 0.5);
transform: translateX(-93%);
transition: all 0.3s ease-in-out;
}
.InputModal.show {
transform: translateX(0px);
}
And the simple Component which should append the class show on button click
function InputModal() {
const [toggleBtn, setToggleBtn] = useState(true);
return (
<div className={toggleBtn ? "inputModal" : "InputModal show"}>
<Input />
<div
className="toggleBtn"
onClick={() => {
setToggleBtn(!toggleBtn);
}}
>
<i className="fas fa-align-justify"></i>
</div>
</div>
);
}
Once I click the toggle button(div) the show class is appended on to the div, but the div is losing all the previous set stylings and gets messed up
You should append instead of change the classes, just like:
function InputModal() {
const [toggleBtn, setToggleBtn] = useState(true);
return (
<div className={`inputModal ${toggleBtn ? "" : "InputModal show"}`}>
<Input />
<div
className="toggleBtn"
onClick={() => {
setToggleBtn(!toggleBtn);
}}
>
<i className="fas fa-align-justify"></i>
</div>
</div>
);
}
I'd like to show the buttons row direction.
I've given disply:flex but it still shows column.
It should be the button has a first character of the name which is underneath the button
and these buttons should be next to each other.
Not like button on the left and the name on the right.
Would be appreciated if I could get help.
RoomList.js
import React from 'react';
import './RoomList.css';
import PropTypes from 'prop-types';
const RoomList = ({ roomList }) => {
return (
<div>
{roomList.map((room) => {
const firstToChar = room.split('');
const firstChar = firstToChar[0];
return (
<div>
<li className="list">
<div className="room-list">
<button type="submit">{firstChar}</button>
<div>{room}</div>
</div>
</li>
</div>
);
})}
</div>
);
};
RoomList.propTypes = {
roomList: PropTypes.func.isRequired,
};
export default RoomList;
RoomList.css
button {
height: 40px;
min-width: 40px;
display: block;
border-radius: 50%;
margin-bottom: 5px;
}
.room-list {
}
.list {
list-style-type: none;
display: flex;
}
The problem is with the HTML you produce. You produce one list by room. Which is not what you want, you want one list, and one item by room in your list.
button {
height: 40px;
min-width: 40px;
display: block;
border-radius: 50%;
margin-bottom: 5px;
}
.room-list {
}
.list {
list-style-type: none;
display: flex;
}
<div>
<div>
<li class="list">
<div class="room-list">
<button type="submit">K</button>
<div>Kitchen</div>
</div>
</li>
</div>
<div>
<li class="list">
<div class="room-list">
<button type="submit">B</button>
<div>Bathroom</div>
</div>
</li>
</div>
</div>
What you want is:
button {
height: 40px;
min-width: 40px;
display: block;
border-radius: 50%;
margin-bottom: 5px;
}
.room-list {
}
.list {
list-style-type: none;
display: flex;
}
<div>
<div>
<li class="list">
<div class="room-list">
<button type="submit">K</button>
<div>Kitchen</div>
</div>
<div class="room-list">
<button type="submit">B</button>
<div>Bathroom</div>
</div>
</li>
</div>
</div>
So you actually want:
const RoomList = ({ roomList }) => {
return (
<div>
<div>
<li className="list">
{roomList.map((room) => {
const firstToChar = room.split('');
const firstChar = firstToChar[0];
return (
<div className="room-list">
<button type="submit">{firstChar}</button>
<div>{room}</div>
</div>
);
})}
</li>
</div>
</div>
);
};
The flex should be on the room list instead
Basically, currently my card's style changes when it is hovered on, but I want that same style to be executed when it is clicked. I've tried using :active and :focus but that only seems to change the style till the time that card is clicked.
Here is the link to my repo: https://github.com/abhudaym/soundboard
Here is my App.js
import React from 'react';
import useSound from 'use-sound';
import Slider from 'react-slick';
import logo from './logo.svg';
import snare from './sounds/snare.mp3';
import './App.css';
import 'slick-carousel/slick/slick.css';
import 'slick-carousel/slick/slick-theme.css';
import 'bootstrap/dist/css/bootstrap.css';
import rollingChair from './sounds/rolling-office-chair.wav';
import quietOffice from './sounds/office-quiet.mp3';
import busyOffice from './sounds/busy-office.wav';
import officeTyping from './sounds/office-typing.wav';
import phone from './sounds/phone.wav';
import ac from './sounds/ac.wav';
import coffeeMachine from './sounds/coffeeMachine.wav';
import photocopier from './sounds/photocopier.wav';
import rainOnWindows from './sounds/rainOnWindows.wav';
function App() {
const [play1, { stop1 }] = useSound(rollingChair);
const [play2, { stop2 }] = useSound(quietOffice);
const [play3, { stop3 }] = useSound(busyOffice);
const [play4, { stop4 }] = useSound(officeTyping);
const [play5, { stop5 }] = useSound(phone);
const [play6, { stop6 }] = useSound(ac);
const [play7, { stop7 }] = useSound(coffeeMachine);
const [play8, { stop8 }] = useSound(photocopier);
const [play9, { stop9 }] = useSound(rainOnWindows);
const [playSnare, { stopSnare }] = useSound(snare);
const settings = {
dots: true,
infinite: true,
speed: 500,
autoplay: true,
slidesToShow: 3,
slidesToScroll: 1,
arrows: false,
};
return (
<section id='services' className='services'>
<div className='container text-center my-auto'>
<Slider {...settings}>
<div className='mb-5 mb-lg-0 row'>
<button onClick={play1} onMouseLeave={stop1}>
<div className='icon-box' data-aos='fade-up' data-aos-delay='100'>
<div className='icon'>
<i className='fas fa-robot'></i>
</div>
Sound-1
</div>
</button>
</div>
<div className='mb-5 mb-lg-0 row'>
<button onClick={play1} onMouseLeave={stop1}>
<div className='icon-box' data-aos='fade-up' data-aos-delay='100'>
<div className='icon'>
<i className='fas fa-robot'></i>
</div>
Sound-1
</div>
</button>
</div>
<div className='mb-5 mb-lg-0 row'>
<button onClick={play1} onMouseLeave={stop1}>
<div className='icon-box' data-aos='fade-up' data-aos-delay='100'>
<div className='icon'>
<i className='fas fa-robot'></i>
</div>
Sound-1
</div>
</button>
</div>
<div className='mb-5 mb-lg-0 row'>
<button onClick={play1} onMouseLeave={stop1}>
<div className='icon-box' data-aos='fade-up' data-aos-delay='100'>
<div className='icon'>
<i className='fas fa-robot'></i>
</div>
Sound-1
</div>
</button>
</div>
<div className='mb-5 mb-lg-0 row'>
<button onClick={play1} onMouseLeave={stop1}>
<div className='icon-box' data-aos='fade-up' data-aos-delay='100'>
<div className='icon'>
<i className='fas fa-robot'></i>
</div>
Sound-1
</div>
</button>
</div>
<div className='mb-5 mb-lg-0 row'>
<button onClick={play1} onMouseLeave={stop1}>
<div className='icon-box' data-aos='fade-up' data-aos-delay='100'>
<div className='icon'>
<i className='fas fa-robot'></i>
</div>
Sound-1
</div>
</button>
</div>
</Slider>
</div>
</section>
);
}
export default App;
Here is my App.css
body{
background-image: linear-gradient(to right, #ffecd2 0%, #fcb69f 100%);
}
.services .icon-box {
padding: 30px;
margin-bottom: 30px;
position: relative;
overflow: hidden;
background: #fff;
box-shadow: 0 0 29px 0 rgba(68, 88, 144, 0.12);
transition: all 0.3s ease-in-out;
border-radius: 8px;
z-index: 1;
}
.services .icon-box::before {
content: '';
position: absolute;
background: #e1f0fa;
right: -60px;
top: -40px;
width: 100px;
height: 100px;
border-radius: 50px;
transition: all 0.3s;
z-index: -1;
}
.services .icon-box:hover::before {
background: #3498db;
right: 0;
top: 0;
width: 100%;
height: 100%;
border-radius: 0px;
}
.services .icon {
margin: 0 auto 20px auto;
padding-top: 10px;
display: inline-block;
text-align: center;
border-radius: 50%;
width: 60px;
height: 60px;
background: #3498db;
transition: all 0.3s ease-in-out;
}
.services .icon i {
font-size: 36px;
line-height: 1;
color: #fff;
}
.services .title {
font-weight: 700;
margin-bottom: 15px;
font-size: 18px;
}
.services .title a {
color: #111;
}
.services .description {
font-size: 15px;
line-height: 28px;
margin-bottom: 0;
}
.services .icon-box:active .title a, .services .icon-box:active .description {
color: #fff;
}
.services .icon-box:active .icon {
background: #fff;
}
.services .icon-box:active .icon i {
color: #3498db;
}
.row{
padding: 50px 20px 20px 0px;
}
.r2{
padding-top: 0px !important;
}
The best way to accomplish what you want is to add an 'active' class to the card when you click on it that contains the same styles as :hover. In this way, you keep the style whenever you want
If the style needs to be present till the page refresh you can have a state and add the additional class to achieve this thing
const [buttonClicked,setButtonClicked]=useState({button1:false,button2:false,button3:false});
this will have a boolean value false by default for setting initially the button will remain unclicked.
during the button click have a function like `
onButtonClick = (clickedButtonName){
setButtonClicked({...buttonClicked,[clickedButtonName]:true })}
send the name as button1,button2 from render like
<button onClick={()=>onButtonClick('button1)} onMouseLeave={stop1}>
now add the additional class in the render method using the state buttonClicked
<button class={`${buttonClicked.button1?'button-active':''}`} onClick={()=>onButtonClick('button1)} onMouseLeave={stop1}>
now if the button is clicked it will have the active class as button-active you can add a class button-active and apply the same styles like hover
I am working on a Reactjs project, for that I am using the Bootstrap framework for designing. In that I have one div, in that div I have One button, In that button I have two Span tags. In first span tags I have Icon and In Second Span tag I have text. My problem is In output the text is coming under the Icon, But what I am expecting is Icon and text should be side by side. So try to help me to debug this issue.
This is App.js
import React from 'react';
import './App.css';
import Navbar from './Navbar/Navbar';
import FlightsButton from './FlightsButton/FlightsButton';
function App() {
return (
<div className="App">
<FlightsButton></FlightsButton>
</div>
);
}
export default App;
This is App.css
There is no css in App.css
This is FlightsButton.js
import React, { Component } from 'react'
import './FlightsButton.css'
import ReusableButtons from '../ReusableButtons/ReusableButtons';
class FlightsButton extends Component {
render() {
return (
<div className='container-fluid'>
<div className='row'>
<div className='col-12'>
<div className='one mt-3 d-inline-block'>
<button type='button' className='buttonOne rounded-top'>
<span className='flightStyle'>
<i class="fa fa-fighter-jet fa-sm flightLogo"></i>
</span>
<span className='flightContent pl-2'>
Flights
</span>
</button>
</div>
<div className='two mt-3 d-inline-block'>
<ReusableButtons>
<span className='hotelStyle'>
<i class="fa fa-bed fa-sm hotelLogo"></i>
</span>
<span className='hotelContent pl-2'>
Hotels
</span>
</ReusableButtons>
</div>
</div>
</div>
</div>
)
}
}
export default FlightsButton
This is FlightsButton.css
.buttonOne {
background-color: #008ca8;
border: none;
padding: 0.50%;
padding-left: 0.50%;
padding-right: 0.50%;
}
.flightLogo {
color:white;
}
.hotelLogo {
color:white;
}
.hotelContent {
color: white;
font-weight: 700;
font-family: -apple-system,BlinkMacSystemFont,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,Arial,sans-serif;
}
.flightContent {
color: white;
font-weight: 700;
font-family: -apple-system,BlinkMacSystemFont,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,Arial,sans-serif;
}
.one {
margin-right: 1%;
/* display: inline-block; */
}
.two {
/* display: inline-block; */
}
This is ReusableButtons,js
import React, { Component } from 'react';
import './ReusableButtons.css';
class ReusableButtons extends Component {
render() {
return (
<div className='buttonUsage'>
<button type='button' className='customButtonStyle rounded-top'>
{this.props.children}
</button>
</div>
)
}
}
export default ReusableButtons
This is ReusableButtons.css
.customButtonStyle {
background-color: #00b2d6;
border: none;
padding: 0.50%;
padding-left: 0.50%;
padding-right: 0.50%;
}
I am not aware of react but I used only HTML and CSS from your code and checked it. It looks fine.
But still, if you facing the problem, then increase the button width this will help you.