Skip to content

Commit

Permalink
type(theme): fix type error. (#444)
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Jan 17, 2023
1 parent 6048cd0 commit b51a9a6
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions themes/theme/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ type Theme = 'light' | 'dark';

export interface Settings {
/** Editor background. */
background: string;
background?: string;
/** Default text color. */
foreground: string;
foreground?: string;
/** Caret color. */
caret?: string;
/** Selection background. */
Expand All @@ -43,14 +43,20 @@ export interface Settings {
fontFamily?: string;
}

export const createTheme = ({ theme, settings, styles }: CreateThemeOptions): Extension => {
export const createTheme = ({ theme, settings = {}, styles = [] }: CreateThemeOptions): Extension => {
const themeOptions: Record<string, StyleSpec> = {
'&': {
backgroundColor: settings.background,
color: settings.foreground,
},
'.cm-gutters': {},
};
const baseStyle: StyleSpec = {};
if (settings.background) {
baseStyle.backgroundColor = settings.background;
}
if (settings.foreground) {
baseStyle.color = settings.foreground;
}
if (settings.background || settings.foreground) {
themeOptions['&'] = baseStyle;
}

if (settings.fontFamily) {
themeOptions['&.cm-editor .cm-scroller'] = {
Expand Down

0 comments on commit b51a9a6

Please sign in to comment.