Open-source eCommerce platform for C# and ASP.NET Core 10 with MongoDB. Build multi-store shops and multi-vendor marketplaces with B2B/B2C, REST API, plugins, Vue 3 and Docker.
C# aspnet-corecsharpdockerdotnetecommerceecommerce-platformmongodbmulti-storemulti-vendornosqlonline-shopshoppingcart
@using System.Text.Encodings.Web
@inject IContextAccessor contextAccessor
@inject StoreInformationSettings StoreInformationSettings
@inject CommonSettings CommonSettings
@{
var supportRtl = contextAccessor.WorkContext.WorkingLanguage.Rtl;
@* Modern: the promo line is store content from the HeaderPromoText page block, the same
block Nordic reads; the bar is left out entirely when that page is missing or
unpublished (PageBlock renders "") *@
var promo = await Component.InvokeAsync("PageBlock", new { systemName = "HeaderPromoText" });
string promoHtml;
using (var promoWriter = new StringWriter())
{
promo.WriteTo(promoWriter, HtmlEncoder.Default);
promoHtml = promoWriter.ToString();
}
}
@if (!string.IsNullOrWhiteSpace(promoHtml))
{
<div class="mdn-promo">
@Html.Raw(promoHtml)
</div>
}
@*<header> rather than a plain div: this is the site banner landmark, and it was the
only region of the page a screen reader had no way to jump to.
Modern: the header itself is not a vue-island. The search box below is an island of its
own (Components/SearchBox), and an island nested in another is compiled twice; only the
icon list, which binds darkMode and the cart counters, needs Vue.*@
<header class="header-nav mdn-header">
<nav class="navbar navbar-expand">
<div class="container" id="header-container">
<div class="menu-container">
<button aria-label="menu-toggler" class="btn menu-toggler" data-bs-toggle="offcanvas" data-bs-target="#sidebar-menu" aria-controls="sidebar-menu">
<span></span><span></span><span></span>
</button>
</div>
<partial name="Partials/Logo"/>
@*Modern: the catalogue menu inline in the bar on desktop; the drawer below still
carries it for phones and tablets. v-pre: category names are database content
and this sits inside a Vue island.*@
<div class="mdn-menu-row" v-pre>
<ul class="mdn-menu" aria-label="@Loc["Categories"]">
@await Component.InvokeAsync("Menu")
</ul>
</div>
@*Modern: the search box sits in the bar and is typed into directly - no modal*@
<div class="mdn-search">
@await Component.InvokeAsync("SearchBox")
</div>
<ul class="navbar-nav top-header-items order-3" vue-island>
<li class="nav-item">
<span class="nav-link">
<div class="form-check form-switch form-check-lg contrast-switch">
<input class="form-check-input" type="checkbox" id="contrast-button" name="contrast-button" v-model="darkMode">
<label class="form-check-label" for="contrast-button">
<i class="b-icon bi bi-sun light" aria-hidden="true"></i>
<i class="b-icon bi bi-moon dark" aria-hidden="true"></i>
</label>
</div>
</span>
</li>
<li class="nav-item">
<span class="nav-link">
<i class="b-icon bi bi-person" data-bs-toggle="offcanvas" data-bs-target="#sidebar-right" aria-controls="sidebar-right" aria-hidden="true"></i>
</span>
</li>
<partial name="Partials/ShoppingCartLinks"/>
</ul>
</div>
</nav>
</header>
@* Drawers and the search modal are rendered at the top level of #app, outside
.header-nav: that element is position:sticky with a z-index, so it forms a
stacking context, and anything inside it ends up underneath the backdrop that
Bootstrap appends to <body>. It also keeps the drawers out of
<nav class="navbar-expand">, which Bootstrap would otherwise flatten into the
bar. The triggers stay in the header and reference these by id. *@
<div class="offcanvas @(supportRtl ? "offcanvas-end b-sidebar b-sidebar-right" : "offcanvas-start b-sidebar") shadow" tabindex="-1" id="sidebar-menu" aria-labelledby="sidebar-menu-label">
<div class="b-sidebar-header">
<button type="button" class="btn-close" data-bs-dismiss="offcanvas" aria-label="Close"></button>
<strong class="ms-2" id="sidebar-menu-label"></strong>
</div>
<div class="b-sidebar-body">
@*the catalogue menu is a navigation landmark of its own, and it lives
in a drawer rather than inside <nav> up in the bar*@
<nav aria-label="@Loc["Categories"]">
<ul class="Menu -vertical">
@await Component.InvokeAsync("Menu")
</ul>
</nav>
</div>
</div>
<div class="offcanvas @(!supportRtl ? "offcanvas-end b-sidebar b-sidebar-right" : "offcanvas-start b-sidebar")" tabindex="-1" id="sidebar-right" aria-labelledby="sidebar-right-label">
<div class="b-sidebar-header">
<button type="button" class="btn-close" data-bs-dismiss="offcanvas" aria-label="Close"></button>
<strong class="ms-2" id="sidebar-right-label">@Loc["Account.MyAccount"]</strong>
</div>
<div class="b-sidebar-body user-panel">
<div class="d-inline-flex flex-wrap mb-2">
<partial name="Partials/Selector_TaxType"/>
<partial name="Partials/Selector_Currency"/>
<partial name="Partials/Selector_Language"/>
@if (CommonSettings.AllowToSelectStore)
{
<partial name="Partials/Selector_Store"/>
}
@if (StoreInformationSettings.AllowCustomerToSelectTheme)
{
<partial name="Partials/Selector_Theme"/>
}
@await Component.InvokeAsync("Widget", new { widgetZone = "header_selectors" })
</div>
<partial name="Partials/HeaderLinks"/>
</div>
</div>
<partial name="Partials/SidebarPanels"/>