Skip to content

Commit

Permalink
fix: disable special colors when in vscode dark mode
Browse files Browse the repository at this point in the history
  • Loading branch information
jokasimr committed Sep 29, 2023
1 parent 8536a83 commit 88908e2
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 11 deletions.
10 changes: 8 additions & 2 deletions src/scitacean/_html_repr/_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,22 @@ def attachment_field_repr_template() -> Template:
return Template(_read_text("attachment_field_repr.html.template", "templates"))


@lru_cache(maxsize=1)
def common_style() -> str:
sheet = _preprocess_style(_read_text("common.css", "styles"))
return f"<style>{sheet}</style>"


@lru_cache(maxsize=1)
def dataset_style() -> str:
sheet = _preprocess_style(_read_text("dataset.css", "styles"))
return f"<style>{sheet}</style>"
return f"{common_style()}<style>{sheet}</style>"


@lru_cache(maxsize=1)
def attachment_style() -> str:
sheet = _preprocess_style(_read_text("attachment.css", "styles"))
return f"<style>{sheet}</style>"
return f"{common_style()}<style>{sheet}</style>"


@lru_cache()
Expand Down
8 changes: 4 additions & 4 deletions src/scitacean/_html_repr/styles/attachment.css
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ tr.cean-header {
}

td.cean-field-type {
color: var(--jp-content-font-color2);
color: var(--sca-font-color2);
}

.cean-field-value {
Expand All @@ -56,7 +56,7 @@ td.cean-field-type {
}

td.cean-field-description {
color: var(--jp-content-font-color1);
color: var(--sca-font-color1);
}

.cean-field-value:hover span,
Expand All @@ -66,7 +66,7 @@ td.cean-field-description {
}

.cean-empty-field {
color: var(--jp-content-font-color2);
color: var(--sca-font-color2);
}

table.cean-attachment-table {
Expand Down Expand Up @@ -108,5 +108,5 @@ details summary {
.cean-lock path {
/* Override the color used in the SVG.
This requires there to be only a single fill color. */
fill: var(--jp-content-font-color2) !important;
fill: var(--sca-font-color2) !important;
}
13 changes: 13 additions & 0 deletions src/scitacean/_html_repr/styles/common.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
:root {
--cean-font-color0: var(--jp-content-font-color0);
--cean-font-color1: var(--jp-content-font-color1);
--cean-font-color2: var(--jp-content-font-color2);
--cean-font-color3: var(--jp-content-font-color3);
}

body.vscode-dark {
--cean-font-color0: var(--vscode-editor-foreground);
--cean-font-color1: var(--vscode-editor-foreground);
--cean-font-color2: var(--vscode-editor-foreground);
--cean-font-color3: var(--vscode-editor-foreground);
}
10 changes: 5 additions & 5 deletions src/scitacean/_html_repr/styles/dataset.css
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ tr.cean-header {
}

td.cean-field-type {
color: var(--jp-content-font-color2);
color: var(--sca-font-color2);
}

.cean-field-value {
Expand All @@ -75,7 +75,7 @@ td.cean-field-type {
}

td.cean-field-description {
color: var(--jp-content-font-color1);
color: var(--sca-font-color1);
}

.cean-field-value:hover span,
Expand All @@ -85,7 +85,7 @@ td.cean-field-description {
}

.cean-empty-field {
color: var(--jp-content-font-color2);
color: var(--sca-font-color2);
}

.cean-missing-value,
Expand Down Expand Up @@ -136,7 +136,7 @@ details summary {
}

.cean-file-info-size {
color: var(--jp-content-font-color1);
color: var(--sca-font-color1);
}

table.cean-files,
Expand Down Expand Up @@ -180,5 +180,5 @@ table.cean-metadata {
.cean-lock path {
/* Override the color used in the SVG.
This requires there to be only a single fill color. */
fill: var(--jp-content-font-color2) !important;
fill: var(--sca-font-color2) !important;
}

0 comments on commit 88908e2

Please sign in to comment.