Compare commits

..

3 Commits

Author SHA1 Message Date
maja
e476e36855 zmena pro lidi 2026-11-25 17:36:29 +01:00
Ondur
69a8138226 objednavky 2026-11-18 18:14:43 +01:00
Ondur
b6f81a12ea ZMENY 2026-11-18 17:47:44 +01:00
14 changed files with 6182 additions and 2112 deletions

View File

@@ -1,19 +1,41 @@
@inherits LayoutComponentBase @inherits LayoutComponentBase
<div class="page"> <div class="page public-layout">
<aside class="sidebar">
<NavMenu />
</aside>
<main class="main-content"> <a href="#public-main-content"
<article class="content"> class="public-skip-link visually-hidden-focusable">
Přeskočit na hlavní obsah
</a>
<header class="sidebar public-header">
<NavMenu />
</header>
<main id="public-main-content"
class="main-content public-main"
tabindex="-1">
<article class="content public-container">
@Body @Body
</article> </article>
</main> </main>
</div> </div>
<div id="blazor-error-ui" data-nosnippet> <div id="blazor-error-ui" data-nosnippet>
Nastala neočekávaná chyba. <span role="alert">
<a href="." class="reload">Obnovit stránku</a> Nastala neočekávaná chyba.
<span class="dismiss">✕</span> </span>
<a href="." class="reload">
Obnovit stránku
</a>
<button type="button"
class="dismiss"
aria-label="Zavřít chybové hlášení"
style="background: none; border: none; color: inherit;">
&#215;
</button>
</div> </div>

View File

@@ -1,98 +1,406 @@
.page { /* ========================================
SKOLNI JARMARK - PUBLIC LAYOUT
======================================== */
.page.public-layout {
--public-primary: #244b36;
--public-primary-hover: #193b29;
--public-secondary: #e6eddf;
--public-background: #f7f7f2;
--public-surface: #ffffff;
--public-text: #26372b;
--public-muted: #59665b;
--public-border: #dce3d9;
--public-radius-sm: 4px;
--public-radius-md: 8px;
--public-radius-lg: 12px;
--public-space-1: 4px;
--public-space-2: 8px;
--public-space-3: 12px;
--public-space-4: 16px;
--public-space-5: 20px;
--public-space-6: 24px;
--public-space-8: 32px;
--public-space-12: 48px;
--public-space-16: 64px;
position: relative;
display: flex; display: flex;
min-height: 100vh; flex-direction: column;
background: #f7f9f5; align-items: stretch;
} width: 100%;
.sidebar {
width: 260px;
min-width: 260px;
min-height: 100vh;
position: sticky;
top: 0;
align-self: flex-start;
z-index: 100;
background: #ffffff;
border-right: 1px solid #e8ede5;
}
.main-content {
flex: 1;
min-width: 0; min-width: 0;
min-height: 100vh; min-height: 100vh;
background: #f7f9f5; min-height: 100dvh;
margin: 0;
padding: 0;
background: var(--public-background);
color: var(--public-text);
font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
font-size: 16px;
line-height: 1.6;
box-sizing: border-box;
} }
.content {
width: 100%; /* ========================================
max-width: 1600px; BOX SIZING
margin: 0 auto; ======================================== */
padding: 30px 35px !important;
.public-layout,
.public-layout ::deep *,
.public-layout ::deep *::before,
.public-layout ::deep *::after {
box-sizing: border-box;
} }
/* ========================================
PUBLIC HEADER - OVERLAP FIX
======================================== */
.public-layout > .sidebar.public-header {
position: relative !important;
top: auto !important;
right: auto !important;
bottom: auto !important;
left: auto !important;
display: block;
flex: 0 0 auto;
align-self: stretch;
width: 100% !important;
min-width: 0 !important;
max-width: 100%;
height: auto !important;
min-height: 0 !important;
max-height: none;
margin: 0;
padding: 0;
background: var(--public-surface);
border-right: none !important;
border-bottom: 1px solid var(--public-border);
transform: none;
z-index: 100;
}
/* ========================================
NAVIGATION CONTAINER
======================================== */
.public-header ::deep .nav-panel {
position: relative;
width: 100%;
min-width: 0;
height: auto;
min-height: 68px;
max-height: none;
margin: 0 auto;
}
.public-header ::deep .nav-scrollable {
position: static;
height: auto;
min-height: 0;
max-height: none;
overflow: visible;
}
/* ========================================
MAIN CONTENT - OVERLAP FIX
======================================== */
.public-layout > .main-content.public-main {
position: relative !important;
top: auto;
left: auto;
right: auto;
bottom: auto;
display: block;
flex: 1 0 auto;
width: 100% !important;
min-width: 0;
max-width: 100%;
height: auto;
min-height: 0;
margin: 0 !important;
padding: 0 !important;
background: var(--public-background);
transform: none;
scroll-margin-top: 16px;
}
/* ========================================
CONTENT CONTAINER
======================================== */
.public-main > .content.public-container {
position: relative;
display: block;
width: 100%;
max-width: 1440px;
min-width: 0;
margin: 0 auto !important;
padding: 32px 32px 64px !important;
box-sizing: border-box;
}
/* ========================================
TYPOGRAPHY
======================================== */
.public-container ::deep h1,
.public-container ::deep h2,
.public-container ::deep h3 {
color: var(--public-text);
font-family: Georgia, "Times New Roman", serif;
font-weight: 700;
line-height: 1.2;
letter-spacing: normal;
}
.public-container ::deep h1 {
font-size: clamp(28px, 4vw, 44px);
}
.public-container ::deep h2 {
font-size: clamp(24px, 3vw, 32px);
}
.public-container ::deep h3 {
font-size: clamp(18px, 2vw, 24px);
}
.public-container ::deep p {
line-height: 1.6;
}
/* ========================================
LINKS
======================================== */
.public-container ::deep a {
text-underline-offset: 3px;
}
/* ========================================
KEYBOARD ACCESSIBILITY
======================================== */
.public-layout ::deep a:focus-visible,
.public-layout ::deep button:focus-visible,
.public-layout ::deep input:focus-visible,
.public-layout ::deep select:focus-visible,
.public-layout ::deep textarea:focus-visible,
.public-layout ::deep [tabindex]:focus-visible {
outline: 3px solid #527b49;
outline-offset: 3px;
}
.public-main:focus-visible {
outline: 3px solid #527b49;
outline-offset: -3px;
}
/* ========================================
SKIP NAVIGATION LINK
======================================== */
.public-skip-link {
position: absolute;
top: 12px;
left: 12px;
z-index: 1100;
width: 1px;
height: 1px;
padding: 0;
overflow: hidden;
clip-path: inset(50%);
white-space: nowrap;
}
.public-skip-link:focus {
width: auto;
height: auto;
padding: 12px 16px;
overflow: visible;
clip-path: none;
background: var(--public-primary);
color: #ffffff;
border-radius: var(--public-radius-md);
font-size: 14px;
font-weight: 600;
text-decoration: none;
white-space: normal;
}
/* ========================================
BLAZOR ERROR MESSAGE
======================================== */
#blazor-error-ui { #blazor-error-ui {
color-scheme: light; display: none;
position: fixed;
left: 0;
right: 0;
bottom: 0;
z-index: 1000;
width: 100%;
padding: 16px 56px 16px 24px;
background: #fff4d6; background: #fff4d6;
color: #58451b; color: #58451b;
bottom: 0; border-top: 1px solid #e5d4a1;
box-shadow: 0 -2px 15px rgba(0, 0, 0, .08);
box-sizing: border-box; box-sizing: border-box;
display: none; color-scheme: light;
left: 0; font-size: 14px;
padding: 14px 25px; line-height: 1.5;
position: fixed;
width: 100%;
z-index: 1000;
border-top: 1px solid #f0dfb4;
} }
#blazor-error-ui .reload { #blazor-error-ui .reload {
color: #315b3e; display: inline-block;
font-weight: 700;
margin-left: 8px; margin-left: 8px;
color: #244b36;
font-weight: 700;
text-decoration: underline;
} }
#blazor-error-ui .dismiss { #blazor-error-ui .dismiss {
cursor: pointer;
position: absolute; position: absolute;
right: 18px; top: 50%;
top: 12px; right: 8px;
transform: translateY(-50%);
display: flex;
align-items: center;
justify-content: center;
width: 44px;
height: 44px;
padding: 0;
background: transparent;
color: #58451b;
border: none;
border-radius: 4px;
font-size: 24px;
cursor: pointer;
} }
@media (max-width: 640.98px) { #blazor-error-ui .dismiss:focus-visible,
.page { #blazor-error-ui .reload:focus-visible {
outline: 3px solid #527b49;
outline-offset: 2px;
}
/* ========================================
TABLET - MAX 1024 PX
======================================== */
@media (max-width: 1024px) {
.public-main > .content.public-container {
padding: 24px 24px 48px !important;
}
.public-layout > .sidebar.public-header {
position: relative !important;
width: 100% !important;
height: auto !important;
min-height: 0 !important;
}
}
/* ========================================
MOBILE - MAX 640 PX
======================================== */
@media (max-width: 640px) {
.page.public-layout {
flex-direction: column; flex-direction: column;
width: 100%;
font-size: 15px;
} }
.sidebar { .public-layout > .sidebar.public-header {
width: 100%; position: relative !important;
top: auto !important;
width: 100% !important;
min-width: 0 !important;
height: auto !important;
min-height: 0 !important;
}
.public-layout > .main-content.public-main {
width: 100% !important;
min-width: 0; min-width: 0;
min-height: auto; margin: 0 !important;
position: relative; padding: 0 !important;
border-right: none;
border-bottom: 1px solid #e8ede5;
} }
.main-content { .public-main > .content.public-container {
width: 100%; width: 100%;
padding: 16px 16px 32px !important;
} }
.content { .public-container ::deep h1 {
padding: 18px 15px !important; font-size: 28px;
}
.public-container ::deep h2 {
font-size: 24px;
}
.public-container ::deep h3 {
font-size: 20px;
}
#blazor-error-ui {
padding: 12px 56px 12px 16px;
}
#blazor-error-ui .reload {
margin-left: 0;
margin-top: 4px;
}
}
/* ========================================
SMALL MOBILE - MAX 360 PX
======================================== */
@media (max-width: 360px) {
.public-main > .content.public-container {
padding: 12px 12px 24px !important;
}
.public-container ::deep h1 {
font-size: 26px;
} }
} }
@media (min-width: 641px) {
.sidebar { /* ========================================
height: 100vh; REDUCED MOTION
} ======================================== */
}
@media (prefers-reduced-motion: reduce) { @media (prefers-reduced-motion: reduce) {
*,
*::before, .public-layout,
*::after { .public-layout ::deep *,
.public-layout ::deep *::before,
.public-layout ::deep *::after {
scroll-behavior: auto !important; scroll-behavior: auto !important;
animation-duration: 0.01ms !important;
animation-iteration-count: 1 !important;
transition-duration: 0.01ms !important;
} }
} }

View File

@@ -5,112 +5,208 @@
<div class="nav-brand-area"> <div class="nav-brand-area">
<a class="navbar-brand" href="/"> <a class="navbar-brand" href="/">
<span class="brand-symbol">🌿</span>
<svg class="brand-symbol"
width="32"
height="32"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.6"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true">
<path d="M20 4C10 4 5 8 5 15
c0 3 2 5 5 5
C17 20 20 12 20 4Z" />
<path d="M3 22L15 10" />
</svg>
<span class="brand-text"> <span class="brand-text">
<strong>Školní jarmark</strong> <strong>Školní jarmark</strong>
<small>ONLINE KATALOG</small>
</span> </span>
</a> </a>
</div> </div>
<input type="checkbox" <input type="checkbox"
title="Navigation menu" id="public-menu-toggle"
title="Navigační menu"
aria-label="Rozbalit nebo sbalit navigační menu"
aria-controls="public-navigation"
class="navbar-toggler" /> class="navbar-toggler" />
<div class="nav-scrollable" <div class="nav-scrollable"
onclick="document.querySelector('.navbar-toggler').click()"> id="public-navigation">
<div class="nav-section-label">HLAVNÍ MENU</div> <nav class="nav public-nav-links"
aria-label="Hlavní navigace">
<nav class="nav flex-column">
<div class="nav-item"> <div class="nav-item">
<NavLink class="nav-link" <NavLink class="nav-link"
href="" href=""
Match="NavLinkMatch.All"> Match="NavLinkMatch.All"
<span class="nav-icon bi bi-house-door-fill-nav-menu"></span> onclick="document.getElementById('public-menu-toggle').checked = false">
<span>Domů</span>
</NavLink> <span>Katalog</span>
</div>
<div class="nav-item">
<NavLink class="nav-link" href="kosik">
<span class="nav-icon bi bi-cart-fill"></span>
<span>Košík</span>
</NavLink> </NavLink>
</div> </div>
<AuthorizeView Roles="Admin"> <AuthorizeView Roles="Admin">
<Authorized> <Authorized>
<div class="nav-section-label secondary-label">
SPRÁVA
</div>
<div class="nav-item"> <div class="nav-item">
<NavLink class="nav-link" href="admin"> <NavLink class="nav-link"
<span class="nav-icon bi bi-lock-nav-menu"></span> href="admin"
onclick="document.getElementById('public-menu-toggle').checked = false">
<span>Administrace</span> <span>Administrace</span>
</NavLink> </NavLink>
</div> </div>
</Authorized> </Authorized>
</AuthorizeView> </AuthorizeView>
</nav> </nav>
<div class="nav-bottom"> <div class="nav-bottom public-account-links">
<div class="nav-section-label">UŽIVATEL</div>
<AuthorizeView> <AuthorizeView>
<Authorized> <Authorized>
<div class="nav-item">
<NavLink class="nav-link" href="Account/Manage"> <div class="nav-item account-item">
<span class="nav-icon bi bi-person-fill-nav-menu"></span> <NavLink class="nav-link"
<span class="user-name">@context.User.Identity?.Name</span> href="Account/Manage"
onclick="document.getElementById('public-menu-toggle').checked = false">
<svg class="nav-icon"
width="20"
height="20"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.7"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true">
<circle cx="12"
cy="8"
r="4" />
<path d="M4 21v-2
a8 8 0 0 1 16 0
v2" />
</svg>
<span class="user-name">
@context.User.Identity?.Name
</span>
</NavLink> </NavLink>
</div> </div>
<div class="nav-item"> <div class="nav-item">
<form action="Account/Logout" method="post">
<AntiforgeryToken />
<input type="hidden" name="ReturnUrl" value="@currentUrl" />
<button type="submit" class="nav-link logout-link"> <form action="Account/Logout"
<span class="nav-icon bi bi-arrow-bar-left-nav-menu"></span> method="post">
<AntiforgeryToken />
<input type="hidden"
name="ReturnUrl"
value="@currentUrl" />
<button type="submit"
class="nav-link logout-link">
<span>Odhlásit</span> <span>Odhlásit</span>
</button> </button>
</form> </form>
</div> </div>
</Authorized> </Authorized>
<NotAuthorized> <NotAuthorized>
<div class="nav-item"> <div class="nav-item">
<NavLink class="nav-link" href="Account/Login">
<span class="nav-icon bi bi-person-badge-nav-menu"></span> <NavLink class="nav-link"
href="Account/Login"
onclick="document.getElementById('public-menu-toggle').checked = false">
<span>Přihlášení</span> <span>Přihlášení</span>
</NavLink> </NavLink>
</div> </div>
<div class="nav-item"> <div class="nav-item">
<NavLink class="nav-link" href="Account/Register">
<span class="nav-icon bi bi-person-nav-menu"></span> <NavLink class="nav-link"
href="Account/Register"
onclick="document.getElementById('public-menu-toggle').checked = false">
<span>Registrace</span> <span>Registrace</span>
</NavLink> </NavLink>
</div> </div>
</NotAuthorized> </NotAuthorized>
</AuthorizeView> </AuthorizeView>
</div> <div class="nav-item cart-item">
<NavLink class="nav-link public-cart-link"
href="kosik"
onclick="document.getElementById('public-menu-toggle').checked = false">
<svg class="nav-icon"
width="20"
height="20"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.7"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true">
<path d="M3 3h2l3.5 13h10
l3-10H6" />
<circle cx="10"
cy="20"
r="1" />
<circle cx="18"
cy="20"
r="1" />
</svg>
<span>Košík</span>
</NavLink>
<div class="nav-footer">
<span class="footer-leaf">🌱</span>
<div>
<strong>Školní jarmark</strong>
<small>Vyrobeno s radostí</small>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
@code { @code {
@@ -124,10 +220,14 @@
NavigationManager.LocationChanged += OnLocationChanged; NavigationManager.LocationChanged += OnLocationChanged;
} }
private void OnLocationChanged(object? sender, LocationChangedEventArgs e) private void OnLocationChanged(
object? sender,
LocationChangedEventArgs e)
{ {
currentUrl = NavigationManager.ToBaseRelativePath(e.Location); currentUrl = NavigationManager.ToBaseRelativePath(
StateHasChanged(); e.Location);
_ = InvokeAsync(StateHasChanged);
} }
public void Dispose() public void Dispose()

View File

@@ -1,329 +1,522 @@
/* ========================================
SKOLNI JARMARK - PUBLIC NAVIGATION
======================================== */
.nav-panel { .nav-panel {
display: flex; --nav-primary: #244b36;
flex-direction: column; --nav-primary-hover: #193b29;
width: 100%; --nav-secondary: #e6eddf;
height: 100%; --nav-text: #26372b;
min-height: 100vh; --nav-muted: #59665b;
background: #ffffff; --nav-border: #dce3d9;
color: #304536; --nav-surface: #ffffff;
} position: relative;
/* Logo */
.nav-brand-area {
height: 100px;
min-height: 100px;
display: flex; display: flex;
align-items: center; align-items: center;
padding: 0 24px; gap: 32px;
border-bottom: 1px solid #edf0e9; width: 100%;
max-width: 1440px;
min-width: 0;
min-height: 76px;
margin: 0 auto;
padding: 12px 32px;
background: var(--nav-surface);
color: var(--nav-text);
box-sizing: border-box;
}
/* ========================================
BRAND
======================================== */
.nav-brand-area {
display: flex;
align-items: center;
flex-shrink: 0;
min-width: 0;
} }
.navbar-brand { .navbar-brand {
display: flex; display: inline-flex;
align-items: center; align-items: center;
gap: 12px; gap: 8px;
color: #294c35 !important; min-height: 44px;
margin: 0;
padding: 0;
color: var(--nav-primary);
text-decoration: none; text-decoration: none;
transition: opacity .2s ease;
} }
.navbar-brand:hover { .navbar-brand:hover {
opacity: .8; color: var(--nav-primary-hover);
} }
.brand-symbol { .brand-symbol {
display: grid; display: block;
place-items: center; width: 32px;
width: 45px; height: 32px;
height: 45px;
flex-shrink: 0; flex-shrink: 0;
border-radius: 15px; color: var(--nav-primary);
background: #eaf1e5;
font-size: 25px;
} }
.brand-text { .brand-text {
display: flex; display: block;
flex-direction: column;
gap: 3px;
} }
.brand-text strong { .brand-text strong {
font-size: 17px; font-family: Georgia, "Times New Roman", serif;
font-weight: 850; font-size: 23px;
letter-spacing: -.5px; font-weight: 700;
line-height: 1.2;
letter-spacing: normal;
white-space: nowrap;
} }
.brand-text small {
color: #92a18e;
font-size: 9px;
font-weight: 800;
letter-spacing: 1.8px;
}
/* Navigace */ /* ========================================
NAVIGATION STRUCTURE
======================================== */
.nav-scrollable { .nav-scrollable {
display: flex; display: flex;
align-items: center;
justify-content: space-between;
flex: 1; flex: 1;
flex-direction: column; gap: 16px;
padding: 30px 15px 20px; min-width: 0;
overflow-y: auto;
} }
.nav-section-label { .public-nav-links {
padding: 0 12px; display: flex;
margin-bottom: 13px; flex-direction: row;
color: #9ba79a; align-items: center;
font-size: 10px; flex-wrap: wrap;
font-weight: 850; gap: 4px;
letter-spacing: 1.6px; margin: 0;
padding: 0;
} }
.secondary-label { .public-account-links {
margin-top: 32px; display: flex;
flex-direction: row;
align-items: center;
justify-content: flex-end;
flex-wrap: wrap;
gap: 8px;
min-width: 0;
margin: 0 0 0 auto;
padding: 0;
} }
.nav-item { .nav-item {
margin-bottom: 6px; display: block;
min-width: 0;
margin: 0;
padding: 0;
font-size: 14px; font-size: 14px;
font-weight: 650; font-weight: 600;
} }
/* ========================================
NAVIGATION LINKS
======================================== */
.nav-item ::deep .nav-link { .nav-item ::deep .nav-link {
position: relative; position: relative;
display: flex; display: flex;
align-items: center; align-items: center;
gap: 13px; justify-content: flex-start;
width: 100%; gap: 8px;
min-height: 49px; min-height: 44px;
padding: 0 14px; margin: 0;
padding: 8px 12px;
border: 1px solid transparent; border: 1px solid transparent;
border-radius: 12px; border-radius: 6px;
background: transparent; background: transparent;
color: #758275; color: var(--nav-muted);
text-decoration: none; font-family: inherit;
font-size: 14px;
font-weight: 600;
line-height: 1.4;
text-align: left; text-align: left;
line-height: normal; text-decoration: none;
transition: background .2s ease, color .2s ease, transform .2s ease, border-color .2s ease; white-space: nowrap;
transition: background-color 150ms ease, color 150ms ease, border-color 150ms ease;
} }
.nav-item ::deep .nav-link:hover { .nav-item ::deep .nav-link:hover {
background: #f4f7f1; background: #f1f4ef;
color: #315b3e; color: var(--nav-primary);
transform: translateX(3px); text-decoration: none;
} }
.nav-item ::deep a.active { .nav-item ::deep a.nav-link.active {
background: #eaf2e5; background: var(--nav-secondary);
color: #315b3e; color: var(--nav-primary);
border-color: #dce9d5; border-color: #dce5d7;
font-weight: 750; font-weight: 700;
} }
.nav-item ::deep a.active::before {
content: ""; /* ========================================
position: absolute; ICONS
left: -15px; ======================================== */
top: 11px;
bottom: 11px;
width: 3px;
border-radius: 0 5px 5px 0;
background: #6f9668;
}
.nav-icon { .nav-icon {
display: inline-flex; display: block;
align-items: center; width: 20px;
justify-content: center; height: 20px;
width: 21px;
height: 21px;
flex-shrink: 0; flex-shrink: 0;
font-size: 17px;
opacity: .85;
} }
.nav-item ::deep .nav-link:hover .nav-icon,
.nav-item ::deep a.active .nav-icon { /* ========================================
opacity: 1; USER ACCOUNT
======================================== */
.account-item {
min-width: 0;
max-width: 200px;
} }
.user-name { .user-name {
display: block;
min-width: 0;
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
white-space: nowrap; white-space: nowrap;
} }
/* Spodní část */
.nav-bottom {
margin-top: auto;
padding-top: 30px;
border-top: 1px solid #edf0e9;
}
.nav-item ::deep form { .nav-item ::deep form {
width: 100%; margin: 0;
padding: 0;
} }
.nav-item ::deep button.nav-link { .nav-item ::deep button.nav-link {
width: 100%;
font-family: inherit; font-family: inherit;
font-size: inherit;
cursor: pointer; cursor: pointer;
} }
.nav-item ::deep .logout-link { .nav-item ::deep .logout-link {
color: #9a7771; color: #8b4038;
} }
.nav-item ::deep .logout-link:hover { .nav-item ::deep .logout-link:hover {
background: #fff1ef; background: #fbefed;
color: #b34e43; color: #74342d;
border-color: #efd8d4;
} }
/* Patička */
.nav-footer { /* ========================================
display: flex; SHOPPING CART - PRIMARY ACTION
align-items: center; ======================================== */
gap: 11px;
margin-top: 28px; .cart-item {
padding: 16px 12px 5px; margin-left: 4px;
border-top: 1px solid #edf0e9;
} }
.footer-leaf { .cart-item ::deep .public-cart-link {
display: grid; display: flex;
place-items: center; align-items: center;
width: 36px; justify-content: center;
height: 36px; gap: 8px;
border-radius: 11px; min-height: 44px;
background: #edf3e9; padding: 10px 20px;
font-size: 19px; border: 1px solid var(--nav-primary);
border-radius: 6px;
background: var(--nav-primary);
color: #ffffff;
font-weight: 700;
}
.cart-item ::deep .public-cart-link:hover {
background: var(--nav-primary-hover);
border-color: var(--nav-primary-hover);
color: #ffffff;
}
.cart-item ::deep a.public-cart-link.active {
background: var(--nav-primary-hover);
border-color: var(--nav-primary-hover);
color: #ffffff;
text-decoration: underline;
text-underline-offset: 4px;
}
/* ========================================
KEYBOARD ACCESSIBILITY
======================================== */
.navbar-brand:focus-visible,
.navbar-toggler:focus-visible,
.nav-panel ::deep .nav-link:focus-visible {
outline: 3px solid #527b49;
outline-offset: 3px;
box-shadow: none;
} }
.nav-footer div {
display: flex;
flex-direction: column;
gap: 3px;
}
.nav-footer strong { /* ========================================
color: #49634b; MOBILE MENU TOGGLE
font-size: 12px; ======================================== */
}
.nav-footer small {
color: #9ba69a;
font-size: 10px;
}
/* Mobilní menu */
.navbar-toggler { .navbar-toggler {
display: none;
appearance: none; appearance: none;
-webkit-appearance: none;
position: absolute; position: absolute;
top: 27px; top: 12px;
right: 20px; right: 24px;
z-index: 5; width: 44px;
width: 42px; height: 44px;
height: 42px;
margin: 0; margin: 0;
border: 1px solid #e4eadf; padding: 0;
border-radius: 12px; border: 1px solid var(--nav-border);
background: #f5f8f2; border-radius: 6px;
background: var(--nav-surface);
color: var(--nav-primary);
cursor: pointer; cursor: pointer;
box-sizing: border-box;
} }
.navbar-toggler::before,
.navbar-toggler::after {
content: "";
position: absolute;
left: 11px;
width: 20px;
height: 2px;
background: currentColor;
border-radius: 1px;
}
.navbar-toggler::before { .navbar-toggler::before {
content: "☰"; top: 14px;
display: grid; box-shadow: 0 6px 0 currentColor;
place-items: center;
width: 100%;
height: 100%;
color: #315b3e;
font-size: 19px;
} }
.navbar-toggler:checked::before { .navbar-toggler::after {
content: "✕"; top: 26px;
} }
@media (min-width: 641px) { .navbar-toggler:checked {
.navbar-toggler { background: var(--nav-secondary);
display: none;
} }
.nav-scrollable { .navbar-toggler:checked::before {
display: flex !important; top: 20px;
height: calc(100vh - 100px); transform: rotate(45deg);
box-shadow: none;
}
.navbar-toggler:checked::after {
top: 20px;
transform: rotate(-45deg);
}
.navbar-toggler:hover {
background-color: var(--nav-secondary);
}
/* ========================================
COMPACT DESKTOP
======================================== */
@media (max-width: 1200px) {
.nav-panel {
gap: 16px;
padding: 12px 24px;
}
.brand-text strong {
font-size: 21px;
}
.public-account-links {
gap: 4px;
}
.nav-item ::deep .nav-link {
padding: 8px 12px;
}
.cart-item ::deep .public-cart-link {
padding: 10px 16px;
}
.account-item {
max-width: 160px;
} }
} }
@media (max-width: 640.98px) {
/* ========================================
TABLET AND MOBILE
======================================== */
@media (max-width: 1024px) {
.nav-panel { .nav-panel {
min-height: auto; display: flex;
height: auto; flex-direction: column;
align-items: stretch;
gap: 0;
min-height: 68px;
padding: 0;
} }
.nav-brand-area { .nav-brand-area {
height: 78px; display: flex;
min-height: 78px; align-items: center;
padding: 0 18px; min-height: 68px;
padding: 12px 84px 12px 24px;
} }
.navbar-toggler { .navbar-toggler {
top: 18px; display: block;
right: 18px;
} }
.nav-scrollable { .nav-scrollable {
display: none; display: none;
padding: 15px 18px 20px; flex-direction: column;
align-items: stretch;
gap: 16px;
width: 100%;
padding: 16px 24px 24px;
border-top: 1px solid var(--nav-border);
} }
.navbar-toggler:checked ~ .nav-scrollable { .navbar-toggler:checked ~ .nav-scrollable {
display: flex; display: flex;
animation: menuEnter .22s ease both;
} }
.nav-bottom { .public-nav-links {
margin-top: 20px; display: flex;
flex-direction: column;
align-items: stretch;
gap: 4px;
width: 100%;
} }
.nav-footer { .public-account-links {
margin-top: 18px; display: flex;
flex-direction: column;
align-items: stretch;
gap: 4px;
width: 100%;
margin: 0;
padding-top: 16px;
border-top: 1px solid var(--nav-border);
}
.nav-item {
width: 100%;
}
.nav-item ::deep .nav-link {
width: 100%;
min-height: 48px;
padding: 12px 16px;
font-size: 15px;
}
.account-item {
max-width: none;
}
.cart-item {
margin: 12px 0 0;
}
.cart-item ::deep .public-cart-link {
width: 100%;
min-height: 48px;
justify-content: center;
}
}
/* ========================================
MOBILE - MAX 640 PX
======================================== */
@media (max-width: 640px) {
.nav-brand-area {
padding: 12px 76px 12px 16px;
}
.navbar-toggler {
right: 16px;
}
.brand-symbol {
width: 28px;
height: 28px;
}
.brand-text strong {
font-size: 20px;
}
.nav-scrollable {
padding: 12px 16px 20px;
} }
} }
@keyframes menuEnter {
from { /* ========================================
opacity: 0; SMALL MOBILE
transform: translateY(-7px); ======================================== */
@media (max-width: 360px) {
.brand-text strong {
font-size: 18px;
} }
to { .brand-symbol {
opacity: 1; width: 24px;
transform: translateY(0); height: 24px;
}
.navbar-brand {
gap: 8px;
}
.nav-brand-area {
padding-left: 12px;
padding-right: 68px;
}
.navbar-toggler {
right: 12px;
}
.nav-scrollable {
padding: 12px 12px 16px;
} }
} }
.nav-scrollable::-webkit-scrollbar {
width: 5px;
}
.nav-scrollable::-webkit-scrollbar-thumb { /* ========================================
background: #dce6d7; REDUCED MOTION
border-radius: 10px; ======================================== */
}
@media (prefers-reduced-motion: reduce) { @media (prefers-reduced-motion: reduce) {
.nav-panel *,
.nav-panel *::before, .navbar-brand,
.nav-panel *::after { .navbar-toggler,
animation: none !important; .nav-panel ::deep .nav-link {
transition: none !important; transition: none !important;
animation: none !important;
} }
} }

View File

@@ -1,11 +1,14 @@
@page "/admin/zbozi/edit" ```razor
@page "/admin/zbozi/edit"
@page "/admin/zbozi/edit/{Id:int}" @page "/admin/zbozi/edit/{Id:int}"
@layout Web_Jarmark.Components.Layout.Admin.AdminLayout @layout Web_Jarmark.Components.Layout.Admin.AdminLayout
@rendermode InteractiveServer @rendermode InteractiveServer
@using Microsoft.EntityFrameworkCore @using Microsoft.EntityFrameworkCore
@using Microsoft.AspNetCore.Authorization @using Microsoft.AspNetCore.Authorization
@using Web_Jarmark.Data @using Web_Jarmark.Data
@using Web_Jarmark.Data.Models @using Web_Jarmark.Data.Models
@inject ApplicationDbContext Db @inject ApplicationDbContext Db
@inject NavigationManager Nav @inject NavigationManager Nav
@@ -41,7 +44,7 @@
<section class="ao-panel" style="max-width:560px;margin:0 auto"> <section class="ao-panel" style="max-width:560px;margin:0 auto">
<div class="ap-field"> <div class="ap-field">
<label>Název</label> <label>Název</label>
<input class="ao-input" @bind="name" /> <input class="ao-input" maxlength="150" @bind="name" />
</div> </div>
<div class="ap-field"> <div class="ap-field">
@@ -57,22 +60,35 @@
<div class="ap-field"> <div class="ap-field">
<label>Popis</label> <label>Popis</label>
<textarea class="ao-input" style="min-height:110px;resize:vertical" @bind="description"></textarea> <textarea class="ao-input"
maxlength="5000"
style="min-height:110px;resize:vertical"
@bind="description"></textarea>
</div> </div>
<div class="ap-field"> <div class="ap-field">
<label>Cena (Kč)</label> <label>Cena (Kč)</label>
<input type="number" step="0.01" class="ao-input" @bind="price" /> <input type="number"
min="0"
step="0.01"
class="ao-input"
@bind="price" />
</div> </div>
<div class="ap-field"> <div class="ap-field">
<label>Sklad (ks)</label> <label>Sklad (ks)</label>
<input type="number" class="ao-input" @bind="stockQuantity" /> <input type="number"
min="0"
step="1"
class="ao-input"
@bind="stockQuantity" />
</div> </div>
<div class="ap-field"> <div class="ap-field">
<label>URL obrázku</label> <label>URL obrázku</label>
<input class="ao-input" @bind="imageUrl" /> <input class="ao-input"
maxlength="2048"
@bind="imageUrl" />
</div> </div>
<label class="ap-switch"> <label class="ap-switch">
@@ -81,9 +97,13 @@
</label> </label>
<div class="ap-form-actions"> <div class="ap-form-actions">
<button type="button" class="ap-btn ap-btn-primary" disabled="@saving" @onclick="SaveAsync"> <button type="button"
class="ap-btn ap-btn-primary"
disabled="@saving"
@onclick="SaveAsync">
@(saving ? "Ukládám…" : "Uložit") @(saving ? "Ukládám…" : "Uložit")
</button> </button>
<a class="ap-btn" href="/admin/zbozi">Zrušit</a> <a class="ap-btn" href="/admin/zbozi">Zrušit</a>
</div> </div>
</section> </section>
@@ -136,7 +156,10 @@
return; return;
} }
var entity = await Db.Products.AsNoTracking().FirstOrDefaultAsync(p => p.Id == Id!.Value); var entity = await Db.Products
.AsNoTracking()
.FirstOrDefaultAsync(p => p.Id == Id!.Value);
if (entity is null) if (entity is null)
{ {
notFound = true; notFound = true;
@@ -151,29 +174,75 @@
stockQuantity = entity.StockQuantity; stockQuantity = entity.StockQuantity;
imageUrl = entity.ImageUrl ?? ""; imageUrl = entity.ImageUrl ?? "";
isVisible = entity.IsVisible; isVisible = entity.IsVisible;
loading = false; loading = false;
} }
private async Task SaveAsync() private async Task SaveAsync()
{ {
if (saving)
return;
saving = true; saving = true;
error = null; error = null;
try try
{ {
name = name?.Trim() ?? "";
description = description?.Trim() ?? "";
imageUrl = imageUrl?.Trim() ?? "";
if (string.IsNullOrWhiteSpace(name)) if (string.IsNullOrWhiteSpace(name))
{ {
error = "Zadejte název produktu."; error = "Zadejte název produktu.";
return; return;
} }
if (categoryId <= 0) if (name.Length > 150)
{ {
error = "Vyberte kategorii."; error = "Název může mít maximálně 150 znaků.";
return;
}
if (description.Length > 5000)
{
error = "Popis může mít maximálně 5000 znaků.";
return;
}
if (price < 0 || price > 100000000)
{
error = "Cena musí být mezi 0 a 100 000 000 Kč.";
return;
}
if (decimal.Round(price, 2) != price)
{
error = "Cena může mít maximálně dvě desetinná místa.";
return;
}
if (stockQuantity < 0)
{
error = "Počet kusů na skladě nemůže být záporný.";
return;
}
if (categoryId <= 0 ||
!await Db.Categories.AnyAsync(c => c.Id == categoryId))
{
error = "Vyberte platnou kategorii.";
return;
}
if (!IsValidImageUrl(imageUrl))
{
error = "Obrázek musí mít platnou HTTPS adresu nebo bezpečnou relativní cestu.";
return; return;
} }
Product entity; Product entity;
if (IsNew) if (IsNew)
{ {
entity = new Product(); entity = new Product();
@@ -181,24 +250,37 @@
} }
else else
{ {
entity = await Db.Products.FirstAsync(p => p.Id == Id!.Value); entity = await Db.Products
.FirstOrDefaultAsync(p => p.Id == Id!.Value);
if (entity is null)
{
notFound = true;
error = "Produkt již neexistuje.";
return;
}
} }
entity.Name = name.Trim(); entity.Name = name;
entity.Description = description?.Trim() ?? ""; entity.Description = description;
entity.CategoryId = categoryId; entity.CategoryId = categoryId;
entity.Price = price; entity.Price = price;
entity.StockQuantity = stockQuantity; entity.StockQuantity = stockQuantity;
entity.ImageUrl = imageUrl?.Trim() ?? ""; entity.ImageUrl = imageUrl;
entity.IsVisible = isVisible; entity.IsVisible = isVisible;
entity.UpdatedAt = DateTime.UtcNow; entity.UpdatedAt = DateTime.UtcNow;
await Db.SaveChangesAsync(); await Db.SaveChangesAsync();
Nav.NavigateTo("/admin/zbozi"); Nav.NavigateTo("/admin/zbozi");
} }
catch (Exception ex) catch (DbUpdateException)
{ {
error = "Uložení se nezdařilo: " + ex.Message; error = "Produkt se nepodařilo uložit. Zkontrolujte zadané údaje.";
}
catch (Exception)
{
error = "Při ukládání nastala neočekávaná chyba.";
} }
finally finally
{ {
@@ -206,5 +288,30 @@
} }
} }
private static bool IsValidImageUrl(string value)
{
if (string.IsNullOrWhiteSpace(value))
return true;
if (value.Length > 2048)
return false;
if (value.StartsWith("//") ||
value.Contains('\\') ||
value.Any(char.IsControl))
return false;
if (Uri.TryCreate(value, UriKind.Absolute, out var uri))
{
return uri.Scheme == Uri.UriSchemeHttps &&
!string.IsNullOrWhiteSpace(uri.Host);
}
return value.StartsWith('/') &&
!value.StartsWith("//") &&
!value.Contains("..");
}
private sealed record CatOption(int Id, string Name); private sealed record CatOption(int Id, string Name);
} }
```

View File

@@ -10,139 +10,798 @@
@implements IDisposable @implements IDisposable
<PageTitle>Detail produktu</PageTitle> <PageTitle>Detail produktu | Školní jarmark</PageTitle>
@if (showNotification) <div class="jarmark-product-detail">
{
<div class="cart-notification" role="status" aria-live="polite">
<span class="notification-icon">✓</span>
<span>@notificationMessage</span>
</div>
}
@if (loading) <!-- NOTIFIKACE -->
{ @if (showNotification)
<p>Načítám produkt...</p> {
} <div class="jarmark-detail-notification"
else if (product == null) role="status"
{ aria-live="polite">
<h3>Produkt nebyl nalezen.</h3>
} <svg width="24"
else height="24"
{ viewBox="0 0 24 24"
<div class="detail-container"> fill="none"
<a href="/" class="back-link">← Zpět do katalogu</a> stroke="currentColor"
stroke-width="1.8"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true">
<circle cx="12" cy="12" r="9" />
<path d="m8 12 3 3 5-6" />
</svg>
<span>@notificationMessage</span>
</div>
}
<!-- NÁVRAT DO KATALOGU -->
<a href="/" class="jarmark-detail-back">
<svg width="20"
height="20"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.8"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true">
<path d="M19 12H5M12 19l-7-7 7-7" />
</svg>
<span>Zpět do katalogu</span>
</a>
<!-- NAČÍTÁNÍ -->
@if (loading)
{
<div class="jarmark-detail-empty"
role="status"
aria-live="polite">
<h2>Načítáme výrobek</h2>
<p>Informace o výrobku se právě načítají.</p>
</div>
}
else if (product == null)
{
<div class="jarmark-detail-empty">
<svg width="48"
height="48"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.4"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true">
<circle cx="11" cy="11" r="7" />
<path d="m20 20-4-4" />
</svg>
<h2>Výrobek nebyl nalezen</h2>
<p>
Tento výrobek již nemusí být dostupný.
Další výrobky najdete v katalogu.
</p>
<a href="/"
class="jarmark-detail-button">
Prohlédnout nabídku
</a>
</div>
}
else
{
<article class="jarmark-detail-card">
<!-- FOTOGRAFIE -->
<div class="jarmark-detail-image">
@if (!string.IsNullOrWhiteSpace(product.ImageUrl)
&& !imageFailed)
{
<img src="@product.ImageUrl"
alt="@product.Name"
decoding="async"
@onerror="HandleImageError" />
}
else
{
<div class="jarmark-detail-placeholder">
<svg width="80"
height="80"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true">
<rect x="3"
y="3"
width="18"
height="18"
rx="2" />
<circle cx="8.5"
cy="8.5"
r="1.5" />
<path d="m21 15-5-5L5 21" />
</svg>
<span>Fotografie není dostupná</span>
</div>
}
<div class="detail-card">
<div class="detail-image">
<img src="@product.ImageUrl" alt="@product.Name" />
</div> </div>
<div class="detail-info">
<span class="detail-category">
@product.Category?.Name
</span>
<h1>@product.Name</h1> <!-- INFORMACE O VÝROBKU -->
<p class="detail-description"> <div class="jarmark-detail-info">
@product.Description
</p> @if (product.Category is not null)
{
<span class="jarmark-detail-category">
@product.Category.Name
</span>
}
<h1 class="jarmark-detail-title">
@product.Name
</h1>
@if (!string.IsNullOrWhiteSpace(product.Description))
{
<p class="jarmark-detail-description">
@product.Description
</p>
}
<!-- SKLADOVÁ DOSTUPNOST -->
<div class="jarmark-detail-stock @(product.StockQuantity > 0 ? "is-available" : "is-unavailable")">
<span class="jarmark-detail-stock-dot"
aria-hidden="true">
</span>
@if (product.StockQuantity > 0)
{
<span>
Skladem: @product.StockQuantity ks
</span>
}
else
{
<span>Není skladem</span>
}
<div class="detail-stock">
<span class="stock-dot"></span>
Skladem: @product.StockQuantity ks
</div> </div>
<div class="detail-divider"></div>
<div class="detail-bottom"> <!-- CENA A NÁKUP -->
<div>
<span class="price-label">Cena produktu</span> <div class="jarmark-detail-purchase">
<div class="detail-price">
<div class="jarmark-detail-price-area">
<span class="jarmark-detail-price-label">
Cena produktu
</span>
<strong class="jarmark-detail-price">
@product.Price.ToString("N0") Kč @product.Price.ToString("N0") Kč
</div>
</strong>
</div> </div>
<button class="product-cart-button" <button type="button"
class="jarmark-detail-button"
disabled="@(product.StockQuantity <= 0)" disabled="@(product.StockQuantity <= 0)"
@onclick="() => HandleAddToCart(product)"> @onclick="() => HandleAddToCart(product)">
🛒 Přidat do košíku
@if (product.StockQuantity > 0)
{
<svg width="22"
height="22"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.7"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true">
<path d="M3 3h2l3.5 13h10l3-10H6" />
<circle cx="10"
cy="20"
r="1" />
<circle cx="18"
cy="20"
r="1" />
</svg>
<span>Přidat do košíku</span>
}
else
{
<span>Vyprodáno</span>
}
</button> </button>
</div> </div>
</div> </div>
</div>
</div> </article>
} }
</div>
<style> <style>
.cart-notification {
position: fixed; /* ========================================
top: 25px; PUBLIC PRODUCT DETAIL
right: 25px; ======================================== */
z-index: 9999;
display: flex; .jarmark-product-detail {
align-items: center; --detail-primary: #244b36;
gap: 12px; --detail-primary-hover: #193b29;
padding: 16px 22px; --detail-secondary: #e6eddf;
background: #ffffff; --detail-surface: #ffffff;
color: #222222; --detail-text: #26372b;
border: 1px solid #d9eadf; --detail-muted: #59665b;
border-radius: 12px; --detail-border: #dce3d9;
box-shadow: 0 8px 30px rgba(0, 0, 0, 0.14); width: 100%;
font-size: 14px; max-width: 1200px;
font-weight: 650; min-width: 0;
animation: notification-in 0.25s ease-out, notification-out 1s ease-in 2.5s forwards; margin: 0 auto;
color: var(--detail-text);
font-family: inherit;
box-sizing: border-box;
} }
.notification-icon {
display: flex;
align-items: center;
justify-content: center;
width: 27px;
height: 27px;
flex-shrink: 0;
border-radius: 50%;
background: #e2f7e9;
color: #168344;
font-size: 17px;
font-weight: 900;
}
@@keyframes notification-in { /* ========================================
from { BACK LINK
opacity: 0; ======================================== */
transform: translateY(-10px);
.jarmark-product-detail .jarmark-detail-back {
display: inline-flex;
align-items: center;
gap: 8px;
min-height: 44px;
margin: 0 0 20px;
padding: 8px 0;
color: var(--detail-primary);
font-size: 14px;
font-weight: 600;
line-height: 1.4;
text-decoration: none;
} }
to { .jarmark-product-detail .jarmark-detail-back svg {
opacity: 1; flex-shrink: 0;
transform: translateY(0); }
}
}
@@keyframes notification-out { .jarmark-product-detail .jarmark-detail-back:hover {
from { color: var(--detail-primary-hover);
opacity: 1; text-decoration: underline;
transform: translateY(0); text-underline-offset: 4px;
}
/* ========================================
PRODUCT CARD
======================================== */
.jarmark-product-detail .jarmark-detail-card {
display: grid;
grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
align-items: start;
gap: 40px;
width: 100%;
min-width: 0;
padding: 32px;
background: var(--detail-surface);
border: 1px solid var(--detail-border);
border-radius: 12px;
box-sizing: border-box;
} }
to {
opacity: 0;
transform: translateY(-12px);
}
}
@@media (max-width: 500px) { /* ========================================
.cart-notification { PRODUCT IMAGE
top: 15px; ======================================== */
right: 12px;
left: 12px; .jarmark-product-detail .jarmark-detail-image {
display: flex;
align-items: center;
justify-content: center; justify-content: center;
width: 100%;
min-width: 0;
aspect-ratio: 1 / 1;
background: #edf0e9;
border: 1px solid var(--detail-border);
border-radius: 8px;
overflow: hidden;
}
.jarmark-product-detail .jarmark-detail-image img {
display: block;
width: 100%;
height: 100%;
max-width: 100%;
padding: 20px;
object-fit: contain;
object-position: center;
box-sizing: border-box;
}
/* ========================================
IMAGE PLACEHOLDER
======================================== */
.jarmark-product-detail .jarmark-detail-placeholder {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 16px;
width: 100%;
height: 100%;
padding: 24px;
background: var(--detail-secondary);
color: #64815d;
text-align: center;
}
.jarmark-product-detail .jarmark-detail-placeholder span {
color: var(--detail-muted);
font-size: 14px;
font-weight: 500;
}
/* ========================================
PRODUCT INFORMATION
======================================== */
.jarmark-product-detail .jarmark-detail-info {
display: flex;
flex-direction: column;
gap: 16px;
width: 100%;
min-width: 0;
padding: 12px 0;
}
.jarmark-product-detail .jarmark-detail-category {
display: block;
color: var(--detail-muted);
font-size: 14px;
font-weight: 500;
line-height: 1.5;
letter-spacing: normal;
text-transform: none;
overflow-wrap: anywhere;
}
.jarmark-product-detail .jarmark-detail-title {
margin: 0;
color: var(--detail-text);
font-family: Georgia, "Times New Roman", serif;
font-size: clamp(30px, 4vw, 44px);
font-weight: 700;
line-height: 1.2;
letter-spacing: normal;
overflow-wrap: anywhere;
}
.jarmark-product-detail .jarmark-detail-description {
margin: 0;
color: var(--detail-muted);
font-size: 16px;
line-height: 1.8;
white-space: pre-line;
overflow-wrap: anywhere;
}
/* ========================================
STOCK AVAILABILITY
======================================== */
.jarmark-product-detail .jarmark-detail-stock {
display: inline-flex;
align-items: center;
gap: 8px;
align-self: flex-start;
margin-top: 8px;
font-size: 14px;
font-weight: 600;
line-height: 1.5;
}
.jarmark-product-detail .jarmark-detail-stock-dot {
display: inline-block;
flex-shrink: 0;
width: 8px;
height: 8px;
background: currentColor;
border-radius: 50%;
}
.jarmark-product-detail .is-available {
color: #34754b;
}
.jarmark-product-detail .is-unavailable {
color: #93483e;
}
/* ========================================
PURCHASE SECTION
======================================== */
.jarmark-product-detail .jarmark-detail-purchase {
display: flex;
flex-direction: column;
gap: 24px;
width: 100%;
margin-top: 12px;
padding-top: 24px;
border-top: 1px solid var(--detail-border);
}
.jarmark-product-detail .jarmark-detail-price-area {
display: flex;
flex-direction: column;
gap: 4px;
}
.jarmark-product-detail .jarmark-detail-price-label {
color: var(--detail-muted);
font-size: 14px;
font-weight: 500;
}
.jarmark-product-detail .jarmark-detail-price {
color: var(--detail-primary);
font-size: clamp(32px, 4vw, 44px);
font-weight: 750;
line-height: 1.2;
font-variant-numeric: tabular-nums;
overflow-wrap: anywhere;
}
/* ========================================
ADD TO CART BUTTON
======================================== */
.jarmark-product-detail .jarmark-detail-button {
display: inline-flex;
align-items: center;
justify-content: center;
gap: 12px;
width: 100%;
min-height: 52px;
margin: 0;
padding: 12px 24px;
background: var(--detail-primary);
color: #ffffff;
border: 1px solid var(--detail-primary);
border-radius: 6px;
font-family: inherit;
font-size: 15px;
font-weight: 650;
line-height: 1.5;
text-align: center;
text-decoration: none;
cursor: pointer;
transition: background-color 150ms ease, border-color 150ms ease;
}
.jarmark-product-detail .jarmark-detail-button svg {
flex-shrink: 0;
}
.jarmark-product-detail .jarmark-detail-button:not(:disabled):hover {
background: var(--detail-primary-hover);
border-color: var(--detail-primary-hover);
color: #ffffff;
text-decoration: none;
}
.jarmark-product-detail .jarmark-detail-button:disabled {
background: #e9ece7;
color: #59665b;
border-color: var(--detail-border);
opacity: 1;
cursor: not-allowed;
}
/* ========================================
EMPTY AND LOADING STATES
======================================== */
.jarmark-product-detail .jarmark-detail-empty {
display: flex;
flex-direction: column;
align-items: flex-start;
gap: 16px;
min-height: 220px;
padding: 32px;
background: var(--detail-surface);
border: 1px solid var(--detail-border);
border-radius: 8px;
}
.jarmark-product-detail .jarmark-detail-empty svg {
color: #64815d;
}
.jarmark-product-detail .jarmark-detail-empty h2 {
margin: 0;
color: var(--detail-text);
font-size: 28px;
line-height: 1.3;
}
.jarmark-product-detail .jarmark-detail-empty p {
margin: 0;
color: var(--detail-muted);
font-size: 15px;
line-height: 1.6;
}
.jarmark-product-detail .jarmark-detail-empty .jarmark-detail-button {
width: auto;
margin-top: 8px;
}
/* ========================================
CART NOTIFICATION
======================================== */
.jarmark-product-detail .jarmark-detail-notification {
position: fixed;
top: 96px;
right: 24px;
z-index: 500;
display: flex;
align-items: center;
gap: 12px;
max-width: 420px;
padding: 16px 20px;
background: var(--detail-surface);
color: var(--detail-text);
border: 1px solid #c7d6c2;
border-left: 4px solid var(--detail-primary);
border-radius: 8px;
box-shadow: 0 4px 16px rgba(0, 0, 0, .08);
font-size: 14px;
font-weight: 500;
line-height: 1.5;
overflow-wrap: anywhere;
}
.jarmark-product-detail .jarmark-detail-notification svg {
flex-shrink: 0;
color: var(--detail-primary);
}
/* ========================================
KEYBOARD ACCESSIBILITY
======================================== */
.jarmark-product-detail .jarmark-detail-back:focus-visible,
.jarmark-product-detail .jarmark-detail-button:focus-visible {
outline: 3px solid #527b49;
outline-offset: 4px;
}
/* ========================================
TABLET
======================================== */
@@media (max-width: 1024px) {
.jarmark-product-detail .jarmark-detail-card {
gap: 24px;
padding: 24px;
}
.jarmark-product-detail .jarmark-detail-title {
font-size: 32px;
}
.jarmark-product-detail .jarmark-detail-info {
padding: 4px 0;
}
.jarmark-product-detail .jarmark-detail-description {
font-size: 15px;
}
.jarmark-product-detail .jarmark-detail-image img {
padding: 16px;
}
}
/* ========================================
MOBILE
======================================== */
@@media (max-width: 768px) {
.jarmark-product-detail .jarmark-detail-card {
grid-template-columns: minmax(0, 1fr);
gap: 24px;
padding: 16px;
border-radius: 8px;
}
.jarmark-product-detail .jarmark-detail-back {
margin-bottom: 12px;
}
.jarmark-product-detail .jarmark-detail-image {
aspect-ratio: 4 / 3;
}
.jarmark-product-detail .jarmark-detail-info {
gap: 12px;
padding: 0;
}
.jarmark-product-detail .jarmark-detail-title {
font-size: 30px;
}
.jarmark-product-detail .jarmark-detail-description {
font-size: 15px;
line-height: 1.7;
}
.jarmark-product-detail .jarmark-detail-purchase {
gap: 16px;
margin-top: 8px;
padding-top: 20px;
}
.jarmark-product-detail .jarmark-detail-price {
font-size: 34px;
}
.jarmark-product-detail .jarmark-detail-button {
min-height: 52px;
padding: 12px 16px;
font-size: 15px;
}
.jarmark-product-detail .jarmark-detail-notification {
top: auto;
right: 12px;
bottom: 16px;
left: 12px;
max-width: none;
padding: 16px;
}
}
/* ========================================
SMALL MOBILE
======================================== */
@@media (max-width: 480px) {
.jarmark-product-detail .jarmark-detail-card {
gap: 20px;
padding: 12px;
}
.jarmark-product-detail .jarmark-detail-image {
aspect-ratio: 1 / 1;
}
.jarmark-product-detail .jarmark-detail-image img {
padding: 12px;
}
.jarmark-product-detail .jarmark-detail-title {
font-size: 28px;
}
.jarmark-product-detail .jarmark-detail-category {
font-size: 13px;
}
.jarmark-product-detail .jarmark-detail-empty {
padding: 20px;
}
.jarmark-product-detail .jarmark-detail-empty h2 {
font-size: 24px;
}
.jarmark-product-detail .jarmark-detail-empty .jarmark-detail-button {
width: 100%;
}
}
/* ========================================
REDUCED MOTION
======================================== */
@@media (prefers-reduced-motion: reduce) {
.jarmark-product-detail,
.jarmark-product-detail * {
animation: none !important;
transition: none !important;
scroll-behavior: auto !important;
} }
} }
</style> </style>
@code { @code {
[Parameter] [Parameter]
public int Id { get; set; } public int Id { get; set; }
@@ -156,6 +815,15 @@ else
private CancellationTokenSource? notificationCts; private CancellationTokenSource? notificationCts;
private bool imageFailed;
private void HandleImageError()
{
imageFailed = true;
}
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {
if (!ApplicationState.TryTakeFromJson<string>( if (!ApplicationState.TryTakeFromJson<string>(
@@ -172,6 +840,7 @@ else
protected override async Task OnParametersSetAsync() protected override async Task OnParametersSetAsync()
{ {
loading = true; loading = true;
imageFailed = false;
product = await DbContext.Products product = await DbContext.Products
.Include(p => p.Category) .Include(p => p.Category)

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -2,45 +2,74 @@
@using Microsoft.AspNetCore.Components.Web @using Microsoft.AspNetCore.Components.Web
@inject NavigationManager NavigationManager @inject NavigationManager NavigationManager
<article class="market-card" <article class="jarmark-product-card">
role="link"
tabindex="0" <!-- FOTOGRAFIE PRODUKTU -->
@onclick="OpenProductDetail"
@onkeydown="HandleCardKeyDown"> <div class="jarmark-card-picture">
<div class="market-product-picture">
@if (!string.IsNullOrWhiteSpace(Product.ImageUrl) && !imageFailed) @if (!string.IsNullOrWhiteSpace(Product.ImageUrl) && !imageFailed)
{ {
<img src="@Product.ImageUrl.Trim()" <img src="@Product.ImageUrl.Trim()"
alt="@Product.Name" alt="@Product.Name"
loading="lazy" loading="lazy"
decoding="async"
@onerror="HandleImageError" /> @onerror="HandleImageError" />
} }
else else
{ {
<span class="product-icon">@ProductIcon</span> <div class="jarmark-card-placeholder"
aria-hidden="true">
<span>@ProductIcon</span>
</div>
} }
</div>
<!-- INFORMACE O PRODUKTU -->
<div class="jarmark-card-body">
@if (Product.Category is not null) @if (Product.Category is not null)
{ {
<span class="market-product-tag"> <div class="jarmark-card-category">
@Product.Category.Name
</span>
}
</div>
<div class="market-card-content"> @Product.Category.Name
<h3>@Product.Name</h3>
</div>
}
<h3 class="jarmark-card-title">
<a href="@($"/produkt/{Product.Id}")"
class="jarmark-card-detail">
@Product.Name
</a>
</h3>
@if (!string.IsNullOrWhiteSpace(Product.Description)) @if (!string.IsNullOrWhiteSpace(Product.Description))
{ {
<p class="market-description"> <p class="jarmark-card-description">
@Product.Description @Product.Description
</p> </p>
} }
<div class="market-stock">
<span class="market-stock-dot @(Product.StockQuantity <= 0 ? "out-of-stock" : "")"></span> <!-- DOSTUPNOST -->
<div class="jarmark-card-stock @(Product.StockQuantity <= 0 ? "is-unavailable" : "is-available")">
<span class="jarmark-stock-indicator"
aria-hidden="true">
</span>
@if (Product.StockQuantity > 0) @if (Product.StockQuantity > 0)
{ {
@@ -50,26 +79,488 @@
{ {
<span>Není skladem</span> <span>Není skladem</span>
} }
</div> </div>
<div class="market-card-bottom">
<strong>@Product.Price.ToString("N0") Kč</strong> <!-- CENA A AKCE -->
<div class="jarmark-card-actions">
<div class="jarmark-card-price">
<strong>@Product.Price.ToString("N0") Kč</strong>
</div>
@if (OnAddToCart.HasDelegate)
{
<button type="button"
class="jarmark-card-cart"
disabled="@(Product.StockQuantity <= 0)"
aria-label="@($"Přidat do košíku: {Product.Name}")"
@onclick="AddToCart"
@onclick:stopPropagation="true">
@if (Product.StockQuantity > 0)
{
<svg width="20"
height="20"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="1.7"
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true">
<path d="M3 3h2l3.5 13h10l3-10H6" />
<circle cx="10"
cy="20"
r="1" />
<circle cx="18"
cy="20"
r="1" />
</svg>
<span>Do košíku</span>
}
else
{
<span>Vyprodáno</span>
}
</button>
}
</div> </div>
@if (OnAddToCart.HasDelegate)
{
<button type="button"
class="product-cart-button"
disabled="@(Product.StockQuantity <= 0)"
@onclick="AddToCart"
@onclick:stopPropagation="true">
🛒 Do košíku
</button>
}
</div> </div>
</article> </article>
<style>
/* ========================================
PUBLIC PRODUCT CARD
======================================== */
.jarmark-product-card {
--card-primary: #244b36;
--card-primary-hover: #193b29;
--card-surface: #ffffff;
--card-text: #26372b;
--card-muted: #59665b;
--card-border: #dce3d9;
position: relative;
isolation: isolate;
display: flex;
flex-direction: column;
width: 100%;
min-width: 0;
height: 100%;
margin: 0;
padding: 0;
background: var(--card-surface);
color: var(--card-text);
border: 1px solid var(--card-border);
border-radius: 8px;
overflow: hidden;
box-sizing: border-box;
font-family: inherit;
transition: border-color 150ms ease;
}
.jarmark-product-card:hover {
border-color: #9aad96;
}
/* ========================================
PRODUCT IMAGE
======================================== */
.jarmark-product-card .jarmark-card-picture {
position: relative;
display: flex;
align-items: center;
justify-content: center;
width: 100%;
aspect-ratio: 4 / 3;
overflow: hidden;
background: #edf0e9;
border-bottom: 1px solid var(--card-border);
}
.jarmark-product-card .jarmark-card-picture img {
display: block;
width: 100%;
height: 100%;
max-width: 100%;
object-fit: contain;
object-position: center;
margin: 0;
padding: 12px;
box-sizing: border-box;
}
/* ========================================
IMAGE FALLBACK
======================================== */
.jarmark-product-card .jarmark-card-placeholder {
display: flex;
align-items: center;
justify-content: center;
width: 100%;
height: 100%;
min-height: 120px;
background: #e6eddf;
color: var(--card-primary);
}
.jarmark-product-card .jarmark-card-placeholder span {
display: block;
font-size: 48px;
line-height: 1;
}
/* ========================================
CARD CONTENT
======================================== */
.jarmark-product-card .jarmark-card-body {
display: flex;
flex: 1;
flex-direction: column;
gap: 12px;
min-width: 0;
padding: 20px;
}
/* ========================================
CATEGORY
======================================== */
.jarmark-product-card .jarmark-card-category {
margin: 0;
color: var(--card-muted);
font-size: 13px;
font-weight: 500;
line-height: 1.4;
letter-spacing: normal;
text-transform: none;
overflow-wrap: anywhere;
}
/* ========================================
PRODUCT NAME AND DETAIL LINK
======================================== */
.jarmark-product-card .jarmark-card-title {
margin: 0;
color: var(--card-text);
font-family: Georgia, "Times New Roman", serif;
font-size: 21px;
font-weight: 700;
line-height: 1.3;
letter-spacing: normal;
overflow-wrap: anywhere;
}
.jarmark-product-card .jarmark-card-detail {
color: inherit;
text-decoration: none;
}
.jarmark-product-card .jarmark-card-detail:hover {
color: var(--card-primary);
text-decoration: underline;
text-underline-offset: 4px;
}
/*
Celá karta zůstává kliknutelná.
Tlačítko košíku má vlastní vrstvu.
*/
.jarmark-product-card .jarmark-card-detail::after {
content: "";
position: absolute;
inset: 0;
z-index: 1;
border-radius: 8px;
}
.jarmark-product-card .jarmark-card-detail:focus-visible::after {
outline: 3px solid #527b49;
outline-offset: -3px;
}
/* ========================================
DESCRIPTION
======================================== */
.jarmark-product-card .jarmark-card-description {
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 3;
overflow: hidden;
overflow-wrap: anywhere;
margin: 0;
color: var(--card-muted);
font-size: 14px;
line-height: 1.6;
}
/* ========================================
STOCK AVAILABILITY
======================================== */
.jarmark-product-card .jarmark-card-stock {
display: flex;
align-items: center;
gap: 8px;
margin: 4px 0 0;
font-size: 13px;
font-weight: 600;
line-height: 1.4;
}
.jarmark-product-card .jarmark-stock-indicator {
display: inline-block;
flex-shrink: 0;
width: 8px;
height: 8px;
background: currentColor;
border-radius: 50%;
}
.jarmark-product-card .is-available {
color: #34754b;
}
.jarmark-product-card .is-unavailable {
color: #93483e;
}
/* ========================================
PRICE AND ACTIONS
======================================== */
.jarmark-product-card .jarmark-card-actions {
display: flex;
flex-direction: column;
gap: 12px;
margin-top: auto;
padding-top: 12px;
}
.jarmark-product-card .jarmark-card-price {
display: flex;
align-items: baseline;
margin: 0;
color: var(--card-primary);
font-size: 26px;
line-height: 1.2;
font-variant-numeric: tabular-nums;
}
.jarmark-product-card .jarmark-card-price strong {
font-weight: 750;
}
/* ========================================
ADD TO CART BUTTON
======================================== */
.jarmark-product-card .jarmark-card-cart {
position: relative;
z-index: 2;
display: flex;
align-items: center;
justify-content: center;
gap: 8px;
width: 100%;
min-height: 48px;
margin: 0;
padding: 12px 16px;
background: var(--card-primary);
color: #ffffff;
border: 1px solid var(--card-primary);
border-radius: 6px;
font-family: inherit;
font-size: 14px;
font-weight: 650;
line-height: 1.4;
text-align: center;
cursor: pointer;
transition: background-color 150ms ease, border-color 150ms ease;
}
.jarmark-product-card .jarmark-card-cart svg {
flex-shrink: 0;
}
.jarmark-product-card .jarmark-card-cart:not(:disabled):hover {
background: var(--card-primary-hover);
border-color: var(--card-primary-hover);
color: #ffffff;
}
.jarmark-product-card .jarmark-card-cart:disabled {
background: #e9ece7;
color: #59665b;
border-color: #dce3d9;
opacity: 1;
cursor: not-allowed;
}
.jarmark-product-card .jarmark-card-cart:focus-visible {
outline: 3px solid #527b49;
outline-offset: 3px;
}
/* ========================================
TABLET
======================================== */
@@media (max-width: 1024px) {
.jarmark-product-card .jarmark-card-body {
padding: 16px;
}
.jarmark-product-card .jarmark-card-title {
font-size: 20px;
}
.jarmark-product-card .jarmark-card-price {
font-size: 24px;
}
}
/* ========================================
MOBILE
======================================== */
@@media (max-width: 640px) {
.jarmark-product-card .jarmark-card-body {
gap: 8px;
padding: 12px;
}
.jarmark-product-card .jarmark-card-title {
font-size: 18px;
}
.jarmark-product-card .jarmark-card-category {
font-size: 12px;
}
.jarmark-product-card .jarmark-card-description {
font-size: 13px;
-webkit-line-clamp: 2;
}
.jarmark-product-card .jarmark-card-stock {
gap: 4px;
font-size: 12px;
}
.jarmark-product-card .jarmark-card-price {
font-size: 22px;
}
.jarmark-product-card .jarmark-card-cart {
min-height: 48px;
padding: 12px 8px;
font-size: 13px;
}
.jarmark-product-card .jarmark-card-cart svg {
width: 18px;
height: 18px;
}
.jarmark-product-card .jarmark-card-placeholder span {
font-size: 40px;
}
}
/* ========================================
SINGLE COLUMN MOBILE
======================================== */
@@media (max-width: 480px) {
.jarmark-product-card .jarmark-card-body {
gap: 12px;
padding: 16px;
}
.jarmark-product-card .jarmark-card-title {
font-size: 22px;
}
.jarmark-product-card .jarmark-card-description {
font-size: 14px;
-webkit-line-clamp: 3;
}
.jarmark-product-card .jarmark-card-category {
font-size: 13px;
}
.jarmark-product-card .jarmark-card-stock {
gap: 8px;
font-size: 13px;
}
.jarmark-product-card .jarmark-card-price {
font-size: 26px;
}
.jarmark-product-card .jarmark-card-cart {
font-size: 15px;
}
}
/* ========================================
REDUCED MOTION
======================================== */
@@media (prefers-reduced-motion: reduce) {
.jarmark-product-card,
.jarmark-product-card * {
animation: none !important;
transition: none !important;
scroll-behavior: auto !important;
}
}
</style>
@code { @code {
[Parameter, EditorRequired] [Parameter, EditorRequired]
public Product Product { get; set; } = default!; public Product Product { get; set; } = default!;
@@ -78,43 +569,38 @@
private bool imageFailed; private bool imageFailed;
protected override void OnParametersSet() protected override void OnParametersSet()
{ {
imageFailed = false; imageFailed = false;
} }
private void OpenProductDetail()
{
NavigationManager.NavigateTo($"/produkt/{Product.Id}");
}
private void HandleCardKeyDown(KeyboardEventArgs e)
{
if (e.Key == "Enter" || e.Key == " ")
{
OpenProductDetail();
}
}
private void HandleImageError() private void HandleImageError()
{ {
imageFailed = true; imageFailed = true;
} }
private string ProductIcon => private string ProductIcon =>
Product.Category?.Name.Contains( Product.Category?.Name.Contains(
"med", "med",
StringComparison.OrdinalIgnoreCase) == true ? "🍯" : StringComparison.OrdinalIgnoreCase) == true ? "🍯" :
Product.Category?.Name.Contains( Product.Category?.Name.Contains(
"cuk", "cuk",
StringComparison.OrdinalIgnoreCase) == true ? "🍪" : StringComparison.OrdinalIgnoreCase) == true ? "🍪" :
Product.Category?.Name.Contains( Product.Category?.Name.Contains(
"dřev", "dřev",
StringComparison.OrdinalIgnoreCase) == true ? "🪵" : StringComparison.OrdinalIgnoreCase) == true ? "🪵" :
"🎁"; "🎁";
private async Task AddToCart() private async Task AddToCart()
{ {
await OnAddToCart.InvokeAsync(Product); await OnAddToCart.InvokeAsync(Product);
} }
} }

View File

@@ -1,3 +1,4 @@
using Microsoft.AspNetCore.Components.Authorization; using Microsoft.AspNetCore.Components.Authorization;
using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Identity;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
@@ -100,7 +101,6 @@ app.Use(async (context, next) =>
}); });
} }
// Token musí být dostupný i v aktuálním requestu
context.Items["CartToken"] = token; context.Items["CartToken"] = token;
await next(); await next();
@@ -115,4 +115,4 @@ app.MapRazorComponents<App>()
app.MapAdditionalIdentityEndpoints(); app.MapAdditionalIdentityEndpoints();
app.Run(); app.Run();