reza added BooToggle

master
Reza_ashrafi 3 years ago
parent fa766b123d
commit 8c8d936dc2
  1. 69
      src/components/BookToggle/index.scss
  2. 36
      src/components/BookToggle/index.tsx
  3. 24
      src/components/ThemeSwitch/index.scss
  4. 1
      src/custom.scss
  5. 21
      src/util/scroll.js
  6. 78
      src/views/Home/Books/Book/index.tsx
  7. 59
      src/views/Home/Books/index.tsx
  8. 101
      src/views/Home/Courses/Course/index.tsx
  9. 54
      src/views/Home/Courses/index.tsx
  10. 1
      src/views/Home/Header/index.scss
  11. 19
      src/views/Home/Header/index.tsx
  12. 1
      src/views/Home/index.tsx

@ -0,0 +1,69 @@
.book-toggle {
width: calc(100% - 60px);
background-color: transparent;
height: calc(100vh / 1.8);
&__info {
width: calc(100% / 2.5);
}
img {
height: 90%;
border-radius: 8px;
}
p {
margin-top: 20px;
}
a {
transition: all 0.3s;
width: fit-content;
border-radius: 4px;
padding: 10px 35px;
align-self: end;
margin-top: 60px;
border: 1px solid white;
color: white;
&:hover{
border-color: $green;
color: $green;
}
}
&-light {
strong,
p {
color: $gray5;
}
}
&-dark {
strong,
p {
color: $gray12;
}
}
}
@media screen and (min-width: 1441px) {
.book-toggle {
strong {
font-size: 21px;
}
p {
font-size: 14px;
}
a {
font-size: 16px;
}
}
}
@media screen and (min-width: 1008px) and (max-width: 1440px) {
.book-toggle {
strong {
font-size: calc(100vw / 70);
}
p {
font-size: calc(100vw / 100);
}
a {
font-size: calc(100vw / 80);
}
}
}

@ -0,0 +1,36 @@
import React from "react";
import {Link} from 'react-router-dom';
import _ from "lodash";
import { connect } from "react-redux";
function BookToggle({ book, theme }: any) {
return (
<div
className={_.join(
[
"book-toggle desktop justify-content-between align-items-center mx-auto px-2",
theme === "light" ? "book-toggle-light" : "book-toggle-dark",
],
" "
)}
>
<div className="book-toggle__info d-flex flex-column">
<strong>{book.name}</strong>
<p>
روز بلوا ۱۲+۱۳۹۸۸۹٪ عماد که یک روحانی خوشنام و چهره تلویزیونی مورد
توجه است، ناگهان با اتهامهایی جدی مواجه میشود که خود و خانواده اش را
در موقعیت پیچیدهای قرار میدهد و...
</p>
<Link to={'/courses/' + book.id}>ادامه</Link>
</div>
<img src={`https://dnvn.ir/api/v1/file/${book.fileIds}`} alt="" />
</div>
);
}
export default connect(
(state: any) => ({
theme: state.publicApi.theme,
}),
{}
)(BookToggle);

@ -83,8 +83,8 @@
} }
.toggle--label { .toggle--label {
/** Placeholder element, starting at blue **/ /** Placeholder element, starting at blue **/
width: 70px; width: 65px;
height: 35px; height: 30px;
margin-right: 60px; margin-right: 60px;
background: var(--blue-color); background: var(--blue-color);
border-radius: 100px; border-radius: 100px;
@ -135,8 +135,8 @@
animation-fill-mode: forwards; animation-fill-mode: forwards;
transition: all 350ms ease-in; transition: all 350ms ease-in;
content: ""; content: "";
width: 25px; width: 20px;
height: 25px; height: 20px;
border: 5px solid var(--yellow-border); border: 5px solid var(--yellow-border);
top: 1px; top: 1px;
left: 0px; left: 0px;
@ -165,23 +165,23 @@
} }
60% { 60% {
left: 0px; left: 0px;
width: 62px; width: 55px;
} }
100% { 100% {
left: 33px; left: 35px;
width: 25px; width: 20px;
} }
} }
@keyframes reverse { @keyframes reverse {
0% { 0% {
left: 33px; left: 30px;
width: 38px; width: 20px;
} }
60% { 60% {
left: 2px; left: 1px;
width: 62px; width: 55px;
} }
100% { 100% {
left: 2px; left: 1px;
} }
} }

@ -1,5 +1,6 @@
@import "./constants/colors.scss"; @import "./constants/colors.scss";
@import "./constants/width.scss"; @import "./constants/width.scss";
@import "./components/BookToggle/index.scss";
@import "./components/BreadCrumbs/index.scss"; @import "./components/BreadCrumbs/index.scss";
@import "./components/GradeFilter/index.scss"; @import "./components/GradeFilter/index.scss";
@import "./components/HomeSearchBox/index.scss"; @import "./components/HomeSearchBox/index.scss";

@ -2,11 +2,22 @@ import { toast } from "react-toastify";
class scroll { class scroll {
goToTop = () => { goToTop = () => {
window.scrollTo(0,0); window.scrollTo(0, 0);
} };
listScroll = () => { bookScroll = (option) => {
const height = window.innerHeight;
} const bookToggle1 = localStorage.getItem('bookToggle1');
if (option === 1) {
localStorage.setItem('bookToggle1', 1);
window.scrollTo(0, 1.1 * height);
} else if (option === 2) {
if(bookToggle1) {
window.scrollTo(0, 2.3 * height);
}else{
window.scrollTo(0, 1.8 * height);
}
}
};
} }
const _scroll = new scroll(); const _scroll = new scroll();

@ -3,8 +3,7 @@ import { Link } from "react-router-dom";
import { connect } from "react-redux"; import { connect } from "react-redux";
import _ from "lodash"; import _ from "lodash";
function Book(props: any) { function Book({ data, theme, setActiveBook }: any) {
const { data, theme } = props;
const desc: any = { const desc: any = {
ریاضی: "ریاضی از ریاضت میاد ولی دانوین آسون و لذت بخشش کرده", ریاضی: "ریاضی از ریاضت میاد ولی دانوین آسون و لذت بخشش کرده",
"علوم تجربی": "علوم تجربی تو دانوین واقعا تجربی و محسوس میشه", "علوم تجربی": "علوم تجربی تو دانوین واقعا تجربی و محسوس میشه",
@ -13,31 +12,58 @@ function Book(props: any) {
فیزیک: "با دانوین فیزیکو با یه لنز جدید ببنید", فیزیک: "با دانوین فیزیکو با یه لنز جدید ببنید",
}; };
return ( return (
<Link <>
to={`/courses/${data.id}`} <div
className={_.join( className={_.join(
[ [
"home-books-book d-flex flex-column", "home-books-book desktop flex-column",
theme === "light" theme === "light"
? "home-books-book-light" ? "home-books-book-light"
: "home-books-book-dark", : "home-books-book-dark",
], ],
" " " "
)} )}
draggable={"false"} onClick={() => setActiveBook(data)}
>
<img
src={`https://dnvn.ir/api/v1/file/${data.fileIds}`}
alt={data.name}
draggable={"false"} draggable={"false"}
/> >
<footer className="d-flex"> <img
<div className="home-books-book__info d-flex flex-column"> src={`https://dnvn.ir/api/v1/file/${data.fileIds}`}
<h2>{data.name}</h2> alt={data.name}
<p>{desc[data.name] || ""}</p> draggable={"false"}
</div> />
</footer> <footer className="d-flex">
</Link> <div className="home-books-book__info d-flex flex-column">
<h2>{data.name}</h2>
<p>{desc[data.name] || ""}</p>
</div>
</footer>
</div>
<Link
to={"/courses/" + data.id}
className={_.join(
[
"home-books-book mobile flex-column",
theme === "light"
? "home-books-book-light"
: "home-books-book-dark",
],
" "
)}
draggable={"false"}
>
<img
src={`https://dnvn.ir/api/v1/file/${data.fileIds}`}
alt={data.name}
draggable={"false"}
/>
<footer className="d-flex">
<div className="home-books-book__info d-flex flex-column">
<h2>{data.name}</h2>
<p>{desc[data.name] || ""}</p>
</div>
</footer>
</Link>
</>
); );
} }

@ -1,10 +1,12 @@
import React, { useEffect } from "react"; import React, { useState } from "react";
import { useSelector, connect } from "react-redux"; import { connect } from "react-redux";
import Carousel from "react-elastic-carousel"; import Carousel from "react-elastic-carousel";
import Book from "./Book/index"; import Book from "./Book/index";
import { book } from "../../../redux/actions"; import BookToggle from "../../../components/BookToggle";
import scroll from "../../../util/scroll";
function Books({list, number}: any) { function Books({ list, number }: any) {
const [activeBook, setActiveBook] = useState(null);
const slideNumberHandler = () => { const slideNumberHandler = () => {
if (window.innerWidth >= 1440) { if (window.innerWidth >= 1440) {
return 5; return 5;
@ -17,36 +19,31 @@ function Books({list, number}: any) {
} }
}; };
return ( return (
<section <section className="home-books d-flex flex-column">
className="home-books d-flex flex-column" <div className="desktop flex-column" onClick={() => scroll.bookScroll(2)}>
> <div className="position-relative">
{window.innerWidth > 1007 ? ( <Carousel
<Carousel itemsToShow={slideNumberHandler()}
itemsToShow={slideNumberHandler()} isRTL={true}
isRTL={true} enableTilt={false}
enableTilt={false} showArrows={true}
showArrows={true} pagination={false}
pagination={false} >
> {list?.map((item: Object, i: any) => (
{list?.map((item: Object, i: any) => ( <Book data={item} key={i} setActiveBook={setActiveBook} />
<Book data={item} key={i} /> ))}
))} </Carousel>
</Carousel>
) : (
<div className="home-books__list d-flex">
{list?.map((item: Object, i: any) => (
<Book data={item} key={i} />
))}
</div> </div>
)} {activeBook && <BookToggle book={activeBook} />}
</div>
<div className="home-books__list mobile">
{list?.map((item: Object, i: any) => (
<Book data={item} key={i} />
))}
</div>
</section> </section>
); );
} }
export default connect( export default connect((state: any) => ({}), {})(Books);
( state : any) => ({
}),
{ }
)(Books);

@ -4,55 +4,66 @@ import { Link } from "react-router-dom";
import { connect } from "react-redux"; import { connect } from "react-redux";
import _ from "lodash"; import _ from "lodash";
function Course(props: any) { function Course({ data, theme, setActiveBook }: any) {
const { data, theme } = props;
return ( return (
<Link <>
to={`/courses/${data.id}`} <div
className={_.join( className={_.join(
[ [
"home-courses-course d-flex flex-column", "home-courses-course desktop flex-column",
theme === "light" theme === "light"
? "home-courses-course-light" ? "home-courses-course-light"
: "home-courses-course-dark", : "home-courses-course-dark",
], ],
" " " "
)} )}
draggable={"false"} onClick={() => setActiveBook(data)}
>
<img
src={`https://dnvn.ir/api/v1/file/${data.fileIds}`}
alt={data.name}
draggable={"false"} draggable={"false"}
/> >
<footer className="d-flex"> <img
<Avatar
src={`https://dnvn.ir/api/v1/file/${data.fileIds}`} src={`https://dnvn.ir/api/v1/file/${data.fileIds}`}
style={{ width: 40, height: 40 }} alt={data.name}
draggable={"false"}
/> />
<div className="home-courses-course__info d-flex flex-column"> <footer className="d-flex">
<h2>{data.name}</h2> <Avatar
{/* {window.innerWidth > 1007 ? ( src={`https://dnvn.ir/api/v1/file/${data.fileIds}`}
<p>{data.text.slice(0, 100)}</p> style={{ width: 40, height: 40 }}
) : ( />
<p>{data.text.slice(0, 50)}</p> <div className="home-courses-course__info d-flex flex-column">
)} */} <h2>{data.name}</h2>
</div>
{/* <ul className="d-flex flex-wrap"> </footer>
{data.tags.length <= 2 </div>
? data.tags.map((item: String, i: any) => <li key={i}>{item}</li>) <Link
: null} to={`/courses/${data.id}`}
{data.tags.length > 2 ? ( className={_.join(
<> [
<li key={1}>{data.tags[0]}</li> "home-courses-course mobile flex-column",
<li key={2}>{data.tags[1]}</li> theme === "light"
<li key={3}>+</li> ? "home-courses-course-light"
</> : "home-courses-course-dark",
) : null} ],
</ul> */} " "
</div> )}
</footer> draggable={"false"}
</Link> >
<img
src={`https://dnvn.ir/api/v1/file/${data.fileIds}`}
alt={data.name}
draggable={"false"}
/>
<footer className="d-flex">
<Avatar
src={`https://dnvn.ir/api/v1/file/${data.fileIds}`}
style={{ width: 40, height: 40 }}
/>
<div className="home-courses-course__info d-flex flex-column">
<h2>{data.name}</h2>
</div>
</footer>
</Link>
</>
); );
} }

@ -1,12 +1,15 @@
import React, { useEffect } from "react"; import React, { useState } from "react";
import Carousel from "react-elastic-carousel"; import Carousel from "react-elastic-carousel";
import Course from "./Course/index"; import Course from "./Course/index";
import { Link } from "react-router-dom"; import { Link } from "react-router-dom";
import ExpandMoreRoundedIcon from "@mui/icons-material/ExpandMoreRounded"; import ExpandMoreRoundedIcon from "@mui/icons-material/ExpandMoreRounded";
import { connect } from "react-redux"; import { connect } from "react-redux";
import _ from "lodash"; import _ from "lodash";
import BookToggle from "../../../components/BookToggle";
import scroll from "../../../util/scroll";
function Courses({ number, courses, selectedSort, theme }: any) { function Courses({ number, courses, selectedSort, theme }: any) {
const [activeBook, setActiveBook] = useState(null);
const slideNumberHandler = () => { const slideNumberHandler = () => {
if (window.innerWidth >= 1440) { if (window.innerWidth >= 1440) {
return 5; return 5;
@ -21,10 +24,13 @@ function Courses({ number, courses, selectedSort, theme }: any) {
const light = theme === "light"; const light = theme === "light";
return ( return (
<section <section
className={_.join([ className={_.join(
"home-courses d-flex flex-column", [
light ? "home-courses-light" : "home-courses-dark", "home-courses d-flex flex-column",
], " ")} light ? "home-courses-light" : "home-courses-dark",
],
" "
)}
> >
<header className="d-flex justify-content-between align-items-center"> <header className="d-flex justify-content-between align-items-center">
<div className="d-flex flex-column"> <div className="d-flex flex-column">
@ -33,25 +39,27 @@ function Courses({ number, courses, selectedSort, theme }: any) {
</div> </div>
<Link to="/">بیشتر</Link> <Link to="/">بیشتر</Link>
</header> </header>
{window.innerWidth > 1007 ? ( <div className="desktop flex-column" onClick={() => scroll.bookScroll(1)}>
<Carousel <div className="position-relative">
itemsToShow={slideNumberHandler()} <Carousel
isRTL={true} itemsToShow={slideNumberHandler()}
enableTilt={false} isRTL={true}
showArrows={true} enableTilt={false}
pagination={false} showArrows={true}
> pagination={false}
{courses?.map((item: Object, i: any) => ( >
<Course data={item} key={i} /> {courses?.map((item: Object, i: any) => (
))} <Course data={item} key={i} setActiveBook={setActiveBook} />
</Carousel> ))}
) : ( </Carousel>
<div className="home-courses__list d-flex">
{courses?.map((item: Object, i: any) => (
<Course data={item} key={i} />
))}
</div> </div>
)} {activeBook && <BookToggle book={activeBook} />}
</div>
<div className="home-courses__list mobile">
{courses?.map((item: Object, i: any) => (
<Course data={item} key={i} />
))}
</div>
<Link <Link
className="home-courses__more align-items-center hidden" className="home-courses__more align-items-center hidden"

@ -70,6 +70,7 @@
.slider-header { .slider-header {
width: 100%; width: 100%;
justify-content: flex-end; justify-content: flex-end;
min-height : calc(100vh - 150px);
img{ img{
width: 100%; width: 100%;

@ -4,28 +4,31 @@ import Carousel from "react-elastic-carousel";
import dropdown from "../../../assets/icons/dropdown.png"; import dropdown from "../../../assets/icons/dropdown.png";
const HomeSlider = ({ headerData}: any) => { const HomeSlider = ({ headerData }: any) => {
return ( return (
<div className="home-slider d-flex"> <div className="home-slider d-flex">
<Carousel <Carousel
itemsToShow={1} itemsToShow={1}
isRTL={true} isRTL={true}
enableTilt={false} enableTilt={true}
showArrows={true} showArrows={true}
pagination={true} pagination={true}
enableAutoPlay={true} enableAutoPlay={true}
> >
{headerData.map((item: any, i: any) => ( {headerData.map((item: any, i: any) => (
<div className="slider-header d-flex"> <div
className="slider-header d-flex"
style={{
background: `url(https://dnvn.ir/api/v1/file/${item.fileId})`,
backgroundRepeat : 'no-repeat',
backgroundClip : 'content-box',
backgroundSize : '100% 100%',
}}
>
{/* < {/* <
className="slider-header__right d-flex" className="slider-header__right d-flex"
style={{ backgroundColor: item.backgroundColor }} style={{ backgroundColor: item.backgroundColor }}
> */} > */}
<img
src={`https://dnvn.ir/api/v1/file/${item.fileId}`}
alt={item.title}
/>
{/* <div {/* <div
style={{ backgroundColor: item.backgroundColor }} style={{ backgroundColor: item.backgroundColor }}
className="slider-header__left d-flex flex-column" className="slider-header__left d-flex flex-column"

@ -30,6 +30,7 @@ function Home({
const [gradeDropdown, setGradeDropdown] = useState(false); const [gradeDropdown, setGradeDropdown] = useState(false);
useEffect(() => { useEffect(() => {
localStorage.removeItem('bookToggle1');
getCourseList(); getCourseList();
scroll.goToTop(); scroll.goToTop();
getHeader({ device: 1 }); getHeader({ device: 1 });

Loading…
Cancel
Save