-
Notifications
You must be signed in to change notification settings - Fork 74
Mini-Challenge 1: Core Concepts and Styling #30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,158 @@ | ||
| import React from 'react'; | ||
| import styled from 'styled-components'; | ||
| import {MdMenu, MdSearch, MdPersonOutline} from 'react-icons/md'; | ||
|
|
||
| const ContainerHeader = styled.header` | ||
| display: flex; | ||
| align-items: center; | ||
| position: fixed; | ||
| top:0; | ||
| width: 100%; | ||
| height: 65px; | ||
| background-color: #ACDEDF; | ||
|
|
||
| `; | ||
|
|
||
| const MenuButton = styled.button` | ||
| display: flex; | ||
| align-items: center; | ||
| justify-content: center; | ||
| width: 55px; | ||
| height: 55px; | ||
| padding: 10px; | ||
| background-color: transparent; | ||
| border:none; | ||
| font-size: 1.3rem; | ||
| `; | ||
|
|
||
| const InputSearch = styled.input` | ||
| align-items: center; | ||
| padding: 10px; | ||
| background-color: transparent; | ||
| box-sizing: content-box; | ||
| padding: 10px; | ||
| box-sizing: content-box; | ||
| border: 1px solid #bbc1bf; | ||
| font-size: 1.3rem; | ||
| background: #0000; | ||
| border-radius: 3px; | ||
| height: 1rem; | ||
| font-size: 1rem; | ||
| padding-left: 30px; | ||
| `; | ||
|
|
||
| const DivSearch = styled.div` | ||
| cursor: text; | ||
| display: inline-flex; | ||
| position: relative; | ||
| font-size: 1rem; | ||
| align-items: center; | ||
| height: 100%; | ||
| justify-content: center; | ||
| `; | ||
|
|
||
| const DivIcon = styled.div` | ||
| justify-content: center; | ||
| color: #fff; | ||
| position: relative; | ||
| left: 30px; | ||
| height: 100%; | ||
| align-items: center; | ||
| display: flex; | ||
| font-size: 1.3rem; | ||
| `; | ||
|
|
||
|
|
||
| const DivFlex = styled.div` | ||
| flex-grow: 1; | ||
| `; | ||
|
|
||
| const ToggleSwitch = styled.label` | ||
| position: relative; | ||
| display: inline-block; | ||
| width: 60px; | ||
| height: 30px; | ||
| `; | ||
|
|
||
| const Slider = styled.span` | ||
| position: absolute; | ||
| cursor: pointer; | ||
| border-radius: 30px; | ||
| top: 0; | ||
| left: 0; | ||
| right: 0; | ||
| bottom: 0; | ||
| background-color: #ccc; | ||
| -webkit-transition: .4s; | ||
| transition: .4s; | ||
| &::before { | ||
| position: absolute; | ||
| content: ""; | ||
| height: 24px; | ||
| width: 24px; | ||
| left: 4px; | ||
| bottom: 4px; | ||
| background-color: white; | ||
| -webkit-transition: .4s; | ||
| transition: .4s; | ||
| border-radius: 50%; | ||
| } | ||
| `; | ||
|
|
||
| const CheckboxSwitch = styled.input` | ||
| background-color: #b39541; | ||
| opacity: 0; | ||
| width: 0px; | ||
| height: 0px; | ||
| &:checked + ${Slider} { | ||
| background: #b39541; | ||
| &::before { | ||
| transform: translateX(24px); | ||
| } | ||
| } | ||
| `; | ||
| const Span = styled.span` | ||
| color: #b39541; | ||
| font-size: 0.8rem; | ||
| padding: 10px; | ||
| `; | ||
|
|
||
| const Avatar = styled.div` | ||
| background-color: #b39541; | ||
| border-radius: 999999px; | ||
| margin: 1%; | ||
| height: 45px; | ||
| width: 45px; | ||
| opacity: 0.5; | ||
| color: #fff; | ||
| display: inline-flex; | ||
| font-size: 1.6rem; | ||
| align-items: center; | ||
| justify-content: center; | ||
| `; | ||
|
Comment on lines
+66
to
+132
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The same CSS extraction comment here |
||
|
|
||
|
|
||
| function Header() { | ||
|
|
||
| return ( | ||
|
|
||
| <ContainerHeader> | ||
| <MenuButton><MdMenu/></MenuButton> | ||
| <DivSearch> | ||
| <DivIcon><MdSearch/></DivIcon> | ||
| <InputSearch placeholder="Search"/> | ||
| </DivSearch> | ||
| <DivFlex/> | ||
| <Span>Dark mode</Span> | ||
| <ToggleSwitch> | ||
| <CheckboxSwitch type="checkbox" /> | ||
| <Slider/> | ||
| </ToggleSwitch> | ||
| <Avatar> | ||
| <MdPersonOutline/> | ||
| </Avatar> | ||
| </ContainerHeader> | ||
| ) | ||
| } | ||
|
|
||
| export default Header; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| import React from 'react'; | ||
| import styled from 'styled-components'; | ||
|
|
||
| const Container = styled.div` | ||
| width: 323px; | ||
| height: 400px; | ||
| margin: 10px; | ||
| max-width: 100%; | ||
| display: inline-grid; | ||
| overflow: hidden; | ||
| border: 1px solid #eee; | ||
| max-width: 100%; | ||
| padding: 10px; | ||
| `; | ||
|
|
||
| const Description = styled.span` | ||
| font-size: .8rem; | ||
| line-height: 1.2rem; | ||
| display: inline-block; | ||
| `; | ||
|
|
||
| const ContainerImg = styled.div` | ||
| text-align:center; | ||
| height: 180px; | ||
| overflow: hidden; | ||
| `; | ||
|
|
||
| const Image = styled.img` | ||
| max-width:100%; | ||
| height: 100%; | ||
| `; | ||
|
|
||
| const Title = styled.h3` | ||
| font-size: 1rem; | ||
| line-height: 1.2rem; | ||
| display: inline-block; | ||
| `; | ||
|
Comment on lines
+4
to
+37
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same CSS extraction comment here |
||
|
|
||
| function VideoCard (data) { | ||
| return ( | ||
| <Container> | ||
| <ContainerImg> | ||
| <Image alt={data.title} src={data.img} /> | ||
| </ContainerImg> | ||
| <Title data-testid="video-title">{data.title}</Title> | ||
| <Description data-testid="video-description">{data.description}</Description> | ||
|
|
||
| </Container> | ||
| ); | ||
|
|
||
| } | ||
|
|
||
| export default VideoCard; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| import React from 'react'; | ||
| import styled from 'styled-components'; | ||
|
|
||
| import {mockVideosData} from '../../mock/youtube-videos-mock'; | ||
| import VideoCard from './VideoCard.component' | ||
|
|
||
|
|
||
|
|
||
| const ContainerVideos = styled.div` | ||
| max-width: 100%; | ||
| margin: 0 5%; | ||
| `; | ||
|
Comment on lines
+9
to
+12
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same CSS extraction comment here |
||
|
|
||
| function VideoCards () { | ||
|
|
||
| return ( | ||
| <ContainerVideos> | ||
| {mockVideosData.items | ||
| .filter((a) => (a.id.kind === "youtube#video")) | ||
| .map((data) => { | ||
| return ( | ||
| <VideoCard | ||
| key={data.id.videoId} | ||
| title={data.snippet.title} | ||
| description={data.snippet.description} | ||
| img={data.snippet.thumbnails.medium.url} | ||
| /> | ||
| ); | ||
| }) | ||
| } | ||
| </ContainerVideos> | ||
| ); | ||
| } | ||
|
|
||
| export default VideoCards; | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please extract all the styles into different files depending of the component. You have various components mixed on the same file. I would create i.e. a file called
SearchBar.styled.js, inside the file I inserted all the related styles for the SearchBar, export all the styles, and in another fileSearchBar.component.jsxuse them.You have all the components in the Header component. React's good practice is to create small components, so you could reuse them in different places of your app, if you keep them in the same it is difficult to keep track where the component is defined and how to reuse it.