Files
n8n-enterprise-unlocked/packages/editor-ui/src/components/InlineExpressionEditor/theme.ts
Giulio Andreini 0746783e02 refactor(editor): Color palette updates, introduce dark mode (#6980)
Github issue / Community forum post (link here to close automatically):

---------

Co-authored-by: Mutasem <mutdmour@gmail.com>
2023-11-01 13:33:36 +01:00

70 lines
1.7 KiB
TypeScript

import { EditorView } from '@codemirror/view';
import { highlighter } from '@/plugins/codemirror/resolvableHighlighter';
const commonThemeProps = {
'&.cm-focused': {
outline: '0 !important',
},
'.cm-content': {
fontFamily: 'var(--font-family-monospace)',
color: 'var(--input-font-color, var(--color-text-dark))',
caretColor: 'var(--color-code-caret)',
},
'.cm-line': {
padding: '0',
},
};
export const inputTheme = ({ isSingleLine } = { isSingleLine: false }) => {
const theme = EditorView.theme({
...commonThemeProps,
'&': {
maxHeight: isSingleLine ? '30px' : '112px',
minHeight: '30px',
width: '100%',
fontSize: 'var(--font-size-2xs)',
padding: '0 0 0 var(--spacing-2xs)',
borderWidth: 'var(--border-width-base)',
borderStyle: 'var(--input-border-style, var(--border-style-base))',
borderColor: 'var(--input-border-color, var(--border-color-base))',
borderRadius: 'var(--input-border-radius, var(--border-radius-base))',
borderTopLeftRadius: '0',
borderBottomLeftRadius: '0',
backgroundColor: 'white',
},
'.cm-scroller': {
lineHeight: '1.68',
},
});
return [theme, highlighter.resolvableStyle];
};
export const outputTheme = () => {
const theme = EditorView.theme({
...commonThemeProps,
'&': {
maxHeight: '95px',
width: '100%',
fontSize: 'var(--font-size-2xs)',
padding: '0',
borderTopLeftRadius: '0',
borderBottomLeftRadius: '0',
backgroundColor: 'white',
},
'.cm-scroller': {
lineHeight: '1.6',
},
'.cm-valid-resolvable': {
padding: '0 2px',
borderRadius: '2px',
},
'.cm-invalid-resolvable': {
padding: '0 2px',
borderRadius: '2px',
},
});
return [theme, highlighter.resolvableStyle];
};