addd code review changes
This commit is contained in:
1 parent
5bf3f8694c
commit
0a075632c3
15 files changed
+640
-234
No files matched your search
@@ -4,10 +4,11 @@ import { useTheme } from "../theme/useTheme";
|
||||
import "../style/navbar.css";
|
||||
|
||||
function SharedNavbar({ variant = "hero", active = "", brandMode = "logo" }) {
|
||||
const { cart, openCart, openProfile, user } = useShop();
|
||||
const { cart, openCart, openProfile, panelOpen, panelType, user } = useShop();
|
||||
const { isLight, toggleTheme } = useTheme();
|
||||
const cartCount = cart.total_quantity || 0;
|
||||
const cartLabel = cartCount > 0 ? `Warenkorb ${cartCount}` : "Warenkorb";
|
||||
const cartCompactLabel = cartCount > 0 ? `Korb ${cartCount}` : "Korb";
|
||||
const cartAriaLabel =
|
||||
cartCount > 0
|
||||
? `Warenkorb mit ${cartCount} ${cartCount === 1 ? "Artikel" : "Artikeln"} öffnen`
|
||||
@@ -44,18 +45,25 @@ function SharedNavbar({ variant = "hero", active = "", brandMode = "logo" }) {
|
||||
</Link>
|
||||
<button
|
||||
type="button"
|
||||
className="nav-link nav-button"
|
||||
className="nav-link nav-button nav-link--cart"
|
||||
onClick={openCart}
|
||||
aria-haspopup="dialog"
|
||||
aria-controls="shop-drawer"
|
||||
aria-expanded={panelOpen && panelType === "cart"}
|
||||
aria-label={cartAriaLabel}
|
||||
>
|
||||
{cartLabel}
|
||||
<span className="nav-label nav-label--full">{cartLabel}</span>
|
||||
<span className="nav-label nav-label--compact">
|
||||
{cartCompactLabel}
|
||||
</span>
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className="nav-link nav-button"
|
||||
onClick={openProfile}
|
||||
aria-haspopup="dialog"
|
||||
aria-controls="shop-drawer"
|
||||
aria-expanded={panelOpen && panelType === "profile"}
|
||||
aria-label={user ? "Profil öffnen" : "Anmelden oder Profil öffnen"}
|
||||
>
|
||||
Profil
|
||||
@@ -64,7 +72,7 @@ function SharedNavbar({ variant = "hero", active = "", brandMode = "logo" }) {
|
||||
type="button"
|
||||
className={`nav-link nav-button nav-theme-switch ${isLight ? "is-light" : ""}`}
|
||||
onClick={toggleTheme}
|
||||
aria-label={isLight ? "Zum Dark Mode wechseln" : "Zum Light Mode wechseln"}
|
||||
aria-label="Light Mode"
|
||||
aria-pressed={isLight}
|
||||
>
|
||||
<span className="nav-theme-switch__track" aria-hidden="true">
|
||||
|
||||
Reference in new issue
Block a user