Skip to content

Commit 910bf0c

Browse files
author
Kylie Stewart
authored
Allow for dynamically updated fontSizes in CodePane (#875)
* Look for props first, then use theme * Changelog++
1 parent ecd313b commit 910bf0c

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## Unreleased
44

5+
- Allow for `props.fontSize` to override the theme's monospace font size in `CodePane`. [#875](https://github.com/FormidableLabs/spectacle/pull/875)
56
- Surface `textDecoration` prop from styled-system for `Link`s. [#869](https://github.com/FormidableLabs/spectacle/pull/869)
67

78
## 6.0.1

src/components/code-pane.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,20 @@ export default function CodePane(props) {
3939
}, [themeContext]);
4040

4141
const fontSize = React.useMemo(() => {
42+
if (props && props.fontSize) {
43+
return props.fontSize;
44+
}
45+
4246
if (
4347
themeContext &&
4448
themeContext.fontSizes &&
4549
themeContext.fontSizes.monospace
4650
) {
4751
return themeContext.fontSizes.monospace;
4852
}
49-
return props.fontSize;
53+
54+
// Default to 15px
55+
return 15;
5056
}, [themeContext, props.fontSize]);
5157

5258
const preStyles = React.useMemo(
@@ -159,7 +165,6 @@ CodePane.propTypes = {
159165
CodePane.defaultProps = {
160166
language: 'javascript',
161167
theme: theme,
162-
fontSize: 15,
163168
highlightStart: -Infinity,
164169
highlightEnd: Infinity
165170
};

0 commit comments

Comments
 (0)