1
0
mirror of https://github.com/thangisme/notes.git synced 2024-11-20 03:16:03 -05:00
notes/docs/customization.md

116 lines
2.9 KiB
Markdown
Raw Normal View History

2017-03-09 13:16:08 -05:00
---
layout: default
title: Customization
2018-11-16 11:47:14 -05:00
nav_order: 6
2017-03-09 13:16:08 -05:00
---
2017-03-26 21:09:19 -04:00
# Customization
2019-01-14 14:18:09 -05:00
{: .no_toc }
2017-03-26 21:09:19 -04:00
## Table of contents
{: .no_toc .text-delta }
1. TOC
{:toc}
---
2018-11-18 11:07:45 -05:00
## Color schemes
{: .d-inline-block }
2018-11-18 11:07:45 -05:00
New
{: .label .label-green }
2018-11-18 11:07:45 -05:00
Just the Docs supports two color schemes: light (default), and dark.
To enable a color scheme, set the `color_scheme` parameter in your site's `_config.yml` file:
#### Example
{: .no_toc }
2018-11-18 11:07:45 -05:00
2019-01-15 20:43:19 -05:00
```yaml
# Color scheme supports "light" (default) and "dark"
color_scheme: dark
2018-11-18 11:07:45 -05:00
```
<button class="btn js-toggle-dark-mode">Preview dark color scheme</button>
<script>
2019-05-04 16:20:36 -04:00
const toggleDarkMode = document.querySelector('.js-toggle-dark-mode');
2018-11-18 11:07:45 -05:00
2019-08-14 10:08:01 -04:00
jtd.addEvent(toggleDarkMode, 'click', function(){
if (jtd.getTheme() === 'dark') {
jtd.setTheme('light');
toggleDarkMode.textContent = 'Preview dark color scheme';
2018-11-18 11:07:45 -05:00
} else {
jtd.setTheme('dark');
toggleDarkMode.textContent = 'Return to the light side';
2018-11-18 11:07:45 -05:00
}
});
2018-11-18 11:07:45 -05:00
</script>
## Custom schemes
2017-03-26 21:09:19 -04:00
### Define a custom scheme
2017-03-26 21:09:19 -04:00
You can add custom schemes.
If you want to add a scheme named `foo` (can be any name) just add a file `_sass/color_schemes/foo.scss` (replace `foo` by your scheme name)
where you override theme variables to change colors, fonts, spacing, etc.
Available variables are listed in the [_variables.scss](https://github.com/pmarsceill/just-the-docs/tree/master/_sass/support/_variables.scss) file.
For example, to change the link color from the purple default to blue, include the following inside your scheme file:
2018-11-18 11:07:45 -05:00
#### Example
{: .no_toc }
2017-03-26 21:09:19 -04:00
```scss
$link-color: $blue-000;
```
2019-01-15 20:43:19 -05:00
_Note:_ Editing the variables directly in `_sass/support/variables.scss` is not recommended and can cause other dependencies to fail.
Please use scheme files.
### Use a custom scheme
To use the custom color scheme, only set the `color_scheme` parameter in your site's `_config.yml` file:
```yaml
color_scheme: foo
```
### Switchable custom scheme
If you want to be able to change the scheme dynamically, for example via javascript, just add a file `assets/css/just-the-docs-foo.scss` (replace `foo` by your scheme name)
with the following content:`
{% raw %}
---
---
{% include css/just-the-docs.scss.liquid color_scheme="foo" %}
{% endraw %}
This allows you to switch the scheme via the following javascript.
```js
jtd.setTheme('foo');
```
2017-03-26 21:09:19 -04:00
## Override and completely custom styles
2019-09-04 09:04:10 -04:00
For styles that aren't defined as variables, you may want to modify specific CSS classes.
Additionally, you may want to add completely custom CSS specific to your content.
To do this, put your styles in the file `_sass/custom/custom.scss`.
This will allow for all overrides to be kept in a single file, and for any upstream changes to still be applied.
2019-09-04 09:04:10 -04:00
For example, if you'd like to add your own styles for printing a page, you could add the following styles.
#### Example
{: .no_toc }
```scss
// Print-only styles.
@media print {
.side-bar, .page-header { display: none; }
.main-content { max-width: auto; margin: 1em;}
}
```