react-native-marked 1.4.3 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -5
- package/dist/commonjs/lib/Markdown.js +3 -2
- package/dist/commonjs/lib/Markdown.js.map +1 -1
- package/dist/commonjs/theme/colors.js.map +1 -1
- package/dist/commonjs/theme/spacing.js +15 -0
- package/dist/commonjs/theme/spacing.js.map +1 -0
- package/dist/commonjs/theme/styles.js +37 -28
- package/dist/commonjs/theme/styles.js.map +1 -1
- package/dist/module/lib/Markdown.js +3 -2
- package/dist/module/lib/Markdown.js.map +1 -1
- package/dist/module/theme/colors.js.map +1 -1
- package/dist/module/theme/spacing.js +8 -0
- package/dist/module/theme/spacing.js.map +1 -0
- package/dist/module/theme/styles.js +34 -28
- package/dist/module/theme/styles.js.map +1 -1
- package/dist/typescript/lib/Markdown.d.ts +1 -1
- package/dist/typescript/lib/Markdown.d.ts.map +1 -1
- package/dist/typescript/lib/types.d.ts +2 -1
- package/dist/typescript/lib/types.d.ts.map +1 -1
- package/dist/typescript/theme/colors.d.ts +3 -2
- package/dist/typescript/theme/colors.d.ts.map +1 -1
- package/dist/typescript/theme/spacing.d.ts +4 -0
- package/dist/typescript/theme/spacing.d.ts.map +1 -0
- package/dist/typescript/theme/styles.d.ts +2 -2
- package/dist/typescript/theme/styles.d.ts.map +1 -1
- package/dist/typescript/theme/types.d.ts +5 -3
- package/dist/typescript/theme/types.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/lib/Markdown.tsx +4 -3
- package/src/lib/types.ts +2 -1
- package/src/theme/colors.ts +3 -2
- package/src/theme/spacing.ts +10 -0
- package/src/theme/styles.ts +33 -29
- package/src/theme/types.ts +5 -4
- package/dist/commonjs/theme/theme.js +0 -19
- package/dist/commonjs/theme/theme.js.map +0 -1
- package/dist/module/theme/theme.js +0 -7
- package/dist/module/theme/theme.js.map +0 -1
- package/dist/typescript/theme/theme.d.ts +0 -4
- package/dist/typescript/theme/theme.d.ts.map +0 -1
- package/src/theme/theme.ts +0 -9
package/README.md
CHANGED
|
@@ -40,11 +40,12 @@ https://snack.expo.dev/@gmsgowtham/react-native-marked
|
|
|
40
40
|
|
|
41
41
|
## [Props](https://github.com/gmsgowtham/react-native-marked/blob/4ef070931b7d309a7490c41e45129e12525d12d9/src/lib/types.ts#L18)
|
|
42
42
|
|
|
43
|
-
| Prop | Description
|
|
44
|
-
| ------------- |
|
|
45
|
-
| value | Markdown value
|
|
46
|
-
| flatListProps | Props for customizing the underlying FlatList used
|
|
47
|
-
| styles | Styles for parsed components
|
|
43
|
+
| Prop | Description | Type | Optional? |
|
|
44
|
+
| ------------- | -------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | --------- |
|
|
45
|
+
| value | Markdown value | string | false |
|
|
46
|
+
| flatListProps | Props for customizing the underlying FlatList used | `Omit<FlatListProps<ReactNode>, 'data' \| 'renderItem' \| 'horizontal'>`<br><br><br>(`'data'`, `'renderItem'`, and `'horizontal'` props are omitted and cannot be overridden.) | true |
|
|
47
|
+
| styles | Styles for parsed components | [MarkedStyles](https://github.com/gmsgowtham/react-native-marked/blob/4ef070931b7d309a7490c41e45129e12525d12d9/src/theme/types.ts#L3) | true |
|
|
48
|
+
| theme | Props for customizing colors and spacing for all components,and it will get overridden with custom component style applied via 'styles' prop | [UserTheme](https://github.com/gmsgowtham/react-native-marked/blob/6eba804c617099ffb574aa97c57a71ea3e0184fb/src/theme/types.ts#L28) | true |
|
|
48
49
|
|
|
49
50
|
## Screenshots
|
|
50
51
|
|
|
@@ -27,10 +27,11 @@ const Markdown = _ref => {
|
|
|
27
27
|
let {
|
|
28
28
|
value,
|
|
29
29
|
flatListProps,
|
|
30
|
+
theme,
|
|
30
31
|
styles: userStyles
|
|
31
32
|
} = _ref;
|
|
32
|
-
const
|
|
33
|
-
const styles = (0, _react.useMemo)(() => (0, _styles.default)(userStyles,
|
|
33
|
+
const colorScheme = (0, _reactNative.useColorScheme)();
|
|
34
|
+
const styles = (0, _react.useMemo)(() => (0, _styles.default)(userStyles, colorScheme, theme), [userStyles, colorScheme, theme]);
|
|
34
35
|
const rnElements = (0, _react.useMemo)(() => {
|
|
35
36
|
const parser = new _Parser.default({
|
|
36
37
|
styles
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Markdown","value","flatListProps","styles","userStyles","
|
|
1
|
+
{"version":3,"names":["Markdown","value","flatListProps","theme","styles","userStyles","colorScheme","useColorScheme","useMemo","getStyles","rnElements","parser","Parser","tokens","marked","lexer","mangle","gfm","parse","renderItem","useCallback","item","keyExtractor","_","index","toString","container","memo"],"sourceRoot":"../../src","sources":["Markdown.tsx"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;AAGA,MAAMA,QAAQ,GAAG,QAKI;EAAA,IALH;IAChBC,KADgB;IAEhBC,aAFgB;IAGhBC,KAHgB;IAIhBC,MAAM,EAAEC;EAJQ,CAKG;EACnB,MAAMC,WAAW,GAAG,IAAAC,2BAAA,GAApB;EACA,MAAMH,MAAM,GAAG,IAAAI,cAAA,EACb,MAAM,IAAAC,eAAA,EAAUJ,UAAV,EAAsBC,WAAtB,EAAmCH,KAAnC,CADO,EAEb,CAACE,UAAD,EAAaC,WAAb,EAA0BH,KAA1B,CAFa,CAAf;EAKA,MAAMO,UAAU,GAAG,IAAAF,cAAA,EAAQ,MAAM;IAC/B,MAAMG,MAAM,GAAG,IAAIC,eAAJ,CAAW;MACxBR;IADwB,CAAX,CAAf;;IAGA,MAAMS,MAAM,GAAGC,cAAA,CAAOC,KAAP,CAAad,KAAb,EAAoB;MACjCe,MAAM,EAAE,KADyB;MAEjCC,GAAG,EAAE;IAF4B,CAApB,CAAf;;IAKA,OAAON,MAAM,CAACO,KAAP,CAAaL,MAAb,CAAP;EACD,CAVkB,EAUhB,CAACZ,KAAD,EAAQG,MAAR,CAVgB,CAAnB;EAYA,MAAMe,UAAU,GAAG,IAAAC,kBAAA,EAAY,SAAmC;IAAA,IAAlC;MAAEC;IAAF,CAAkC;IAChE,oBAAO,4DAAGA,IAAH,CAAP;EACD,CAFkB,EAEhB,EAFgB,CAAnB;EAIA,MAAMC,YAAY,GAAG,IAAAF,kBAAA,EACnB,CAACG,CAAD,EAAeC,KAAf,KAAiCA,KAAK,CAACC,QAAN,EADd,EAEnB,EAFmB,CAArB;EAKA,oBACE,6BAAC,qBAAD;IACE,YAAY,EAAEH,YADhB;IAEE,mBAAmB,EAAE,CAFvB;IAGE,kBAAkB,EAAE,CAHtB;IAIE,qBAAqB,MAJvB;IAKE,KAAK,EAAElB,MAAM,CAACsB;EALhB,GAMMxB,aANN;IAOE,IAAI,EAAEQ,UAPR;IAQE,UAAU,EAAES;EARd,GADF;AAYD,CA7CD;;4BA+Ce,IAAAQ,WAAA,EAAK3B,QAAL,C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["colors","light","background","code","link","text","border","dark"],"sourceRoot":"../../src","sources":["colors.ts"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"names":["colors","light","background","code","link","text","border","dark"],"sourceRoot":"../../src","sources":["colors.ts"],"mappings":";;;;;;AAGA,MAAMA,MAAgD,GAAG;EACvDC,KAAK,EAAE;IACLC,UAAU,EAAE,SADP;IAELC,IAAI,EAAE,SAFD;IAGLC,IAAI,EAAE,SAHD;IAILC,IAAI,EAAE,SAJD;IAKLC,MAAM,EAAE;EALH,CADgD;EAQvDC,IAAI,EAAE;IACJL,UAAU,EAAE,SADR;IAEJC,IAAI,EAAE,SAFF;IAGJC,IAAI,EAAE,SAHF;IAIJC,IAAI,EAAE,SAJF;IAKJC,MAAM,EAAE;EALJ;AARiD,CAAzD;eAiBeN,M"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
const padding = {
|
|
8
|
+
xs: 2,
|
|
9
|
+
s: 4,
|
|
10
|
+
m: 8,
|
|
11
|
+
l: 16
|
|
12
|
+
};
|
|
13
|
+
var _default = padding;
|
|
14
|
+
exports.default = _default;
|
|
15
|
+
//# sourceMappingURL=spacing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["padding","xs","s","m","l"],"sourceRoot":"../../src","sources":["spacing.ts"],"mappings":";;;;;;AAEA,MAAMA,OAAwC,GAAG;EAC/CC,EAAE,EAAE,CAD2C;EAE/CC,CAAC,EAAE,CAF4C;EAG/CC,CAAC,EAAE,CAH4C;EAI/CC,CAAC,EAAE;AAJ4C,CAAjD;eAOeJ,O"}
|
|
@@ -7,29 +7,38 @@ exports.default = void 0;
|
|
|
7
7
|
|
|
8
8
|
var _reactNative = require("react-native");
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _spacing = _interopRequireDefault(require("./spacing"));
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
var _colors = _interopRequireDefault(require("./colors"));
|
|
13
|
+
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
+
|
|
16
|
+
const getFontStyles = mdColors => {
|
|
13
17
|
return _reactNative.StyleSheet.create({
|
|
14
18
|
regular: {
|
|
15
19
|
fontSize: 16,
|
|
16
20
|
lineHeight: 24,
|
|
17
|
-
color:
|
|
21
|
+
color: mdColors.text
|
|
18
22
|
},
|
|
19
23
|
heading: {
|
|
20
24
|
fontWeight: '500',
|
|
21
|
-
color:
|
|
25
|
+
color: mdColors.text
|
|
22
26
|
}
|
|
23
27
|
});
|
|
24
28
|
};
|
|
25
29
|
|
|
26
|
-
const getStyles = (userStyles, colorScheme) => {
|
|
27
|
-
const
|
|
28
|
-
|
|
30
|
+
const getStyles = (userStyles, colorScheme, userTheme) => {
|
|
31
|
+
const mdColors = { ..._colors.default[colorScheme || 'light'],
|
|
32
|
+
...(userTheme === null || userTheme === void 0 ? void 0 : userTheme.colors)
|
|
33
|
+
};
|
|
34
|
+
const mdSpacing = { ..._spacing.default,
|
|
35
|
+
...(userTheme === null || userTheme === void 0 ? void 0 : userTheme.spacing)
|
|
36
|
+
};
|
|
37
|
+
const fontStyle = getFontStyles(mdColors);
|
|
29
38
|
|
|
30
39
|
const defaultStyles = _reactNative.StyleSheet.create({
|
|
31
40
|
container: {
|
|
32
|
-
backgroundColor:
|
|
41
|
+
backgroundColor: mdColors.background
|
|
33
42
|
},
|
|
34
43
|
em: { ...fontStyle.regular,
|
|
35
44
|
fontStyle: 'italic'
|
|
@@ -44,69 +53,69 @@ const getStyles = (userStyles, colorScheme) => {
|
|
|
44
53
|
text: { ...fontStyle.regular
|
|
45
54
|
},
|
|
46
55
|
paragraph: { ...fontStyle.regular,
|
|
47
|
-
paddingVertical:
|
|
56
|
+
paddingVertical: mdSpacing.m
|
|
48
57
|
},
|
|
49
58
|
link: { ...fontStyle.regular,
|
|
50
59
|
fontStyle: 'italic',
|
|
51
|
-
color:
|
|
60
|
+
color: mdColors.link
|
|
52
61
|
},
|
|
53
62
|
blockquote: {
|
|
54
|
-
borderLeftColor:
|
|
55
|
-
paddingLeft:
|
|
56
|
-
borderLeftWidth:
|
|
63
|
+
borderLeftColor: mdColors.border,
|
|
64
|
+
paddingLeft: mdSpacing.l,
|
|
65
|
+
borderLeftWidth: mdSpacing.s,
|
|
57
66
|
opacity: 0.8
|
|
58
67
|
},
|
|
59
68
|
h1: {
|
|
60
69
|
fontSize: 32,
|
|
61
70
|
lineHeight: 40,
|
|
62
71
|
fontWeight: 'bold',
|
|
63
|
-
marginVertical:
|
|
72
|
+
marginVertical: mdSpacing.m,
|
|
64
73
|
letterSpacing: 0,
|
|
65
|
-
paddingBottom:
|
|
66
|
-
borderBottomColor:
|
|
74
|
+
paddingBottom: mdSpacing.s,
|
|
75
|
+
borderBottomColor: mdColors.border,
|
|
67
76
|
borderBottomWidth: 1
|
|
68
77
|
},
|
|
69
78
|
h2: { ...fontStyle.heading,
|
|
70
79
|
fontSize: 28,
|
|
71
80
|
lineHeight: 36,
|
|
72
|
-
marginVertical:
|
|
73
|
-
paddingBottom:
|
|
74
|
-
borderBottomColor:
|
|
81
|
+
marginVertical: mdSpacing.m,
|
|
82
|
+
paddingBottom: mdSpacing.s,
|
|
83
|
+
borderBottomColor: mdColors.border,
|
|
75
84
|
borderBottomWidth: 1
|
|
76
85
|
},
|
|
77
86
|
h3: { ...fontStyle.heading,
|
|
78
87
|
fontSize: 24,
|
|
79
88
|
lineHeight: 32,
|
|
80
|
-
marginVertical:
|
|
89
|
+
marginVertical: mdSpacing.s
|
|
81
90
|
},
|
|
82
91
|
h4: { ...fontStyle.heading,
|
|
83
92
|
fontSize: 22,
|
|
84
93
|
lineHeight: 28,
|
|
85
|
-
marginVertical:
|
|
94
|
+
marginVertical: mdSpacing.s
|
|
86
95
|
},
|
|
87
96
|
h5: { ...fontStyle.regular,
|
|
88
97
|
...fontStyle.heading,
|
|
89
|
-
marginVertical:
|
|
98
|
+
marginVertical: mdSpacing.xs
|
|
90
99
|
},
|
|
91
100
|
h6: { ...fontStyle.heading,
|
|
92
101
|
fontSize: 14,
|
|
93
102
|
lineHeight: 20,
|
|
94
|
-
marginVertical:
|
|
103
|
+
marginVertical: mdSpacing.xs
|
|
95
104
|
},
|
|
96
105
|
codespan: { ...fontStyle.regular,
|
|
97
106
|
fontStyle: 'italic',
|
|
98
|
-
backgroundColor:
|
|
107
|
+
backgroundColor: mdColors.code,
|
|
99
108
|
fontWeight: '300'
|
|
100
109
|
},
|
|
101
110
|
code: {
|
|
102
|
-
padding:
|
|
103
|
-
backgroundColor:
|
|
111
|
+
padding: mdSpacing.l,
|
|
112
|
+
backgroundColor: mdColors.code,
|
|
104
113
|
minWidth: '100%'
|
|
105
114
|
},
|
|
106
115
|
hr: {
|
|
107
116
|
borderBottomWidth: 1,
|
|
108
|
-
borderBottomColor:
|
|
109
|
-
marginVertical:
|
|
117
|
+
borderBottomColor: mdColors.border,
|
|
118
|
+
marginVertical: mdSpacing.s
|
|
110
119
|
},
|
|
111
120
|
li: { ...fontStyle.regular,
|
|
112
121
|
flexShrink: 1
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["getFontStyles","
|
|
1
|
+
{"version":3,"names":["getFontStyles","mdColors","StyleSheet","create","regular","fontSize","lineHeight","color","text","heading","fontWeight","getStyles","userStyles","colorScheme","userTheme","colors","mdSpacing","spacing","fontStyle","defaultStyles","container","backgroundColor","background","em","strong","strikethrough","textDecorationLine","textDecorationStyle","paragraph","paddingVertical","m","link","blockquote","borderLeftColor","border","paddingLeft","l","borderLeftWidth","s","opacity","h1","marginVertical","letterSpacing","paddingBottom","borderBottomColor","borderBottomWidth","h2","h3","h4","h5","xs","h6","codespan","code","padding","minWidth","hr","li","flexShrink","image","resizeMode"],"sourceRoot":"../../src","sources":["styles.ts"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;;;AAGA,MAAMA,aAAa,GAAIC,QAAD,IAA8B;EAClD,OAAOC,uBAAA,CAAWC,MAAX,CAAkB;IACvBC,OAAO,EAAE;MACPC,QAAQ,EAAE,EADH;MAEPC,UAAU,EAAE,EAFL;MAGPC,KAAK,EAAEN,QAAQ,CAACO;IAHT,CADc;IAMvBC,OAAO,EAAE;MACPC,UAAU,EAAE,KADL;MAEPH,KAAK,EAAEN,QAAQ,CAACO;IAFT;EANc,CAAlB,CAAP;AAWD,CAZD;;AAcA,MAAMG,SAAS,GAAG,CAChBC,UADgB,EAEhBC,WAFgB,EAGhBC,SAHgB,KAIC;EACjB,MAAMb,QAAQ,GAAG,EAAE,GAAGc,eAAA,CAAOF,WAAW,IAAI,OAAtB,CAAL;IAAqC,IAAGC,SAAH,aAAGA,SAAH,uBAAGA,SAAS,CAAEC,MAAd;EAArC,CAAjB;EACA,MAAMC,SAAS,GAAG,EAAE,GAAGC,gBAAL;IAAc,IAAGH,SAAH,aAAGA,SAAH,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;MAEFD,iBAAiB,EAAE3C,QAAQ,CAACiC,MAF1B;MAGFO,cAAc,EAAEzB,SAAS,CAACsB;IAHxB,CAxFgD;IA6FpDmB,EAAE,EAAE,EACF,GAAGvC,SAAS,CAACd,OADX;MAEFsD,UAAU,EAAE;IAFV,CA7FgD;IAiGpDC,KAAK,EAAE;MACLC,UAAU,EAAE;IADP;EAjG6C,CAAhC,CAAtB;;EAsGA,OAAO,EACL,GAAGzC,aADE;IAEL,GAAGP;EAFE,CAAP;AAID,CAnHD;;eAqHeD,S"}
|
|
@@ -10,10 +10,11 @@ const Markdown = _ref => {
|
|
|
10
10
|
let {
|
|
11
11
|
value,
|
|
12
12
|
flatListProps,
|
|
13
|
+
theme,
|
|
13
14
|
styles: userStyles
|
|
14
15
|
} = _ref;
|
|
15
|
-
const
|
|
16
|
-
const styles = useMemo(() => getStyles(userStyles,
|
|
16
|
+
const colorScheme = useColorScheme();
|
|
17
|
+
const styles = useMemo(() => getStyles(userStyles, colorScheme, theme), [userStyles, colorScheme, theme]);
|
|
17
18
|
const rnElements = useMemo(() => {
|
|
18
19
|
const parser = new Parser({
|
|
19
20
|
styles
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","memo","useCallback","useMemo","FlatList","useColorScheme","marked","Parser","getStyles","Markdown","value","flatListProps","styles","userStyles","
|
|
1
|
+
{"version":3,"names":["React","memo","useCallback","useMemo","FlatList","useColorScheme","marked","Parser","getStyles","Markdown","value","flatListProps","theme","styles","userStyles","colorScheme","rnElements","parser","tokens","lexer","mangle","gfm","parse","renderItem","item","keyExtractor","_","index","toString","container"],"sourceRoot":"../../src","sources":["Markdown.tsx"],"mappings":";;AAAA,OAAOA,KAAP,IAAgBC,IAAhB,EAAiCC,WAAjC,EAA8CC,OAA9C,QAA6D,OAA7D;AACA,SAASC,QAAT,EAAmBC,cAAnB,QAAyC,cAAzC;AACA,SAASC,MAAT,QAAuB,QAAvB;AACA,OAAOC,MAAP,MAAmB,UAAnB;AAC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AA+CA,4BAAetB,IAAI,CAACQ,QAAD,CAAnB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["colors","light","background","code","link","text","border","dark"],"sourceRoot":"../../src","sources":["colors.ts"],"mappings":"
|
|
1
|
+
{"version":3,"names":["colors","light","background","code","link","text","border","dark"],"sourceRoot":"../../src","sources":["colors.ts"],"mappings":"AAGA,MAAMA,MAAgD,GAAG;EACvDC,KAAK,EAAE;IACLC,UAAU,EAAE,SADP;IAELC,IAAI,EAAE,SAFD;IAGLC,IAAI,EAAE,SAHD;IAILC,IAAI,EAAE,SAJD;IAKLC,MAAM,EAAE;EALH,CADgD;EAQvDC,IAAI,EAAE;IACJL,UAAU,EAAE,SADR;IAEJC,IAAI,EAAE,SAFF;IAGJC,IAAI,EAAE,SAHF;IAIJC,IAAI,EAAE,SAJF;IAKJC,MAAM,EAAE;EALJ;AARiD,CAAzD;AAiBA,eAAeN,MAAf"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["padding","xs","s","m","l"],"sourceRoot":"../../src","sources":["spacing.ts"],"mappings":"AAEA,MAAMA,OAAwC,GAAG;EAC/CC,EAAE,EAAE,CAD2C;EAE/CC,CAAC,EAAE,CAF4C;EAG/CC,CAAC,EAAE,CAH4C;EAI/CC,CAAC,EAAE;AAJ4C,CAAjD;AAOA,eAAeJ,OAAf"}
|
|
@@ -1,26 +1,32 @@
|
|
|
1
1
|
import { StyleSheet } from 'react-native';
|
|
2
|
-
import
|
|
2
|
+
import spacing from './spacing';
|
|
3
|
+
import colors from './colors';
|
|
3
4
|
|
|
4
|
-
const getFontStyles =
|
|
5
|
+
const getFontStyles = mdColors => {
|
|
5
6
|
return StyleSheet.create({
|
|
6
7
|
regular: {
|
|
7
8
|
fontSize: 16,
|
|
8
9
|
lineHeight: 24,
|
|
9
|
-
color:
|
|
10
|
+
color: mdColors.text
|
|
10
11
|
},
|
|
11
12
|
heading: {
|
|
12
13
|
fontWeight: '500',
|
|
13
|
-
color:
|
|
14
|
+
color: mdColors.text
|
|
14
15
|
}
|
|
15
16
|
});
|
|
16
17
|
};
|
|
17
18
|
|
|
18
|
-
const getStyles = (userStyles, colorScheme) => {
|
|
19
|
-
const
|
|
20
|
-
|
|
19
|
+
const getStyles = (userStyles, colorScheme, userTheme) => {
|
|
20
|
+
const mdColors = { ...colors[colorScheme || 'light'],
|
|
21
|
+
...(userTheme === null || userTheme === void 0 ? void 0 : userTheme.colors)
|
|
22
|
+
};
|
|
23
|
+
const mdSpacing = { ...spacing,
|
|
24
|
+
...(userTheme === null || userTheme === void 0 ? void 0 : userTheme.spacing)
|
|
25
|
+
};
|
|
26
|
+
const fontStyle = getFontStyles(mdColors);
|
|
21
27
|
const defaultStyles = StyleSheet.create({
|
|
22
28
|
container: {
|
|
23
|
-
backgroundColor:
|
|
29
|
+
backgroundColor: mdColors.background
|
|
24
30
|
},
|
|
25
31
|
em: { ...fontStyle.regular,
|
|
26
32
|
fontStyle: 'italic'
|
|
@@ -35,69 +41,69 @@ const getStyles = (userStyles, colorScheme) => {
|
|
|
35
41
|
text: { ...fontStyle.regular
|
|
36
42
|
},
|
|
37
43
|
paragraph: { ...fontStyle.regular,
|
|
38
|
-
paddingVertical:
|
|
44
|
+
paddingVertical: mdSpacing.m
|
|
39
45
|
},
|
|
40
46
|
link: { ...fontStyle.regular,
|
|
41
47
|
fontStyle: 'italic',
|
|
42
|
-
color:
|
|
48
|
+
color: mdColors.link
|
|
43
49
|
},
|
|
44
50
|
blockquote: {
|
|
45
|
-
borderLeftColor:
|
|
46
|
-
paddingLeft:
|
|
47
|
-
borderLeftWidth:
|
|
51
|
+
borderLeftColor: mdColors.border,
|
|
52
|
+
paddingLeft: mdSpacing.l,
|
|
53
|
+
borderLeftWidth: mdSpacing.s,
|
|
48
54
|
opacity: 0.8
|
|
49
55
|
},
|
|
50
56
|
h1: {
|
|
51
57
|
fontSize: 32,
|
|
52
58
|
lineHeight: 40,
|
|
53
59
|
fontWeight: 'bold',
|
|
54
|
-
marginVertical:
|
|
60
|
+
marginVertical: mdSpacing.m,
|
|
55
61
|
letterSpacing: 0,
|
|
56
|
-
paddingBottom:
|
|
57
|
-
borderBottomColor:
|
|
62
|
+
paddingBottom: mdSpacing.s,
|
|
63
|
+
borderBottomColor: mdColors.border,
|
|
58
64
|
borderBottomWidth: 1
|
|
59
65
|
},
|
|
60
66
|
h2: { ...fontStyle.heading,
|
|
61
67
|
fontSize: 28,
|
|
62
68
|
lineHeight: 36,
|
|
63
|
-
marginVertical:
|
|
64
|
-
paddingBottom:
|
|
65
|
-
borderBottomColor:
|
|
69
|
+
marginVertical: mdSpacing.m,
|
|
70
|
+
paddingBottom: mdSpacing.s,
|
|
71
|
+
borderBottomColor: mdColors.border,
|
|
66
72
|
borderBottomWidth: 1
|
|
67
73
|
},
|
|
68
74
|
h3: { ...fontStyle.heading,
|
|
69
75
|
fontSize: 24,
|
|
70
76
|
lineHeight: 32,
|
|
71
|
-
marginVertical:
|
|
77
|
+
marginVertical: mdSpacing.s
|
|
72
78
|
},
|
|
73
79
|
h4: { ...fontStyle.heading,
|
|
74
80
|
fontSize: 22,
|
|
75
81
|
lineHeight: 28,
|
|
76
|
-
marginVertical:
|
|
82
|
+
marginVertical: mdSpacing.s
|
|
77
83
|
},
|
|
78
84
|
h5: { ...fontStyle.regular,
|
|
79
85
|
...fontStyle.heading,
|
|
80
|
-
marginVertical:
|
|
86
|
+
marginVertical: mdSpacing.xs
|
|
81
87
|
},
|
|
82
88
|
h6: { ...fontStyle.heading,
|
|
83
89
|
fontSize: 14,
|
|
84
90
|
lineHeight: 20,
|
|
85
|
-
marginVertical:
|
|
91
|
+
marginVertical: mdSpacing.xs
|
|
86
92
|
},
|
|
87
93
|
codespan: { ...fontStyle.regular,
|
|
88
94
|
fontStyle: 'italic',
|
|
89
|
-
backgroundColor:
|
|
95
|
+
backgroundColor: mdColors.code,
|
|
90
96
|
fontWeight: '300'
|
|
91
97
|
},
|
|
92
98
|
code: {
|
|
93
|
-
padding:
|
|
94
|
-
backgroundColor:
|
|
99
|
+
padding: mdSpacing.l,
|
|
100
|
+
backgroundColor: mdColors.code,
|
|
95
101
|
minWidth: '100%'
|
|
96
102
|
},
|
|
97
103
|
hr: {
|
|
98
104
|
borderBottomWidth: 1,
|
|
99
|
-
borderBottomColor:
|
|
100
|
-
marginVertical:
|
|
105
|
+
borderBottomColor: mdColors.border,
|
|
106
|
+
marginVertical: mdSpacing.s
|
|
101
107
|
},
|
|
102
108
|
li: { ...fontStyle.regular,
|
|
103
109
|
flexShrink: 1
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["StyleSheet","
|
|
1
|
+
{"version":3,"names":["StyleSheet","spacing","colors","getFontStyles","mdColors","create","regular","fontSize","lineHeight","color","text","heading","fontWeight","getStyles","userStyles","colorScheme","userTheme","mdSpacing","fontStyle","defaultStyles","container","backgroundColor","background","em","strong","strikethrough","textDecorationLine","textDecorationStyle","paragraph","paddingVertical","m","link","blockquote","borderLeftColor","border","paddingLeft","l","borderLeftWidth","s","opacity","h1","marginVertical","letterSpacing","paddingBottom","borderBottomColor","borderBottomWidth","h2","h3","h4","h5","xs","h6","codespan","code","padding","minWidth","hr","li","flexShrink","image","resizeMode"],"sourceRoot":"../../src","sources":["styles.ts"],"mappings":"AAAA,SAA0BA,UAA1B,QAA4C,cAA5C;AACA,OAAOC,OAAP,MAAoB,WAApB;AACA,OAAOC,MAAP,MAA4C,UAA5C;;AAGA,MAAMC,aAAa,GAAIC,QAAD,IAA8B;EAClD,OAAOJ,UAAU,CAACK,MAAX,CAAkB;IACvBC,OAAO,EAAE;MACPC,QAAQ,EAAE,EADH;MAEPC,UAAU,EAAE,EAFL;MAGPC,KAAK,EAAEL,QAAQ,CAACM;IAHT,CADc;IAMvBC,OAAO,EAAE;MACPC,UAAU,EAAE,KADL;MAEPH,KAAK,EAAEL,QAAQ,CAACM;IAFT;EANc,CAAlB,CAAP;AAWD,CAZD;;AAcA,MAAMG,SAAS,GA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AAS,EAAE,QAFH;MAGRG,eAAe,EAAEjB,QAAQ,CAACiD,IAHlB;MAIRzC,UAAU,EAAE;IAJJ,CA7E0C;IAmFpDyC,IAAI,EAAE;MACJC,OAAO,EAAErC,SAAS,CAACmB,CADf;MAEJf,eAAe,EAAEjB,QAAQ,CAACiD,IAFtB;MAGJE,QAAQ,EAAE;IAHN,CAnF8C;IAwFpDC,EAAE,EAAE;MACFX,iBAAiB,EAAE,CADjB;MAEFD,iBAAiB,EAAExC,QAAQ,CAAC8B,MAF1B;MAGFO,cAAc,EAAExB,SAAS,CAACqB;IAHxB,CAxFgD;IA6FpDmB,EAAE,EAAE,EACF,GAAGvC,SAAS,CAACZ,OADX;MAEFoD,UAAU,EAAE;IAFV,CA7FgD;IAiGpDC,KAAK,EAAE;MACLC,UAAU,EAAE;IADP;EAjG6C,CAAhC,CAAtB;EAsGA,OAAO,EACL,GAAGzC,aADE;IAEL,GAAGL;EAFE,CAAP;AAID,CAnHD;;AAqHA,eAAeD,SAAf"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { MarkdownProps } from './types';
|
|
3
|
-
declare const _default: React.MemoExoticComponent<({ value, flatListProps, styles: userStyles, }: MarkdownProps) => JSX.Element>;
|
|
3
|
+
declare const _default: React.MemoExoticComponent<({ value, flatListProps, theme, styles: userStyles, }: MarkdownProps) => JSX.Element>;
|
|
4
4
|
export default _default;
|
|
5
5
|
//# sourceMappingURL=Markdown.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Markdown.d.ts","sourceRoot":"","sources":["../../../src/lib/Markdown.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAgD,MAAM,OAAO,CAAC;AAKrE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;;
|
|
1
|
+
{"version":3,"file":"Markdown.d.ts","sourceRoot":"","sources":["../../../src/lib/Markdown.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAgD,MAAM,OAAO,CAAC;AAKrE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;;AAiD7C,wBAA8B"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
2
|
import type { FlatListProps } from 'react-native';
|
|
3
|
-
import type { MarkedStyles } from './../theme/types';
|
|
3
|
+
import type { MarkedStyles, UserTheme } from './../theme/types';
|
|
4
4
|
export interface ParserOptions {
|
|
5
5
|
styles?: MarkedStyles;
|
|
6
6
|
}
|
|
@@ -8,5 +8,6 @@ export interface MarkdownProps {
|
|
|
8
8
|
value: string;
|
|
9
9
|
flatListProps?: Omit<FlatListProps<ReactNode>, 'data' | 'renderItem' | 'horizontal'>;
|
|
10
10
|
styles?: MarkedStyles;
|
|
11
|
+
theme?: UserTheme;
|
|
11
12
|
}
|
|
12
13
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/lib/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/lib/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAEhE,MAAM,WAAW,aAAa;IAC5B,MAAM,CAAC,EAAE,YAAY,CAAC;CACvB;AAED,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,CAAC,EAAE,IAAI,CAClB,aAAa,CAAC,SAAS,CAAC,EACxB,MAAM,GAAG,YAAY,GAAG,YAAY,CACrC,CAAC;IACF,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
declare
|
|
1
|
+
export declare type ColorKeysType = 'background' | 'code' | 'link' | 'text' | 'border';
|
|
2
|
+
export declare type ColorsPropType = Record<ColorKeysType, string>;
|
|
3
|
+
declare const colors: Record<'light' | 'dark', ColorsPropType>;
|
|
3
4
|
export default colors;
|
|
4
5
|
//# sourceMappingURL=colors.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"colors.d.ts","sourceRoot":"","sources":["../../../src/theme/colors.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"colors.d.ts","sourceRoot":"","sources":["../../../src/theme/colors.ts"],"names":[],"mappings":"AAAA,oBAAY,aAAa,GAAG,YAAY,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,QAAQ,CAAC;AAC/E,oBAAY,cAAc,GAAG,MAAM,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC;AAE3D,QAAA,MAAM,MAAM,EAAE,MAAM,CAAC,OAAO,GAAG,MAAM,EAAE,cAAc,CAepD,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spacing.d.ts","sourceRoot":"","sources":["../../../src/theme/spacing.ts"],"names":[],"mappings":"AAAA,oBAAY,eAAe,GAAG,IAAI,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC;AAErD,QAAA,MAAM,OAAO,EAAE,MAAM,CAAC,eAAe,EAAE,MAAM,CAK5C,CAAC;AAEF,eAAe,OAAO,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ColorSchemeName } from 'react-native';
|
|
2
|
-
import type { MarkedStyles } from './types';
|
|
3
|
-
declare const getStyles: (userStyles?: MarkedStyles, colorScheme?: ColorSchemeName) => MarkedStyles;
|
|
2
|
+
import type { MarkedStyles, UserTheme } from './types';
|
|
3
|
+
declare const getStyles: (userStyles?: MarkedStyles, colorScheme?: ColorSchemeName, userTheme?: UserTheme) => MarkedStyles;
|
|
4
4
|
export default getStyles;
|
|
5
5
|
//# sourceMappingURL=styles.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../src/theme/styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAc,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../src/theme/styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAc,MAAM,cAAc,CAAC;AAG3D,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAgBvD,QAAA,MAAM,SAAS,gBACA,YAAY,gBACX,eAAe,cACjB,SAAS,KACpB,YA+GF,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { ImageStyle, TextStyle, ViewStyle } from 'react-native';
|
|
2
|
+
import type { ColorKeysType } from './colors';
|
|
3
|
+
import type { SpacingKeysType } from './spacing';
|
|
2
4
|
export interface MarkedStyles {
|
|
3
5
|
container?: ViewStyle;
|
|
4
6
|
em?: TextStyle;
|
|
@@ -21,8 +23,8 @@ export interface MarkedStyles {
|
|
|
21
23
|
li?: TextStyle;
|
|
22
24
|
image?: ImageStyle;
|
|
23
25
|
}
|
|
24
|
-
export
|
|
25
|
-
|
|
26
|
-
|
|
26
|
+
export interface UserTheme {
|
|
27
|
+
colors?: Record<ColorKeysType, string>;
|
|
28
|
+
spacing?: Record<SpacingKeysType, number>;
|
|
27
29
|
}
|
|
28
30
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/theme/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/theme/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACrE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAEjD,MAAM,WAAW,YAAY;IAC3B,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,EAAE,CAAC,EAAE,SAAS,CAAC;IACf,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,aAAa,CAAC,EAAE,SAAS,CAAC;IAC1B,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,UAAU,CAAC,EAAE,SAAS,CAAC;IACvB,EAAE,CAAC,EAAE,SAAS,CAAC;IACf,EAAE,CAAC,EAAE,SAAS,CAAC;IACf,EAAE,CAAC,EAAE,SAAS,CAAC;IACf,EAAE,CAAC,EAAE,SAAS,CAAC;IACf,EAAE,CAAC,EAAE,SAAS,CAAC;IACf,EAAE,CAAC,EAAE,SAAS,CAAC;IACf,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,EAAE,CAAC,EAAE,SAAS,CAAC;IACf,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,EAAE,CAAC,EAAE,SAAS,CAAC;IACf,KAAK,CAAC,EAAE,UAAU,CAAC;CACpB;AAED,MAAM,WAAW,SAAS;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC;IACvC,OAAO,CAAC,EAAE,MAAM,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC;CAC3C"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-marked",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "Markdown renderer for React Native powered by marked.js",
|
|
5
5
|
"main": "dist/commonjs/index",
|
|
6
6
|
"module": "dist/module/index",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"@evilmartians/lefthook": "1.1.3",
|
|
54
54
|
"@react-native-community/eslint-config": "3.1.0",
|
|
55
55
|
"@release-it/conventional-changelog": "5.1.1",
|
|
56
|
-
"@testing-library/jest-native": "5.1.
|
|
56
|
+
"@testing-library/jest-native": "5.1.2",
|
|
57
57
|
"@testing-library/react-native": "11.3.0",
|
|
58
58
|
"@types/jest": "29.2.0",
|
|
59
59
|
"@types/marked": "4.0.7",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"@typescript-eslint/eslint-plugin": "5.40.1",
|
|
63
63
|
"@typescript-eslint/parser": "5.40.1",
|
|
64
64
|
"commitlint": "17.1.2",
|
|
65
|
-
"eslint": "8.
|
|
65
|
+
"eslint": "8.26.0",
|
|
66
66
|
"eslint-config-prettier": "8.5.0",
|
|
67
67
|
"eslint-plugin-jest": "27.1.3",
|
|
68
68
|
"eslint-plugin-prettier": "4.2.1",
|
package/src/lib/Markdown.tsx
CHANGED
|
@@ -8,12 +8,13 @@ import type { MarkdownProps } from './types';
|
|
|
8
8
|
const Markdown = ({
|
|
9
9
|
value,
|
|
10
10
|
flatListProps,
|
|
11
|
+
theme,
|
|
11
12
|
styles: userStyles,
|
|
12
13
|
}: MarkdownProps) => {
|
|
13
|
-
const
|
|
14
|
+
const colorScheme = useColorScheme();
|
|
14
15
|
const styles = useMemo(
|
|
15
|
-
() => getStyles(userStyles,
|
|
16
|
-
[userStyles,
|
|
16
|
+
() => getStyles(userStyles, colorScheme, theme),
|
|
17
|
+
[userStyles, colorScheme, theme]
|
|
17
18
|
);
|
|
18
19
|
|
|
19
20
|
const rnElements = useMemo(() => {
|
package/src/lib/types.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
2
|
import type { FlatListProps } from 'react-native';
|
|
3
|
-
import type { MarkedStyles } from './../theme/types';
|
|
3
|
+
import type { MarkedStyles, UserTheme } from './../theme/types';
|
|
4
4
|
|
|
5
5
|
export interface ParserOptions {
|
|
6
6
|
styles?: MarkedStyles;
|
|
@@ -13,4 +13,5 @@ export interface MarkdownProps {
|
|
|
13
13
|
'data' | 'renderItem' | 'horizontal'
|
|
14
14
|
>;
|
|
15
15
|
styles?: MarkedStyles;
|
|
16
|
+
theme?: UserTheme;
|
|
16
17
|
}
|
package/src/theme/colors.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
export type ColorKeysType = 'background' | 'code' | 'link' | 'text' | 'border';
|
|
2
|
+
export type ColorsPropType = Record<ColorKeysType, string>;
|
|
2
3
|
|
|
3
|
-
const colors: Record<'light' | 'dark',
|
|
4
|
+
const colors: Record<'light' | 'dark', ColorsPropType> = {
|
|
4
5
|
light: {
|
|
5
6
|
background: '#ffffff',
|
|
6
7
|
code: '#f6f8fa',
|
package/src/theme/styles.ts
CHANGED
|
@@ -1,30 +1,34 @@
|
|
|
1
1
|
import { ColorSchemeName, StyleSheet } from 'react-native';
|
|
2
|
-
import
|
|
3
|
-
import
|
|
2
|
+
import spacing from './spacing';
|
|
3
|
+
import colors, { type ColorsPropType } from './colors';
|
|
4
|
+
import type { MarkedStyles, UserTheme } from './types';
|
|
4
5
|
|
|
5
|
-
const getFontStyles = (
|
|
6
|
+
const getFontStyles = (mdColors: ColorsPropType) => {
|
|
6
7
|
return StyleSheet.create({
|
|
7
8
|
regular: {
|
|
8
9
|
fontSize: 16,
|
|
9
10
|
lineHeight: 24,
|
|
10
|
-
color:
|
|
11
|
+
color: mdColors.text,
|
|
11
12
|
},
|
|
12
13
|
heading: {
|
|
13
14
|
fontWeight: '500',
|
|
14
|
-
color:
|
|
15
|
+
color: mdColors.text,
|
|
15
16
|
},
|
|
16
17
|
});
|
|
17
18
|
};
|
|
18
19
|
|
|
19
20
|
const getStyles = (
|
|
20
21
|
userStyles?: MarkedStyles,
|
|
21
|
-
colorScheme?: ColorSchemeName
|
|
22
|
+
colorScheme?: ColorSchemeName,
|
|
23
|
+
userTheme?: UserTheme
|
|
22
24
|
): MarkedStyles => {
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
+
const mdColors = { ...colors[colorScheme || 'light'], ...userTheme?.colors };
|
|
26
|
+
const mdSpacing = { ...spacing, ...userTheme?.spacing };
|
|
27
|
+
|
|
28
|
+
const fontStyle = getFontStyles(mdColors);
|
|
25
29
|
const defaultStyles = StyleSheet.create<MarkedStyles>({
|
|
26
30
|
container: {
|
|
27
|
-
backgroundColor:
|
|
31
|
+
backgroundColor: mdColors.background,
|
|
28
32
|
},
|
|
29
33
|
em: {
|
|
30
34
|
...fontStyle.regular,
|
|
@@ -44,76 +48,76 @@ const getStyles = (
|
|
|
44
48
|
},
|
|
45
49
|
paragraph: {
|
|
46
50
|
...fontStyle.regular,
|
|
47
|
-
paddingVertical:
|
|
51
|
+
paddingVertical: mdSpacing.m,
|
|
48
52
|
},
|
|
49
53
|
link: {
|
|
50
54
|
...fontStyle.regular,
|
|
51
55
|
fontStyle: 'italic',
|
|
52
|
-
color:
|
|
56
|
+
color: mdColors.link,
|
|
53
57
|
},
|
|
54
58
|
blockquote: {
|
|
55
|
-
borderLeftColor:
|
|
56
|
-
paddingLeft:
|
|
57
|
-
borderLeftWidth:
|
|
59
|
+
borderLeftColor: mdColors.border,
|
|
60
|
+
paddingLeft: mdSpacing.l,
|
|
61
|
+
borderLeftWidth: mdSpacing.s,
|
|
58
62
|
opacity: 0.8,
|
|
59
63
|
},
|
|
60
64
|
h1: {
|
|
61
65
|
fontSize: 32,
|
|
62
66
|
lineHeight: 40,
|
|
63
67
|
fontWeight: 'bold',
|
|
64
|
-
marginVertical:
|
|
68
|
+
marginVertical: mdSpacing.m,
|
|
65
69
|
letterSpacing: 0,
|
|
66
|
-
paddingBottom:
|
|
67
|
-
borderBottomColor:
|
|
70
|
+
paddingBottom: mdSpacing.s,
|
|
71
|
+
borderBottomColor: mdColors.border,
|
|
68
72
|
borderBottomWidth: 1,
|
|
69
73
|
},
|
|
70
74
|
h2: {
|
|
71
75
|
...fontStyle.heading,
|
|
72
76
|
fontSize: 28,
|
|
73
77
|
lineHeight: 36,
|
|
74
|
-
marginVertical:
|
|
75
|
-
paddingBottom:
|
|
76
|
-
borderBottomColor:
|
|
78
|
+
marginVertical: mdSpacing.m,
|
|
79
|
+
paddingBottom: mdSpacing.s,
|
|
80
|
+
borderBottomColor: mdColors.border,
|
|
77
81
|
borderBottomWidth: 1,
|
|
78
82
|
},
|
|
79
83
|
h3: {
|
|
80
84
|
...fontStyle.heading,
|
|
81
85
|
fontSize: 24,
|
|
82
86
|
lineHeight: 32,
|
|
83
|
-
marginVertical:
|
|
87
|
+
marginVertical: mdSpacing.s,
|
|
84
88
|
},
|
|
85
89
|
h4: {
|
|
86
90
|
...fontStyle.heading,
|
|
87
91
|
fontSize: 22,
|
|
88
92
|
lineHeight: 28,
|
|
89
|
-
marginVertical:
|
|
93
|
+
marginVertical: mdSpacing.s,
|
|
90
94
|
},
|
|
91
95
|
h5: {
|
|
92
96
|
...fontStyle.regular,
|
|
93
97
|
...fontStyle.heading,
|
|
94
|
-
marginVertical:
|
|
98
|
+
marginVertical: mdSpacing.xs,
|
|
95
99
|
},
|
|
96
100
|
h6: {
|
|
97
101
|
...fontStyle.heading,
|
|
98
102
|
fontSize: 14,
|
|
99
103
|
lineHeight: 20,
|
|
100
|
-
marginVertical:
|
|
104
|
+
marginVertical: mdSpacing.xs,
|
|
101
105
|
},
|
|
102
106
|
codespan: {
|
|
103
107
|
...fontStyle.regular,
|
|
104
108
|
fontStyle: 'italic',
|
|
105
|
-
backgroundColor:
|
|
109
|
+
backgroundColor: mdColors.code,
|
|
106
110
|
fontWeight: '300',
|
|
107
111
|
},
|
|
108
112
|
code: {
|
|
109
|
-
padding:
|
|
110
|
-
backgroundColor:
|
|
113
|
+
padding: mdSpacing.l,
|
|
114
|
+
backgroundColor: mdColors.code,
|
|
111
115
|
minWidth: '100%',
|
|
112
116
|
},
|
|
113
117
|
hr: {
|
|
114
118
|
borderBottomWidth: 1,
|
|
115
|
-
borderBottomColor:
|
|
116
|
-
marginVertical:
|
|
119
|
+
borderBottomColor: mdColors.border,
|
|
120
|
+
marginVertical: mdSpacing.s,
|
|
117
121
|
},
|
|
118
122
|
li: {
|
|
119
123
|
...fontStyle.regular,
|
package/src/theme/types.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { ImageStyle, TextStyle, ViewStyle } from 'react-native';
|
|
2
|
+
import type { ColorKeysType } from './colors';
|
|
3
|
+
import type { SpacingKeysType } from './spacing';
|
|
2
4
|
|
|
3
5
|
export interface MarkedStyles {
|
|
4
6
|
container?: ViewStyle;
|
|
@@ -23,8 +25,7 @@ export interface MarkedStyles {
|
|
|
23
25
|
image?: ImageStyle;
|
|
24
26
|
}
|
|
25
27
|
|
|
26
|
-
export
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
colors: Record<ColorKeys, string>;
|
|
28
|
+
export interface UserTheme {
|
|
29
|
+
colors?: Record<ColorKeysType, string>;
|
|
30
|
+
spacing?: Record<SpacingKeysType, number>;
|
|
30
31
|
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getTheme = void 0;
|
|
7
|
-
|
|
8
|
-
var _colors = _interopRequireDefault(require("./colors"));
|
|
9
|
-
|
|
10
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
|
|
12
|
-
const getTheme = theme => {
|
|
13
|
-
return {
|
|
14
|
-
colors: _colors.default[theme || 'light']
|
|
15
|
-
};
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
exports.getTheme = getTheme;
|
|
19
|
-
//# sourceMappingURL=theme.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["getTheme","theme","colors"],"sourceRoot":"../../src","sources":["theme.ts"],"mappings":";;;;;;;AACA;;;;AAGO,MAAMA,QAAQ,GAAIC,KAAD,IAAmC;EACzD,OAAO;IACLC,MAAM,EAAEA,eAAA,CAAOD,KAAK,IAAI,OAAhB;EADH,CAAP;AAGD,CAJM"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["colors","getTheme","theme"],"sourceRoot":"../../src","sources":["theme.ts"],"mappings":"AACA,OAAOA,MAAP,MAAmB,UAAnB;AAGA,OAAO,MAAMC,QAAQ,GAAIC,KAAD,IAAmC;EACzD,OAAO;IACLF,MAAM,EAAEA,MAAM,CAACE,KAAK,IAAI,OAAV;EADT,CAAP;AAGD,CAJM"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../../src/theme/theme.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAEpD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAErC,eAAO,MAAM,QAAQ,UAAW,eAAe,KAAG,KAIjD,CAAC"}
|
package/src/theme/theme.ts
DELETED