@fsegurai/codemirror-theme-nord 6.0.1-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,30 @@
1
+ <!-- NOTE: README.md is generated from src/README.md -->
2
+
3
+ # @fsegurai/codemirror-theme-nord [![NPM version](https://img.shields.io/npm/v/@fsegurai/codemirror-theme-nord.svg)](https://www.npmjs.org/package/@fsegurai/codemirror-theme-nord)
4
+
5
+ [ [**WEBSITE**](https://codemirror.net/6/) | [**ISSUES**](https://github.com/codemirror/codemirror.next/issues) | [*
6
+ *FORUM**](https://discuss.codemirror.net/c/next/) | [**CHANGELOG
7
+ **](https://github.com/codemirror/theme-one-dark/blob/main/CHANGELOG.md) ]
8
+
9
+ This package implements the Nord theme for the
10
+ [CodeMirror](https://codemirror.net/6/) code editor.
11
+
12
+ The [project page](https://codemirror.net/6/) has more information, a
13
+ number of [examples](https://codemirror.net/6/examples/) and the
14
+ [documentation](https://codemirror.net/6/docs/).
15
+
16
+ This code is released under an
17
+ [MIT license](https://github.com/fsegurai/cm6-themes/tree/main/LICENSE).
18
+
19
+ We aim to be an inclusive, welcoming community. To make that explicit,
20
+ we have a [code of
21
+ conduct](http://contributor-covenant.org/version/1/1/0/) that applies
22
+ to communication around the project.
23
+
24
+ ## API Reference
25
+
26
+ @nord
27
+
28
+ @nordTheme
29
+
30
+ @nordHighlightStyle
package/dist/index.cjs ADDED
@@ -0,0 +1,200 @@
1
+ 'use strict';
2
+
3
+ var view = require('@codemirror/view');
4
+ var language = require('@codemirror/language');
5
+ var highlight = require('@lezer/highlight');
6
+
7
+ // Colors from https://www.nordtheme.com/docs/colors-and-palettes
8
+ // Polar Night
9
+ const base00 = '#2e3440', // black
10
+ base01 = '#3b4252', // dark grey
11
+ base02 = '#434c5e', base03 = '#4c566a'; // grey
12
+ // Snow Storm
13
+ const base04 = '#d8dee9', // grey
14
+ base05 = '#e5e9f0', // off white
15
+ base06 = '#eceff4'; // white
16
+ // Frost
17
+ const base07 = '#8fbcbb', // moss green
18
+ base08 = '#88c0d0', // ice blue
19
+ base09 = '#81a1c1', // water blue
20
+ base0A = '#5e81ac'; // deep blue
21
+ // Aurora
22
+ const base0b = '#bf616a', // red
23
+ base0C = '#d08770', // orange
24
+ base0D = '#ebcb8b', // yellow
25
+ base0E = '#a3be8c', // green
26
+ base0F = '#b48ead'; // purple
27
+ const invalid = '#d30102', darkBackground = '#252a33', highlightBackground = base03, background = base00, tooltipBackground = base01, selection = base03, cursor = base04;
28
+ /// The editor theme styles for Nord.
29
+ const nordTheme = view.EditorView.theme({
30
+ '&': {
31
+ color: base04,
32
+ backgroundColor: background
33
+ },
34
+ '.cm-content': {
35
+ caretColor: cursor
36
+ },
37
+ '.cm-cursor, .cm-dropCursor': { borderLeftColor: cursor },
38
+ '&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection': { backgroundColor: selection },
39
+ '.cm-panels': { backgroundColor: darkBackground, color: base03 },
40
+ '.cm-panels.cm-panels-top': { borderBottom: '2px solid black' },
41
+ '.cm-panels.cm-panels-bottom': { borderTop: '2px solid black' },
42
+ '.cm-searchMatch': {
43
+ backgroundColor: 'transparent',
44
+ outline: `1px solid ${base07}`
45
+ },
46
+ '.cm-searchMatch.cm-searchMatch-selected': {
47
+ backgroundColor: base04,
48
+ color: base00
49
+ },
50
+ '.cm-activeLine': { backgroundColor: highlightBackground },
51
+ '.cm-selectionMatch': {
52
+ backgroundColor: base05,
53
+ color: base01
54
+ },
55
+ '&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket': {
56
+ outline: `1px solid ${base07}`
57
+ },
58
+ '&.cm-focused .cm-matchingBracket': {
59
+ backgroundColor: base06,
60
+ color: base02
61
+ },
62
+ '.cm-gutters': {
63
+ backgroundColor: base00,
64
+ color: base03,
65
+ border: 'none'
66
+ },
67
+ '.cm-activeLineGutter': {
68
+ backgroundColor: highlightBackground,
69
+ color: base04
70
+ },
71
+ '.cm-foldPlaceholder': {
72
+ backgroundColor: 'transparent',
73
+ border: 'none',
74
+ color: '#ddd'
75
+ },
76
+ '.cm-tooltip': {
77
+ border: 'none',
78
+ backgroundColor: tooltipBackground
79
+ },
80
+ '.cm-tooltip .cm-tooltip-arrow:before': {
81
+ borderTopColor: 'transparent',
82
+ borderBottomColor: 'transparent'
83
+ },
84
+ '.cm-tooltip .cm-tooltip-arrow:after': {
85
+ borderTopColor: tooltipBackground,
86
+ borderBottomColor: tooltipBackground
87
+ },
88
+ '.cm-tooltip-autocomplete': {
89
+ '& > ul > li[aria-selected]': {
90
+ backgroundColor: highlightBackground,
91
+ color: base03
92
+ }
93
+ }
94
+ }, { dark: true });
95
+ /// The highlighting style for code in the Nord theme.
96
+ const nordHighlightStyle = language.HighlightStyle.define([
97
+ { tag: highlight.tags.keyword, color: base0A },
98
+ {
99
+ tag: [highlight.tags.name, highlight.tags.deleted, highlight.tags.character, highlight.tags.propertyName, highlight.tags.macroName],
100
+ color: base08
101
+ },
102
+ { tag: [highlight.tags.variableName], color: base07 },
103
+ { tag: [highlight.tags.function(highlight.tags.variableName)], color: base07 },
104
+ { tag: [highlight.tags.labelName], color: base09 },
105
+ {
106
+ tag: [highlight.tags.color, highlight.tags.constant(highlight.tags.name), highlight.tags.standard(highlight.tags.name)],
107
+ color: base0A
108
+ },
109
+ { tag: [highlight.tags.definition(highlight.tags.name), highlight.tags.separator], color: base0E },
110
+ { tag: [highlight.tags.brace], color: base07 },
111
+ {
112
+ tag: [highlight.tags.annotation],
113
+ color: invalid
114
+ },
115
+ {
116
+ tag: [highlight.tags.number, highlight.tags.changed, highlight.tags.annotation, highlight.tags.modifier, highlight.tags.self, highlight.tags.namespace],
117
+ color: base0F
118
+ },
119
+ {
120
+ tag: [highlight.tags.typeName, highlight.tags.className],
121
+ color: base0D
122
+ },
123
+ {
124
+ tag: [highlight.tags.operator, highlight.tags.operatorKeyword],
125
+ color: base0E
126
+ },
127
+ {
128
+ tag: [highlight.tags.tagName],
129
+ color: base0F
130
+ },
131
+ {
132
+ tag: [highlight.tags.squareBracket],
133
+ color: base0b
134
+ },
135
+ {
136
+ tag: [highlight.tags.angleBracket],
137
+ color: base0C
138
+ },
139
+ {
140
+ tag: [highlight.tags.attributeName],
141
+ color: base0D
142
+ },
143
+ {
144
+ tag: [highlight.tags.regexp],
145
+ color: base0A
146
+ },
147
+ {
148
+ tag: [highlight.tags.quote],
149
+ color: base0F
150
+ },
151
+ { tag: [highlight.tags.string], color: base0E },
152
+ {
153
+ tag: highlight.tags.link,
154
+ color: base0E,
155
+ textDecoration: 'underline',
156
+ textUnderlinePosition: 'under'
157
+ },
158
+ {
159
+ tag: [highlight.tags.url, highlight.tags.escape, highlight.tags.special(highlight.tags.string)],
160
+ color: base07
161
+ },
162
+ { tag: [highlight.tags.meta], color: base08 },
163
+ { tag: [highlight.tags.monospace], color: base04, fontStyle: 'italic' },
164
+ { tag: [highlight.tags.comment], color: base03, fontStyle: 'italic' },
165
+ { tag: highlight.tags.strong, fontWeight: 'bold', color: base0A },
166
+ { tag: highlight.tags.emphasis, fontStyle: 'italic', color: base0A },
167
+ { tag: highlight.tags.strikethrough, textDecoration: 'line-through' },
168
+ { tag: highlight.tags.heading, fontWeight: 'bold', color: base0A },
169
+ { tag: highlight.tags.special(highlight.tags.heading1), fontWeight: 'bold', color: base0A },
170
+ { tag: highlight.tags.heading1, fontWeight: 'bold', color: base0A },
171
+ {
172
+ tag: [highlight.tags.heading2, highlight.tags.heading3, highlight.tags.heading4],
173
+ fontWeight: 'bold',
174
+ color: base0A
175
+ },
176
+ {
177
+ tag: [highlight.tags.heading5, highlight.tags.heading6],
178
+ color: base0A
179
+ },
180
+ { tag: [highlight.tags.atom, highlight.tags.bool, highlight.tags.special(highlight.tags.variableName)], color: base0C },
181
+ {
182
+ tag: [highlight.tags.processingInstruction, highlight.tags.inserted],
183
+ color: base07
184
+ },
185
+ {
186
+ tag: [highlight.tags.contentSeparator],
187
+ color: base0D
188
+ },
189
+ { tag: highlight.tags.invalid, color: base02, borderBottom: `1px dotted ${invalid}` }
190
+ ]);
191
+ /// Extension to enable the Nord theme (both the editor theme and
192
+ /// the highlight style).
193
+ const nord = [
194
+ nordTheme,
195
+ language.syntaxHighlighting(nordHighlightStyle)
196
+ ];
197
+
198
+ exports.nord = nord;
199
+ exports.nordHighlightStyle = nordHighlightStyle;
200
+ exports.nordTheme = nordTheme;
@@ -0,0 +1,8 @@
1
+ import { Extension } from '@codemirror/state';
2
+ import { HighlightStyle } from '@codemirror/language';
3
+
4
+ declare const nordTheme: Extension;
5
+ declare const nordHighlightStyle: HighlightStyle;
6
+ declare const nord: Extension;
7
+
8
+ export { nord, nordHighlightStyle, nordTheme };
@@ -0,0 +1,8 @@
1
+ import { Extension } from '@codemirror/state';
2
+ import { HighlightStyle } from '@codemirror/language';
3
+
4
+ declare const nordTheme: Extension;
5
+ declare const nordHighlightStyle: HighlightStyle;
6
+ declare const nord: Extension;
7
+
8
+ export { nord, nordHighlightStyle, nordTheme };
package/dist/index.js ADDED
@@ -0,0 +1,196 @@
1
+ import { EditorView } from '@codemirror/view';
2
+ import { HighlightStyle, syntaxHighlighting } from '@codemirror/language';
3
+ import { tags } from '@lezer/highlight';
4
+
5
+ // Colors from https://www.nordtheme.com/docs/colors-and-palettes
6
+ // Polar Night
7
+ const base00 = '#2e3440', // black
8
+ base01 = '#3b4252', // dark grey
9
+ base02 = '#434c5e', base03 = '#4c566a'; // grey
10
+ // Snow Storm
11
+ const base04 = '#d8dee9', // grey
12
+ base05 = '#e5e9f0', // off white
13
+ base06 = '#eceff4'; // white
14
+ // Frost
15
+ const base07 = '#8fbcbb', // moss green
16
+ base08 = '#88c0d0', // ice blue
17
+ base09 = '#81a1c1', // water blue
18
+ base0A = '#5e81ac'; // deep blue
19
+ // Aurora
20
+ const base0b = '#bf616a', // red
21
+ base0C = '#d08770', // orange
22
+ base0D = '#ebcb8b', // yellow
23
+ base0E = '#a3be8c', // green
24
+ base0F = '#b48ead'; // purple
25
+ const invalid = '#d30102', darkBackground = '#252a33', highlightBackground = base03, background = base00, tooltipBackground = base01, selection = base03, cursor = base04;
26
+ /// The editor theme styles for Nord.
27
+ const nordTheme = /*@__PURE__*/EditorView.theme({
28
+ '&': {
29
+ color: base04,
30
+ backgroundColor: background
31
+ },
32
+ '.cm-content': {
33
+ caretColor: cursor
34
+ },
35
+ '.cm-cursor, .cm-dropCursor': { borderLeftColor: cursor },
36
+ '&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection': { backgroundColor: selection },
37
+ '.cm-panels': { backgroundColor: darkBackground, color: base03 },
38
+ '.cm-panels.cm-panels-top': { borderBottom: '2px solid black' },
39
+ '.cm-panels.cm-panels-bottom': { borderTop: '2px solid black' },
40
+ '.cm-searchMatch': {
41
+ backgroundColor: 'transparent',
42
+ outline: `1px solid ${base07}`
43
+ },
44
+ '.cm-searchMatch.cm-searchMatch-selected': {
45
+ backgroundColor: base04,
46
+ color: base00
47
+ },
48
+ '.cm-activeLine': { backgroundColor: highlightBackground },
49
+ '.cm-selectionMatch': {
50
+ backgroundColor: base05,
51
+ color: base01
52
+ },
53
+ '&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket': {
54
+ outline: `1px solid ${base07}`
55
+ },
56
+ '&.cm-focused .cm-matchingBracket': {
57
+ backgroundColor: base06,
58
+ color: base02
59
+ },
60
+ '.cm-gutters': {
61
+ backgroundColor: base00,
62
+ color: base03,
63
+ border: 'none'
64
+ },
65
+ '.cm-activeLineGutter': {
66
+ backgroundColor: highlightBackground,
67
+ color: base04
68
+ },
69
+ '.cm-foldPlaceholder': {
70
+ backgroundColor: 'transparent',
71
+ border: 'none',
72
+ color: '#ddd'
73
+ },
74
+ '.cm-tooltip': {
75
+ border: 'none',
76
+ backgroundColor: tooltipBackground
77
+ },
78
+ '.cm-tooltip .cm-tooltip-arrow:before': {
79
+ borderTopColor: 'transparent',
80
+ borderBottomColor: 'transparent'
81
+ },
82
+ '.cm-tooltip .cm-tooltip-arrow:after': {
83
+ borderTopColor: tooltipBackground,
84
+ borderBottomColor: tooltipBackground
85
+ },
86
+ '.cm-tooltip-autocomplete': {
87
+ '& > ul > li[aria-selected]': {
88
+ backgroundColor: highlightBackground,
89
+ color: base03
90
+ }
91
+ }
92
+ }, { dark: true });
93
+ /// The highlighting style for code in the Nord theme.
94
+ const nordHighlightStyle = /*@__PURE__*/HighlightStyle.define([
95
+ { tag: tags.keyword, color: base0A },
96
+ {
97
+ tag: [tags.name, tags.deleted, tags.character, tags.propertyName, tags.macroName],
98
+ color: base08
99
+ },
100
+ { tag: [tags.variableName], color: base07 },
101
+ { tag: [/*@__PURE__*/tags.function(tags.variableName)], color: base07 },
102
+ { tag: [tags.labelName], color: base09 },
103
+ {
104
+ tag: [tags.color, /*@__PURE__*/tags.constant(tags.name), /*@__PURE__*/tags.standard(tags.name)],
105
+ color: base0A
106
+ },
107
+ { tag: [/*@__PURE__*/tags.definition(tags.name), tags.separator], color: base0E },
108
+ { tag: [tags.brace], color: base07 },
109
+ {
110
+ tag: [tags.annotation],
111
+ color: invalid
112
+ },
113
+ {
114
+ tag: [tags.number, tags.changed, tags.annotation, tags.modifier, tags.self, tags.namespace],
115
+ color: base0F
116
+ },
117
+ {
118
+ tag: [tags.typeName, tags.className],
119
+ color: base0D
120
+ },
121
+ {
122
+ tag: [tags.operator, tags.operatorKeyword],
123
+ color: base0E
124
+ },
125
+ {
126
+ tag: [tags.tagName],
127
+ color: base0F
128
+ },
129
+ {
130
+ tag: [tags.squareBracket],
131
+ color: base0b
132
+ },
133
+ {
134
+ tag: [tags.angleBracket],
135
+ color: base0C
136
+ },
137
+ {
138
+ tag: [tags.attributeName],
139
+ color: base0D
140
+ },
141
+ {
142
+ tag: [tags.regexp],
143
+ color: base0A
144
+ },
145
+ {
146
+ tag: [tags.quote],
147
+ color: base0F
148
+ },
149
+ { tag: [tags.string], color: base0E },
150
+ {
151
+ tag: tags.link,
152
+ color: base0E,
153
+ textDecoration: 'underline',
154
+ textUnderlinePosition: 'under'
155
+ },
156
+ {
157
+ tag: [tags.url, tags.escape, /*@__PURE__*/tags.special(tags.string)],
158
+ color: base07
159
+ },
160
+ { tag: [tags.meta], color: base08 },
161
+ { tag: [tags.monospace], color: base04, fontStyle: 'italic' },
162
+ { tag: [tags.comment], color: base03, fontStyle: 'italic' },
163
+ { tag: tags.strong, fontWeight: 'bold', color: base0A },
164
+ { tag: tags.emphasis, fontStyle: 'italic', color: base0A },
165
+ { tag: tags.strikethrough, textDecoration: 'line-through' },
166
+ { tag: tags.heading, fontWeight: 'bold', color: base0A },
167
+ { tag: /*@__PURE__*/tags.special(tags.heading1), fontWeight: 'bold', color: base0A },
168
+ { tag: tags.heading1, fontWeight: 'bold', color: base0A },
169
+ {
170
+ tag: [tags.heading2, tags.heading3, tags.heading4],
171
+ fontWeight: 'bold',
172
+ color: base0A
173
+ },
174
+ {
175
+ tag: [tags.heading5, tags.heading6],
176
+ color: base0A
177
+ },
178
+ { tag: [tags.atom, tags.bool, /*@__PURE__*/tags.special(tags.variableName)], color: base0C },
179
+ {
180
+ tag: [tags.processingInstruction, tags.inserted],
181
+ color: base07
182
+ },
183
+ {
184
+ tag: [tags.contentSeparator],
185
+ color: base0D
186
+ },
187
+ { tag: tags.invalid, color: base02, borderBottom: `1px dotted ${invalid}` }
188
+ ]);
189
+ /// Extension to enable the Nord theme (both the editor theme and
190
+ /// the highlight style).
191
+ const nord = [
192
+ nordTheme,
193
+ /*@__PURE__*/syntaxHighlighting(nordHighlightStyle)
194
+ ];
195
+
196
+ export { nord, nordHighlightStyle, nordTheme };
package/package.json ADDED
@@ -0,0 +1,45 @@
1
+ {
2
+ "name": "@fsegurai/codemirror-theme-nord",
3
+ "description": "Nord theme for the CodeMirror code editor",
4
+ "version": "6.0.1-alpha.0",
5
+ "type": "module",
6
+ "main": "dist/index.cjs",
7
+ "exports": {
8
+ "import": "./dist/index.js",
9
+ "require": "./dist/index.cjs"
10
+ },
11
+ "types": "dist/index.d.ts",
12
+ "module": "dist/index.js",
13
+ "sideEffects": false,
14
+ "scripts": {
15
+ "test": "cm-runtests",
16
+ "prepare": "cm-buildhelper src/index.ts"
17
+ },
18
+ "keywords": [
19
+ "editor",
20
+ "code",
21
+ "codemirror"
22
+ ],
23
+ "author": {
24
+ "name": "Fabián Segura",
25
+ "url": "https://www.fsegurai.com/"
26
+ },
27
+ "license": "MIT",
28
+ "repository": {
29
+ "type": "git",
30
+ "url": "git+https://github.com/fsegurai/codemirror-themes.git"
31
+ },
32
+ "bugs": {
33
+ "url": "https://github.com/fsegurai/codemirror-themes/issues"
34
+ },
35
+ "homepage": "https://github.com/fsegurai/codemirror-themes#readme",
36
+ "peerDependencies": {
37
+ "@lezer/highlight": "^1.0.0",
38
+ "@codemirror/language": "^6.0.0",
39
+ "@codemirror/state": "^6.0.0",
40
+ "@codemirror/view": "^6.0.0"
41
+ },
42
+ "devDependencies": {
43
+ "@codemirror/buildhelper": "^1.0.1"
44
+ }
45
+ }