diff --git a/howto/src/App.js b/howto/src/App.js index 4e858f0..88c96a3 100644 --- a/howto/src/App.js +++ b/howto/src/App.js @@ -12,53 +12,15 @@ import { postUser, fetchHowto } from './Components/Store/actions/action' import Header from './Components/Header' import HowToCard from './Components/HowToCard' import Signup from './Components/Signup' -import formSchema from './Components/Validation/FormSchema' import Login from './Components/Login' -import SearchBar from './Components/SearchBar' import AddHowToForm from './Components/AddHowToForm' import EditHowToForm from './Components/EditHowToForm' +import SearchBar from './Components/SearchBar' +import Dropdown from './Components/Dropdown' +import Delete from './Components/Delete' import styled, { keyframes } from 'styled-components' - - - -const StyledCardsDiv = styled.div` -display:flex; -flex-direction: column; -align-items: center; -.cardsHeading{ - display: flex; - justify-content: space-between; - align-items: center; - color: white; - background: black; - width: 100%; - h1{ - padding: 5px 15px; - font-size: 1.5rem; - } - form{ - select{ - color: white; - font-size: 1.3rem; - background: black; - border: 0px solid silver; - option{ - font-size: 2rem; - } - } - } - h3{ - padding: 5px; - font-size: 1rem; - } -} -h2{ - font-size: 2rem; -} -` - const StyledBody = styled.div` background: url( 'https://images.unsplash.com/photo-1579546929518-9e396f3cc809?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1950&q=80' @@ -99,6 +61,9 @@ padding: 2%; width: 95%; ` const kfLogo = keyframes` +25%{ + border: 1px dotted gray; +} 100%{ background teal; color: black; @@ -107,7 +72,7 @@ const kfLogo = keyframes` ` const StyledLogo = styled.img` width: 20%; -border: 1px solid gray; +border: 1px dotted gray; border-radius: 50% 50%; margin: 150px 0px 32px 0px; color: white; @@ -117,6 +82,31 @@ box-shadow: 0px 0px 80px 1px; animation: ${kfLogo} 1.3s ease-in-out forwards; ` +const StyledCardsDiv = styled.div` +display:flex; +flex-direction: column; +align-items: center; +.cardsHeading{ + display: flex; + justify-content: space-between; + align-items: center; + color: white; + background: black; + width: 100%; + h1{ + padding: 5px 15px; + font-size: 1.5rem; + } + h3{ + padding: 5px; + font-size: 1rem; + } +} +h2{ + font-size: 2rem; +} +` + /////////////////////////////////(╯°□°)╯︵ ┻━┻ @@ -136,7 +126,8 @@ const initialLogIn = { } const initialHowToForm = { - username: '', + title: '', + author: '', topic: '', steps: '', } @@ -160,6 +151,7 @@ function App(props) { const [formErrors, setFormErrors] = useState(initialFormErrors) const [disabled, setDisabled] = useState(initialDisabled) const [users, setUser] = useState(initialUsers) + const [login, setLogin] = useState(initialLogIn) /////////////////////////////// //HowToCardStates(╯°□°)╯︵ ┻━┻ @@ -189,6 +181,7 @@ function App(props) { }) .catch(err => { console.log(err) + debugger }) } @@ -200,6 +193,7 @@ function App(props) { }) .catch(err => { console.log(err) + debugger }) } //////////////////////////////////////////////// @@ -208,9 +202,9 @@ function App(props) { //////////////FORM HELPER FUNCTIONS START HERE////// /////////////////////////////////////////////////// - const inputChange = (name, value) => { + const inputChange = (name, value, values, setValues, schema) => { yup - .reach(formSchema, name) + .reach(schema, name) .validate(value) @@ -228,8 +222,8 @@ function App(props) { }) }) - setSignUpFormValues({ - ...signUpFormValues, + setValues({ + ...values, [name]: value }) } @@ -243,7 +237,7 @@ function App(props) { password: signUpFormValues.password.trim(), email: signUpFormValues.email.trim(), } - props.postUser(newUser) + postNewUser(newUser) } const submitCard = () => { @@ -264,11 +258,11 @@ function App(props) { props.fetchHowto() }, []) - useEffect(() => { - formSchema.isValid(signUpFormValues).then(valid => { - setDisabled(!valid) - }) - }, [signUpFormValues]) + // useEffect(() => { + // formSchemaLogin.isValid(login).then(valid => { + // setDisabled(!valid) + // }) + // }, [login]) return ( @@ -285,21 +279,34 @@ function App(props) { + + + + - {/* A workable link is commented out inside the Header Component */} + @@ -307,9 +314,11 @@ function App(props) { @@ -319,7 +328,15 @@ function App(props) { - + @@ -332,17 +349,13 @@ function App(props) {

Popular How To's!

- - -
- + + {props.isLoading &&

LOADING...

} {props.error && (

ERROR {this.props.error}

)} diff --git a/howto/src/Components/AddHowToForm.js b/howto/src/Components/AddHowToForm.js index bc6d7c2..4748dc0 100644 --- a/howto/src/Components/AddHowToForm.js +++ b/howto/src/Components/AddHowToForm.js @@ -1,25 +1,27 @@ -import React from 'react' +import React, { useEffect } from 'react' import styled from 'styled-components' +import formSchemaCard from './Validation/FormSchemaCard' + +import Logo from './Logo' const StyledAddForm = styled.form` display: flex; flex-direction: column; align-items: center; -width: 30%; -margin: 20px;; -padding: 30px; +width: 27%; + +padding: 16px; color: white; font-size: 1.3rem; text-align: center; -background: black; +background: url('https://images.unsplash.com/photo-1557683311-eac922347aa1?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=2030&q=80'); border-radius: 20% 20%; h2{ - } input { display: flex; - color: lightblue; + color: white; font-size: 2rem; background: black; border-radius: 10px; @@ -27,24 +29,33 @@ input { } #stepsInput{ display: flex; - } - button{ color: white; - background: green; + background: violet; width: 40%; padding: 5px; border-radius: 15px; + &:hover{ + cursor: pointer; + background: gold; + } } ` export default function AddHowToForm(props){ - const { inputChange, submit, disabled, errors } = props + const { + values, + setValues, + inputChange, + submit, + disabled, + setDisabled, + errors } = props const onInputChange = e =>{ const { name, value } = e.target - inputChange(name, value) + inputChange(name, value, values, setValues, formSchemaCard) } const onSubmit = e =>{ @@ -52,6 +63,12 @@ export default function AddHowToForm(props){ submit() } + useEffect(() => { + formSchemaCard.isValid(values).then(valid => { + setDisabled(!valid) + }) + }, [values]) + return( {errors.topic}
{errors.steps}
+ +

Create a How To

-