Skip to content

Fixed theme colours. Adjusted theme and font colours for improved contrast. #240

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

Open
wants to merge 2 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
80 changes: 72 additions & 8 deletions src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ body {
}

.dark-theme {
background-color: rgb(125, 119, 119);
background-color: rgb(34 34 34);
color: rgb(235, 235, 235);
transition: 0.5s ease-in-out;
}
Expand All @@ -178,7 +178,7 @@ body {
}

.green-theme {
background-color: rgb(123, 214, 165);
background-color: rgb(171 240 203);
color: rgb(68, 52, 70);
transition: 0.5s ease-in-out;
}
Expand All @@ -197,15 +197,72 @@ body {

.blue-theme {
color: rgb(45, 43, 43);
background-color: #1370a3;
background-color: #bfe8ff;
transition: 0.5s ease-in-out;
}

.yellow-theme {
color: rgb(29, 28, 28);
background-color: #d29117;
background-color: #ffdea1;
transition: 0.5s ease-in-out;
}

.purple-theme .hover {
background: linear-gradient(90deg, rgb(101, 199, 63) 50%, rgb(120, 70, 153) 0)
var(--_p, 100%) / 200% no-repeat;
-webkit-background-clip: text;
background-clip: text;
transition: 0.4s;
}

.green-theme .hover {
background: linear-gradient(90deg, rgb(101, 199, 63) 50%, rgb(10, 79, 14) 0)
var(--_p, 100%) / 200% no-repeat;
-webkit-background-clip: text;
background-clip: text;
transition: 0.4s;
}

.pink-theme .hover {
background: linear-gradient(90deg, rgb(101, 199, 63) 50%, rgb(167, 61, 135) 0)
var(--_p, 100%) / 200% no-repeat;
-webkit-background-clip: text;
background-clip: text;
transition: 0.4s;
}

.skin-theme .hover {
background: linear-gradient(90deg, rgb(101, 199, 63) 50%, rgb(153, 70, 70) 0)
var(--_p, 100%) / 200% no-repeat;
-webkit-background-clip: text;
background-clip: text;
transition: 0.4s;
}

.dark-theme .hover {
background: linear-gradient(90deg, rgb(101, 199, 63) 50%, rgb(245, 245, 245) 0)
var(--_p, 100%) / 200% no-repeat;
-webkit-background-clip: text;
background-clip: text;
transition: 0.4s;
}

.blue-theme .hover {
background: linear-gradient(90deg, rgb(101, 199, 63) 50%, rgb(30, 73, 125) 0)
var(--_p, 100%) / 200% no-repeat;
-webkit-background-clip: text;
background-clip: text;
transition: 0.4s;
}

.yellow-theme .hover {
background: linear-gradient(90deg, rgb(101, 199, 63) 50%, rgb(200, 130, 0) 0)
var(--_p, 100%) / 200% no-repeat;
-webkit-background-clip: text;
background-clip: text;
transition: 0.4s;
}

.skin-theme .title {
color: rgb(153, 70, 70);
}
Expand All @@ -214,6 +271,10 @@ body {
color: rgb(120, 70, 153);
}

.blue-theme .title {
color: rgb(30, 73, 125);
}

.green-theme .title {
color: rgb(10, 79, 14);
}
Expand All @@ -222,11 +283,14 @@ body {
color: rgb(167, 61, 135);
}

.bright-theme {
background-color: #fff;
transition: 0.5s ease-in-out;
color: #000;
.dark-theme .title {
color: rgb(245, 245, 245);
}

.yellow-theme .title {
color: rgb(200, 130, 0);
}

.dark-theme-toast {
background-color: rgb(0, 0, 0);
}
Expand Down
96 changes: 54 additions & 42 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,53 +3,52 @@ import './App.css'
import Footer from './components/Footer'
import ThemeButton from './components/ThemeButton'
import useWindowDimensions from './custom-hooks/useWindowDimensions'
// ...

const App = () => {
// ... (existing code)
function App() {
const minPasswordLength = 6
const { height } = useWindowDimensions()

const handleFormSubmit = async (e) => {
e.preventDefault();
setShowToast(false);
const [form, setForm] = useState({
email: '',
password: '',
})

if (
form.password.length < minPasswordLength ||
!validateEmail(form.email)
) {
setToggleClass((prevState) => !prevState);
setShowToast(true);
setTimeout(() => {
setShowToast(false);
}, 1000);
} else {
// Form is valid, submit the form to the server or take necessary action.
try {
const response = await fetch('https://formspree.io/f/xqkjbjzw', {
method: 'POST',
body: JSON.stringify(form),
});
const [toggleClass, setToggleClass] = useState(false)
const [showToast, setShowToast] = useState(false)
const [isPasswordShown, setPasswordShown] = useState(false)
const [themeState, setThemeState] = useState(
localStorage.getItem('theme') || 'purple',
)

if (response.ok) {
// Handle a successful submission, e.g., redirect the user.
} else {
// Handle errors from the server.
}
} catch (error) {
// Handle network or other errors.
}
}
// updated into one handle
const handleForm = (e) => {
setForm({
...form,
[e.target.name]: e.target.value,
})
}

const handleSubmit = (e) => {
e.preventDefault()
if (form.password.length < minPasswordLength || !validateEmail(form.email)) {
const validateEmail = (email) => String(email)
.toLowerCase()
.trim() // Trim to ignore spaces after user email input
.match(
/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,
)

// eslint-disable-next-line no-unused-vars
const [emojiState, setEmojiState] = React.useState()
const annoyingSubmitButton = () => {
setShowToast(false)

if (
form.password.length < minPasswordLength
|| !validateEmail(form.email)
) {
setToggleClass((prevState) => !prevState)
setShowToast(true)
setTimeout(() => {
setShowToast(false)
}, 1000)
} else {
// call the API here o whatever action you need to do
}
}
// To remember user's selected theme.
Expand All @@ -65,7 +64,14 @@ const App = () => {
<span className="mask">
<div className="link-container">
<span className="link-title1 title">
<span className="hover">Annoying Submit Button</span>
<span className={`${form.password.length < minPasswordLength
|| !validateEmail(form.email)
? ''
: 'hover'
}`}
>
Annoying Submit Button
</span>
{' '}
<span
className={`${emojiState} ${form.password.length < minPasswordLength
Expand All @@ -78,7 +84,14 @@ const App = () => {
{' '}
</span>
<span className="link-title2 title">
<span className="hover">Annoying Submit Button</span>
<span className={`${form.password.length < minPasswordLength
|| !validateEmail(form.email)
? ''
: 'hover'
}`}
>
Annoying Submit Button
</span>
{' '}
<span
className={`${emojiState} ${form.password.length < minPasswordLength
Expand All @@ -99,7 +112,6 @@ const App = () => {
action="https://formspree.io/f/xqkjbjzw"
method="POST"
onChange={handleForm}
onSubmit={handleSubmit}
>
<div className="input-block">
<label htmlFor="email" className={`label ${themeState}-theme`}>
Expand Down Expand Up @@ -194,7 +206,7 @@ const App = () => {
</section>
{height < 680 ? null : <Footer theme={themeState} />}
</div>
);
};
)
}

export default App;
export default App
1 change: 1 addition & 0 deletions src/components/Footer/Footer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ function Footer({ theme }) {
return dateObj.getFullYear()
}, [])

/* eslint-disable jsx-a11y/control-has-associated-label */
return (
<footer className={`${theme}-footer`}>
<div className="footer-content">
Expand Down
21 changes: 12 additions & 9 deletions src/components/ThemeButton/ThemeButton.css
Original file line number Diff line number Diff line change
Expand Up @@ -60,29 +60,32 @@
transition: 0.5s ease-in-out;
}

.dark-a {
.dark-d {
box-shadow: 0px 0px 2px 1px rgb(236, 236, 236);
}

.green-a {
.green-d {
box-shadow: 0px 0px 2px 1px rgb(16, 97, 14);
}

.skin-b {
.skin-d {
box-shadow: 0px 0px 2px 1px rgb(122, 44, 44);
}

.pink-c {
.pink-d {
box-shadow: 0px 0px 2px 1px rgb(220, 34, 173);
}
.yellow-g{
box-shadow: 0px 0px 2px 1px rgb(103, 61, 30);

.yellow-d {
box-shadow: 0px 0px 2px 1px rgb(183, 165, 74);
}
.blue-f{
box-shadow: 0px 0px 2px 1px rgb(132, 221, 122);

.blue-d {
box-shadow: 0px 0px 2px 1px rgb(93, 144, 210);
}

.purple-d {
box-shadow: 0px 0px 2px 1px rgb(110, 40, 110);
box-shadow: 0px 0px 2px 1px rgb(105, 68, 161);
}

.theme-container * {
Expand Down