-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Abstracted header into component, removed unneccessary comments and i…
…mports
- Loading branch information
1 parent
4718008
commit 36cd904
Showing
8 changed files
with
96 additions
and
235 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
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,63 @@ | ||
import { | ||
IonBackButton, | ||
IonButton, | ||
IonButtons, | ||
IonHeader, | ||
IonTitle, | ||
IonToolbar, | ||
} from "@ionic/react"; | ||
import { useHistory } from "react-router"; | ||
|
||
export const Header = ({ | ||
hasBackButton = false, | ||
backButton = undefined, | ||
hasCartButton = false, | ||
hasTitleImage = true, | ||
large = false, | ||
toolbarClassName = "", | ||
}) => { | ||
const history = useHistory(); | ||
return ( | ||
<IonHeader collapse={large ? "condense" : undefined}> | ||
<IonToolbar className={toolbarClassName}> | ||
{hasBackButton && ( | ||
<> | ||
{backButton !== undefined ? ( | ||
<>{backButton}</> | ||
) : ( | ||
<IonButtons slot="start"> | ||
<IonBackButton defaultHref="/" /> | ||
</IonButtons> | ||
)} | ||
</> | ||
)} | ||
<IonTitle size={large ? "large" : "small"}> | ||
{hasTitleImage && ( | ||
<img | ||
src="assets/chopchop.svg" | ||
height="28px" | ||
width="144px" | ||
alt="Chop Chop" | ||
/> | ||
)} | ||
</IonTitle> | ||
{hasCartButton && ( | ||
<IonButtons slot="end"> | ||
<IonButton | ||
onClick={(e) => { | ||
history.push("/cart"); | ||
}} | ||
> | ||
<img | ||
src="assets/cart.svg" | ||
height="28px" | ||
width="44px" | ||
alt="Cart" | ||
/> | ||
</IonButton> | ||
</IonButtons> | ||
)} | ||
</IonToolbar> | ||
</IonHeader> | ||
); | ||
}; |
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
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
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
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
Oops, something went wrong.