-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from include-davis/feat/delivery-form
Implement DeliveryFormSection component
- Loading branch information
Showing
14 changed files
with
481 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
...(pages)/checkout/_components/CheckoutForm/DeliveryFormSection/Address/Address.module.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
.input_group { | ||
display: flex; | ||
gap: var(--small-spacer); | ||
} | ||
|
||
.address { | ||
display: flex; | ||
flex-direction: column; | ||
gap: var(--small-spacer); | ||
|
||
.add_field { | ||
color: var(--tertiary); | ||
cursor: pointer; | ||
} | ||
} |
62 changes: 62 additions & 0 deletions
62
app/(pages)/checkout/_components/CheckoutForm/DeliveryFormSection/Address/Address.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import InputField from '../InputField/InputField'; | ||
|
||
import { useState } from 'react'; | ||
import { IoIosSearch } from 'react-icons/io'; | ||
|
||
import styles from './Address.module.scss'; | ||
|
||
export default function Address({ | ||
updateShippingField, | ||
}: { | ||
updateShippingField: (property: string, value: string) => void; | ||
}) { | ||
const [isFieldAdded, setFieldAdded] = useState(false); | ||
|
||
return ( | ||
<> | ||
<div className={styles.address}> | ||
<InputField | ||
label="Address" | ||
name="address" | ||
type="text" | ||
icon={IoIosSearch} | ||
handleFieldChange={updateShippingField} | ||
/> | ||
{!isFieldAdded && ( | ||
<div onClick={() => setFieldAdded(true)} className={styles.add_field}> | ||
+ Add apartment, suite, etc. | ||
</div> | ||
)} | ||
{isFieldAdded && ( | ||
<InputField | ||
label="Apartment, suite, etc. (optional)" | ||
name="apartment" | ||
type="text" | ||
handleFieldChange={updateShippingField} | ||
/> | ||
)} | ||
</div> | ||
<div className={styles.input_group}> | ||
<InputField | ||
label="City" | ||
name="city" | ||
type="text" | ||
handleFieldChange={updateShippingField} | ||
/> | ||
<InputField | ||
label="State" | ||
name="state" | ||
type="select" | ||
list={['CA']} | ||
handleFieldChange={updateShippingField} | ||
/> | ||
<InputField | ||
label="ZIP code" | ||
name="zip" | ||
type="text" | ||
handleFieldChange={updateShippingField} | ||
/> | ||
</div> | ||
</> | ||
); | ||
} |
8 changes: 8 additions & 0 deletions
8
...es)/checkout/_components/CheckoutForm/DeliveryFormSection/DeliveryFormSection.module.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
@use "app/(pages)/_globals/mixins"; | ||
|
||
.delivery_form { | ||
display: flex; | ||
flex-direction: column; | ||
gap: var(--small-spacer); | ||
padding: var(--spacer); | ||
} |
16 changes: 16 additions & 0 deletions
16
app/(pages)/checkout/_components/CheckoutForm/DeliveryFormSection/DeliveryFormSection.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
'use client'; | ||
|
||
import DeliveryOptions from './DeliveryOptions/DeliveryOptions'; | ||
import ShippingInfo from './ShippingInfo/ShippingInfo'; | ||
|
||
import styles from './DeliveryFormSection.module.scss'; | ||
|
||
export default function DeliveryFormSection() { | ||
return ( | ||
<form className={styles.delivery_form}> | ||
<h2 className={styles.heading}>Delivery</h2> | ||
<DeliveryOptions /> | ||
<ShippingInfo /> | ||
</form> | ||
); | ||
} |
46 changes: 46 additions & 0 deletions
46
.../_components/CheckoutForm/DeliveryFormSection/DeliveryOptions/DeliveryOptions.module.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
.delivery_options { | ||
border: none; | ||
border-radius: var(--b-radius); | ||
background-color: white; | ||
|
||
.opt { | ||
display: flex; | ||
align-items: center; | ||
gap: var(--tiny-spacer); | ||
padding: var(--small-spacer); | ||
border: var(--b-input); | ||
border-radius: var(--b-radius); | ||
|
||
&:has(> input:checked) { | ||
background-color: var(--tertiary-light); | ||
border: 1px solid var(--tertiary); | ||
outline: none; | ||
accent-color: var(--tertiary); | ||
} | ||
|
||
&:first-child { | ||
border-bottom-left-radius: 0; | ||
border-bottom-right-radius: 0; | ||
|
||
&:not(:has(> input:checked)) { | ||
border-bottom: none; | ||
} | ||
} | ||
|
||
&:last-child { | ||
border-top-left-radius: 0; | ||
border-top-right-radius: 0; | ||
|
||
&:not(:has(> input:checked)) { | ||
border-top: none; | ||
} | ||
} | ||
|
||
.icon { | ||
font-size: var(--icon-input-size); | ||
margin-left: auto; | ||
color: var(--tertiary); | ||
fill: var(--tertiary); | ||
} | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
...checkout/_components/CheckoutForm/DeliveryFormSection/DeliveryOptions/DeliveryOptions.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { ElementType } from 'react'; | ||
import { CiDeliveryTruck } from 'react-icons/ci'; | ||
import { PiHouseLineLight } from 'react-icons/pi'; | ||
|
||
import styles from './DeliveryOptions.module.scss'; | ||
|
||
export default function DeliveryOptions() { | ||
return ( | ||
<fieldset className={styles.delivery_options}> | ||
<Option | ||
label="Ship" | ||
value="ship" | ||
icon={CiDeliveryTruck} | ||
isDefault={true} | ||
/> | ||
<Option label="Pick up" value="pickUp" icon={PiHouseLineLight} /> | ||
</fieldset> | ||
); | ||
} | ||
|
||
function Option({ | ||
label, | ||
value, | ||
isDefault, | ||
icon: Icon, | ||
}: { | ||
label: string; | ||
value: string; | ||
isDefault?: boolean; | ||
icon?: ElementType; | ||
}) { | ||
return ( | ||
<div className={styles.opt}> | ||
<input | ||
type="radio" | ||
id={value} | ||
value={value} | ||
name="delivery_opt" | ||
defaultChecked={isDefault} | ||
/> | ||
<label htmlFor={value}>{label}</label> | ||
{Icon && <Icon className={styles.icon} />} | ||
</div> | ||
); | ||
} |
62 changes: 62 additions & 0 deletions
62
...)/checkout/_components/CheckoutForm/DeliveryFormSection/InputField/InputField.module.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
.input_field { | ||
position: relative; | ||
width: 100%; | ||
|
||
input, select { | ||
padding: var(--small-spacer) var(--small-spacer) ; | ||
width: 100%; | ||
border: var(--b-input); | ||
border-radius: var(--b-radius); | ||
transition: 250ms; | ||
|
||
&:focus { | ||
border: var(--b-input-focus); | ||
outline: none; | ||
} | ||
|
||
&.invalid, | ||
&::placeholder { | ||
color: var(--text-grey); | ||
} | ||
} | ||
|
||
/* remove default Safari styling */ | ||
select { | ||
-webkit-appearance: none; | ||
appearance: none; | ||
} | ||
|
||
.icon { | ||
font-size: var(--icon-input-size); | ||
fill: var(--text-grey); | ||
position: absolute; | ||
right: var(--small-spacer); | ||
top: 50%; | ||
transform: translateY(-50%); | ||
} | ||
|
||
label { | ||
position: absolute; | ||
top: var(--tiny-spacer); | ||
left: var(--small-spacer); | ||
color: var(--text-grey); | ||
transition: transform 250ms; | ||
transform-origin: left center; | ||
} | ||
|
||
select.valid + label, | ||
input:not(:placeholder-shown) + label { | ||
transform: translateY(-10%) scale(0.75); | ||
} | ||
|
||
select.valid, | ||
input:not(:placeholder-shown) { | ||
padding-top: var(--spacer); | ||
padding-bottom: var(--tiny-spacer); | ||
} | ||
|
||
select.invalid + label, | ||
input:placeholder-shown + label { | ||
display: none; | ||
} | ||
} |
Oops, something went wrong.