Skip to content

Default scheme colors not used for Social cards when automatic/light dark mode is set #6929

@mitches-got-glitches

Description

@mitches-got-glitches

Context

I'm creating a personal blog with mkdocs-material==9.5.14 and the built-in Blog plugin.

Bug description

If I set my palette as the following with a non-default primary color set in the default scheme, then this color isn't used by the social plugin when creating the social cards, it just uses the default.

theme: palette: - media: "(prefers-color-scheme)" toggle: icon: material/brightness-auto name: Switch to light mode - media: "(prefers-color-scheme: light)" scheme: default primary: black accent: orange toggle: icon: material/brightness-5 name: Switch to dark mode - media: "(prefers-color-scheme: dark)" scheme: slate toggle: icon: material/brightness-4 name: Switch to system preference

image

If I repeat the palette colors in the top item under palette, then these are used by the social plugin when creating a card.

theme: palette: - media: "(prefers-color-scheme)" primary: black accent: orange toggle: icon: material/brightness-auto name: Switch to light mode - media: "(prefers-color-scheme: light)" scheme: default primary: black accent: orange toggle: icon: material/brightness-5 name: Switch to dark mode - media: "(prefers-color-scheme: dark)" scheme: slate toggle: icon: material/brightness-4 name: Switch to system preference

image

If I move the media: "(prefers-color-scheme: light)" item to the top item, then the colors also will be used properly by the social plugin, without the need for repetition.

theme: palette: - media: "(prefers-color-scheme: light)" scheme: default primary: black accent: orange toggle: icon: material/brightness-5 name: Switch to dark mode - media: "(prefers-color-scheme)" toggle: icon: material/brightness-auto name: Switch to light mode - media: "(prefers-color-scheme: dark)" scheme: slate toggle: icon: material/brightness-4 name: Switch to system preference

Suggested solutions

  • When selecting the color scheme to socials, search for the media item with schema: default and use those colors. The order of the list in the YAML won't matter with this solution.
  • Document the above behaviour in the docs - suggesting either repetition or making sure default scheme is the first item.

Related links

Reproduction

9.5.14-media-palette-unused-socials.zip

I've put in some commented sections so that anyone checking can try all of the light/dark mode suggestions in the docs and confirm this bug.

Steps to reproduce

Using the makefile on Linux...

  1. make all (installs imaging dependencies and requirements into a virtual environment
  2. Remove - info from the plugins in mkdocs.yml
  3. Activate venv with source .venv/bin/activate
  4. make docs

Browser

No response

Before submitting

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIssue reports a bugresolvedIssue is resolved, yet unreleased if open

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions