Skip to content

Commit 9677e6b

Browse files
committed
feat: add kbd hint
1 parent e8e3022 commit 9677e6b

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed

src/overrides/partials/header.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@
8181
<label class="md-header__button md-icon" for="__search">
8282
{% include ".icons/material/magnify.svg" %}
8383
</label>
84+
{% if page and nav and page.url == nav.homepage.url %}
85+
<span class="kbd-hint" aria-hidden="true">/</span>
86+
{% endif %}
8487
{% include "partials/search.html" %}
8588
{% endif %}
8689
{% if config.repo_url %}

src/stylesheets/extra.css

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,56 @@ body[dir=rtl] .metadata.page-metadata .contributors-text{
5454

5555
.arithmatex{
5656
overflow-y: hidden !important;
57+
}
58+
59+
/* Keyboard hint for search ("/") */
60+
.kbd-hint {
61+
display: inline-flex;
62+
align-items: center;
63+
justify-content: center;
64+
margin-left: 4px;
65+
padding: 0 6px;
66+
height: 22px;
67+
border-radius: 4px;
68+
border: 1px solid var(--md-default-fg-color--lightest, rgba(0,0,0,.2));
69+
background: var(--md-default-bg-color, #fff);
70+
color: var(--md-default-fg-color, rgba(0,0,0,.87));
71+
font: 500 12px/1 var(--md-text-font, system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, sans-serif);
72+
opacity: .72;
73+
}
74+
75+
/* Show "/" hint inside the search input on desktop */
76+
.md-search__form {
77+
position: relative;
78+
}
79+
80+
.md-search__form::after {
81+
content: "/";
82+
position: absolute;
83+
right: 10px;
84+
top: 50%;
85+
transform: translateY(-50%);
86+
display: inline-flex;
87+
align-items: center;
88+
justify-content: center;
89+
height: 20px;
90+
padding: 0 6px;
91+
border-radius: 4px;
92+
border: 1px solid var(--md-default-fg-color--lightest, rgba(0,0,0,.2));
93+
background: var(--md-default-bg-color, #fff);
94+
color: var(--md-default-fg-color, rgba(0,0,0,.87));
95+
font: 500 12px/1 var(--md-text-font, system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, sans-serif);
96+
opacity: .72;
97+
pointer-events: none;
98+
}
99+
100+
/* Hide hint when typing/focused so it doesn't overlap text */
101+
.md-search__form:focus-within::after,
102+
.md-search__form input:not(:placeholder-shown) + .md-search__icon ~ *::after {
103+
opacity: 0;
104+
}
105+
106+
/* Only show on wider viewports where the inline search is visible */
107+
@media (max-width: 959px) {
108+
.md-search__form::after { display: none; }
57109
}

0 commit comments

Comments
 (0)