Skip to content

Commit

Permalink
fix: tagged ode typescript fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
atanasster committed Feb 27, 2020
1 parent 7dfe0ca commit a83bab3
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions blocks/core/src/StorySource/TaggedSource.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,14 @@ export const TaggedSource: React.FC<TaggedSourceProps> = ({
: undefined;
if (tags) {
tags.forEach((tag, index) => {
const colorIdx = index % (theme.styles.length - 1);
const style = theme.styles[colorIdx];
const color: string = style.style.color || theme.plain.color || '#fff';
let color: string;
if (theme) {
const colorIdx = index % (theme.styles.length - 1);
const style = theme.styles[colorIdx];
color = style.style.color || theme.plain.color || '#fff';
} else {
color = '#333';
}
tag.color = color;
});
}
Expand All @@ -63,7 +68,7 @@ export const TaggedSource: React.FC<TaggedSourceProps> = ({
className={`${className}`}
style={{ ...style, padding: '10px 10px 25px 10px', margin: 0 }}
>
{tokens.map((line, i) => (
{tokens.map((line: { content: string }[], i: number) => (
<div {...getLineProps({ line, key: i })}>
{(() => {
let column = 0;
Expand All @@ -84,7 +89,7 @@ export const TaggedSource: React.FC<TaggedSourceProps> = ({
: null;
column += token.content.length;
if (param) {
const splitToken = getTokenProps({
const splitToken: string[] = getTokenProps({
token,
key,
}).children.split(/(\s+)/);
Expand Down

0 comments on commit a83bab3

Please sign in to comment.