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

--ifm-color-primary not used unless USE_SIMPLE_CSS_MINIFIER=true is set #10504

Closed
4 of 7 tasks
MSohm opened this issue Sep 16, 2024 · 3 comments
Closed
4 of 7 tasks

--ifm-color-primary not used unless USE_SIMPLE_CSS_MINIFIER=true is set #10504

MSohm opened this issue Sep 16, 2024 · 3 comments
Labels
bug An error in the Docusaurus core causing instability or issues with its execution closed: duplicate This issue or pull request already exists in another issue or pull request

Comments

@MSohm
Copy link

MSohm commented Sep 16, 2024

Have you read the Contributing Guidelines on issues?

Prerequisites

  • I'm using the latest version of Docusaurus.
  • I have tried the npm run clear or yarn clear command.
  • I have tried rm -rf node_modules yarn.lock package-lock.json and re-installing packages.
  • I have tried creating a repro with https://new.docusaurus.io.
  • I have read the console error message carefully (if applicable).

Description

The custom theme colours (and possibly other CSS) is not applied after yarn build. The custom css is used for yarn start. If I set the environment variable USE_SIMPLE_CSS_MINIFIER to true, the custom css is available in the production build.

Workaround
Sent the environment variable USE_SIMPLE_CSS_MINIFIER to true.

Reproducible demo

CodeSandbox-Demo

Steps to reproduce

Steps to Reproduce

  1. Use the custom.css below.
  2. Ensure USE_SIMPLE_CSS_MINIFIER is not set (or set to false).
  3. Run yarn start and observe the hero background and links are orange.
  4. Run yarn build
  5. Run yarn serve
/**
 * Any CSS included here will be global. The classic template
 * bundles Infima by default. Infima is a CSS framework designed to
 * work well for content-centric websites.
 */

/* Custom fonts */
@font-face {
	font-family: 'Figtree';
	src: url('/static/fonts/Figtree/Figtree-VariableFont_wght.ttf') format('truetype');
	font-weight: 200 900;
	font-stretch: 75% 125%;
}

html {
	font-family: 'Figtree';
}

h1,
h2,
h3,
h4,
h5,
h6 {
	font-family: 'Figtree';
}

/* You can override the default Infima variables here. */
:root {
	--ifm-color-primary: #f26336;
	--ifm-color-primary-dark: #f04d1a;
	--ifm-color-primary-darker: #ec440f;
	--ifm-color-primary-darkest: #c3380d;
	--ifm-color-primary-light: #f47952;
	--ifm-color-primary-lighter: #f58360;
	--ifm-color-primary-lightest: #f7a489;
	--ifm-code-font-size: 95%;
	--docusaurus-highlighted-code-line-bg: rgba(0, 0, 0, 0.1);

	/* Docusaurus theme background colors */
	--doc-light-theme-background: #e3e3e3;
	--doc-dark-theme-background: #1c1e21;

	--doc-dark-theme-content: #e3e3e3;
	--doc-light-theme-content: #1c1e21;

	--ifm-font-size-base: 110%;

	article header h1 {
		font-size: 2.5rem !important;
	}

	.table-of-contents {
		font-size: 0.9rem;
	}

	/* Copied from dev portal global.css */
	--header-height: 60px;

	/* Legacy Colours */
	--slate: #2e2e2e;
	--naval: #293643;
	--burnt-orange: #bf4320;
	--deep-orange: #7e2d16;
	--smoke: #f2f2f2;
	--white: #ffffff;
	--deep-cyan: #2b5776;
	--copper: #b67935;
	--emerald: #3e8551;
	--black: #000000;
	--grey: #d9d9d9;
	--light-grey: #e5e5e5;
	--neutral-grey: #d9d9d9;
	--snow: #fafafa;
	--azure-grey: #4a4e57;
	--tricorn-black: #282828;
	--smoke: #f2f2f2;

	/* New Colours */
	--dark-grey: #2a3135;
	--teal: #007484;
	--light-teal: #53ced6;
	--beige: #f5f2ea;
	--white: #ffffff;
	--background: #fafafa;
	--black: #000000;
	--error-red: #ca3232;
	--orange: #ff6230;
	--grey-f4: #f4f4f4;
	--grey-e5: #e5e5e5;
	--grey-d9: #d9d9d9;
	--grey-c8: #c8c8c8;
	--muted-orange: #fce0d7;
}

/* For readability concerns, you should choose a lighter palette in dark mode. */
[data-theme='dark'] {
	--ifm-color-primary: #f26336;
	--ifm-color-primary-dark: #f04d1a;
	--ifm-color-primary-darker: #ec440f;
	--ifm-color-primary-darkest: #c3380d;
	--ifm-color-primary-light: #f47952;
	--ifm-color-primary-lighter: #f58360;
	--ifm-color-primary-lightest: #f7a489;
	--docusaurus-highlighted-code-line-bg: rgba(0, 0, 0, 0.3);
}

/* Used to prevent a doc from appearing in the autogenerated sidebard */
.hiddenDoc {
	display: none !important;
}

Expected behavior

The hero background and links are orange.

Actual behavior

The hero background and links are blue.

Your environment

  • Public source code: Not available
  • Public site URL: Still a work in progress
  • Docusaurus version used: 3.5.2
  • Environment name and version (e.g. Chrome 89, Node.js 16.4): Chrome 128.0.6613.138, Node v20.11.1, Yarn 1.22.19
  • Operating system and version (e.g. Ubuntu 20.04.2 LTS): macOS 14.6.1

Self-service

  • I'd be willing to fix this bug myself.
@MSohm MSohm added bug An error in the Docusaurus core causing instability or issues with its execution status: needs triage This issue has not been triaged by maintainers labels Sep 16, 2024
@Josh-Cena
Copy link
Collaborator

I'm fairly sure this is because of #9303. The problem is not with --ifm-color-primary (everyone uses it including ourselves so the chance of it not working is 0). It's with the CSS nesting syntax you are using, which invalidates :root. It works once you take them out.

@slorber slorber removed the status: needs triage This issue has not been triaged by maintainers label Sep 16, 2024
@slorber
Copy link
Collaborator

slorber commented Sep 16, 2024

yes that looks like it's the same CSS nesting issue

@slorber slorber closed this as not planned Won't fix, can't repro, duplicate, stale Sep 16, 2024
@slorber slorber added the closed: duplicate This issue or pull request already exists in another issue or pull request label Sep 16, 2024
@MSohm
Copy link
Author

MSohm commented Sep 16, 2024

I found the root cause was an incorrect path to the font.
If I change:

@font-face {
	font-family: 'Figtree';
	src: url('/static/fonts/Figtree/Figtree-VariableFont_wght.ttf') format('truetype');
	font-weight: 200 900;
	font-stretch: 75% 125%;
}

To (remove static from the path)

@font-face {
	font-family: 'Figtree';
	src: url('/fonts/Figtree/Figtree-VariableFont_wght.ttf') format('truetype');
	font-weight: 200 900;
	font-stretch: 75% 125%;
}

It works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An error in the Docusaurus core causing instability or issues with its execution closed: duplicate This issue or pull request already exists in another issue or pull request
Projects
None yet
Development

No branches or pull requests

3 participants