Skip to content

Commit

Permalink
Merge pull request #125 from the-collab-lab/feature/updateButtonsWith…
Browse files Browse the repository at this point in the history
…Component

Feature/update buttons with component
  • Loading branch information
flbarfield committed Apr 6, 2024
2 parents ca13b84 + c3562a0 commit e970f96
Show file tree
Hide file tree
Showing 11 changed files with 153 additions and 84 deletions.
71 changes: 41 additions & 30 deletions src/components/AddItemForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,14 @@ export default function AddItemForm({ listPath, data }) {
return (
<section className="addItemSection">
<header className="addItemHeader">
<div className="squareButtonContainer">
<div className="buttonBackSquare"></div>
<button
className={(addItemToggle, 'addItemButton, buttonSquare')}
onClick={(e) => handleAddItemToggle(e)}
>
{addItemToggle}
</button>
</div>
<Button
className={(addItemToggle, 'addItemButton')}
fn={(e) => handleAddItemToggle(e)}
color="#89D2FF"
text={addItemToggle}
buttonWidth="55px"
shadowAndContainerWidth="63px"
/>

<h2 data-testid="addItemForm-header" id="addItemH2">
Add Item
Expand All @@ -100,37 +99,49 @@ export default function AddItemForm({ listPath, data }) {
</div>
<h4>When would you like a reminder to buy this item?</h4>
<div className="addItemButtonGroup">
<button
className={'durationButton'}
onClick={(e) => {
<Button
className="durationButton"
fn={(e) => {
handleSelection(e);
}}
value={7}
data-testId="replaceTime"
>
7 Days
</button>
<button
className={'durationButton'}
onClick={(e) => {
testId="replaceTime"
text="7 Days"
shadowAndContainerWidth="110px"
buttonWidth="102px"
/>

<Button
className="durationButton"
fn={(e) => {
handleSelection(e);
}}
value={14}
>
14 Days
</button>
<button
className={'durationButton'}
onClick={(e) => {
text="14 Days"
shadowAndContainerWidth="110px"
buttonWidth="102px"
/>

<Button
className="durationButton"
fn={(e) => {
handleSelection(e);
}}
value={30}
>
30 Days
</button>
text="30 Days"
shadowAndContainerWidth="110px"
buttonWidth="102px"
/>
</div>
<div>
<Button text="Add Item" testId="submit-button" color="#DCFF4B" />
<div className="formButtonContainer">
<Button
color="#DCFF4B"
value={7}
testId="submit-button"
text="Add Item"
shadowAndContainerWidth="163px"
buttonWidth="155px"
/>
</div>
<div>
<h6 data-testid="addItemFormMessage">{message}</h6>
Expand Down
12 changes: 10 additions & 2 deletions src/components/AddListForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,16 @@ export default function AddListForm({ setListPath }) {
List Name
</label>
<input id="newListName" name="newListName" onChange={handleChange} />
<Button text="Create List" type="submit" color="#89D2FF" />
{message && <small>{message}</small>}
<div className="formButtonContainer">
<Button
text="Create List"
type="submit"
color="#89D2FF"
shadowAndContainerWidth="163px"
buttonWidth="155px"
/>
</div>
<h6>{message}</h6>
</form>
</div>
</div>
Expand Down
27 changes: 17 additions & 10 deletions src/components/Button.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,24 @@ export default function Button({
fn,
testId,
buttonWidth,
shadowAndContainerWidth,
}) {
return (
<button
className={className}
value={value}
type={type}
onClick={fn}
style={{ backgroundColor: color, width: buttonWidth }}
data-testid={testId}
>
{text}
</button>
<div className="buttonContainer" style={{ width: shadowAndContainerWidth }}>
<span
className="buttonBack"
style={{ width: shadowAndContainerWidth }}
></span>
<button
className={className}
value={value}
type={type}
onClick={fn}
style={{ backgroundColor: color, width: buttonWidth }}
data-testid={testId}
>
{text}
</button>
</div>
);
}
10 changes: 5 additions & 5 deletions src/components/ListItem.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React, { useState } from 'react';
import { updateItem } from '../api/firebase';
import { useMutation } from 'react-query';
import Button from './Button';
import { getNextPurchasedDate } from '../utils';
import { deleteItem } from '../api/firebase';
import { compareIfDateIsLessThan24Hours, getDaysBetweenDates } from '../utils';
Expand Down Expand Up @@ -94,23 +93,24 @@ export function ListItem({ item, listPath }) {

return (
<div className="listItemRow">
<div className="checkboxBackground">
<span className="checkboxBackground">
<input
type="checkbox"
id={id}
name="item"
checked={isDisabled}
onChange={handleCheckboxCheck}
/>
</div>
</span>
<div className="nameAndUrgency">
<p className="listItemName">{name}</p>
<p className="listItemUrgency">{urgency}</p>
</div>
<div className="squareButtonContainer">
<div className="deleteButtonContainer">
<div className="buttonBackSquare"></div>

<button
className="buttonSquare buttonDelete"
className="buttonDelete"
onClick={() => {
handleDeleteItem();
}}
Expand Down
8 changes: 7 additions & 1 deletion src/components/ListSearchItems.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,13 @@ export default function ListSearchItems({ data, listPath }) {
/>
</form>

<Button text="Clear" fn={clearSearch} color="#DCFF4B" />
<Button
text="Clear"
fn={clearSearch}
color="#DCFF4B"
shadowAndContainerWidth="100px"
buttonWidth="92px"
/>
</div>
)}

Expand Down
14 changes: 9 additions & 5 deletions src/components/SelectListForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,15 @@ export default function SelectListForm({
);
})}
</select>
<Button
text="View List"
fn={() => navigate('/list')}
color="#DCFF4B"
/>
<div className="formButtonContainer">
<Button
text="View List"
fn={() => navigate('/list')}
color="#DCFF4B"
shadowAndContainerWidth="163px"
buttonWidth="155px"
/>
</div>
</form>
</div>
)}
Expand Down
14 changes: 9 additions & 5 deletions src/components/ShareForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,15 @@ const ShareForm = ({ listPath }) => {
</div>

<div>
<Button
text="Send List"
color="#89D2FF"
testId="shareForm-submit-button"
/>
<div className="formButtonContainer">
<Button
text="Send List"
color="#89D2FF"
testId="shareForm-submit-button"
shadowAndContainerWidth="163px"
buttonWidth="155px"
/>
</div>
</div>
<h6 data-testid="shareForm-validation-message">{message}</h6>
{isSuccess && (
Expand Down
54 changes: 30 additions & 24 deletions src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ select,
option,
label,
small,
button {
button,
p {
font-family: 'Work Sans';
margin: 0px;
}
Expand Down Expand Up @@ -112,28 +113,44 @@ small {
form {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
width: 90%;
}
.form {
display: flex;
justify-content: center;
}

.formButtonContainer {
display: flex;
justify-content: center;
width: 100%;
}

.formButtonContainer {
display: flex;
justify-content: center;
width: 100%;
}

.buttonContainer,
.squareButtonContainer {
.deleteButtonContainer {
display: grid;
justify-content: center;
}

.buttonContainer > *,
.squareButtonContainer > * {
.deleteButtonContainer > * {
grid-column-start: 1;
grid-row-start: 1;
}

button {
width: 150px;
/* width: 150px; */
height: 55px;
/* padding: 0px 30px 0px 30px; */
font-size: 20px;
border: 2px solid black;
white-space: nowrap;
}
.buttonBack {
width: 158px;
Expand All @@ -145,14 +162,6 @@ button:hover {
transform: translate(8px, 8px);
}

.buttonSquare {
height: 55px;
width: 55px;
background-color: var(--blue);
color: white;
font-size: 40px;
}

.buttonBackSquare {
width: 63px;
height: 63px;
Expand All @@ -166,12 +175,17 @@ button:hover {
input,
select {
border: solid 2px black;
width: 100%;
padding: 15px;
}

input:focus {
outline: var(--black);
}

#itemName {
width: clamp(200px, 80%, 600px);
}
.form {
padding-bottom: 10px;
}
Expand All @@ -181,11 +195,7 @@ input:focus {
}

form > * {
margin: 10px;
}

.sideBySide-section {
border: 1px solid black;
margin: 10px 0px 10px 0px;
}

@media screen and (min-width: 780px) {
Expand All @@ -210,13 +220,9 @@ form > * {
h4,
label {
font-size: 22px;
text-align: left;
text-align: center;
}

/* input {
font-size: 40px;
} */

h5,
label[for='email'],
label[for='itemName'],
Expand Down
4 changes: 4 additions & 0 deletions src/views/Home.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
h4,
label {
text-align: center;
}
Loading

0 comments on commit e970f96

Please sign in to comment.