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

UI Wizard #27

Open
wants to merge 3 commits into
base: master
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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
node_modules
node_modules
31,030 changes: 31,025 additions & 5 deletions package-lock.json

Large diffs are not rendered by default.

55 changes: 39 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,45 @@
{
"name": "frontend-challenge",
"version": "1.0.0",
"description": "Sheypoor frontend challenge",
"main": "sdk/index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"name": "sheypoor",
"version": "0.1.0",
"private": true,
"dependencies": {
"@material-ui/core": "^4.12.4",
"@testing-library/jest-dom": "^5.17.0",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"@types/jest": "^29.5.4",
"@types/node": "^20.6.0",
"@types/react": "^18.2.21",
"@types/react-dom": "^18.2.7",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-scripts": "5.0.1",
"sass": "^1.66.1",
"typescript": "^5.2.2",
"web-vitals": "^2.1.4"
},
"repository": {
"type": "git",
"url": "git+https://github.com/sheypoor/frontend-challenge.git"
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"author": "Pendar Safari <[email protected]>",
"license": "ISC",
"bugs": {
"url": "https://github.com/sheypoor/frontend-challenge/issues"
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"homepage": "https://github.com/sheypoor/frontend-challenge#readme",
"dependencies": {
"sdk": "file:sdk"
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
23 changes: 23 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!-- @format -->

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="/sheypoor-logo.png" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using create-react-app" />
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />

<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />

<title>TASK</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
</body>
</html>
25 changes: 25 additions & 0 deletions public/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"short_name": "React App",
"name": "Create React App Sample",
"icons": [
{
"src": "favicon.ico",
"sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon"
},
{
"src": "logo192.png",
"type": "image/png",
"sizes": "192x192"
},
{
"src": "logo512.png",
"type": "image/png",
"sizes": "512x512"
}
],
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}
Binary file added public/sheypoor-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 0 additions & 7 deletions sdk/index.js

This file was deleted.

8 changes: 0 additions & 8 deletions sdk/package.json

This file was deleted.

13 changes: 13 additions & 0 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/** @format */

import User from "./components/Widget/User";

function App() {
return (
<div className='app'>
<User />
</div>
);
}

export default App;
13 changes: 13 additions & 0 deletions src/components/UI/Buttons/BackButton/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/** @format */

import classes from "./index.module.scss";

const BackButton = ({ onClick }) => {
return (
<button onClick={onClick} className={classes.button}>
مرحله قبل
</button>
);
};

export default BackButton;
10 changes: 10 additions & 0 deletions src/components/UI/Buttons/BackButton/index.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/** @format */
.button {
padding: 6px;
border-radius: 4px;
border: 1px solid transparent;
cursor: pointer;
min-width: 60px;
background-color: #323131;
color: #fff;
}
18 changes: 18 additions & 0 deletions src/components/UI/Buttons/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/** @format */

import classes from "./index.module.scss";
import { CircularProgressOnButton } from "../CircularProgressOnButton";
const Button = ({ onClick, children, isLoading }) => {
return (
<button
onClick={onClick}
className={`${classes.button} ${
isLoading ? classes.disabled : classes.active
}`}>
{isLoading && <CircularProgressOnButton />}
{children}
</button>
);
};

export default Button;
17 changes: 17 additions & 0 deletions src/components/UI/Buttons/index.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/** @format */
.button {
border-radius: 4px;
border: 1px solid transparent;
cursor: pointer;
min-width: 65px;
padding: 6px;
position: relative;
}
.active {
background-color: var(--color-primary);
color: var(--color-light);
}
.disabled {
background-color: var(--color-medium);
color: var(--color-darkest);
}
9 changes: 9 additions & 0 deletions src/components/UI/CircularProgressOnButton/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/** @format */

import React from "react";
import classes from "./index.module.scss";
import { CircularProgress } from "@material-ui/core";

export const CircularProgressOnButton = () => {
return <CircularProgress size={20} className={classes.progressBar} />;
};
9 changes: 9 additions & 0 deletions src/components/UI/CircularProgressOnButton/index.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/** @format */

.progressBar {
position: absolute;
top: 50%;
left: 50%;
margin-top: -12px;
margin-left: -12px;
}
22 changes: 22 additions & 0 deletions src/components/UI/Inputs/Select/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/** @format */

import { newsletterOptions } from "../../../../shared/constants";
import classes from "./index.module.scss";

const Select = ({ newsletter, onChange }) => {
return (
<select
dir='rtl'
className={classes.select}
onChange={onChange}
value={newsletter}>
{newsletterOptions.map((option) => (
<option key={option.id} value={option.id}>
{option.title}
</option>
))}
</select>
);
};

export default Select;
9 changes: 9 additions & 0 deletions src/components/UI/Inputs/Select/index.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/** @format */

.select {
padding: 8px;
margin: 8px 0;
border-radius: 3px;
border: 0.5px solid #939191;
min-width: 200px;
}
19 changes: 19 additions & 0 deletions src/components/UI/Inputs/TextInput/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/** @format */

import classes from "./index.module.scss";

const TextInput = ({ placeholder, value, name, onChange, type, error }) => {
return (
<input
placeholder={placeholder}
value={value}
onChange={onChange}
name={name}
type={type}
className={`${classes.input} ${error?.[name] ? classes.error : ""}`}
error={error}
/>
);
};

export default TextInput;
19 changes: 19 additions & 0 deletions src/components/UI/Inputs/TextInput/index.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/** @format */

.input {
padding: 8px;
margin: 8px 0;
border-radius: 3px;
border: 0.5px solid var(--color-darkest);
width: 200px;
&::-webkit-input-placeholder {
text-align: right;
}
&:focus {
outline: none;
}
}

.error {
border: 1.3px solid red;
}
18 changes: 18 additions & 0 deletions src/components/Widget/TankYou/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/** @format */

import { USER_NAME_STEP } from "../../../shared/constants";
import Button from "../../UI/Buttons";
import classes from "./index.module.scss";

const TankYou = ({ dispatch }) => {
return (
<div className={classes.container}>
<h3>کاربر با موفقیت ثبت شد</h3>
<Button onClick={() => dispatch({ type: USER_NAME_STEP })}>
افزودن کاربر جدید
</Button>
</div>
);
};

export default TankYou;
15 changes: 15 additions & 0 deletions src/components/Widget/TankYou/index.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/** @format */

.container {
color: var(--color-success);
display: flex;
align-items: center;
justify-content: space-between;
flex-direction: column;
padding: 2rem;

h3 {
margin-bottom: 2rem;
font-size: 16px;
}
}
26 changes: 26 additions & 0 deletions src/components/Widget/User/_components/NewsletterStep/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/** @format */

import TextInput from "../../../../UI/Inputs/TextInput";
import Select from "../../../../UI/Inputs/Select";

const NewsletterStep = ({ dispatch, email, newsletter, error }) => {
return (
<>
<TextInput
name='email'
placeholder='آدرس ایمیل'
onChange={(e) => dispatch({ type: "EMAIL", payload: e.target.value })}
value={email}
error={error}
/>
<Select
newsletter={newsletter}
onChange={(e) =>
dispatch({ type: "NEWS_LETTER", payload: e.target.value })
}
/>
</>
);
};

export default NewsletterStep;
28 changes: 28 additions & 0 deletions src/components/Widget/User/_components/UsernameStep/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/** @format */

import TextInput from "../../../../UI/Inputs/TextInput";

const UsernameStep = ({ dispatch, error, username, age }) => {
return (
<>
<TextInput
name='username'
placeholder='نام کاربری'
onChange={(e) =>
dispatch({ type: "USER_NAME", payload: e.target.value })
}
error={error}
value={username}
/>
<TextInput
name='age'
placeholder='سن'
onChange={(e) => dispatch({ type: "AGE", payload: e.target.value })}
value={age}
error={error}
/>
</>
);
};

export default UsernameStep;
Loading