Multi palettes feature: prototype proposal and example #7736
FrancoisCapon
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
The main idea is to set palettes :
section_palettethat mean for all pages of the section and subsectionspage_palettecan set or override his section paletteHere is an example of my proposal with the metas in the top of the page (page_palette == section_palette => palette is defined by section) ; there is a lot of colors in the example ("Christmas garland" effect) but it only to test different cases!
mkdocs-material-palettes-example-site.zip
The implementation of the prototype is "light":
palette.htmlto usepage.meta.page_paletteif existhooksof 60 lines to handlenavstructure (once)<form class="md-header__option" data-md-component="palette"> {% for option in config.theme.palette %} {% set scheme = option.scheme | d("default", true) %} {% set primary = option.primary | d("indigo", true) %} {% set accent = option.accent | d("indigo", true) %} ++ {% if page.meta and page.meta.page_palette %} ++ {% if page.meta.page_palette.primary %} ++ {% set primary = page.meta.page_palette.primary %} ++ {% endif %} ++ {% if page.meta.page_palette.accent %} ++ {% set accent = page.meta.page_palette.accent %} ++ {% elif page.meta.page_palette.primary %} ++ {% set accent = page.meta.page_palette.primary %} ++ {% endif %} ++ {% endif %} <input class="md-option" data-md-color-media="{{ option.media }}" data-md-color-scheme="{{ scheme | replace(' ', '-') }}" data-md-color-primary="{{ primary | replace(' ', '-') }}" data-md-color-accent="{{ accent | replace(' ', '-') }}" {% if option.toggle %} aria-label="{{ option.toggle.name }}" {% else %} aria-hidden="true" {% endif %} type="radio" name="__palette" id="__palette_{{ loop.index0 }}"> {% if option.toggle %} <label class="md-header__button md-icon" title="{{ option.toggle.name }}" for="__palette_{{ loop.index % loop.length }}" hidden> {% include ".icons/" ~ option.toggle.icon ~ ".svg" %} </label> {% endif %} {% endfor %} </form>Beta Was this translation helpful? Give feedback.
All reactions