Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions dist/readthedocs-addons.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/readthedocs-addons.js.map

Large diffs are not rendered by default.

57 changes: 57 additions & 0 deletions src/search.css
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@
);
--readthedocs-search-result-active-background-color: rgb(245, 245, 245);
--readthedocs-search-result-border-color: rgb(224, 224, 224);
--readthedocs-search-recent-item-background-color: rgba(
110,
160,
236,
0.04
);
--readthedocs-search-recent-item-border-color: rgba(110, 160, 236, 0.3);
}
}

Expand Down Expand Up @@ -161,6 +168,33 @@
hyphens: auto;
}

:host > div .recent-searches {
position: relative;
padding-top: 0.9rem;
margin: 0 0.5em 1em 0.5em;
}

:host > div .recent-searches-title {
display: block;
font-size: 0.9rem;
position: absolute;
top: 0;
left: 14px;
background: var(--readthedocs-search-content-background-color);
margin: 0 5px;
padding: 0 5px;
}

:host > div .recent-searches-container {
display: block;
margin: 0;
padding: 10px 14px;
border-radius: 0.3rem;
border-style: solid;
border-width: 1px;
border-color: var(--readthedocs-search-filters-border-color);
}

div.hit-block {
padding-top: 3px;
border-top: 1px solid var(--readthedocs-search-result-border-color);
Expand All @@ -170,6 +204,20 @@ div.hit-block {
background-color: var(--readthedocs-search-result-background-color);
}

div.hit-block.recent-search-item {
background-color: var(--readthedocs-search-recent-item-background-color);
border-left: 3px solid var(--readthedocs-search-recent-item-border-color);
padding-left: 0.5em;
border-radius: 4px;
border-top: none;
padding-top: 0;
margin-bottom: 0.75em;
}

div.hit-block.recent-search-item:last-child {
margin-bottom: 0;
}

div.hit-block a.hit-block-heading {
display: flex;
align-items: center;
Expand Down Expand Up @@ -205,6 +253,15 @@ button.close-icon {

background: transparent;
cursor: pointer;
opacity: 0.5;
transition:
opacity 0.2s ease,
transform 0.2s ease;
}

button.close-icon:hover {
opacity: 1;
transform: scale(1.1);
}

button.close-icon svg {
Expand Down
60 changes: 32 additions & 28 deletions src/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -357,34 +357,38 @@ export class SearchElement extends LitElement {
});

return html`
<div class="hit">
<p>Recent:</p>
${recentSearches.map(
({ block, result }) =>
html`<div class="hit-block">
<div class="hit-block-heading-container">
<a
class="hit-block-heading"
href="${this.getResultLink(result)}"
>
<i>${listIcon.node[0]}</i>
<h2>${result.title} ${this.renderExternalProject(result)}</h2>
</a>
<button
class="close-icon"
@click=${() => this.removeRecentSearch(block, result)}
>
${xmark.node[0]}
</button>
</div>

${html`${this.renderBlockResult(
block,
`recent-search-${block.id}`,
result,
)}`}
</div>`,
)}
<div class="recent-searches">
<span class="recent-searches-title">Recent results</span>
<div class="recent-searches-container">
${recentSearches.map(
({ block, result }) =>
html`<div class="hit-block recent-search-item">
<div class="hit-block-heading-container">
<a
class="hit-block-heading"
href="${this.getResultLink(result)}"
>
<i>${listIcon.node[0]}</i>
<h2>
${result.title} ${this.renderExternalProject(result)}
</h2>
</a>
<button
class="close-icon"
@click=${() => this.removeRecentSearch(block, result)}
>
${xmark.node[0]}
</button>
</div>

${html`${this.renderBlockResult(
block,
`recent-search-${block.id}`,
result,
)}`}
</div>`,
)}
</div>
</div>
`;
}
Expand Down