https://github.com/prettier/eslint-config-prettier
https://github.com/jsx-eslint/eslint-plugin-react
https://github.com/facebook/react/tree/main/packages/eslint-plugin-react-hooks
{ | |
"extends": [ | |
"eslint:recommended", | |
"plugin:react/recommended", | |
"plugin:react/jsx-runtime", | |
"prettier" | |
], | |
"plugins": ["react-hooks"], | |
"env": { | |
"browser": true | |
}, | |
"parserOptions": { | |
"ecmaVersion": 2021, | |
"ecmaFeatures": { | |
"jsx": true | |
}, | |
"sourceType": "module" | |
}, | |
"settings": { | |
"react": { | |
"version": "detect" | |
} | |
}, | |
"rules": { | |
"react/prop-types": "off", | |
"react-hooks/rules-of-hooks": "error", | |
"react-hooks/exhaustive-deps": "warn" | |
} | |
} |
{ | |
"trailingComma": "es5", | |
"tabWidth": 2, | |
"semi": true, | |
"singleQuote": true, | |
"arrowParens": "avoid" | |
} |
Create react app documentation - https://create-react-app.dev/
React router - https://reactrouter.com/en/main
TV Maze API - https://www.tvmaze.com/api
React Query - https://tanstack.com/query/v4/docs/overview
Styled Components - https://styled-components.com/
VSCode Styled Component syntax highlight - https://marketplace.visualstudio.com/items?itemName=styled-components.vscode-styled-components
Favicon generator - https://favicon.io/favicon-converter/
<link
href="https://fonts.googleapis.com/css?family=Roboto:300,400,700,&display=swap"
rel="stylesheet"
/>
<title>Box Office</title>
const theme = {
fontFamily: 'Roboto, sans-serif',
mainColors: {
blue: '#2400ff',
gray: '#c6c6c6',
dark: '#353535',
},
};
const GlobalStyles = createGlobalStyle`
body {
font-family: ${({ theme }) => theme.fontFamily};
font-size: 18px;
margin: 0;
padding-top: 40px;
padding-left: 15px;
padding-right: 15px;
}
`;
const NavList = styled.ul`
display: flex;
justify-content: center;
list-style: none;
margin: 0 0 30px;
padding: 0;
li {
margin: 0 10px;
}
`;
const LinkStyled = styled(NavLink)`
display: block;
padding: 3px 15px;
position: relative;
text-decoration: none;
color: ${({ theme }) => theme.mainColors.gray};
&.active {
color: ${({ theme }) => theme.mainColors.blue};
&:after {
content: '';
position: absolute;
display: block;
height: 2px;
left: 0%;
bottom: 0;
background-color: ${({ theme }) => theme.mainColors.blue};
animation: slide-in 0.3s ease-in forwards;
@keyframes slide-in {
from {
left: 50%;
width: 0;
}
to {
left: 0%;
width: 100%;
}
}
}
}
`;
const StyledRadio = styled.label`
display: block;
position: relative;
padding-left: 25px;
cursor: pointer;
font-size: 13px;
user-select: none;
font-weight: 700;
line-height: 1.65;
input {
position: absolute;
opacity: 0;
cursor: pointer;
}
span {
position: absolute;
top: 0;
left: 0;
height: 16px;
width: 16px;
background-color: #fff;
border: 2px solid ${({ theme }) => theme.mainColors.blue};
border-radius: 50%;
}
input:checked ~ span {
background-color: #fff;
border: 2px solid ${({ theme }) => theme.mainColors.blue};
}
span:after {
content: '';
position: absolute;
display: none;
}
input:checked ~ span:after {
display: block;
}
span:after {
top: 4px;
left: 4px;
width: 8px;
height: 8px;
border-radius: 50%;
background: ${({ theme }) => theme.mainColors.blue};
}
`;
const TitleWrapper = styled.div`
text-align: center;
margin: 0 0 40px;
h1 {
color: ${({ theme }) => theme.mainColors.blue};
letter-spacing: 10px;
text-transform: uppercase;
margin: 0 0 10px;
}
p {
color: ${({ theme }) => theme.mainColors.dark};
margin: 0;
}
`;
const SearchInput = styled.input`
display: block;
font-family: 'Roboto', sans-serif;
width: 200px;
margin: auto;
outline: none;
padding: 13px 15px;
border: 1px solid #dbdbdb;
box-shadow: 0px 0px 10px 0px rgba(219, 219, 219, 0.5);
font-size: 14px;
border-radius: 12px;
color: #8d8d8d;
&::placeholder {
font-weight: 300;
color: #8d8d8d;
}
`;
export const RadiosWrapper = styled.div`
display: flex;
justify-content: center;
margin: 20px 0;
label {
margin: 0 15px;
}
`;
const SearchButtonWrapper = styled.div`
text-align: center;
margin-bottom: 35px;
button {
color: #fff;
background-color: ${({ theme }) => theme.mainColors.blue};
margin: auto;
padding: 10px 50px;
font-size: 15px;
border: none;
outline: none;
border-radius: 12px;
&:hover {
cursor: pointer;
}
}
`;
import styled from 'styled-components';
export const FlexGrid = styled.div`
display: flex;
justify-content: center;
flex-wrap: wrap;
`;
import styled from 'styled-components';
export const SearchImgWrapper = styled.div`
width: 100%;
height: 420px;
border-radius: 40px;
overflow: hidden;
border: 1px solid #ddd;
img {
object-fit: cover;
height: 100%;
width: 100%;
}
`;
export const SearchCard = styled.div`
width: 300px;
height: 100%;
margin: 0 15px 40px;
h1 {
margin: 10px 0;
font-size: 21px;
}
p {
margin-top: 0;
margin-bottom: 5px;
}
`;
import styled from 'styled-components';
export const StarIcon = styled.div`
display: inline-block;
width: 18px;
height: 18px;
background-color: ${props => (props.active ? '#ffc806' : '#ddd')};
clip-path: polygon(
50% 0%,
61% 35%,
98% 35%,
68% 57%,
79% 91%,
50% 70%,
21% 91%,
32% 57%,
2% 35%,
39% 35%
);
`;
import styled from 'styled-components';
export const TextCenter = styled.div`
text-align: center;
`;
const BackHomeWrapper = styled.div`
margin-bottom: 30px;
text-align: left;
a {
padding: 10px;
color: ${({ theme }) => theme.mainColors.dark};
text-decoration: none;
&:hover {
text-decoration: underline;
}
}
`;
const ShowPageWrapper = styled.div`
margin: auto;
@media only screen and (min-width: 768px) {
max-width: 700px;
}
@media only screen and (min-width: 992px) {
max-width: 900px;
}
`;
const InfoBlock = styled.div`
margin-bottom: 40px;
h2 {
margin: 0;
margin-bottom: 30px;
font-size: 22px;
}
`;
const CastList = styled.div`
display: flex;
flex-wrap: wrap;
.cast-item {
flex: 1 0 50%;
display: flex;
margin-bottom: 20px;
align-items: center;
@media only screen and (max-width: 768px) {
flex: 1 0 100%;
}
}
.pic-wrapper {
width: 50px;
min-width: 50px;
height: 50px;
overflow: hidden;
border-radius: 50%;
img {
object-fit: cover;
width: 100%;
height: 100%;
}
}
.actor {
margin-left: 25px;
}
`;
const DetailsWrapper = styled.div`
p {
margin: 5px 0;
}
`;
const SeasonsWrapper = styled.div`
p {
margin: 5px 0;
}
`;
const SeasonList = styled.div`
display: flex;
flex-direction: column;
.season-item {
display: flex;
align-items: center;
margin: 10px 0;
&:last-child {
margin-bottom: 0;
}
.left {
flex: 0 0 30%;
border-right: 1px solid #b0b0b0;
padding-right: 20px;
}
.right {
padding-left: 20px;
flex: 1;
}
}
`;
const ActionSection = styled.div`
margin-top: 15px;
display: flex;
justify-content: space-between;
align-items: center;
a {
text-decoration-color: #000;
color: #000;
&:hover {
text-decoration-color: blue;
color: blue;
}
}
`;
const StarBtn = styled.button`
outline: none;
border: 1px solid #8e8e8e;
border-radius: 15px;
padding: 5px 20px;
background-color: #fff;
display: flex;
justify-content: center;
align-items: center;
&:hover {
cursor: pointer;
}
`;
const MainDataWrapper = styled.div`
display: flex;
margin-bottom: 40px;
.img-wrap {
width: 275px;
max-width: 100%;
margin: 0 auto;
img {
width: 100%;
height: auto;
border: 1px solid #ddd;
border-radius: 40px;
}
}
@media only screen and (max-width: 768px) {
flex-direction: column;
img {
margin-bottom: 20px;
margin: auto;
}
}
`;
const DataSection = styled.div`
margin-left: 20px;
flex: 1;
@media only screen and (max-width: 768px) {
margin-left: 0;
margin-top: 20px;
}
`;
const Headline = styled.div`
display: flex;
align-items: center;
flex-wrap: wrap;
h1 {
margin: 0;
border-right: 1px solid #ddd;
padding-right: 25px;
margin-right: 20px;
}
div {
display: flex;
align-items: center;
span {
margin-left: 10px;
}
}
`;
const Summary = styled.div`
color: #5f5f5f;
line-height: 1.5;
`;
const Genres = styled.div`
display: inline-flex;
flex-wrap: wrap;
span {
margin: 6px;
margin-bottom: 0;
color: blue;
background-color: #d0c9ff;
padding: 3px 13px;
border-radius: 20px;
font-size: 14px;
}
`;
export const FlexGrid = styled.div`
display: flex;
justify-content: center;
flex-wrap: wrap;
animation: fadein 0.3s ease-in forwards;
@keyframes fadein {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
`;
const StarBtn = styled.button`
outline: none;
border: 1px solid #8e8e8e;
border-radius: 15px;
padding: 5px 20px;
background-color: #fff;
display: flex;
justify-content: center;
align-items: center;
&:hover {
cursor: pointer;
}
&.animate {
${StarIcon} {
animation: increase 0.75s ease-in forwards;
@keyframes increase {
0% {
transform: scale(1);
}
50% {
transform: scale(3) rotate(45deg);
}
100% {
transform: scale(1);
}
}
}
}
`;
Transform HTML string into a short string without HTML tags:
summary.split(' ').slice(0, 10).join(' ').replace(/<.+?>/g, '');
Example:
const htmlString =
"<p>Don't ever tell a 75-year-old to go quietly into the night. <b>Hey Lady!</b> is about a wiry old gal with a whiskey voice and a bourbon appetite, who refuses to let herself be put out to pasture.</p>";
const result = htmlString
.split(' ')
.slice(0, 10)
.join(' ')
.replace(/<.+?>/g, '');
// "Don't ever tell a 75-year-old to go quietly into the"