Skip to content
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

Obviate background-from-color-variable #1558

Merged
merged 2 commits into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 0 additions & 19 deletions src/pydata_sphinx_theme/assets/styles/abstracts/_color.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,6 @@
// loading the math module
@use "sass:math";

// Set background color from a color variable
//
@mixin background-from-color-variable($color-variable) {
&:before {
content: "";
width: 100%;
height: 100%;
position: absolute;
left: 0;
top: 0;
background-color: var(#{$color-variable});
z-index: -1;
// So that hovering over the text within background is still possible.
// Otherwise the background overlays the text and you cannot click or select easily.
// ref: https://developer.mozilla.org/en-US/docs/Web/CSS/pointer-events
pointer-events: none;
}
}

/**
* Function to get items from nested maps
*/
Expand Down
46 changes: 12 additions & 34 deletions src/pydata_sphinx_theme/assets/styles/content/_admonitions.scss
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ div.admonition,
padding: 0.4rem 0.6rem 0.4rem 2rem;
font-weight: var(--pst-admonition-font-weight-heading);
position: relative;
@include background-from-color-variable(--pst-color-info-bg);
background-color: var(--pst-color-info-bg);
// now that we use solid colors we want the title on top
z-index: 1;

Expand All @@ -63,9 +63,7 @@ div.admonition,
&.attention {
border-color: var(--pst-color-attention);
> .admonition-title {
&:before {
background-color: var(--pst-color-attention-bg);
}
background-color: var(--pst-color-attention-bg);

&:after {
color: var(--pst-color-attention);
Expand All @@ -77,9 +75,7 @@ div.admonition,
&.caution {
border-color: var(--pst-color-warning);
> .admonition-title {
&:before {
background-color: var(--pst-color-warning-bg);
}
background-color: var(--pst-color-warning-bg);

&:after {
color: var(--pst-color-warning);
Expand All @@ -91,9 +87,7 @@ div.admonition,
&.warning {
border-color: var(--pst-color-warning);
> .admonition-title {
&:before {
background-color: var(--pst-color-warning-bg);
}
background-color: var(--pst-color-warning-bg);

&:after {
color: var(--pst-color-warning);
Expand All @@ -105,9 +99,7 @@ div.admonition,
&.danger {
border-color: var(--pst-color-danger);
> .admonition-title {
&:before {
background-color: var(--pst-color-danger-bg);
}
background-color: var(--pst-color-danger-bg);

&:after {
color: var(--pst-color-danger);
Expand All @@ -119,9 +111,7 @@ div.admonition,
&.error {
border-color: var(--pst-color-danger);
> .admonition-title {
&:before {
background-color: var(--pst-color-danger-bg);
}
background-color: var(--pst-color-danger-bg);

&:after {
color: var(--pst-color-danger);
Expand All @@ -133,9 +123,7 @@ div.admonition,
&.hint {
border-color: var(--pst-color-success);
> .admonition-title {
&:before {
background-color: var(--pst-color-success-bg);
}
background-color: var(--pst-color-success-bg);

&:after {
color: var(--pst-color-success);
Expand All @@ -147,9 +135,7 @@ div.admonition,
&.tip {
border-color: var(--pst-color-success);
> .admonition-title {
&:before {
background-color: var(--pst-color-success-bg);
}
background-color: var(--pst-color-success-bg);

&:after {
color: var(--pst-color-success);
Expand All @@ -161,9 +147,7 @@ div.admonition,
&.important {
border-color: var(--pst-color-attention);
> .admonition-title {
&:before {
background-color: var(--pst-color-attention-bg);
}
background-color: var(--pst-color-attention-bg);

&:after {
color: var(--pst-color-attention);
Expand All @@ -175,9 +159,7 @@ div.admonition,
&.note {
border-color: var(--pst-color-info);
> .admonition-title {
&:before {
background-color: var(--pst-color-info-bg);
}
background-color: var(--pst-color-info-bg);

&:after {
color: var(--pst-color-info);
Expand All @@ -189,9 +171,7 @@ div.admonition,
&.seealso {
border-color: var(--pst-color-success);
> .admonition-title {
&:before {
background-color: var(--pst-color-success-bg);
}
background-color: var(--pst-color-success-bg);

&:after {
color: var(--pst-color-success);
Expand All @@ -203,9 +183,7 @@ div.admonition,
&.admonition-todo {
border-color: var(--pst-color-secondary);
> .admonition-title {
&:before {
background-color: var(--pst-color-secondary-bg);
}
background-color: var(--pst-color-secondary-bg);

&:after {
color: var(--pst-color-secondary);
Expand Down
2 changes: 1 addition & 1 deletion src/pydata_sphinx_theme/assets/styles/content/_quotes.scss
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ blockquote {
margin-bottom: 0;
}

@include background-from-color-variable(--pst-color-on-background);
background-color: var(--pst-color-surface);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In addition to removing the mixin, I also changed the color variable here because I think the desired style for blockquotes is for them to have a background color that stands out against the page's background.

For reference on why I chose --pst-color-surface: Color variables.

Before:

before this PR the blockquote box did not stand out from the page

After:

after this PR the blockquote box has a gray background that stands out from the white page


//hack to make the text in the blockquote selectable
&:before {
Expand Down
3 changes: 1 addition & 2 deletions src/pydata_sphinx_theme/assets/styles/content/_spans.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ span.guilabel {
padding: 2.4px 6px;
margin: auto 2px;
position: relative;

@include background-from-color-variable(--pst-color-info-bg);
background-color: var(--pst-color-info-bg);
}

a.reference.download:before {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,7 @@ details.sd-dropdown {
}
}

// Background color and border are grey by default
background-color: unset !important;
@include background-from-color-variable(--pst-sd-dropdown-bg-color);
background-color: var(--pst-sd-dropdown-bg-color) !important;

// Add a left border with the same structure as our admonitions
border-left: 0.2rem solid var(--pst-sd-dropdown-color) !important;
Expand Down