Album cards not flexing in row direction - ipad view - reactjs

I am trying to set the 2 columns for tablet view but for some reason the albums dont flex in row direction. I am using react an.
Can someone help me see the issue?
I leave these links for full code:
https://music-release-site-by-maria-and-daniela.netlify.app/
https://github.com/dannuzak/project-music-releases
Mobile view CSS
* {
box-sizing: border-box;
margin: 0;
text-decoration: none;
}
body {
font-family: Arial, Helvetica, sans-serif;
background-color: #111418;
}
.header {
margin: 40px;
padding-bottom: 10px;
font-size: 0.8rem;
border-bottom: #353a45 solid 1px;
color: #fff;
}
.albums-container {
display: flex;
flex-direction: column;
align-content: center;
margin: 10%;
}
.album-card {
margin-bottom: 10%;
height: 360px;
margin-bottom: 20%;
display: flex;
flex-direction: column;
justify-content: space-around;
}
.album-cover {
/* height: 300px;
width: 100%; */
position: relative;
}
.cover {
width: 100%;
}
#media all and (min-width: 768px) {
.albums-container {
display: flex;
width: 95%;
margin: 0;
flex-direction: row;
flex-wrap: wrap;
justify-content: space-around;
}
.album-card {
width: 40%;
display: flex;
flex-direction: column;
flex-wrap: wrap; // I have removed this //
}
}
---- Header component--
import React from 'react'
const Header = () => {
return (
<header className="header">
<h1>New albums & singles</h1>
</header>
);
}
--------- Album component
<>
<div className="album-card">
<div className = "album-cover">
<div className="icon-container">
<img className="icon heart" src="/icons/heart.svg" alt="heart icon"/>
<img className="icon play" src="/icons/play.svg" alt="play button icon"/>
<img className="icon dots" src="/icons/dots.svg" alt="dots icon"/>
</div>
<a href={props.urlAlbum} target= "_blank" rel="noopener noreferrer">
<img className="cover" src={props.image} alt="Album cover"/>
</a>
</div>
<div>
<a href={props.urlAlbum} target= "_blank" rel="noopener noreferrer">
<h2 className="album-name">{props.name}</h2>
</a>
</div>
<div className="album-artist">
<a href={props.urlArtist} target= "_blank" rel="noopener noreferrer">
<h2>{props.artists}</h2>
</a>
</div>
</div>
</>
export default Header;

Related

Reactjs Accordion Bullet

How do I make background color of "-" bullet expand when I active the content.
Image 1 is what I want to do while Image 2 is what I do...
Want to be like tis
[1]
(https://i.stack.imgur.com/5NDOX.png)
My Demo
[2]
(https://i.stack.imgur.com/0ztPK.png)
My Js Code
`
const [isActive, setIsActive] = useState(false);
<div className="support">
<div className='containerFour'>
<h1>FAQ</h1>
<h1>Tell us what you're searching for</h1>
<div className="accordion">
<div className="accordionItem">
<div className="accordionTitle" onClick={() => setIsActive(!isActive)}>
<h1 className='accordionH'>What payment methods are available to complete your purchase?</h1>
<div className='accordionBullet'>{isActive ? <img src={Close} /> : <img src={Open}/>}</div>
</div>
{isActive && <div className="accordionContent">Test</div>}
</div>
</div>
</div>
</div>
`
My Css
.support .accordion {
width: 811px;
margin-left: auto;
margin-right: auto;
}
.support .accordionItem {
margin-bottom: 1.5rem;
}
.support .accordionBullet{
background-color: #205696;;
padding-top: 1rem;
}
.support .accordionTitle {
display: flex;
flex-direction: row;
justify-content: space-between;
cursor: pointer;
background-color: #D9D9D9;;
}
.support .accordionH{
font-family: 'Urbanist';
font-style: normal;
font-weight: 700;
font-size: 24px;
line-height: 29px;
color: #000000;
}
.support .accordionTitle:hover {
background-color: #D9D9D9;;
}
.support .accordionContent {
background-color: #D9D9D9;
}
Currently, the accordionBullet is inside the accordionTitle. Its maximum height = height of the h1 heading only.
Put accordionBullet beside accordionItem so that it can expand with its height.
<div className="accordion">
<div className="accordionItem">
... (Title + Content) ...
</div>
<div className="accordionBullet">
...
</div>
</div>
.accordion {
display: flex;
}

How to style two different elements with the same styles in styled-components

<header>
<div class="max-width">
<h1>
<a href="./">
<img src="./assets/Logo.svg" alt="My Blog" />
</a>
</h1>
<ul>
<li class="profile-img">
<a href="#">
<img src="./assets/profile.jpg" alt="My Page" />
</a>
</li>
<li>
<a href="#" class="button">
<img src="./assets/icon-modify-white.svg" alt="" />
<span>Write</span>
</a>
</li>
<li>
<button class="button white">
<img src="./assets/icon-logout.svg" alt="" />
<span>Logout</span>
</button>
</li>
<li>
<a href="#" class="button gray">
<img src="./assets/icon-login.svg" alt="" />
<span>Login</span>
</a>
</li>
</div>
</header>
header {
background: var(--white-color);
}
header .max-width {
display: flex;
align-items: center;
justify-content: space-between;
gap: 4rem;
padding: 1rem 0;
}
header h1 {
font-size: 3rem;
}
header h1 a {
display: block;
padding: 0.4rem;
margin-left: -0.4rem;
}
header h1 a img {
display: block;
}
header ul {
display: flex;
align-items: center;
gap: 1rem;
}
.profile-img a {
width: 4.4rem;
height: 4.4rem;
display: block;
border-radius: 50%;
}
.profile-img img {
width: 100%;
height: 100%;
object-fit: cover;
}
header .button {
text-transform: none;
}
.button {
display: inline-flex;
align-items: center;
justify-content: center;
gap: 0.8rem;
height: 4rem;
padding: 0.2rem 1.2em 0;
border: 0;
border-radius: var(--border-radius);
background: var(--main-color);
color: var(--white-color);
text-transform: uppercase;
font-weight: bold;
line-height: 1;
}
.button img {
height: 1.2em;
margin-top: -0.2rem;
vertical-align: middle;
}
.button.gray {
background: var(--gray-background);
color: var(--black-color);
}
.button.white {
padding: 0.2rem 0.8em 0;
background: var(--white-color);
color: var(--black-color);
}
.button.white img {
height: 1.4em;
}
I'm trying to switch the HTML, CSS codes above to React Components with styled-components.
Developing into React components, I've had a Button component which is either a button or an a element and has the same className button
I have the similar issue with Styled Components - two different elements with the same styles and tried with the answer on it but didn't work so I posted a question.
Below is what I switched with the answer.
Header.jsx
import { BrowserRouter as Router, Switch, Route, Link } from 'react-router-dom';
import {
HeaderContainer,
MaxWidth,
H1,
NavMyBlog,
Ul,
ProfileImg,
} from './Header.element'
import {
Button,
BtnGrey,
BtnWhite,
} from '../Button/Button'
export default function Header() {
return (
<HeaderContainer>
<MaxWidth>
<H1>
<NavMyBlog to="./">
<img src={require("../../assets/Logo.svg").default} alt="My Blog" />
</NavMyBlog>
</H1>
<Ul>
{/* <!-- 로그인 --> */}
<ProfileImg>
<Link to="#">
<img src={require("../../assets/profile.jpg").default} alt="My Page" />
</Link>
</ProfileImg>
<li>
<Link to="#" className="button">
<img src={require("../../assets/icon-modify-white.svg").default} alt="" />
<span>Write</span>
</Link>
</li>
<li>
<BtnWhite className="button white">
<img src={require("../../assets/icon-logout.svg").default} alt="" />
<span>Logout</span>
</BtnWhite>
</li>
{/* <!-- //로그인 --> */}
{/* <!-- 로그아웃 --> */}
<li>
<BtnGrey to="#" className="button gray">
<img src={require("../../assets/icon-login.svg").default} alt="" />
<span>Login</span>
</BtnGrey>
</li>
<li class="only-pc">
<a href="#" className="button gray">
<img src={require("../../assets/icon-register.svg").default} alt="" />
<span>Register</span>
</a>
</li>
{/* <!--// 로그아웃 --> */}
</Ul>
</MaxWidth>
</HeaderContainer>
)
}
Header.element.jsx
import styled from 'styled-components'
import { Link } from 'react-router-dom';
export const HeaderContainer = styled.header`
background: var(--white-color);
&.button {
text-transform: none;
}
`
export const MaxWidth = styled.div`
display: flex;
align-items: center;
justify-content: space-between;
gap: 4rem;
padding: 1rem 0;
`
export const H1 = styled.h1`
font-size: 3rem;
`
export const NavMyBlog = styled(Link)`
display: block;
padding: 0.4rem;
margin-left: -0.4rem;
img{
display: block;
}
`
export const Ul = styled.ul`
display: flex;
align-items: center;
gap: 1rem;
`
export const ProfileImg = styled.li`
Link{
width: 4.4rem;
height: 4.4rem;
display: block;
border-radius: 50%;
}
img{
width: 100%;
height: 100%;
object-fit: cover;
}
`
Button.jsx
import styled, { css } from 'styled-components'
import { Link } from 'react-router-dom';
export const Button = css`
display: inline-flex;
align-items: center;
justify-content: center;
gap: 0.8rem;
height: 4rem;
padding: 0.2rem 1.2em 0;
border: 0;
border-radius: var(--border-radius);
background: var(--main-color);
color: var(--white-color);
text-transform: uppercase;
font-weight: bold;
line-height: 1;
img {
height: 1.2em;
margin-top: -0.2rem;
vertical-align: middle;
}
`
export const BtnGrey = styled(Link)`
background: var(--gray-background);
color: var(--black-color);
`
export const BtnWhite = styled.button`
${Button}
padding: 0.2rem 0.8em 0;
background: var(--white-color);
color: var(--black-color);
img {
height: 1.4em;
}
`

Hide header in mobile only

I'm making a header for my website, and I added this snippet
#media only screen and (max-width: 993px)
{ .site-header, .rightside, .site-identity, .nav, .leftside, .search, .search-container, .iconbar,
{display: none !important;}
}
to hide it on mobile, I've used it previously with different classes and it used to work, but now it doesn't seem to work with my current header. What am I doing wrong?
Header code:
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<script src="https://kit.fontawesome.com/706d8a1355.js" crossorigin="anonymous"></script>
<style>
body {
margin: 0;
}
a {
text-decoration: none;
color: #a1a1a1;
transition: all 0.2s ease;
}
a:hover {
color: #f8f8ff;
}
.site-header {
overflow: hidden;
background-color: #333;
width: 100vw;
display: flex;
align-items: center;
justify-content: space-between;
}
.site-identity {
float: left;
display: flex;
white-space: nowrap;
align-items: center;
}
.site-identity h1 {
font-size: 1.2em;
}
.site-identity img {
max-width: 50px;
float: left;
margin: 0.3em; /*LOGO*/
}
.nav {
display: flex;
margin-left: 3em;
white-space: nowrap;
font-weight: bold;
}
.nav a {
/* Leave 0 the first, the second is between them*/
padding: 0em 1em;
}
.search {
float: left;
border: none;
overflow: hidden;
border-radius: 20px;
background: #1B1B1B;
width: 60%;
padding: 0.5px 0.5px;
}
.search input[type="text"] {
border: 0px;
width: 67%;
background: none;
font-size: 14px;
}
.search input[type="text"]:focus {
outline: 0;
color: #f8f8ff;
}
.icon-bar {
display: flex;
margin-left: 0.5em;
margin-right: 0.5em;
}
.icon-bar a {
color: #a1a1a1;
font-size: 20px;
padding: 0em 0.2em;
}
.icon-bar a:hover {
color: #f8f8ff;
}
button[type=submit] {
overflow: hidden;
float: right;
cursor: pointer;
color: #a1a1a1;
background: none;
border: 1px solid transparent;
}
button[type=submit]:hover {
color: #f8f8ff;
}
.leftside {
display: flex;
justify-content: right;
align-items: center;
width:42%;
}
.rightside {
display: flex;
align-items: center;
}
/* Responsive layout - makes the three columns stack on top of each other instead of next to each other */
#media only screen and (max-width: 993px)
{ .site-header, .rightside, .site-identity, .nav, .leftside, .search, .search-container, .iconbar,
{display: none !important;}
}
</style>
<body>
<header class="site-header">
<div class="rightside">
<div class="site-identity">
<img src="http://via.placeholder.com/400" alt="title"/>
<h1>title</h1>
</div>
<div class="nav">
opt1
opt2
opt3
opt4
</div>
</div>
<div class="leftside">
<div class="search">
<div class="search-container">
<form action="/action_page.php">
<input type="text" placeholder="Search..." name="search">
<button type="submit"><i class="fa-solid fa-magnifying-glass"></i></button>
</form>
</div>
</div>
<div class="icon-bar">
<a class="active" href="mio-account"><i class="fa fa-user-circle"></i></a>
<i class="fa fa-heart"></i>
<i class="fa fa-bell"></i>
<i class="fa fa-shopping-cart"></i>
</div>
</div>
</header>
</body>

React Router Link in image extends beyond image?

The Link for my image extends beyond the image itself:
There is a blank space between the edge of the image and the next element, which is a Tabs from Material UI I called TradingTabs.
This is what my code looks like:
import { Link } from "react-router-dom";
...
<div className="header">
<div className="header-left">
<Link to="/">
<img
className="header-logo"
src={logo}
alt=""
/>
</Link>
<TradingTabs />
</div>
<div className="header-middle">
...
.header{
display: flex;
width: 100%;
align-items: center;
height: 60px;
justify-content: space-between;
position: sticky;
top: 0;
z-index: 100;
background-color: white;
border-bottom: 1px solid lightgray;
}
.header-left{
margin-left: 2%;
display: flex;
width: 500px;
align-items: center;
}
.header-logo{
width: 30%;
}
How can I fix it so the Link only wraps the actual size of the image?

How do I add a font aswesome's className or id in React

I tried to add an className in fontawesome and give a property(width,padding,fontsize, etc)in the sass but it didn't work what I expected.
Is there any syntax give a className or id in the fa react? It works when I give a div+className and using flexbox but you know this is pretty not a good way if we can use className or id. I will leave my code below!
!
or
didn't work...
This is my whole main.js file! I will leave my part of my code(my question part)
import React, { Component } from "react";
import "./Main.scss";
import "./Common.scss";
import { FontAwesomeIcon } from "#fortawesome/react-fontawesome";
import {
faHeart,
faComment,
faPaperPlane,
faBookmark,
faEllipsisH,
} from "#fortawesome/free-solid-svg-icons";
// import { FaRegComment } from "#fortawesome/free-solid-svg-icons";
// how to impport this faRegComment?
class Main extends Component {
render() {
return (
<>
<div class="main-wrapper">
<div class="nav">
<p class="logo"> Westagram </p>
<input
class="search-box"
type="text"
placeholder=" Search"
/>
{/* ,style="font-family:Arial, FontAwesome */}
<div class="icons">
<img
id="compass"
src="https://s3.ap-northeast-2.amazonaws.com/cdn.wecode.co.kr/bearu/explore.png"
/>
<img
id="heart"
src="https://s3.ap-northeast-2.amazonaws.com/cdn.wecode.co.kr/bearu/heart.png"
/>
<img
id="my-page"
src=" https://s3.ap-northeast-2.amazonaws.com/cdn.wecode.co.kr/bearu/profile.png"
/>
</div>
</div>
<div class="main">
<div class="feeds">
<div class="article">
<div class="identi">
<img class="selfi-identi" src="/images/about.png" />
<span class="name"> Jiwan Jeon </span>
{/* <i id="test" class="fa fa-ellipsis-h" aria-hidden="true"></i> */}
<div class="faEllipsisH">
<FontAwesomeIcon icon={faEllipsisH}></FontAwesomeIcon>
</div>
</div>
<div class="pic">
<img id="feed-pic" src="/images/ucscPic.png" />
</div>
<div class="show-box">
<div class="reaction-icons">
<FontAwesomeIcon icon={faHeart}></FontAwesomeIcon>
<FontAwesomeIcon icon={faComment}></FontAwesomeIcon>
<FontAwesomeIcon icon={faPaperPlane}></FontAwesomeIcon>
<FontAwesomeIcon icon={faBookmark}></FontAwesomeIcon>
</div>
<div class="like-counts">
<span>like 4,000</span>
</div>
<div class="check-comments">
<span>
UC Santa Cruz will continue to offer most courses remotely
or online for spring and summer 2021, providing in-person
instruction for a small
</span>
<a id="space" href="">
expanding
</a>
<br />
Check the all comments
<ul class="feed-comments">
<li>test</li>
</ul>
</div>
</div>
<div class="comment">
<i class="fa fa-smile-o"></i>
<input
class="user-input"
type="text"
placeholder="Add Comment..."
/>
<button class="post">Post</button>
</div>
</div>
</div>
</div>
<div class="main-right">
<div class="top">
<img class="selfi" src="/images/about.png" />
<div class="main-right-name">
<span id="eng-name">JiwanJeon94</span>
<br />
<span id="kr-name">전지완</span>
</div>
Transform
</div>
<div class="middle">
<div class="middle-words">
<span id="recommendation">Suggestions For You</span>
<a href="" id="view-all">
view all
</a>
</div>
<div class="recommendation-people">
<div id="recommendation-section1">
<img
id="recommendation-people-selfi"
src="/images/about.png"
/>
<span>Recommendation for you</span>
Follow
</div>
<div id="recommendation-section1">
<img
id="recommendation-people-selfi"
src="/images/about.png"
/>
<span>Recommendation for you</span>
Follow
</div>
<div id="recommendation-section1">
<img
id="recommendation-people-selfi"
src="/images/about.png"
/>
<span>Recommendation for you</span>
Follow
</div>
<div id="recommendation-section1">
<img
id="recommendation-people-selfi"
src="/images/about.png"
/>
<span>Recommendation for you</span>
Follow
</div>
<div id="recommendation-section1">
<img
id="recommendation-people-selfi"
src="/images/about.png"
/>
<span>Recommendation for you</span>
Follow
</div>
</div>
</div>
<div class="footer">
<div class="footer-top">
About
Help
press
API
Jobs
Privacy
Terms
Locations
TopAccounts
Hashtags
Language
<br />
<br />
</div>
<span>2021 INSTAGRAM FROM FACEBOOK</span>
</div>
</div>
</div>
</>
);
}
}
export default Main;
This is my fa icons part
<div class="show-box">
<div class="reaction-icons">
<FontAwesomeIcon icon={faHeart}></FontAwesomeIcon>
<FontAwesomeIcon icon={faComment}></FontAwesomeIcon>
<FontAwesomeIcon icon={faPaperPlane}></FontAwesomeIcon>
<FontAwesomeIcon icon={faBookmark}></FontAwesomeIcon>
</div>
I Will leave sass file just in case
#font-face {
font-family: instagramFont;
src: url("./westagram.ttf") format("opentype");
}
#mixin icon-size() {
width: 30px;
height: 30px;
}
#root {
height: 100vh;
.main-wrapper {
margin: 10px 10px 10px 10px;
height: 100%;
.nav {
position: fixed;
display: flex;
flex-direction: row;
justify-content: space-around;
width: 100%;
padding-top: 20px;
padding-bottom: 10px;
border-bottom: solid 1px #dbdbdb;
z-index: 9999;
.logo {
font-family: instagramFont;
padding-right: 100px;
font-size: 2rem;
}
.search-box {
margin-top: 5px;
width: 250px;
// main css파일이랑 똑같이 세팅 했는데 개발자툴이랑 왜 다른지 -해결-
height: 28px;
}
.icons {
margin-left: 100px;
#compass {
#include icon-size();
//30*30 으로 세팅했는데 개발자툴에서는 왜 53*53인지
}
#heart {
#include icon-size();
}
#my-page {
#include icon-size();
}
}
}
.main {
position: relative;
top: 70px;
left: 8px;
width: 100%;
height: 100%;
.feeds {
position: relative;
top: 40px;
right: 5px;
left: 61px;
width: 60%;
.article {
position: absolute;
display: flex;
flex-direction: column;
width: 614px;
height: 954px;
padding-bottom: 10px;
.identi {
position: relative;
display: flex;
flex-direction: row;
align-items: flex-start;
height: 50px;
.selfi-identi {
width: 30px;
height: 30px;
// padding: 15px 20px 20px 20px;
border-radius: 50%;
}
.name {
margin-top: 10px;
margin-left: 5px;
}
#test {
padding-top: 23px;
padding-left: 410px;
}
.faEllipsisH {
padding-top: 10px;
padding-left: 40px;
// padding-bottom: 20px;
}
}
.pic {
#feed-pic {
position: relative;
padding: 3px 3px 3px 3px;
width: 614px;
height: 614px;
padding: 5px 0px 2px 0px;
}
}
.show-box {
position: relative;
display: flex;
flex-direction: column;
justify-content: space-between;
height: 170px;
padding: 5px 0px 20px 0px;
.reation-icons {
#heartShowBox {
padding-left: 10px;
font-size: 30px;
width: 30px;
}
.fa-comment-o {
padding-left: 10px;
padding-right: 5px;
}
.fa-send-o {
padding-left: 10px;
font-size: 30px;
}
.fa-bookmark-o {
padding-left: 450px;
font-size: 30px;
}
}
.like-counts {
margin-top: 10px;
padding-top: 20px;
}
.check-comments {
.space {
padding-top: 400px;
}
}
}
.comment {
position: relative;
// margin-top: 75px;x
.fa-smile-o {
font-size: 30px;
}
.user-input {
width: 530px;
height: 20px;
}
.post {
height: 25px;
border: solid 1px #d3d3d3;
border-radius: 5px;
background-color: #b2dffc;
font-size: 15px;
cursor: pointer;
}
}
}
}
}
.main-right {
position: fixed;
width: 28%;
height: 98%;
top: 11.9%;
right: 4%;
.top {
position: relative;
display: flex;
flex-direction: row;
padding-bottom: 3px;
.selfi {
width: 50px;
height: 50px;
padding: 15px 20px 20px 20px;
border-radius: 50%;
}
.main-right-name {
position: relative;
padding-top: 25px;
#kr-name {
opacity: 0.3;
}
}
a {
margin-left: 40px;
margin-top: 20px;
}
}
.middle {
height: 30%;
padding-bottom: 100px;
.middle-words {
padding-bottom: 25px;
#recommendation {
margin-left: 23px;
}
#view-all {
margin-left: 70px;
}
}
.recommendation-people {
display: flex;
flex-direction: column;
#recommendation-section1 {
#recommendation-people-selfi {
width: 30px;
height: 30px;
margin-top: 13px;
padding: 5px 5px 5px 5px;
border-radius: 50%;
}
span {
position: relative;
right: 5px;
top: -18px;
}
a {
position: absolute;
right: 3px;
font-size: 14px;
}
}
}
}
.footer {
margin-left: 10px;
.footer-top {
.a {
margin: 0px 0px 0px 5px;
opacity: 0.3;
}
}
}
span {
margin-left: 5px;
opacity: 0.3;
}
}
}
}
For the first, replace all class with className.
className work fine with FontAwesomeIcon:
<FontAwesomeIcon icon={faHeart} className="awesome-custom"></FontAwesomeIcon>;
Chech this example: https://codesandbox.io/s/cold-frost-bv362?file=/src/App.js

Resources