Skip to content

Commit

Permalink
maint: styles for dark theme search bar (#511)
Browse files Browse the repository at this point in the history
Co-authored-by: pyansys-ci-bot <[email protected]>
Co-authored-by: Jorge Martínez <[email protected]>
  • Loading branch information
3 people authored Sep 26, 2024
1 parent 5159d3b commit 8673840
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 7 deletions.
1 change: 1 addition & 0 deletions doc/changelog.d/511.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
maint: styles for dark theme search bar
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@

<script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js"></script>

{% if theme_static_search %}

{% set theme_static_search = theme_static_search | default({}) %}
{% else %}
{% set theme_static_search = {'keys': ['title', 'text'], 'threshold': 0.5, 'shouldSort': 'True', 'ignoreLocation': 'False', 'useExtendedSearch': 'True'} %}
{% endif %}

{% set theme_limit = theme_static_search.limit | default(10) %}
{% set min_chars_for_search = theme_static_search.min_chars_for_search | default(1) %}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ html[data-theme="light"] {
--ast-catagory-header-text: #353535;
--ast-catagory-suggestion-text: #8e8e8e;
--ast-suggestion-text-color: #000000;
--ast-hover-suggestion-text-background: #ececec;

/**
* dropdown header
Expand Down Expand Up @@ -375,6 +376,7 @@ html[data-theme="dark"] {
--ast-catagory-header-text: #ececec;
--ast-catagory-suggestion-text: #686868;
--ast-suggestion-text-color: #ffffff;
--ast-hover-suggestion-text-background: #3d3d3d;

/**
* dropdown header
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
@import "ansys-sphinx-theme-variable.css";
.results {
display: flex;
flex-direction: column;
align-content: flex-start;
justify-content: center;
position: absolute;
background-color: white;
background-color: var(--ast-search-bar-enable-background);
width: 700px;
padding: 10px;
border: 1px solid #ddd; /* Optional: Add border for better visibility */
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); /* Optional: Add shadow for better visibility */
border: 1px solid var(--ast-search-bar-enable-border);
box-shadow: var(--ast-box-shadow-active);
overflow: auto;
height: 500px;
}
Expand All @@ -24,8 +25,9 @@
.result-title {
font-size: 1em;
font-weight: bold;
background-color: #f3f4f5;
background-color: var(--ast-suggestion-header-background);
font-family: "Open Sans", sans-serif;
color: var(--ast-catagory-header-text);
}

.result-title:focus,
Expand Down Expand Up @@ -55,18 +57,17 @@

.result-item:hover {
background-color: var(
--ast-color-hover-card-background
--ast-hover-suggestion-text-background
); /* Background when hovered */
}

.no-results {
font-style: italic;
color: #777;
color: var(--ast-color-text);
font-family: "Open Sans", sans-serif;
}

html[data-theme="light"] .highlight {
background-color: #ececec;
color: var(--ast-highlight-color);
}

Expand Down Expand Up @@ -160,3 +161,8 @@ html[data-theme="light"] .highlight {
.search-icon {
cursor: pointer;
}

.bd-main.blurred {
opacity: 0.5;
transition: opacity 0.3s ease;
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
const searchBar = document.getElementById("search-bar");
const searchBarBox = searchBar.querySelector(".bd-search input");
resultsContainer = document.getElementById("results");
const content = document.querySelector(".bd-main");

// Function to expand the search bar and display results
function expandSearchBox() {
searchBarBox.classList.add("expanded");
content.classList.add("blurred");
searchBarBox.focus();

if (searchBarBox.value.trim().length >= parseInt(min_chars_for_search)) {
Expand All @@ -26,6 +28,7 @@ document.addEventListener("keydown", function (event) {
case "Escape":
resultsContainer.style.display = "none";
searchBarBox.classList.remove("expanded");
content.classList.remove("blurred");
break;
}
});
Expand All @@ -38,5 +41,6 @@ document.addEventListener("click", function (event) {
) {
resultsContainer.style.display = "none";
searchBarBox.classList.remove("expanded");
content.classList.remove("blurred");
}
});

0 comments on commit 8673840

Please sign in to comment.