Skip to content

Commit becefba

Browse files
committed
feat: conditionally render search button in DocsHeader based on ShowSearch parameter, allowing for flexible display on different layouts
1 parent dbbcd2c commit becefba

1 file changed

Lines changed: 16 additions & 8 deletions

File tree

src/ShellDocs.Components/Chrome/DocsHeader.razor

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,17 @@
6363
</nav>
6464

6565
<div class="docs-header-actions">
66-
<button type="button" class="docs-header-search" @onclick="OpenSearch" aria-label="Search">
67-
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="11" r="7"/><path d="M21 21l-4.35-4.35"/></svg>
68-
<span class="docs-header-search-label">Search</span>
69-
<span class="docs-header-kbd">
70-
<kbd>Ctrl</kbd>
71-
<kbd>K</kbd>
72-
</span>
73-
</button>
66+
@if (ShowSearch)
67+
{
68+
<button type="button" class="docs-header-search" @onclick="OpenSearch" aria-label="Search">
69+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="11" r="7"/><path d="M21 21l-4.35-4.35"/></svg>
70+
<span class="docs-header-search-label">Search</span>
71+
<span class="docs-header-kbd">
72+
<kbd>Ctrl</kbd>
73+
<kbd>K</kbd>
74+
</span>
75+
</button>
76+
}
7477

7578
<ThemeToggle />
7679

@@ -87,6 +90,11 @@
8790
@implements IDisposable
8891

8992
@code {
93+
/* Search chip toggle. Marketing pages (HomeLayout) pass false — visitors
94+
there aren't looking to grep docs. Docs pages (DocsLayout TopNav variant)
95+
leave the default true. */
96+
[Parameter] public bool ShowSearch { get; set; } = true;
97+
9098
private const string DefaultIcon =
9199
"<svg viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.75\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><rect x=\"3\" y=\"3\" width=\"18\" height=\"18\" rx=\"3\"/></svg>";
92100

0 commit comments

Comments
 (0)