Skip to content
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

Negin ghasemi 39601418 #4

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"dependencies": {
"react": "^17.0.1",
"react-dom": "^17.0.1",
"react-icons": "^4.2.0",
"react-router-dom": "^5.2.0",
"react-scripts": "4.0.3"
},
Expand Down
32 changes: 19 additions & 13 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
<!DOCTYPE html>
<html lang="fa-IR">
<head>
<meta charset="utf-8" />
<title>React Project</title>
<meta name="theme-color" content="#000000" />
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<meta name="description" content="this is a test project" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="icon" type="image/png" href="%PUBLIC_URL%/icons/favicon.png" />
</head>
<body dir="rtl">
<noscript>Enable JS</noscript>
<div id="root"></div>
</body>

<head>
<meta charset="utf-8" />
<title>React Project</title>
<meta name="theme-color" content="#000000" />
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<meta name="description" content="this is a test project" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="icon" type="image/png" href="%PUBLIC_URL%/icons/favicon.png" />
<link href="https://cdn.jsdelivr.net/gh/rastikerdar/[email protected]/dist/font-face.css" rel="stylesheet"
type="text/css" />

</head>

<body dir="rtl">
<noscript>Enable JS</noscript>
<div id="root"></div>
</body>

</html>
5 changes: 3 additions & 2 deletions src/Routes.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { BrowserRouter as Router , Switch , Route } from 'react-router-dom'
import { BrowserRouter as Router, Switch, Route } from 'react-router-dom'
import NeginGhasemi from './views/39601418/index'

export default function Routes() {
return (
<Router>
<Switch>


<Route path="/39601418/" component={NeginGhasemi} />

</Switch>
</Router>
Expand Down
4 changes: 2 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import ReactDom from 'react-dom'

import Routes from './Routes'

ReactDom.render(
ReactDom.render(
<React.StrictMode>
<Routes />
</React.StrictMode>
, document.getElementById('root'))
, document.getElementById('root'))
37 changes: 37 additions & 0 deletions src/views/39601418/components/productCard/ProductCard.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@

import Rial from '../rial/Rial'
import { intCommas } from '../../functions/functions';

export default function ProductCard({ data }) {

return (
<div className="product-card">
<img src={data.image} alt={data.title} />
<h3 className="product-card__title">{data.title}</h3>
<div className="price-box">
{data.discount === 0 ? (
<p className="price rial">{intCommas(data.price)}
<Rial />
</p>
) : (
<div className="price-box__discount">

<div>
<del>{intCommas(data.price)}</del>
<p className="price">{intCommas(data.discount)}
<Rial />
</p>
</div>

<span>{intCommas(Math.round(100 - ((data.price - data.discount) * 100) / data.price))}%</span>

</div>
)}
</div>

<div className="add-to-cart">
<button className="add-btn"> افزودن به سبد خرید</button>
</div>
</div>
);
}
7 changes: 7 additions & 0 deletions src/views/39601418/components/rial/Rial.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@


export default function rial() {
return (
<label className="rial"> ریال </label>
)
}
109 changes: 109 additions & 0 deletions src/views/39601418/css/header.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
header{
width: 100%;
color: #fff;
line-height: 66px;
background-color: #E53935;
user-select: none;
}


header .container{
width: 90%;
display: flex;
margin:0 auto ;
max-width:900px;
position: relative;
align-items: center;
justify-content: space-between;
}


.logged-user{

align-items: center;
display: flex;

}


.logged-user h3{
font-weight: normal;
font-size: 14px;
margin-right:6px;
margin-left: 8px;


}
/* header .container h3{
font-weight: normal;
font-size: 14px;
} */


.cart{
cursor: pointer;
}


.cart h3{
font-size: 14px;
margin-right:4px;
margin-left: 8px;
align-items: center;
/* display: inline; */
/* flex-direction: row; */
display: flex;
/* justify-content: center; */
}

.cart h3 p{
margin-right:6px ;
font-weight: normal;
}

.cart h3 span{
font-size: 18px;
margin-right: 4px;
padding-right: 2px;
}


.cart-content{
left:0;
width: 90%;
color: #424242;
padding: 16px;
display: none;
list-style: none;
max-width:250px;
position: absolute;
border-radius: 0 0 12px 12px;
border:1px solid #E53935;
border-top: none;
box-shadow: 0 7px 10px rgba(0,0,0,0.2);
background-color: #F5F5F5;
}



.cart-content li{
font-size: 14px;
}


.cart:hover > .cart-content{

display: block;
}



.cart-content__sum{
width: 100%;
display: flex;
line-height: 44px;
font-weight: 700;
align-items:center;
justify-content: space-between;
border-top: 1px solid #212121;
}
25 changes: 25 additions & 0 deletions src/views/39601418/css/main.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
*{
margin: 0;
padding: 0;
box-sizing: border-box;
}

body{
direction: rtl;
font-family: 'Vazir', sans-serif;

}

button{
font-family: 'Vazir', sans-serif;

}
.rial{
font-size: 12px;
margin-right: 4px;
}



@import './header.css';
@import './product-card.css';
92 changes: 92 additions & 0 deletions src/views/39601418/css/product-card.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
.products{
width: 100%;
padding:0 16px;
margin-top: 16px;
display: flex;
align-items: center;
flex-wrap: wrap;
justify-content: center;
}


.product-card{
width: 90%;
margin: 30px;
padding:12px;
display: flex;
max-width: 240px;
user-select: none;
min-height: 420px;
border-radius: 12px;
flex-direction: column;
justify-content: space-between;
background-color: #fff;
transition-duration: 300ms;
}


.product-card:hover{
box-shadow: 0 7px 10px rgba(0,0,0,0.2);
}

.product-card img{
width:100%;
border-radius: 8px;
}

.price-box{
padding: 6px 16px;
}

.price-box__discount{
display: flex;
align-items:flex-start ;
justify-content:space-between;
}


.price-box__discount span{
color:#fff;
font-size: 12px;
padding: 2px 10px;
border-radius: 16px;
background-color: #f03;
}

.price-box__discount del{
color: #f03;
font-size: 14px;
}

.price{
font-size: 18px !important;
font-weight: bold !important;
}



.product-card__title{
margin: 6px 0;
font-size: 14px;
padding: 0 16px;
font-weight: normal;
}


.add-to-cart .add-btn{
width: 100%;
border: none;
color: #fff;
cursor: pointer;
font-size: 16px;
line-height: 36px;
margin-top: 6px;
border-radius: 8px;
background-color: #f06576;
transition-duration: 300ms;
}


.add-to-cart .add-btn:hover{
background-color: #f0253d;
}
18 changes: 18 additions & 0 deletions src/views/39601418/functions/functions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
function intCommas(number) {
return convertToFaDigit(number.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
}

function convertToFaDigit(number) {
let b = '' + number;
for (let c = 48; c <= 57; c++) {
let d = String.fromCharCode(c);
let e = String.fromCharCode(c + 1728);
b = b.replace(new RegExp(d.toString(), "g"), e.toString())
}

return b;
}

export {
intCommas, convertToFaDigit
}
Loading