Skip to content

refactor: using-scss-variables #696

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 19 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
11427c1
fix: search button for field
Revathyvenugopal162 May 9, 2025
18db9c8
feat: search for mobile view
Revathyvenugopal162 May 9, 2025
16da9ed
chore: adding changelog file 689.fixed.md [dependabot-skip]
pyansys-ci-bot May 9, 2025
b881df0
Merge branch 'main' into fix/screen-view
Revathyvenugopal162 May 12, 2025
18fe4ae
fix: add percentage
Revathyvenugopal162 May 12, 2025
ae8fd4d
fix(styles): update the laptop width
Revathyvenugopal162 May 12, 2025
eebe5ae
fix(styles): update the shortcut visisbility
Revathyvenugopal162 May 12, 2025
7fa5225
Merge branch 'main' into fix/screen-view
Revathyvenugopal162 May 12, 2025
8169bf7
fix(js): update the mobile search
Revathyvenugopal162 May 12, 2025
8dfa6b6
Merge branch 'main' into fix/screen-view
Revathyvenugopal162 May 12, 2025
dfe3cbb
fix: media container to 1040
Revathyvenugopal162 May 13, 2025
0e32194
Merge branch 'fix/screen-view' of https://github.com/ansys/ansys-sphi…
Revathyvenugopal162 May 13, 2025
2eacb3e
fix: media sidebar
Revathyvenugopal162 May 13, 2025
af19fd6
feat: add minimum to 1040px
Revathyvenugopal162 May 13, 2025
d2c801b
fix: cleanup
Revathyvenugopal162 May 13, 2025
86f585a
refactor: add SCSS variables for layout dimensions
germa89 May 13, 2025
0000a3c
refactor: reorganize SCSS variables for better readability
germa89 May 13, 2025
f09adab
refactor: reorder breakpoint variables for consistency
germa89 May 13, 2025
a9527de
chore: adding changelog file 696.miscellaneous.md [dependabot-skip]
pyansys-ci-bot May 13, 2025
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
1 change: 1 addition & 0 deletions doc/changelog.d/689.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
smaller screen view and search for mobile views
1 change: 1 addition & 0 deletions doc/changelog.d/696.miscellaneous.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
using-scss-variables
15 changes: 15 additions & 0 deletions src/ansys_sphinx_theme/assets/styles/_variables.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Variables for Ansys Sphinx Theme

// content variables
$article-width: 1000px;
$sidebar-primary-width: 75%;
$sidebar-primary-max-width: 350px;


// Breakpoint variables
$bs-breakpoint-xxl: 1600px;
$bs-breakpoint-xl: 1200px;
$bs-breakpoint-lg: 1040px;
$bs-breakpoint-md: 720px;
$bs-breakpoint-sm: 540px;
$bs-breakpoint-xs: 0px;
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,19 @@
src: url(../fonts/SourceSansPro-Regular.ttf);
}

// Import SCSS variables

@import 'variables';


:root {
/** Ansys specific changes to the theme */
--bs-breakpoint-lg: $bs-breakpoint-lg !important;
--bs-breakpoint-md: $bs-breakpoint-md;
--bs-breakpoint-sm: $bs-breakpoint-sm;
--bs-breakpoint-xs: $bs-breakpoint-xs;
--bs-breakpoint-xl: $bs-breakpoint-xl;
--breakpoint-sidebar-primary: $bs-breakpoint-lg;

/**
* Ansys Font family
Expand Down Expand Up @@ -52,6 +63,7 @@
--bs-nav-link-font-size: 0.875rem; /* 14px */
--bs-navbar-color: var(--bs-ast-navbar-color);
--ast-font-sidebar-header: 1rem; /* 16px */

/**
* weight
*/
Expand Down Expand Up @@ -422,3 +434,106 @@ h6 {
h1 {
line-height: 56px;
}


/* Mobile-specific overrides (≤ 1040px) */
@media (max-width: $bs-breakpoint-lg) {
.navbar-header-items {
display: none !important;
flex-grow: 1 !important;
padding: 0 0 0 0.5rem !important;
}

ul.navbar-nav {
align-items: baseline;
}

.navbar-center-items .navbar-item {
display: inline-block;
}

.navbar-persistent--mobile {
display: none;
}

.navbar-persistent--container {
display: flex;
}

.bd-sidebar-primary {
flex-grow: 0.75;
height: 100vh;
left: 0;
margin-left: -75%;
max-height: 100vh !important;
max-width: $sidebar-primary-max-width !important;
position: fixed;
top: 0;
transition: visibility 0.2s ease-out,margin 0.2s ease-out;
visibility: hidden;
width: $sidebar-primary-width;
z-index: 1050;
display: flex !important;
}

.bd-sidebar-primary[open] {
visibility: visible !important;
}

button.primary-toggle {
display: flex !important;
}

#pst-collapse-sidebar-button {
display: none !important;
}

nav.bd-links {
display: block !important;
}

.nav-link .hide-on-wide {
display: none !important;
}

.bd-sidebar-primary.hide-on-wide {
display: flex !important;
}

.bd-sidebar-primary .sidebar-header-items {
display: flex !important;
}
}

/* Desktop-specific overrides (> 1040px) */
@media (min-width: $bs-breakpoint-lg) {
.navbar-header-items {
display: inherit;
flex-grow: 1;
padding: 0 0 0 0.5rem;
}

ul.navbar-nav {
align-items: baseline;
}

.navbar-center-items .navbar-item {
display: inline-block;
}

.navbar-persistent--mobile {
display: none;
}

.navbar-persistent--container {
display: flex;
}

.bd-sidebar-primary {
font-size: var(--pst-sidebar-font-size);
}

button.primary-toggle {
display: none;
}
}
59 changes: 47 additions & 12 deletions src/ansys_sphinx_theme/assets/styles/ast-search.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
/* Static Search Results Container */
@import 'variables';

.bd-search{
display: flex;
}
.static-search-results {
display: flex;
flex-direction: column;
Expand Down Expand Up @@ -81,10 +86,6 @@ html[data-theme="light"] .highlight {
.bd-search .search-button__kbd-shortcut {
background-color: var(--ast-search-bar-enable-background) !important;
box-shadow: none !important;
height: 2.25rem; /* 36px */
display: flex;
flex-wrap: wrap;
align-content: center;
}

/* Index Select Dropdown */
Expand Down Expand Up @@ -150,20 +151,54 @@ html[data-theme="light"] .highlight {
}

/* Responsive Styles */
@media (max-width: 48rem) { /* 768px */
.bd-search input.expanded {
width: 6.25rem; /* 100px */
@media (min-width: $bs-breakpoint-lg) and (max-width: 85.375rem) {
.bd-search input.form-control.expanded {
width: 100%; /* 320px */
}

.bd-search input.form-control {
width: 100%; /* 240px */
}

.bd-search .search-button__kbd-shortcut {
display: none !important;
}

.static-search-results {
width: 50%; /* 480px */
}
}

@media (max-width: $bs-breakpoint-lg) {

.bd-search input.form-control.expanded {
width: 5rem; /* 320px */
}

.form-control {
width: 3.125rem; /* 50px */
.bd-search input.form-control {
width: 100%; /* 240px */
}

.result {
width: 6.25rem; /* 100px */
.static-search-results {
width: 50%; /* 480px */
}

.bd-search .search-button__kbd-shortcut {
display: none;
display: none !important;
}
}

// laptop
@media (min-width: 85.375rem) and (max-width: 128rem) {
.bd-search input.form-control.expanded {
width: 35rem; /* 560px */
}

.bd-search input.form-control {
width: 100%; /* 240px */
}

.static-search-results {
width: 37rem; /* 600px */
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
* _sidebar-primary.scss
*
*/

@import "variables";

.bd-sidebar-primary,
.bd-sidebar-secondary {
max-height: calc(100vh - var(--pst-header-height) - 1vh);
Expand Down Expand Up @@ -269,23 +272,23 @@ a.headerlink {
color: #222;
}

@media (min-width: 1200px) {
@media (min-width: $bs-breakpoint-xl) {
.container,
.container-lg,
.container-md,
.container-sm,
.container-xl {
max-width: 1200px;
max-width: $bs-breakpoint-xl;
}
}

@media (min-width: 1600px) {
@media (min-width: $bs-breakpoint-xxl) {
.container,
.container-lg,
.container-md,
.container-sm,
.container-xl {
max-width: 1600px;
max-width: $bs-breakpoint-xxl;
}
}

Expand Down Expand Up @@ -740,31 +743,31 @@ button.btn.version-switcher__button:hover {

.bd-main .bd-content .bd-article-container {
padding: 8px;
width: 1000px;
width: $article-width;
max-width: 100%;
}

@media (min-width: 960px) {
@media (min-width: $bs-breakpoint-lg) {
.bd-sidebar-primary {
width: 20%;
}
}

@media (min-width: 960px) {
@media (min-width: $bs-breakpoint-lg) {
.col-lg-3 {
width: fit-content;
}
}

@media (min-width: 960px) {
@media (min-width: $bs-breakpoint-lg) {
.bd-page-width {
max-width: min(100%, 1700px) !important;
max-width: min(100%, $bs-breakpoint-lg + 30px) !important;
}
}

@media (min-width: 960px) {
@media (min-width: $bs-breakpoint-lg) {
.bd-main .bd-content .bd-article-container {
width: min(100%, 1070px);
width: min(100%, $bs-breakpoint-lg + 30px);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

<div class="search-bar pst-js-only" id="search-bar">
<div class="search-bar" id="search-bar">
<form class="bd-search d-flex align-items-center" action="{{ pathto('search') }}" method="get">
<i class="fa-solid fa-magnifying-glass"></i>
<input type="search" class="form-control" name="q" placeholder="{{ theme_search_bar_text }}"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,31 @@
const SEARCH_BAR = document.getElementById("search-bar");
const SEARCH_INPUT = SEARCH_BAR.querySelector(".bd-search input.form-control");
const RESULTS = document.getElementById("static-search-results");
// Determine which search bar to use (mobile or desktop)
let SEARCH_BAR;
let RESULTS;
if (window.innerWidth < 1040) {
SEARCH_BAR = document.querySelector(
"div.sidebar-header-items__end #search-bar",
);
} else {
SEARCH_BAR = document.getElementById("search-bar");
}

// Fallback if nothing is found
if (!SEARCH_BAR) {
console.warn("SEARCH_BAR not found for current view.");
}

// Get input and results area

const SEARCH_INPUT = SEARCH_BAR?.querySelector(".bd-search input.form-control");

if (window.innerWidth < 1040) {
RESULTS = document.querySelector(
"div.sidebar-header-items__end .static-search-results",
);
} else {
RESULTS = document.querySelector(".static-search-results");
}

const MAIN_PAGE_CONTENT = document.querySelector(".bd-main");
let CURRENT_INDEX = -1;

Expand Down Expand Up @@ -144,7 +169,6 @@ require(["fuse"], function (Fuse) {
searchingBanner.className = "searching-banner";
searchingBanner.textContent = "Searching...";
searchingBanner.style.display = "block";
console.log("Searching...");
searchingBanner.style.fontStyle = "italic";
RESULTS.appendChild(searchingBanner);
}
Expand Down Expand Up @@ -248,7 +272,6 @@ require(["fuse"], function (Fuse) {
}
}

// Add event listeners
SEARCH_INPUT.addEventListener("click", expandSearchInput);
SEARCH_INPUT.addEventListener("keydown", handleKeyDownSearchInput);
document.addEventListener("keydown", handleGlobalKeyDown);
Expand Down