|
|
@ -1,11 +1,14 @@ |
|
|
|
import React from "react"; |
|
|
|
import React from "react"; |
|
|
|
import { Link } from "react-router-dom"; |
|
|
|
import { Link } from "react-router-dom"; |
|
|
|
import { connect } from "react-redux"; |
|
|
|
import { connect } from "react-redux"; |
|
|
|
|
|
|
|
import { blog } from "../../../../../redux/actions"; |
|
|
|
import _ from "lodash"; |
|
|
|
import _ from "lodash"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//assets
|
|
|
|
import arrowGreenIcon from "../../../../../assets/icons/dropdown-blue.svg"; |
|
|
|
import arrowGreenIcon from "../../../../../assets/icons/dropdown-blue.svg"; |
|
|
|
import arrowWhiteIcon from "../../../../../assets/icons/arrow-left-white.svg"; |
|
|
|
import arrowWhiteIcon from "../../../../../assets/icons/arrow-left-white.svg"; |
|
|
|
|
|
|
|
|
|
|
|
function Blogs({ list, isDark }) { |
|
|
|
function Blogs({ list, isDark, setActive }) { |
|
|
|
return ( |
|
|
|
return ( |
|
|
|
<div className="w-full pr-4"> |
|
|
|
<div className="w-full pr-4"> |
|
|
|
<div className="w-full flex flex-col rounded-md py-4 overflow-hidden"> |
|
|
|
<div className="w-full flex flex-col rounded-md py-4 overflow-hidden"> |
|
|
@ -14,11 +17,7 @@ function Blogs({ list, isDark }) { |
|
|
|
خواندنیها |
|
|
|
خواندنیها |
|
|
|
</strong> |
|
|
|
</strong> |
|
|
|
{isDark ? ( |
|
|
|
{isDark ? ( |
|
|
|
<img |
|
|
|
<img src={arrowWhiteIcon} alt="" className={`transform ml-4 w-7`} /> |
|
|
|
src={ arrowWhiteIcon} |
|
|
|
|
|
|
|
alt="" |
|
|
|
|
|
|
|
className={`transform ml-4 w-7`} |
|
|
|
|
|
|
|
/> |
|
|
|
|
|
|
|
) : ( |
|
|
|
) : ( |
|
|
|
<img |
|
|
|
<img |
|
|
|
src={arrowGreenIcon} |
|
|
|
src={arrowGreenIcon} |
|
|
@ -29,7 +28,7 @@ function Blogs({ list, isDark }) { |
|
|
|
</header> |
|
|
|
</header> |
|
|
|
<ul className="list-none w-full overflow-x-scroll pt-3 flex flex-row pb-16 no-scrollbar"> |
|
|
|
<ul className="list-none w-full overflow-x-scroll pt-3 flex flex-row pb-16 no-scrollbar"> |
|
|
|
{list.map((blog, index) => ( |
|
|
|
{list.map((blog, index) => ( |
|
|
|
<Blog blog={blog} key={index} /> |
|
|
|
<Blog blog={blog} key={index} setActive={setActive} /> |
|
|
|
))} |
|
|
|
))} |
|
|
|
</ul> |
|
|
|
</ul> |
|
|
|
</div> |
|
|
|
</div> |
|
|
@ -37,23 +36,24 @@ function Blogs({ list, isDark }) { |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const Blog = ({ blog }) => { |
|
|
|
const Blog = ({ blog, setActive }) => { |
|
|
|
return ( |
|
|
|
return ( |
|
|
|
<li className="flex flex-col ml-3"> |
|
|
|
<li className="flex flex-col ml-3"> |
|
|
|
<Link |
|
|
|
<Link |
|
|
|
to={"/blogs/" + blog.name} |
|
|
|
to={"/blogs/" + blog?.id} |
|
|
|
className="flex flex-row justify-center items-end rounded-md" |
|
|
|
className="flex flex-row justify-center items-end rounded-md" |
|
|
|
style={{ |
|
|
|
style={{ |
|
|
|
background: `url(https://dnvn.ir/api/v1/file/${blog?.fileIds})`, |
|
|
|
background: `url(https://dnvn.ir/api/v1/file/${blog?.fileIds})`, |
|
|
|
backgroundPosition: "contain", |
|
|
|
backgroundPosition: "contain", |
|
|
|
backgroundSize: "100% 100%", |
|
|
|
backgroundSize: "100% 100%", |
|
|
|
minWidth: 200, |
|
|
|
minWidth: 200, |
|
|
|
width: 'calc(100vw / 1.6)', |
|
|
|
width: "calc(100vw / 1.6)", |
|
|
|
maxWidth: 350, |
|
|
|
maxWidth: 350, |
|
|
|
minHeight: 160, |
|
|
|
minHeight: 160, |
|
|
|
height : 'calc(100vw / 1.6 * 3 / 4)', |
|
|
|
height: "calc(100vw / 1.6 * 3 / 4)", |
|
|
|
maxHeight : 300 |
|
|
|
maxHeight: 300, |
|
|
|
}} |
|
|
|
}} |
|
|
|
|
|
|
|
onClick={() => setActive(blog?.id)} |
|
|
|
> |
|
|
|
> |
|
|
|
<div className="w-11/12 bg-white rounded-md shadow-md flex flex-col transform translate-y-1/2 p-2 dark:bg-gray36"> |
|
|
|
<div className="w-11/12 bg-white rounded-md shadow-md flex flex-col transform translate-y-1/2 p-2 dark:bg-gray36"> |
|
|
|
<h2 className="text-xs font-semibold text-blue5F dark:text-white leading-5"> |
|
|
|
<h2 className="text-xs font-semibold text-blue5F dark:text-white leading-5"> |
|
|
@ -86,4 +86,8 @@ const mapStateToProps = (state) => ({ |
|
|
|
isDark: state.publicApi.isDark, |
|
|
|
isDark: state.publicApi.isDark, |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
export default connect(mapStateToProps, {})(Blogs); |
|
|
|
const mapDispatchToProps = { |
|
|
|
|
|
|
|
setActive: blog.active, |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(Blogs); |
|
|
|