Remove flags

This commit is contained in:
Eric Bailey
2024-09-18 12:18:25 -05:00
parent ebb6f6e2c4
commit d7063c43d0
4 changed files with 12 additions and 21 deletions
+6 -13
View File
@@ -1,7 +1,6 @@
import React from 'react' import React from 'react'
import {useMediaQuery} from 'react-responsive' import {useMediaQuery} from 'react-responsive'
import {useGate} from '#/lib/statsig/statsig'
import { import {
computeFontScaleMultiplier, computeFontScaleMultiplier,
getFontFamily, getFontFamily,
@@ -33,9 +32,10 @@ export type Alf = {
setFontScale: (fontScale: Exclude<Device['fontScale'], undefined>) => void setFontScale: (fontScale: Exclude<Device['fontScale'], undefined>) => void
setFontFamily: (fontFamily: Device['fontFamily']) => void setFontFamily: (fontFamily: Device['fontFamily']) => void
} }
flags: { /**
neue: boolean * Feature flags or other gated options
} */
flags: {}
} }
/* /*
@@ -58,17 +58,13 @@ export const Context = React.createContext<Alf>({
setFontScale: () => {}, setFontScale: () => {},
setFontFamily: () => {}, setFontFamily: () => {},
}, },
flags: { flags: {},
neue: false,
},
}) })
export function ThemeProvider({ export function ThemeProvider({
children, children,
theme: themeName, theme: themeName,
}: React.PropsWithChildren<{theme: ThemeName}>) { }: React.PropsWithChildren<{theme: ThemeName}>) {
const gate = useGate()
const [neue] = React.useState(() => gate('typography_neue'))
const [fontScale, setFontScale] = React.useState<Alf['fonts']['scale']>(() => const [fontScale, setFontScale] = React.useState<Alf['fonts']['scale']>(() =>
getFontScale(), getFontScale(),
) )
@@ -121,14 +117,11 @@ export function ThemeProvider({
setFontScale: setFontScaleAndPersist, setFontScale: setFontScaleAndPersist,
setFontFamily: setFontFamilyAndPersist, setFontFamily: setFontFamilyAndPersist,
}, },
flags: { flags: {},
neue,
},
}), }),
[ [
themeName, themeName,
themes, themes,
neue,
fontScale, fontScale,
setFontScaleAndPersist, setFontScaleAndPersist,
fontFamily, fontFamily,
+2 -4
View File
@@ -39,12 +39,10 @@ export function normalizeTextStyles(
{ {
fontScale, fontScale,
fontFamily, fontFamily,
flags,
}: { }: {
fontScale: number fontScale: number
fontFamily: Alf['fonts']['family'] fontFamily: Alf['fonts']['family']
flags: {neue: boolean} } & Pick<Alf, 'flags'>,
},
) { ) {
const s = flatten(styles) const s = flatten(styles)
// should always be defined on these components // should always be defined on these components
@@ -58,7 +56,7 @@ export function normalizeTextStyles(
s.lineHeight = s.fontSize s.lineHeight = s.fontSize
} }
if (flags.neue && fontFamily === 'theme') { if (fontFamily === 'theme') {
applyFonts(s) applyFonts(s)
} }
+1 -1
View File
@@ -1,3 +1,3 @@
export type Gate = export type Gate =
// Keep this alphabetic please. // Keep this alphabetic please.
'debug_show_feedcontext' | 'typography_neue' | 'suggested_feeds_interstitial' 'debug_show_feedcontext' | 'suggested_feeds_interstitial'
+3 -3
View File
@@ -33,7 +33,7 @@ export function Text({
const theme = useTheme() const theme = useTheme()
const typography = theme.typography[type] const typography = theme.typography[type]
const lineHeightStyle = lineHeight ? lh(theme, type, lineHeight) : undefined const lineHeightStyle = lineHeight ? lh(theme, type, lineHeight) : undefined
const {fonts, flags} = useAlf() const {fonts} = useAlf()
if (selectable && isIOS) { if (selectable && isIOS) {
const flattened = StyleSheet.flatten([ const flattened = StyleSheet.flatten([
@@ -43,7 +43,7 @@ export function Text({
style, style,
]) ])
if (flags.neue && fonts.family === 'theme') { if (fonts.family === 'theme') {
applyFonts(flattened) applyFonts(flattened)
} }
@@ -73,7 +73,7 @@ export function Text({
style, style,
]) ])
if (flags.neue && fonts.family === 'theme') { if (fonts.family === 'theme') {
applyFonts(flattened) applyFonts(flattened)
} }