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

gatsby-remark-images with MDX: Can't set backgroundColor #25272

Closed
Cecile-Lebleu opened this issue Jun 24, 2020 · 2 comments
Closed

gatsby-remark-images with MDX: Can't set backgroundColor #25272

Cecile-Lebleu opened this issue Jun 24, 2020 · 2 comments
Assignees
Labels
type: bug An issue or pull request relating to a bug in Gatsby

Comments

@Cecile-Lebleu
Copy link
Contributor

Description

A png image added inline in a md or mdx file using gatsby-remark-images shows a white background, when the backgroundColor has been specified in gatsby-config.js.

Steps to reproduce

Using gatsby-plugin-mdx and gatsby-remark-images, using the same syntax and very similar structure as the docs. I set the background color in gatsby-config.js but it doesn't change from white. The goal is no background, so I tried with none, transparent, and with color names or codes; but it stays white. Currently set to red to see if it changes.
Inspecting the element I see it's getting an inline box-shadow inserted (box-shadow: white 0px 0px 0px 400px inset;), and I can't overwrite it.

Live example: http://diarly.surge.sh/help/Configuration/
In the link there's an image that should have a red or transparent background, but instead, it's white.

Expected result

The background color should change to the color specified in gatsby-config.js.

Actual result

The image background color is white, no matter the value entered to backgroundColor in gatsby-config.js.

Environment

System:
OS: macOS 10.15.5
CPU: (8) x64 Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz
Shell: 5.7.1 - /bin/zsh
Binaries:
Node: 12.9.0 - /usr/local/bin/node
Yarn: 1.22.4 - /usr/local/bin/yarn
npm: 6.14.5 - /usr/local/bin/npm
Languages:
Python: 2.7.16 - /usr/bin/python
Browsers:
Chrome: 83.0.4103.116
Firefox: 76.0.1
Safari: 13.1.1
npmPackages:
gatsby: ^2.22.10 => 2.22.10
gatsby-cli: ^2.12.51 => 2.12.51
gatsby-image: ^2.4.5 => 2.4.5
gatsby-plugin-cookiehub-banner: ^0.1.0 => 0.1.0
gatsby-plugin-google-analytics-gdpr: 0.0.5 => 0.0.5
gatsby-plugin-google-fonts: ^1.0.1 => 1.0.1
gatsby-plugin-manifest: ^2.4.9 => 2.4.9
gatsby-plugin-mdx: ^1.2.17 => 1.2.17
gatsby-plugin-offline: ^3.2.7 => 3.2.7
gatsby-plugin-react-helmet: ^3.3.2 => 3.3.2
gatsby-plugin-sass: ^2.3.2 => 2.3.2
gatsby-plugin-sharp: ^2.6.9 => 2.6.9
gatsby-plugin-sitemap: ^2.4.3 => 2.4.3
gatsby-remark-copy-linked-files: ^2.3.5 => 2.3.5
gatsby-remark-images: ^3.3.8 => 3.3.8
gatsby-source-filesystem: ^2.3.8 => 2.3.8
gatsby-transformer-sharp: ^2.5.3 => 2.5.3
npmGlobalPackages:
gatsby-cli: 2.7.37

@Cecile-Lebleu Cecile-Lebleu added the type: bug An issue or pull request relating to a bug in Gatsby label Jun 24, 2020
@gatsbot gatsbot bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Jun 24, 2020
@Cecile-Lebleu Cecile-Lebleu added topic: remark/mdx Related to Markdown, remark & MDX ecosystem topic: MDX topic: media Related to gatsby-plugin-image, or general image/media processing topics labels Jun 24, 2020
@pieh pieh removed the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Jun 25, 2020
@pieh pieh self-assigned this Jun 25, 2020
@pieh
Copy link
Contributor

pieh commented Jun 25, 2020

This is unfortunately known issue. Root cause is tracked in #21592

As a workaround please configure your gatsby-plugin-mdx as follows:

{
      resolve: `gatsby-plugin-mdx`,
      options: {
        // a workaround to solve mdx-remark plugin compat issue
        // we add gatsby-remark-images (with same options) to both
        // `plugins` and `gatsbyRemarkPlugins`
        plugins: [
          {
            resolve: `gatsby-remark-images`,
            options: {
              maxWidth: 590,
              backgroundColor: `red`,
            },
          },
        ],
        gatsbyRemarkPlugins: [
          {
            resolve: `gatsby-remark-images`,
            options: {
              maxWidth: 590,
              backgroundColor: `red`,
            },
          },
          // rest of regular subplugins
        ]
      }
}

@pieh pieh removed topic: remark/mdx Related to Markdown, remark & MDX ecosystem topic: media Related to gatsby-plugin-image, or general image/media processing topics labels Jun 25, 2020
@Cecile-Lebleu
Copy link
Contributor Author

Worked great with red and with transparent too. Goal achieved. Thanks @pieh :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug An issue or pull request relating to a bug in Gatsby
Projects
None yet
Development

No branches or pull requests

2 participants