Skip to content

Commit

Permalink
Merge pull request #1 from MuhammadKhalilzadeh/textfields
Browse files Browse the repository at this point in the history
Text fields, still some inconsistencies are remaining
  • Loading branch information
MuhammadKhalilzadeh authored May 7, 2024
2 parents 201d621 + 136a1bc commit d15d947
Show file tree
Hide file tree
Showing 13 changed files with 997 additions and 136 deletions.
687 changes: 651 additions & 36 deletions Client/package-lock.json

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions Client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@
"preview": "vite preview"
},
"dependencies": {
"@emotion/react": "^11.11.4",
"@emotion/styled": "^11.11.5",
"@mui/material": "^5.15.16",
"react": "^18.2.0",
"@fontsource/roboto": "^5.0.13",
"@mui/icons-material": "^5.15.16",
"react-dom": "^18.2.0"
},
"devDependencies": {
Expand Down
31 changes: 6 additions & 25 deletions Client/src/App.jsx
Original file line number Diff line number Diff line change
@@ -1,35 +1,16 @@
import { useState } from 'react'
import reactLogo from './assets/react.svg'
import viteLogo from '/vite.svg'
import './App.css'
import { useState } from "react";
import PlayGround from "./screens/PlayGround/PlayGround";

function App() {
const [count, setCount] = useState(0)
const [count, setCount] = useState(0);

return (
<>
<div>
<a href="https://vitejs.dev" target="_blank">
<img src={viteLogo} className="logo" alt="Vite logo" />
</a>
<a href="https://react.dev" target="_blank">
<img src={reactLogo} className="logo react" alt="React logo" />
</a>
<PlayGround />
</div>
<h1>Vite + React</h1>
<div className="card">
<button onClick={() => setCount((count) => count + 1)}>
count is {count}
</button>
<p>
Edit <code>src/App.jsx</code> and save to test HMR
</p>
</div>
<p className="read-the-docs">
Click on the Vite and React logos to learn more
</p>
</>
)
);
}

export default App
export default App;
3 changes: 3 additions & 0 deletions Client/src/assets/icons/icon-red-error-0.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import React from "react";
import "./descriptionTextField.css";
import { TextField } from "@mui/material";

function DescriptionTextField({ hintText, hasError }) {
return (
<div className="description-field-holder">
<div className="text-field-title">Website</div>
<TextField
error={hasError}
className="description-field-area"
multiline
rows={4}
placeholder="Enter a description..."
helperText={hintText}
/>
</div>
);
}

export default DescriptionTextField;
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
:root {
--color-title-1: #344054;
--font-family-1: "Roboto", "Helvetica", "Arial", sans-serif;
--text-field-margin-0: 10px 20px;
}

.description-field-holder {
margin: var(--text-field-margin-0);
margin-top: 20px;
}

.text-field-title {
color: var(--color-title-1);
font-weight: bold;
font-family: var(--font-family-1);
margin-bottom: 10px;
}

.description-field-area {
font-size: 13px;
border-radius: 8px;
}

.description-field-label {
margin-top: 10px;
font-family: var(--font-family);
font-size: 11px;
}

.with-error {
color: red;
}
55 changes: 55 additions & 0 deletions Client/src/components/TextFields/Email/EmailTextField.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import React, { useState } from "react";
import "./emailTextField.css";
import { InputAdornment, TextField } from "@mui/material";
import ErrorOutlineIcon from "@mui/icons-material/ErrorOutline";
import HelpOutlineIcon from "@mui/icons-material/HelpOutline";

function EmailTextField({
id,
label,
variant,
placeholder,
icon,
helperText,
error,
}) {
const [showIcon, setShowIcon] = useState(false);

// State to control mouse hover effect
const handleMouseEnter = () => setShowIcon(true);
const handleMouseLeave = () => setShowIcon(false);

return (
<>
<div className="email-text-field-title">Email</div>
<div className="email-text-field">
<TextField
error={error}
className="email-text-field-input"
id={id}
label={label}
variant={variant}
placeholder={placeholder}
InputProps={{
endAdornment: (
<InputAdornment position="end">
{error && showIcon && (
<ErrorOutlineIcon style={{ fill: "red" }} />
)}
{error && !showIcon && (
<ErrorOutlineIcon style={{ fill: "red" }} />
)}
{!error && showIcon && <HelpOutlineIcon />}
</InputAdornment>
),
}}
helperText={helperText}
onMouseEnter={handleMouseEnter}
onMouseLeave={handleMouseLeave}
/>
</div>
</>
);
}

export default EmailTextField;
15 changes: 15 additions & 0 deletions Client/src/components/TextFields/Email/emailTextField.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#outlined-basic {
width: 320px;
font-size: 13px;
}

.email-text-field {
position: relative;
margin: 10px 20px;
}

.email-text-field-title {
font-family: "Roboto", "Helvetica", "Arial", sans-serif;
margin: 0 20px;
margin-top: 30px;
}
54 changes: 54 additions & 0 deletions Client/src/components/TextFields/Website/WebsiteTextField.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import React, { useState } from "react";
import "./websiteTextField.css";
import HelpOutlineIcon from "@mui/icons-material/HelpOutline";
import ContentCopyIcon from "@mui/icons-material/ContentCopy";

function WebsiteTextField({
showHelp = true,
hasCopyButton = false,
hintText,
}) {
const [copied, setCopied] = useState(false);

const handleCopy = () => {
setCopied(true);
setTimeout(() => setCopied(false), 1000);
};

return (
<>
<div className="website-textfield-title">Website</div>
<div className="website-textfield">
<label className="website-label" htmlFor="website">
http://
</label>
<input
type="url"
name="website-url"
id="website-url"
className="website-url"
/>
{showHelp && (
<div
className={
`website-icon-holder ` + !hasCopyButton
? "with-no-copy-button"
: ""
}
>
<HelpOutlineIcon style={{ fill: "var(--icon-color)" }} />
</div>
)}
{hasCopyButton && (
<div className="copy-to-clipboard-button" onClick={handleCopy}>
<ContentCopyIcon className="copy-icon" />
<span>{copied ? " Copied " : " Copy "}</span>
</div>
)}
</div>
<label className="website-textfield-hint">{hintText}</label>
</>
);
}

export default WebsiteTextField;
84 changes: 84 additions & 0 deletions Client/src/components/TextFields/Website/websiteTextField.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
:root {
--border-color: #d0d5dd;
--label-font-color: #475467;
--icon-color: #98a2b3;
--text-field-margin-0: 10px 20px;
--text-field-margin-1: 10px 20px 5px;
--font-family: "Roboto", "Helvetica", "Arial", sans-serif;
}

.website-textfield-title {
font-family: "Roboto", "Helvetica", "Arial", sans-serif;
margin: 0 20px;
margin-top: 30px;
}

.website-textfield {
font-family: var(--font-family);
display: flex;
align-items: center;
position: relative;
margin: var(--text-field-margin-1);
}

.website-textfield-hint {
margin: var(--text-field-margin-0);
font-family: var(--font-family);
font-size: 11px;
}

.website-label {
height: 33px;
padding: 5px 20px 5px 10px;
border: solid 1px var(--border-color);
border-right: none;
border-radius: 8px 0 0 8px;
font-size: 13px;
text-align: center;
display: flex;
justify-content: center;
align-items: center;
color: var(--label-font-color);
}

.website-url {
width: 248px;
height: 33px;
padding: 5px 15px;
border: solid 1px var(--border-color);
}

.website-icon-holder {
width: 40px;
height: 33px;
padding: 5px;
border: solid 1px var(--border-color);
border-left: none;
text-align: center;
display: flex;
justify-content: center;
align-items: center;
}

.copy-to-clipboard-button {
height: 33px;
padding: 5px 20px 5px 10px;
border: solid 1px var(--border-color);
border-left: none;
border-radius: 0 8px 8px 0;
font-size: 13px;
text-align: center;
display: flex;
justify-content: space-evenly;
align-items: center;
color: var(--label-font-color);
cursor: pointer;
}

.copy-icon {
margin-right: 10px;
}

.with-no-copy-button {
display: none;
}
68 changes: 0 additions & 68 deletions Client/src/index.css

This file was deleted.

Loading

0 comments on commit d15d947

Please sign in to comment.