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

ENH: Enable a minimal theme option for simpler admonition style #106

Merged
merged 7 commits into from
Jul 15, 2024
Merged
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
Binary file added docs/source/_static/img/definition-minimal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/source/_static/img/definition.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,10 @@
"use_issues_button": True,
"use_repository_button": True,
}

# sphinx-proof extension options
proof_minimal_theme = False

# MyST Parser Configuration

myst_enable_extensions = ["dollarmath", "amsmath"]
1 change: 1 addition & 0 deletions docs/source/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

install
syntax
options
testing
zreferences
```
Expand Down
30 changes: 30 additions & 0 deletions docs/source/options.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Options

This package has the option to choose a more **minimal** color scheme.

The aim is to create admonitions that are clearly different to the core text with
colors that do not over emphasises the admonition such as

```{figure} _static/img/definition-minimal.png
```

compared to the current default

```{figure} _static/img/definition.png
```

To enable the `minimal` color scheme you can use the following.

## Jupyter Book Project

Add `proof_minimal_theme = True` to your `_config.yml`

```yaml
sphinx:
config:
proof_minimal_theme: true
```

## Sphinx Project

Add `proof_minimal_theme = True` to your `conf.py`
10 changes: 9 additions & 1 deletion sphinx_proof/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,13 @@ def init_numfig(app: Sphinx, config: Config) -> None:


def copy_asset_files(app: Sphinx, exc: Union[bool, Exception]):
static_path = Path(__file__).parent.joinpath("_static", "proof.css").absolute()

if app.config["proof_minimal_theme"]:
static_path = (
Path(__file__).parent.joinpath("_static", "minimal", "proof.css").absolute()
)
else:
static_path = Path(__file__).parent.joinpath("_static", "proof.css").absolute()
asset_files = [str(static_path)]

if exc is None:
Expand All @@ -74,6 +80,8 @@ def copy_asset_files(app: Sphinx, exc: Union[bool, Exception]):

def setup(app: Sphinx) -> Dict[str, Any]:

app.add_config_value("proof_minimal_theme", False, "html")

app.add_css_file("proof.css")
app.connect("build-finished", copy_asset_files)
app.connect("config-inited", init_numfig)
Expand Down
222 changes: 222 additions & 0 deletions sphinx_proof/_static/minimal/proof.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,222 @@
/*********************************************
* Variables *
*********************************************/
:root {
--theorem-border-color: rgba(68,138,255,.1);
--axiom-border-color: #ffc107;
--criterion-border-color: #fd7e14;
--lemma-border-color: #36cf03;
--definition-border-color: #007bff;
--remark-border-color: #79ff6f;
--conjecture-border-color: #775f15;
--corollary-border-color: #c500c1;
--example-border-color: #f9377b;
--property-border-color: #fdf914;
--obseration-border-color: #7707ff;
--proposition-border-color: #4f7aa8;
--assumption-border-color: #07fffb;

/* --note-title-color: rgba(68,138,255,.1);
--note-border-color: #007bff;
--warning-title-color: rgba(220,53,69,.1);
--warning-border-color: #dc3545;
--hint-title-color: rgba(255,193,7,.2);
--hint-border-color: #ffc107;
--caution-title-color: rgba(253,126,20,.1);
--caution-border-color: #fd7e14; */

--grey-title-color: rgba(204,204,204,.2);
--grey-border-color: #ccc;
}

/*********************************************
* Main body *
*********************************************/

/* Remove content box */
div.proof p.admonition-title::before {
content: none;
}

/*********************************************
* Proof *
*********************************************/
div#proof{
padding: .4rem .6rem .4rem 2rem !important;
border-color: var(--grey-border-color);
background-color: none;
}

/*********************************************
* Theorem *
*********************************************/
div.theorem {
border-color: var(--theorem-border-color);
background-color: none;
}

div.theorem p.admonition-title {
background-color: transparent;
}

/*********************************************
* Axiom *
*********************************************/
div.axiom {
border-color: var(--axiom-border-color);
background-color: none;
}

div.axiom p.admonition-title {
background-color: transparent;
}

/*********************************************
* Criterion *
*********************************************/
div.criterion {
border-color: var(--criterion-border-color);
background-color: none;
}

div.criterion p.admonition-title {
background-color: transparent;
}

/*********************************************
* Lemma *
*********************************************/
div.lemma {
border-color: var(--lemma-border-color);
background-color: none;
}

div.lemma p.admonition-title {
background-color: transparent;
}

/*********************************************
* Definition *
*********************************************/
div.definition {
border-color: var(--definition-border-color);
background-color: none;
}

div.definition p.admonition-title {
background-color: transparent;
}

/*********************************************
* Remark *
*********************************************/
div.remark {
border-color: var(--remark-border-color);
background-color: none;
}

div.remark p.admonition-title {
background-color: transparent;
}

/*********************************************
* Conjecture *
*********************************************/
div.conjecture {
border-color: var(--conjecture-border-color);
background-color: none;
}

div.conjecture p.admonition-title {
background-color: transparent;
}

/*********************************************
* Corollary *
*********************************************/
div.corollary {
border-color: var(--corollary-border-color);
background-color: none;
}

div.corollary p.admonition-title {
background-color: transparent;
}

/*********************************************
* Algorithm *
*********************************************/
div.algorithm {
border: none;
background-color: none;
}

div.algorithm p.admonition-title {
background-color: transparent;
border-top: .15rem solid var(--grey-border-color);
border-bottom: .15rem solid var(--grey-border-color);
}

div.algorithm div.section {
font-family: SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;
font-size: .85rem;
}

/*********************************************
* Example *
*********************************************/
div.example {
border-color: var(--example-border-color);
background-color: none;
}

div.example p.admonition-title {
background-color: transparent;
}

/*********************************************
* Property *
*********************************************/
div.property {
border-color: var(--property-border-color);
background-color: none;
}

div.property p.admonition-title {
background-color: transparent;
}

/*********************************************
* Observation *
*********************************************/
div.observation {
border-color: var(--observation-border-color);
background-color: none;
}

div.observation p.admonition-title {
background-color: transparent;
}

/*********************************************
* Proposition *
*********************************************/
div.proposition {
border-color: var(--proposition-border-color);
background-color: none;
}

div.proposition p.admonition-title {
background-color: transparent;
}
/*********************************************
* Assumption *
*********************************************/
div.assumption {
border-color: var(--assumption-border-color);
background-color: none;
}

div.assumption p.admonition-title {
background-color: transparent;
}