microsoft / microsoft/react-native-windows

Reconcile AppTheme's high contrast APIs with Lean Core Appearance APIs

Open
#3,701 13 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Area: Theming enhancement Upstream Workstream: Component Parity
Dominant language
C++
Stars
17.3k
Forks
1.2k
Avg merge
1d 13h
Merged PRs (30d)
33

Description

Align AppTheme API with Lean Core Appearance API

We have a Windows-only API module called AppTheme. Which enables you to listen to the dark and light theme state changes for Windows.

As of this commit, React Native core has an iOS and Android ones. It operates very similarly to how ours does, but there are some API name changes.

This proposal is to align the names with the Lean Core implementation, so that we can push up the Windows theme changed event work up to React Native to sit along side the iOS and Android implementations.

Summary

We must make sure our Windows implementation of the theme changed event maps to the React Native Appearance and the getColorScheme() function, instead of AppTheme and the currentTheme string property.

We should also separately PR the highContrastedChanged work into the Appearance API to enable support for that type of theme change.

Motivation

In order for our Windows implementation of theme changed events to work properly in React Native's lean core, we must align with their implementation of theme changed events.

This Windows alignment is happening on the JS-layer only.

The JS API to align with can be found in the Libraries/Utilities/Appearance.js file on the React Native repo.

Basic example

import { Appearance } from 'react-native'

  render() {
    return (
      <Button title='click me' color={Appearance.getColorScheme() === 'dark' ? 'grey' : 'orange'}></Button>
    );
  }

Contributing Back

As mentioned above, it's important that during this alignment that we do not lose the highContrastedChanged implemented within AppTheme. This is an important feature for windows users and something we should contribute back to React Native core with.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with React Native's Libraries/Utilities/Appearance.js and search the Windows implementation for AppTheme, currentTheme, and highContrastedChanged. Align the Windows JavaScript API with Appearance and getColorScheme while preserving high-contrast change support; done means the Windows theme-change behavior uses the aligned names without losing that feature.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react-native
Domain
desktop, frontend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.