Skip to content

Commit 43acc41

Browse files
BigHeadCreationsgnprice
authored andcommitted
theme [nfc]: Rename internally from default/night to light/dark
This resolves part of #5169: we rename the values in the internal ThemeName type, and various local identifiers. Still open from #5169 is to rename what we actually show to the user in the settings UI, and the ThemeSetting values that reflect that.
1 parent 33750f8 commit 43acc41

File tree

12 files changed

+32
-34
lines changed

12 files changed

+32
-34
lines changed

src/boot/OfflineNoticeProvider.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ const backgroundColorForTheme = (theme: ThemeName): string =>
140140
// TODO(redesign): Choose these more intentionally; these are just the
141141
// semitransparent HALF_COLOR flattened with themeData.backgroundColor.
142142
// See https://github.com/zulip/zulip-mobile/pull/5491#issuecomment-1282859332
143-
theme === 'default' ? '#bfbfbf' : '#50565e';
143+
theme === 'light' ? '#bfbfbf' : '#50565e';
144144

145145
/**
146146
* Shows a notice if the app is working in offline mode.

src/common/Popup.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export default function Popup(props: Props): Node {
5151
const themeToUse = getThemeToUse(theme, osScheme);
5252

5353
// TODO(color/theme): find a cleaner way to express this
54-
const isDarkTheme = themeToUse !== 'default';
54+
const isDarkTheme = themeToUse !== 'light';
5555
return (
5656
<View style={[{ backgroundColor: themeContext.backgroundColor }, styles.popup]}>
5757
<View style={isDarkTheme && styles.overlay}>{props.children}</View>

src/common/ZulipStatusBar.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { getThemeToUse } from '../settings/settingsSelectors';
1515
type BarStyle = React$ElementConfig<typeof StatusBar>['barStyle'];
1616

1717
export const getStatusBarColor = (backgroundColor: string | void, theme: ThemeName): string =>
18-
backgroundColor ?? (theme === 'night' ? 'hsl(212, 28%, 18%)' : 'white');
18+
backgroundColor ?? (theme === 'dark' ? 'hsl(212, 28%, 18%)' : 'white');
1919

2020
export const getStatusBarStyle = (statusBarColor: string): BarStyle =>
2121
foregroundColorFromBackground(statusBarColor) === 'white' /* force newline */
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
/* @flow strict-local */
22
import { getStatusBarColor } from '../ZulipStatusBar';
33

4-
const themeNight = 'night';
5-
const themeDefault = 'default';
4+
const themeDark = 'dark';
5+
const themeLight = 'light';
66

77
describe('getStatusBarColor', () => {
88
test('returns specific color when given, regardless of theme', () => {
9-
expect(getStatusBarColor('#fff', themeDefault)).toEqual('#fff');
10-
expect(getStatusBarColor('#fff', themeNight)).toEqual('#fff');
9+
expect(getStatusBarColor('#fff', themeLight)).toEqual('#fff');
10+
expect(getStatusBarColor('#fff', themeDark)).toEqual('#fff');
1111
});
1212

1313
test('returns color according to theme for default case', () => {
14-
expect(getStatusBarColor(undefined, themeDefault)).toEqual('white');
15-
expect(getStatusBarColor(undefined, themeNight)).toEqual('hsl(212, 28%, 18%)');
14+
expect(getStatusBarColor(undefined, themeLight)).toEqual('white');
15+
expect(getStatusBarColor(undefined, themeDark)).toEqual('hsl(212, 28%, 18%)');
1616
});
1717
});

src/nav/ZulipNavigationContainer.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ export default function ZulipAppContainer(props: Props): Node {
4040

4141
const themeContext = useContext(ThemeContext);
4242

43-
const BaseTheme = themeToUse === 'night' ? DarkTheme : DefaultTheme;
43+
const BaseTheme = themeToUse === 'dark' ? DarkTheme : DefaultTheme;
4444

4545
const theme = {
4646
...BaseTheme,
47-
dark: themeToUse === 'night',
47+
dark: themeToUse === 'dark',
4848
colors: {
4949
...BaseTheme.colors,
5050
primary: themeContext.color,

src/reduxTypes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ export type RealmState = {|
355355
* OS theme by calling the React Native hook useColorScheme and pass
356356
* that to the helper function getThemeToUse.
357357
*/
358-
export type ThemeName = 'default' | 'night';
358+
export type ThemeName = 'light' | 'dark';
359359

360360
/**
361361
* The theme setting.

src/settings/settingsSelectors.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,4 @@ import type { ColorSchemeName } from 'react-native/Libraries/Utilities/NativeApp
33
import type { ThemeSetting, ThemeName } from '../reduxTypes';
44

55
export const getThemeToUse = (theme: ThemeSetting, osScheme: ?ColorSchemeName): ThemeName =>
6-
// This is a no-op stub. We'll give it more interesting behavior soon.
7-
theme;
6+
theme === 'default' ? 'light' : 'dark';

src/start/IosCompliantAppleAuthButton/Custom.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,21 @@ const styles = createStyleSheet({
2323
borderRadius: 22,
2424
overflow: 'hidden',
2525
},
26-
nightFrame: {
26+
darkFrame: {
2727
backgroundColor: 'black',
2828
},
29-
dayFrame: {
29+
lightFrame: {
3030
backgroundColor: 'white',
3131
borderWidth: 1.5,
3232
borderColor: 'black',
3333
},
3434
text: {
3535
fontSize: 16,
3636
},
37-
nightText: {
37+
darkText: {
3838
color: 'white',
3939
},
40-
dayText: {
40+
lightText: {
4141
color: 'black',
4242
},
4343
});
@@ -57,13 +57,13 @@ type Props = $ReadOnly<{|
5757
*/
5858
export default function Custom(props: Props): Node {
5959
const { style, onPress, theme } = props;
60-
const logoSource = theme === 'default' ? appleLogoBlackImg : appleLogoWhiteImg;
60+
const logoSource = theme === 'light' ? appleLogoBlackImg : appleLogoWhiteImg;
6161
const frameStyle = [
6262
styles.frame,
63-
theme === 'default' ? styles.dayFrame : styles.nightFrame,
63+
theme === 'light' ? styles.lightFrame : styles.darkFrame,
6464
style,
6565
];
66-
const textStyle = [styles.text, theme === 'default' ? styles.dayText : styles.nightText];
66+
const textStyle = [styles.text, theme === 'light' ? styles.lightText : styles.darkText];
6767

6868
return (
6969
<View style={frameStyle}>

src/start/IosCompliantAppleAuthButton/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export default function IosCompliantAppleAuthButton(props: Props): Node {
6060
<AppleAuthentication.AppleAuthenticationButton
6161
buttonType={AppleAuthentication.AppleAuthenticationButtonType.SIGN_IN}
6262
buttonStyle={
63-
themeToUse === 'default'
63+
themeToUse === 'light'
6464
? AppleAuthentication.AppleAuthenticationButtonStyle.WHITE_OUTLINE
6565
: AppleAuthentication.AppleAuthenticationButtonStyle.BLACK
6666
}

src/styles/theme.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ export type ThemeData = {|
1212
dividerColor: string,
1313
|};
1414

15-
export const themeData: {| [name: ThemeName | 'light']: ThemeData |} = {
16-
night: {
17-
themeName: 'night',
15+
export const themeData: {| [name: ThemeName]: ThemeData |} = {
16+
dark: {
17+
themeName: 'dark',
1818
color: 'hsl(210, 11%, 85%)',
1919
backgroundColor: 'hsl(212, 28%, 18%)',
2020
cardColor: 'hsl(212, 31%, 21%)',
@@ -23,7 +23,7 @@ export const themeData: {| [name: ThemeName | 'light']: ThemeData |} = {
2323
dividerColor: 'hsla(0, 0%, 100%, 0.12)',
2424
},
2525
light: {
26-
themeName: 'default',
26+
themeName: 'light',
2727
color: 'hsl(0, 0%, 20%)',
2828
backgroundColor: 'white',
2929
cardColor: 'hsl(0, 0%, 97%)',
@@ -32,6 +32,5 @@ export const themeData: {| [name: ThemeName | 'light']: ThemeData |} = {
3232
dividerColor: 'hsla(0, 0%, 0%, 0.12)',
3333
},
3434
};
35-
themeData.default = themeData.light;
3635

37-
export const ThemeContext: Context<ThemeData> = React.createContext(themeData.default);
36+
export const ThemeContext: Context<ThemeData> = React.createContext(themeData.light);

0 commit comments

Comments
 (0)