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