Compare commits

..

5 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
Ondur
28316b58ab program 2026-11-18 17:33:30 +01:00
Ondur
26c82eca08 oprava tokenu 2026-11-18 17:26:16 +01:00
14 changed files with 6182 additions and 2110 deletions

View File

@@ -1,19 +1,41 @@
@inherits LayoutComponentBase
<div class="page">
<aside class="sidebar">
<NavMenu />
</aside>
<div class="page public-layout">
<main class="main-content">
<article class="content">
<a href="#public-main-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
</article>
</main>
</div>
<div id="blazor-error-ui" data-nosnippet>
<span role="alert">
Nastala neočekávaná chyba.
<a href="." class="reload">Obnovit stránku</a>
<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>

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;
min-height: 100vh;
background: #f7f9f5;
}
.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;
flex-direction: column;
align-items: stretch;
width: 100%;
min-width: 0;
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;
margin: 0 auto;
padding: 30px 35px !important;
/* ========================================
BOX SIZING
======================================== */
.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 {
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;
color: #58451b;
bottom: 0;
box-shadow: 0 -2px 15px rgba(0, 0, 0, .08);
border-top: 1px solid #e5d4a1;
box-sizing: border-box;
display: none;
left: 0;
padding: 14px 25px;
position: fixed;
width: 100%;
z-index: 1000;
border-top: 1px solid #f0dfb4;
color-scheme: light;
font-size: 14px;
line-height: 1.5;
}
#blazor-error-ui .reload {
color: #315b3e;
font-weight: 700;
display: inline-block;
margin-left: 8px;
color: #244b36;
font-weight: 700;
text-decoration: underline;
}
#blazor-error-ui .dismiss {
cursor: pointer;
position: absolute;
right: 18px;
top: 12px;
top: 50%;
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) {
.page {
#blazor-error-ui .dismiss:focus-visible,
#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;
width: 100%;
font-size: 15px;
}
.sidebar {
width: 100%;
.public-layout > .sidebar.public-header {
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-height: auto;
position: relative;
border-right: none;
border-bottom: 1px solid #e8ede5;
margin: 0 !important;
padding: 0 !important;
}
.main-content {
.public-main > .content.public-container {
width: 100%;
padding: 16px 16px 32px !important;
}
.content {
padding: 18px 15px !important;
.public-container ::deep h1 {
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;
}
}
@media (min-width: 641px) {
.sidebar {
height: 100vh;
/* ========================================
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;
}
}
/* ========================================
REDUCED MOTION
======================================== */
@media (prefers-reduced-motion: reduce) {
*,
*::before,
*::after {
.public-layout,
.public-layout ::deep *,
.public-layout ::deep *::before,
.public-layout ::deep *::after {
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">
<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">
<strong>Školní jarmark</strong>
<small>ONLINE KATALOG</small>
</span>
</a>
</div>
<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" />
<div class="nav-scrollable"
onclick="document.querySelector('.navbar-toggler').click()">
id="public-navigation">
<div class="nav-section-label">HLAVNÍ MENU</div>
<nav class="nav flex-column">
<nav class="nav public-nav-links"
aria-label="Hlavní navigace">
<div class="nav-item">
<NavLink class="nav-link"
href=""
Match="NavLinkMatch.All">
<span class="nav-icon bi bi-house-door-fill-nav-menu"></span>
<span>Domů</span>
</NavLink>
</div>
Match="NavLinkMatch.All"
onclick="document.getElementById('public-menu-toggle').checked = false">
<span>Katalog</span>
<div class="nav-item">
<NavLink class="nav-link" href="kosik">
<span class="nav-icon bi bi-cart-fill"></span>
<span>Košík</span>
</NavLink>
</div>
<AuthorizeView Roles="Admin">
<Authorized>
<div class="nav-section-label secondary-label">
SPRÁVA
</div>
<div class="nav-item">
<NavLink class="nav-link" href="admin">
<span class="nav-icon bi bi-lock-nav-menu"></span>
<NavLink class="nav-link"
href="admin"
onclick="document.getElementById('public-menu-toggle').checked = false">
<span>Administrace</span>
</NavLink>
</div>
</Authorized>
</AuthorizeView>
</nav>
<div class="nav-bottom">
<div class="nav-section-label">UŽIVATEL</div>
<div class="nav-bottom public-account-links">
<AuthorizeView>
<Authorized>
<div class="nav-item">
<NavLink class="nav-link" href="Account/Manage">
<span class="nav-icon bi bi-person-fill-nav-menu"></span>
<span class="user-name">@context.User.Identity?.Name</span>
<div class="nav-item account-item">
<NavLink class="nav-link"
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>
</div>
<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">
<span class="nav-icon bi bi-arrow-bar-left-nav-menu"></span>
<form action="Account/Logout"
method="post">
<AntiforgeryToken />
<input type="hidden"
name="ReturnUrl"
value="@currentUrl" />
<button type="submit"
class="nav-link logout-link">
<span>Odhlásit</span>
</button>
</form>
</div>
</Authorized>
<NotAuthorized>
<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>
</NavLink>
</div>
<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>
</NavLink>
</div>
</NotAuthorized>
</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>
@code {
@@ -124,10 +220,14 @@
NavigationManager.LocationChanged += OnLocationChanged;
}
private void OnLocationChanged(object? sender, LocationChangedEventArgs e)
private void OnLocationChanged(
object? sender,
LocationChangedEventArgs e)
{
currentUrl = NavigationManager.ToBaseRelativePath(e.Location);
StateHasChanged();
currentUrl = NavigationManager.ToBaseRelativePath(
e.Location);
_ = InvokeAsync(StateHasChanged);
}
public void Dispose()

View File

@@ -1,329 +1,522 @@
/* ========================================
SKOLNI JARMARK - PUBLIC NAVIGATION
======================================== */
.nav-panel {
display: flex;
flex-direction: column;
width: 100%;
height: 100%;
min-height: 100vh;
background: #ffffff;
color: #304536;
}
/* Logo */
.nav-brand-area {
height: 100px;
min-height: 100px;
--nav-primary: #244b36;
--nav-primary-hover: #193b29;
--nav-secondary: #e6eddf;
--nav-text: #26372b;
--nav-muted: #59665b;
--nav-border: #dce3d9;
--nav-surface: #ffffff;
position: relative;
display: flex;
align-items: center;
padding: 0 24px;
border-bottom: 1px solid #edf0e9;
gap: 32px;
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 {
display: flex;
display: inline-flex;
align-items: center;
gap: 12px;
color: #294c35 !important;
gap: 8px;
min-height: 44px;
margin: 0;
padding: 0;
color: var(--nav-primary);
text-decoration: none;
transition: opacity .2s ease;
}
.navbar-brand:hover {
opacity: .8;
color: var(--nav-primary-hover);
}
.brand-symbol {
display: grid;
place-items: center;
width: 45px;
height: 45px;
display: block;
width: 32px;
height: 32px;
flex-shrink: 0;
border-radius: 15px;
background: #eaf1e5;
font-size: 25px;
color: var(--nav-primary);
}
.brand-text {
display: flex;
flex-direction: column;
gap: 3px;
display: block;
}
.brand-text strong {
font-size: 17px;
font-weight: 850;
letter-spacing: -.5px;
font-family: Georgia, "Times New Roman", serif;
font-size: 23px;
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 {
display: flex;
align-items: center;
justify-content: space-between;
flex: 1;
flex-direction: column;
padding: 30px 15px 20px;
overflow-y: auto;
gap: 16px;
min-width: 0;
}
.nav-section-label {
padding: 0 12px;
margin-bottom: 13px;
color: #9ba79a;
font-size: 10px;
font-weight: 850;
letter-spacing: 1.6px;
.public-nav-links {
display: flex;
flex-direction: row;
align-items: center;
flex-wrap: wrap;
gap: 4px;
margin: 0;
padding: 0;
}
.secondary-label {
margin-top: 32px;
.public-account-links {
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 {
margin-bottom: 6px;
display: block;
min-width: 0;
margin: 0;
padding: 0;
font-size: 14px;
font-weight: 650;
font-weight: 600;
}
/* ========================================
NAVIGATION LINKS
======================================== */
.nav-item ::deep .nav-link {
position: relative;
display: flex;
align-items: center;
gap: 13px;
width: 100%;
min-height: 49px;
padding: 0 14px;
justify-content: flex-start;
gap: 8px;
min-height: 44px;
margin: 0;
padding: 8px 12px;
border: 1px solid transparent;
border-radius: 12px;
border-radius: 6px;
background: transparent;
color: #758275;
text-decoration: none;
color: var(--nav-muted);
font-family: inherit;
font-size: 14px;
font-weight: 600;
line-height: 1.4;
text-align: left;
line-height: normal;
transition: background .2s ease, color .2s ease, transform .2s ease, border-color .2s ease;
text-decoration: none;
white-space: nowrap;
transition: background-color 150ms ease, color 150ms ease, border-color 150ms ease;
}
.nav-item ::deep .nav-link:hover {
background: #f4f7f1;
color: #315b3e;
transform: translateX(3px);
background: #f1f4ef;
color: var(--nav-primary);
text-decoration: none;
}
.nav-item ::deep a.active {
background: #eaf2e5;
color: #315b3e;
border-color: #dce9d5;
font-weight: 750;
.nav-item ::deep a.nav-link.active {
background: var(--nav-secondary);
color: var(--nav-primary);
border-color: #dce5d7;
font-weight: 700;
}
.nav-item ::deep a.active::before {
content: "";
position: absolute;
left: -15px;
top: 11px;
bottom: 11px;
width: 3px;
border-radius: 0 5px 5px 0;
background: #6f9668;
}
/* ========================================
ICONS
======================================== */
.nav-icon {
display: inline-flex;
align-items: center;
justify-content: center;
width: 21px;
height: 21px;
display: block;
width: 20px;
height: 20px;
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 {
display: block;
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
/* Spodní část */
.nav-bottom {
margin-top: auto;
padding-top: 30px;
border-top: 1px solid #edf0e9;
}
.nav-item ::deep form {
width: 100%;
margin: 0;
padding: 0;
}
.nav-item ::deep button.nav-link {
width: 100%;
font-family: inherit;
font-size: inherit;
cursor: pointer;
}
.nav-item ::deep .logout-link {
color: #9a7771;
color: #8b4038;
}
.nav-item ::deep .logout-link:hover {
background: #fff1ef;
color: #b34e43;
background: #fbefed;
color: #74342d;
border-color: #efd8d4;
}
/* Patička */
.nav-footer {
/* ========================================
SHOPPING CART - PRIMARY ACTION
======================================== */
.cart-item {
margin-left: 4px;
}
.cart-item ::deep .public-cart-link {
display: flex;
align-items: center;
gap: 11px;
margin-top: 28px;
padding: 16px 12px 5px;
border-top: 1px solid #edf0e9;
justify-content: center;
gap: 8px;
min-height: 44px;
padding: 10px 20px;
border: 1px solid var(--nav-primary);
border-radius: 6px;
background: var(--nav-primary);
color: #ffffff;
font-weight: 700;
}
.footer-leaf {
display: grid;
place-items: center;
width: 36px;
height: 36px;
border-radius: 11px;
background: #edf3e9;
font-size: 19px;
.cart-item ::deep .public-cart-link:hover {
background: var(--nav-primary-hover);
border-color: var(--nav-primary-hover);
color: #ffffff;
}
.nav-footer div {
display: flex;
flex-direction: column;
gap: 3px;
.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;
}
.nav-footer strong {
color: #49634b;
font-size: 12px;
/* ========================================
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 small {
color: #9ba69a;
font-size: 10px;
}
/* Mobilní menu */
/* ========================================
MOBILE MENU TOGGLE
======================================== */
.navbar-toggler {
display: none;
appearance: none;
-webkit-appearance: none;
position: absolute;
top: 27px;
right: 20px;
z-index: 5;
width: 42px;
height: 42px;
top: 12px;
right: 24px;
width: 44px;
height: 44px;
margin: 0;
border: 1px solid #e4eadf;
border-radius: 12px;
background: #f5f8f2;
padding: 0;
border: 1px solid var(--nav-border);
border-radius: 6px;
background: var(--nav-surface);
color: var(--nav-primary);
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 {
content: "☰";
display: grid;
place-items: center;
width: 100%;
height: 100%;
color: #315b3e;
font-size: 19px;
top: 14px;
box-shadow: 0 6px 0 currentColor;
}
.navbar-toggler::after {
top: 26px;
}
.navbar-toggler:checked {
background: var(--nav-secondary);
}
.navbar-toggler:checked::before {
content: "✕";
top: 20px;
transform: rotate(45deg);
box-shadow: none;
}
@media (min-width: 641px) {
.navbar-toggler {
display: none;
.navbar-toggler:checked::after {
top: 20px;
transform: rotate(-45deg);
}
.nav-scrollable {
display: flex !important;
height: calc(100vh - 100px);
}
.navbar-toggler:hover {
background-color: var(--nav-secondary);
}
@media (max-width: 640.98px) {
/* ========================================
COMPACT DESKTOP
======================================== */
@media (max-width: 1200px) {
.nav-panel {
min-height: auto;
height: auto;
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;
}
}
/* ========================================
TABLET AND MOBILE
======================================== */
@media (max-width: 1024px) {
.nav-panel {
display: flex;
flex-direction: column;
align-items: stretch;
gap: 0;
min-height: 68px;
padding: 0;
}
.nav-brand-area {
height: 78px;
min-height: 78px;
padding: 0 18px;
display: flex;
align-items: center;
min-height: 68px;
padding: 12px 84px 12px 24px;
}
.navbar-toggler {
top: 18px;
right: 18px;
display: block;
}
.nav-scrollable {
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 {
display: flex;
animation: menuEnter .22s ease both;
}
.nav-bottom {
margin-top: 20px;
.public-nav-links {
display: flex;
flex-direction: column;
align-items: stretch;
gap: 4px;
width: 100%;
}
.nav-footer {
margin-top: 18px;
.public-account-links {
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;
}
}
@keyframes menuEnter {
from {
opacity: 0;
transform: translateY(-7px);
/* ========================================
MOBILE - MAX 640 PX
======================================== */
@media (max-width: 640px) {
.nav-brand-area {
padding: 12px 76px 12px 16px;
}
to {
opacity: 1;
transform: translateY(0);
.navbar-toggler {
right: 16px;
}
.brand-symbol {
width: 28px;
height: 28px;
}
.brand-text strong {
font-size: 20px;
}
.nav-scrollable {
padding: 12px 16px 20px;
}
}
.nav-scrollable::-webkit-scrollbar {
width: 5px;
/* ========================================
SMALL MOBILE
======================================== */
@media (max-width: 360px) {
.brand-text strong {
font-size: 18px;
}
.nav-scrollable::-webkit-scrollbar-thumb {
background: #dce6d7;
border-radius: 10px;
.brand-symbol {
width: 24px;
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;
}
}
/* ========================================
REDUCED MOTION
======================================== */
@media (prefers-reduced-motion: reduce) {
.nav-panel *,
.nav-panel *::before,
.nav-panel *::after {
animation: none !important;
.navbar-brand,
.navbar-toggler,
.nav-panel ::deep .nav-link {
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}"
@layout Web_Jarmark.Components.Layout.Admin.AdminLayout
@rendermode InteractiveServer
@using Microsoft.EntityFrameworkCore
@using Microsoft.AspNetCore.Authorization
@using Web_Jarmark.Data
@using Web_Jarmark.Data.Models
@inject ApplicationDbContext Db
@inject NavigationManager Nav
@@ -41,7 +44,7 @@
<section class="ao-panel" style="max-width:560px;margin:0 auto">
<div class="ap-field">
<label>Název</label>
<input class="ao-input" @bind="name" />
<input class="ao-input" maxlength="150" @bind="name" />
</div>
<div class="ap-field">
@@ -57,22 +60,35 @@
<div class="ap-field">
<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 class="ap-field">
<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 class="ap-field">
<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 class="ap-field">
<label>URL obrázku</label>
<input class="ao-input" @bind="imageUrl" />
<input class="ao-input"
maxlength="2048"
@bind="imageUrl" />
</div>
<label class="ap-switch">
@@ -81,9 +97,13 @@
</label>
<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")
</button>
<a class="ap-btn" href="/admin/zbozi">Zrušit</a>
</div>
</section>
@@ -136,7 +156,10 @@
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)
{
notFound = true;
@@ -151,29 +174,75 @@
stockQuantity = entity.StockQuantity;
imageUrl = entity.ImageUrl ?? "";
isVisible = entity.IsVisible;
loading = false;
}
private async Task SaveAsync()
{
if (saving)
return;
saving = true;
error = null;
try
{
name = name?.Trim() ?? "";
description = description?.Trim() ?? "";
imageUrl = imageUrl?.Trim() ?? "";
if (string.IsNullOrWhiteSpace(name))
{
error = "Zadejte název produktu.";
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;
}
Product entity;
if (IsNew)
{
entity = new Product();
@@ -181,24 +250,37 @@
}
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.Description = description?.Trim() ?? "";
entity.Name = name;
entity.Description = description;
entity.CategoryId = categoryId;
entity.Price = price;
entity.StockQuantity = stockQuantity;
entity.ImageUrl = imageUrl?.Trim() ?? "";
entity.ImageUrl = imageUrl;
entity.IsVisible = isVisible;
entity.UpdatedAt = DateTime.UtcNow;
await Db.SaveChangesAsync();
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
{
@@ -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);
}
```

View File

@@ -10,139 +10,798 @@
@implements IDisposable
<PageTitle>Detail produktu</PageTitle>
<PageTitle>Detail produktu | Školní jarmark</PageTitle>
<div class="jarmark-product-detail">
<!-- NOTIFIKACE -->
@if (showNotification)
{
<div class="cart-notification" role="status" aria-live="polite">
<span class="notification-icon">✓</span>
<div class="jarmark-detail-notification"
role="status"
aria-live="polite">
<svg width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
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)
{
<p>Načítám produkt...</p>
<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)
{
<h3>Produkt nebyl nalezen.</h3>
<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
{
<div class="detail-container">
<a href="/" class="back-link">← Zpět do katalogu</a>
<article class="jarmark-detail-card">
<div class="detail-card">
<div class="detail-image">
<img src="@product.ImageUrl" alt="@product.Name" />
</div>
<!-- FOTOGRAFIE -->
<div class="detail-info">
<span class="detail-category">
@product.Category?.Name
</span>
<div class="jarmark-detail-image">
<h1>@product.Name</h1>
@if (!string.IsNullOrWhiteSpace(product.ImageUrl)
&& !imageFailed)
{
<img src="@product.ImageUrl"
alt="@product.Name"
decoding="async"
@onerror="HandleImageError" />
}
else
{
<div class="jarmark-detail-placeholder">
<p class="detail-description">
@product.Description
</p>
<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">
<div class="detail-stock">
<span class="stock-dot"></span>
Skladem: @product.StockQuantity ks
</div>
<rect x="3"
y="3"
width="18"
height="18"
rx="2" />
<div class="detail-divider"></div>
<circle cx="8.5"
cy="8.5"
r="1.5" />
<div class="detail-bottom">
<div>
<span class="price-label">Cena produktu</span>
<div class="detail-price">
@product.Price.ToString("N0") Kč
</div>
</div>
<path d="m21 15-5-5L5 21" />
</svg>
<span>Fotografie není dostupná</span>
<button class="product-cart-button"
disabled="@(product.StockQuantity <= 0)"
@onclick="() => HandleAddToCart(product)">
🛒 Přidat do košíku
</button>
</div>
</div>
</div>
</div>
}
</div>
<!-- INFORMACE O VÝROBKU -->
<div class="jarmark-detail-info">
@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>
<!-- CENA A NÁKUP -->
<div class="jarmark-detail-purchase">
<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č
</strong>
</div>
<button type="button"
class="jarmark-detail-button"
disabled="@(product.StockQuantity <= 0)"
@onclick="() => HandleAddToCart(product)">
@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>
</div>
</div>
</article>
}
</div>
<style>
.cart-notification {
/* ========================================
PUBLIC PRODUCT DETAIL
======================================== */
.jarmark-product-detail {
--detail-primary: #244b36;
--detail-primary-hover: #193b29;
--detail-secondary: #e6eddf;
--detail-surface: #ffffff;
--detail-text: #26372b;
--detail-muted: #59665b;
--detail-border: #dce3d9;
width: 100%;
max-width: 1200px;
min-width: 0;
margin: 0 auto;
color: var(--detail-text);
font-family: inherit;
box-sizing: border-box;
}
/* ========================================
BACK LINK
======================================== */
.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;
}
.jarmark-product-detail .jarmark-detail-back svg {
flex-shrink: 0;
}
.jarmark-product-detail .jarmark-detail-back:hover {
color: var(--detail-primary-hover);
text-decoration: underline;
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;
}
/* ========================================
PRODUCT IMAGE
======================================== */
.jarmark-product-detail .jarmark-detail-image {
display: flex;
align-items: 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: 25px;
right: 25px;
z-index: 9999;
top: 96px;
right: 24px;
z-index: 500;
display: flex;
align-items: center;
gap: 12px;
padding: 16px 22px;
background: #ffffff;
color: #222222;
border: 1px solid #d9eadf;
border-radius: 12px;
box-shadow: 0 8px 30px rgba(0, 0, 0, 0.14);
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: 650;
animation: notification-in 0.25s ease-out, notification-out 1s ease-in 2.5s forwards;
font-weight: 500;
line-height: 1.5;
overflow-wrap: anywhere;
}
.notification-icon {
display: flex;
align-items: center;
justify-content: center;
width: 27px;
height: 27px;
.jarmark-product-detail .jarmark-detail-notification svg {
flex-shrink: 0;
border-radius: 50%;
background: #e2f7e9;
color: #168344;
font-size: 17px;
font-weight: 900;
color: var(--detail-primary);
}
@@keyframes notification-in {
from {
opacity: 0;
transform: translateY(-10px);
/* ========================================
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;
}
to {
opacity: 1;
transform: translateY(0);
/* ========================================
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;
}
}
@@keyframes notification-out {
from {
opacity: 1;
transform: translateY(0);
/* ========================================
MOBILE
======================================== */
@@media (max-width: 768px) {
.jarmark-product-detail .jarmark-detail-card {
grid-template-columns: minmax(0, 1fr);
gap: 24px;
padding: 16px;
border-radius: 8px;
}
to {
opacity: 0;
transform: translateY(-12px);
}
.jarmark-product-detail .jarmark-detail-back {
margin-bottom: 12px;
}
@@media (max-width: 500px) {
.cart-notification {
top: 15px;
.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;
justify-content: center;
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>
@code {
[Parameter]
public int Id { get; set; }
@@ -156,6 +815,15 @@ else
private CancellationTokenSource? notificationCts;
private bool imageFailed;
private void HandleImageError()
{
imageFailed = true;
}
protected override async Task OnInitializedAsync()
{
if (!ApplicationState.TryTakeFromJson<string>(
@@ -172,6 +840,7 @@ else
protected override async Task OnParametersSetAsync()
{
loading = true;
imageFailed = false;
product = await DbContext.Products
.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
@inject NavigationManager NavigationManager
<article class="market-card"
role="link"
tabindex="0"
@onclick="OpenProductDetail"
@onkeydown="HandleCardKeyDown">
<article class="jarmark-product-card">
<!-- FOTOGRAFIE PRODUKTU -->
<div class="jarmark-card-picture">
<div class="market-product-picture">
@if (!string.IsNullOrWhiteSpace(Product.ImageUrl) && !imageFailed)
{
<img src="@Product.ImageUrl.Trim()"
alt="@Product.Name"
loading="lazy"
decoding="async"
@onerror="HandleImageError" />
}
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)
{
<span class="market-product-tag">
@Product.Category.Name
</span>
}
</div>
<div class="jarmark-card-category">
<div class="market-card-content">
<h3>@Product.Name</h3>
@Product.Category.Name
</div>
}
<h3 class="jarmark-card-title">
<a href="@($"/produkt/{Product.Id}")"
class="jarmark-card-detail">
@Product.Name
</a>
</h3>
@if (!string.IsNullOrWhiteSpace(Product.Description))
{
<p class="market-description">
<p class="jarmark-card-description">
@Product.Description
</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)
{
@@ -50,26 +79,488 @@
{
<span>Není skladem</span>
}
</div>
<div class="market-card-bottom">
<!-- 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="product-cart-button"
class="jarmark-card-cart"
disabled="@(Product.StockQuantity <= 0)"
aria-label="@($"Přidat do košíku: {Product.Name}")"
@onclick="AddToCart"
@onclick:stopPropagation="true">
🛒 Do košíku
@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>
</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 {
[Parameter, EditorRequired]
public Product Product { get; set; } = default!;
@@ -78,43 +569,38 @@
private bool imageFailed;
protected override void OnParametersSet()
{
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()
{
imageFailed = true;
}
private string ProductIcon =>
Product.Category?.Name.Contains(
"med",
StringComparison.OrdinalIgnoreCase) == true ? "🍯" :
Product.Category?.Name.Contains(
"cuk",
StringComparison.OrdinalIgnoreCase) == true ? "🍪" :
Product.Category?.Name.Contains(
"dřev",
StringComparison.OrdinalIgnoreCase) == true ? "🪵" :
"🎁";
private async Task AddToCart()
{
await OnAddToCart.InvokeAsync(Product);
}
}

View File

@@ -101,6 +101,8 @@ app.Use(async (context, next) =>
});
}
context.Items["CartToken"] = token;
await next();
});