Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
node_modules
dist
49 changes: 49 additions & 0 deletions dist/create-theme.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { Extension } from '@codemirror/state';
import { TagStyle } from '@codemirror/language';
interface Options {
/**
* Theme variant. Determines which styles CodeMirror will apply by default.
*/
variant: Variant;
/**
* Settings to customize the look of the editor, like background, gutter, selection and others.
*/
settings: Settings;
/**
* Syntax highlighting styles.
*/
styles: TagStyle[];
}
type Variant = 'light' | 'dark';
interface Settings {
/**
* Editor background.
*/
background: string;
/**
* Default text color.
*/
foreground: string;
/**
* Caret color.
*/
caret: string;
/**
* Selection background.
*/
selection: string;
/**
* Background of highlighted lines.
*/
lineHighlight: string;
/**
* Gutter background.
*/
gutterBackground: string;
/**
* Text color inside gutter.
*/
gutterForeground: string;
}
declare const createTheme: ({ variant, settings, styles }: Options) => Extension;
export default createTheme;
36 changes: 36 additions & 0 deletions dist/create-theme.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { EditorView } from '@codemirror/view';
import { HighlightStyle, syntaxHighlighting, } from '@codemirror/language';
const createTheme = ({ variant, settings, styles }) => {
const theme = EditorView.theme({
// eslint-disable-next-line @typescript-eslint/naming-convention
'&': {
backgroundColor: settings.background,
color: settings.foreground,
},
'.cm-content': {
caretColor: settings.caret,
},
'.cm-cursor, .cm-dropCursor': {
borderLeftColor: settings.caret,
},
'&.cm-focused .cm-selectionBackgroundm .cm-selectionBackground, .cm-content ::selection': {
backgroundColor: settings.selection,
},
'.cm-activeLine': {
backgroundColor: settings.lineHighlight,
},
'.cm-gutters': {
backgroundColor: settings.gutterBackground,
color: settings.gutterForeground,
},
'.cm-activeLineGutter': {
backgroundColor: settings.lineHighlight,
},
}, {
dark: variant === 'dark',
});
const highlightStyle = HighlightStyle.define(styles);
const extension = [theme, syntaxHighlighting(highlightStyle)];
return extension;
};
export default createTheme;
17 changes: 17 additions & 0 deletions dist/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
export { default as createTheme } from './create-theme.js';
export * from './themes/amy.js';
export * from './themes/ayu-light.js';
export * from './themes/barf.js';
export * from './themes/bespin.js';
export * from './themes/birds-of-paradise.js';
export * from './themes/boys-and-girls.js';
export * from './themes/clouds.js';
export * from './themes/cobalt.js';
export * from './themes/cool-glow.js';
export * from './themes/dracula.js';
export * from './themes/espresso.js';
export * from './themes/noctis-lilac.js';
export * from './themes/rose-pine-dawn.js';
export * from './themes/smoothy.js';
export * from './themes/solarized-light.js';
export * from './themes/tomorrow.js';
17 changes: 17 additions & 0 deletions dist/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
export { default as createTheme } from './create-theme.js';
export * from './themes/amy.js';
export * from './themes/ayu-light.js';
export * from './themes/barf.js';
export * from './themes/bespin.js';
export * from './themes/birds-of-paradise.js';
export * from './themes/boys-and-girls.js';
export * from './themes/clouds.js';
export * from './themes/cobalt.js';
export * from './themes/cool-glow.js';
export * from './themes/dracula.js';
export * from './themes/espresso.js';
export * from './themes/noctis-lilac.js';
export * from './themes/rose-pine-dawn.js';
export * from './themes/smoothy.js';
export * from './themes/solarized-light.js';
export * from './themes/tomorrow.js';
1 change: 1 addition & 0 deletions dist/themes/amy.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export declare const amy: import("@codemirror/state").Extension;
85 changes: 85 additions & 0 deletions dist/themes/amy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import { tags as t } from '@lezer/highlight';
import createTheme from '../create-theme.js';
// Author: William D. Neumann
export const amy = createTheme({
variant: 'dark',
settings: {
background: '#200020',
foreground: '#D0D0FF',
caret: '#7070FF',
selection: '#80000080',
gutterBackground: '#200020',
gutterForeground: '#C080C0',
lineHighlight: '#80000040',
},
styles: [
{
tag: t.comment,
color: '#404080',
},
{
tag: [t.string, t.regexp],
color: '#999999',
},
{
tag: t.number,
color: '#7090B0',
},
{
tag: [t.bool, t.null],
color: '#8080A0',
},
{
tag: [t.punctuation, t.derefOperator],
color: '#805080',
},
{
tag: t.keyword,
color: '#60B0FF',
},
{
tag: t.definitionKeyword,
color: '#B0FFF0',
},
{
tag: t.moduleKeyword,
color: '#60B0FF',
},
{
tag: t.operator,
color: '#A0A0FF',
},
{
tag: [t.variableName, t.self],
color: '#008080',
},
{
tag: t.operatorKeyword,
color: '#A0A0FF',
},
{
tag: t.controlKeyword,
color: '#80A0FF',
},
{
tag: t.className,
color: '#70E080',
},
{
tag: [t.function(t.propertyName), t.propertyName],
color: '#50A0A0',
},
{
tag: t.tagName,
color: '#009090',
},
{
tag: t.modifier,
color: '#B0FFF0',
},
{
tag: [t.squareBracket, t.attributeName],
color: '#D0D0FF',
},
],
});
1 change: 1 addition & 0 deletions dist/themes/ayu-light.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export declare const ayuLight: import("@codemirror/state").Extension;
77 changes: 77 additions & 0 deletions dist/themes/ayu-light.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import { tags as t } from '@lezer/highlight';
import createTheme from '../create-theme.js';
// Author: Konstantin Pschera
export const ayuLight = createTheme({
variant: 'light',
settings: {
background: '#fcfcfc',
foreground: '#5c6166',
caret: '#ffaa33',
selection: '#036dd626',
gutterBackground: '#fcfcfc',
gutterForeground: '#8a919966',
lineHighlight: '#8a91991a',
},
styles: [
{
tag: t.comment,
color: '#787b8099',
},
{
tag: t.string,
color: '#86b300',
},
{
tag: t.regexp,
color: '#4cbf99',
},
{
tag: [t.number, t.bool, t.null],
color: '#ffaa33',
},
{
tag: t.variableName,
color: '#5c6166',
},
{
tag: [t.definitionKeyword, t.modifier],
color: '#fa8d3e',
},
{
tag: [t.keyword, t.special(t.brace)],
color: '#fa8d3e',
},
{
tag: t.operator,
color: '#ed9366',
},
{
tag: t.separator,
color: '#5c6166b3',
},
{
tag: t.punctuation,
color: '#5c6166',
},
{
tag: [t.definition(t.propertyName), t.function(t.variableName)],
color: '#f2ae49',
},
{
tag: [t.className, t.definition(t.typeName)],
color: '#22a4e6',
},
{
tag: [t.tagName, t.typeName, t.self, t.labelName],
color: '#55b4d4',
},
{
tag: t.angleBracket,
color: '#55b4d480',
},
{
tag: t.attributeName,
color: '#f2ae49',
},
],
});
1 change: 1 addition & 0 deletions dist/themes/barf.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export declare const barf: import("@codemirror/state").Extension;
59 changes: 59 additions & 0 deletions dist/themes/barf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import { tags as t } from '@lezer/highlight';
import createTheme from '../create-theme.js';
// Author: unknown
export const barf = createTheme({
variant: 'dark',
settings: {
background: '#15191EFA',
foreground: '#EEF2F7',
caret: '#C4C4C4',
selection: '#90B2D557',
gutterBackground: '#15191EFA',
gutterForeground: '#aaaaaa95',
lineHighlight: '#57575712',
},
styles: [
{
tag: t.comment,
color: '#6E6E6E',
},
{
tag: [t.string, t.regexp, t.special(t.brace)],
color: '#5C81B3',
},
{
tag: t.number,
color: '#C1E1B8',
},
{
tag: t.bool,
color: '#53667D',
},
{
tag: [t.definitionKeyword, t.modifier, t.function(t.propertyName)],
color: '#A3D295',
fontWeight: 'bold',
},
{
tag: [t.keyword, t.moduleKeyword, t.operatorKeyword, t.operator],
color: '#697A8E',
fontWeight: 'bold',
},
{
tag: [t.variableName, t.attributeName],
color: '#708E67',
},
{
tag: [
t.function(t.variableName),
t.definition(t.propertyName),
t.derefOperator,
],
color: '#fff',
},
{
tag: t.tagName,
color: '#A3D295',
},
],
});
1 change: 1 addition & 0 deletions dist/themes/bespin.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export declare const bespin: import("@codemirror/state").Extension;
Loading