Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Default value is ignored if device color scheme is dark

オープン
#456 コメント 0 件 リアクション 1 件 担当者 0 名 GitHub で見る

@orhels がすでに取り組んでいます。

2026年2月26日 から。

  • #457 @orhels による — オープン

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
58/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
javascript, react
領域
frontend

調査の方向性

customProperties.js の 71 行目から始め、デバイスをダークモードにして、提示された defineVars の例を再現します。デフォルト値と、カラースキーム以外のメディアクエリを持つ変数がデフォルト値を維持することを確認し、次にライトモードでも同じ動作を検証して、既存のテストカバレッジに適切なリグレッションケースがあるか確認します。

索引モデルが issue の本文から書いたものです。

説明

bug
Describe the issue

When using dark mode on device the default value of defineVars with media-queries other than preferes-color-scheme are ignored. If using light mode the default value is used as expected.

From researching this a bit if think the issue is at line 71 in customProperties.js:

   if (variableValue != null) {
    if (typeof variableValue === 'object' && variableValue.default != null) {
      let defaultValue = variableValue.default;
      if (colorScheme === 'dark') {
        defaultValue = variableValue['@media (prefers-color-scheme: dark)'];
      }
      return defaultValue;
    }
    return variableValue;

It looks like the if-check if (colorScheme === 'dark') should also check if the variableValue['@media (prefers-color-scheme: dark)'] exists before setting the defaultValue.

Expected behavior

When device is set to dark mode styling should behave the same as in light mode.

Steps to reproduce
  1. Define a css-var like this:
// fontSize.css.js
export const fontSize = css.defineVars({
  small: {
    default: '32px',
    '@media (min-width: 800px)': '20px',
  }
})
  1. Use the var in a component:
import { fontSize } from './fontSize.css';

export function ComponentA() {
	return <html.p style={styles.componentA}>Responsive test</html.p>;
}

const styles = css.create({
	componentA: {
		fontSize: fontSize.small,
	},
});
  1. Check the component on device/simulator in dark-mode.
Test case

No response

Additional comments

Images from the above example running in our test-app. (Ignore the ugly theme switcher in the upper right)

Light-mode:
Image

Dark-mode:
Image

主要言語
JavaScript
スター
3.6k
フォーク
208
PR マージ指標
30日以内にマージされた PR はありません

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

react/react-strict-dom のほかの issue

react/react-strict-dom の issue をすべて見る

似ている issue

JavaScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。