Skip to content

Commit fa79197

Browse files
authored
Merge pull request #539 from gmsgowtham/fix/color-overrides
fix: deprecate background property from UserTheme and fix h1 text color
2 parents 2a5e7d2 + e819285 commit fa79197

File tree

5 files changed

+22
-9
lines changed

5 files changed

+22
-9
lines changed

src/lib/Markdown.tsx

+1-5
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import React, {
77
import { FlatList, useColorScheme } from "react-native";
88
import type { MarkdownProps } from "./types";
99
import useMarkdown from "../hooks/useMarkdown";
10-
import colors from "../theme/colors";
1110

1211
const Markdown = ({
1312
value,
@@ -45,10 +44,7 @@ const Markdown = ({
4544
maxToRenderPerBatch={8}
4645
initialNumToRender={8}
4746
style={{
48-
backgroundColor:
49-
colorScheme === "light"
50-
? colors.light.background
51-
: colors.dark.background,
47+
backgroundColor: colorScheme === "light" ? "#ffffff" : "#000000",
5248
}}
5349
{...flatListProps}
5450
data={rnElements}

src/lib/__tests__/__snapshots__/Markdown.spec.tsx.snap

+6
Original file line numberDiff line numberDiff line change
@@ -2412,6 +2412,7 @@ exports[`Headings Alternate Syntax: Heading level 1 1`] = `
24122412
{
24132413
"borderBottomColor": "#d0d7de",
24142414
"borderBottomWidth": 1,
2415+
"color": "#333333",
24152416
"fontSize": 32,
24162417
"fontWeight": "bold",
24172418
"letterSpacing": 0,
@@ -2460,6 +2461,7 @@ exports[`Headings Alternate Syntax: Heading level 1 1`] = `
24602461
{
24612462
"borderBottomColor": "#d0d7de",
24622463
"borderBottomWidth": 1,
2464+
"color": "#333333",
24632465
"fontSize": 32,
24642466
"fontWeight": "bold",
24652467
"letterSpacing": 0,
@@ -2588,6 +2590,7 @@ exports[`Headings Best Practice 1`] = `
25882590
{
25892591
"borderBottomColor": "#d0d7de",
25902592
"borderBottomWidth": 1,
2593+
"color": "#333333",
25912594
"fontSize": 32,
25922595
"fontWeight": "bold",
25932596
"letterSpacing": 0,
@@ -2698,6 +2701,7 @@ exports[`Headings Best Practice 1`] = `
26982701
{
26992702
"borderBottomColor": "#d0d7de",
27002703
"borderBottomWidth": 1,
2704+
"color": "#333333",
27012705
"fontSize": 32,
27022706
"fontWeight": "bold",
27032707
"letterSpacing": 0,
@@ -2758,6 +2762,7 @@ exports[`Headings Heading level 1 1`] = `
27582762
{
27592763
"borderBottomColor": "#d0d7de",
27602764
"borderBottomWidth": 1,
2765+
"color": "#333333",
27612766
"fontSize": 32,
27622767
"fontWeight": "bold",
27632768
"letterSpacing": 0,
@@ -2806,6 +2811,7 @@ exports[`Headings Heading level 1 1`] = `
28062811
{
28072812
"borderBottomColor": "#d0d7de",
28082813
"borderBottomWidth": 1,
2814+
"color": "#333333",
28092815
"fontSize": 32,
28102816
"fontWeight": "bold",
28112817
"letterSpacing": 0,

src/theme/colors.ts

+12-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
1-
export type ColorKeysType = "background" | "code" | "link" | "text" | "border";
2-
export type ColorsPropType = Record<ColorKeysType, string>;
1+
import type { ColorValue } from "react-native";
2+
3+
export interface ColorsPropType {
4+
code: ColorValue;
5+
link: ColorValue;
6+
text: ColorValue;
7+
border: ColorValue;
8+
/**
9+
* @deprecated Use flatlist containerStyle or style prop for setting background color
10+
*/
11+
background?: ColorValue;
12+
}
313

414
const colors: Record<"light" | "dark", ColorsPropType> = {
515
light: {

src/theme/styles.ts

+1
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ const getStyles = (
7575
userStyles?.blockquote,
7676
]),
7777
h1: StyleSheet.flatten([
78+
fontStyle.heading,
7879
{
7980
fontSize: 32,
8081
lineHeight: 40,

src/theme/types.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { ImageStyle, TextStyle, ViewStyle } from "react-native";
2-
import type { ColorKeysType } from "./colors";
2+
import type { ColorsPropType } from "./colors";
33
import type { SpacingKeysType } from "./spacing";
44

55
export interface MarkedStyles {
@@ -28,6 +28,6 @@ export interface MarkedStyles {
2828
}
2929

3030
export interface UserTheme {
31-
colors?: Record<ColorKeysType, string>;
31+
colors?: ColorsPropType;
3232
spacing?: Record<SpacingKeysType, number>;
3333
}

0 commit comments

Comments
 (0)