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
58 changes: 58 additions & 0 deletions client/modules/IDE/components/Editor/highlightStyle.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { HighlightStyle } from '@codemirror/language';
import { tags } from '@lezer/highlight';

export const highlightStyle = HighlightStyle.define([
{ tag: tags.comment, class: 'cm-comment' },
{ tag: tags.lineComment, class: 'cm-comment' },
{ tag: tags.blockComment, class: 'cm-comment' },
{ tag: tags.docComment, class: 'cm-comment' },
{ tag: tags.docString, class: 'cm-comment' },
{ tag: tags.name, class: 'cm-variable' },
{ tag: tags.variableName, class: 'cm-variable' },
{ tag: tags.typeName, class: 'cm-variable' },
{ tag: tags.className, class: 'cm-variable' },
{ tag: tags.string, class: 'cm-string' },
{ tag: tags.character, class: 'cm-string' },
{ tag: tags.attributeName, class: 'cm-string' },
{ tag: tags.regexp, class: 'cm-regexp' },
{ tag: tags.number, class: 'cm-number' },
{ tag: tags.integer, class: 'cm-number' },
{ tag: tags.float, class: 'cm-number' },
{ tag: tags.atom, class: 'cm-atom' },
{ tag: tags.bool, class: 'cm-atom' },
{ tag: tags.null, class: 'cm-atom' },
{ tag: tags.keyword, class: 'cm-keyword' },
{ tag: tags.self, class: 'cm-keyword' },
{ tag: tags.function, class: 'cm-keyword' },
{ tag: tags.operator, class: 'cm-operator' },
{ tag: tags.operatorKeyword, class: 'cm-operator' },
{ tag: tags.controlKeyword, class: 'cm-operator' },
{ tag: tags.derefOperator, class: 'cm-operator' },
{ tag: tags.arithmeticOperator, class: 'cm-operator' },
{ tag: tags.logicOperator, class: 'cm-operator' },
{ tag: tags.bitwiseOperator, class: 'cm-operator' },
{ tag: tags.compareOperator, class: 'cm-operator' },
{ tag: tags.updateOperator, class: 'cm-operator' },
{ tag: tags.typeOperator, class: 'cm-operator' },
{ tag: tags.controlOperator, class: 'cm-operator' },
{ tag: tags.definitionKeyword, class: 'cm-keyword' },
{ tag: tags.tagName, class: 'cm-tag' },
{ tag: tags.heading, class: 'cm-tag' },
{ tag: tags.heading1, class: 'cm-tag' },
{ tag: tags.heading2, class: 'cm-tag' },
{ tag: tags.heading3, class: 'cm-tag' },
{ tag: tags.heading4, class: 'cm-tag' },
{ tag: tags.heading5, class: 'cm-tag' },
{ tag: tags.heading6, class: 'cm-tag' },
{ tag: tags.list, class: 'cm-tag' },
{ tag: tags.quote, class: 'cm-tag' },
{ tag: tags.emphasis, class: 'cm-tag' },
{ tag: tags.strong, class: 'cm-tag' },
{ tag: tags.link, class: 'cm-tag' },
{ tag: tags.propertyName, class: 'cm-property' },
{ tag: tags.attributeName, class: 'cm-attribute' }
// { tag: tags.special(tags.variableName), class: 'p5-variable' }
// { tag: tags.definition, class: 'cm-def' },
// { tag: tags.const, class: 'cm-def' },
// { tag: tags.local, class: 'cm-def' },
]);
3 changes: 2 additions & 1 deletion client/modules/IDE/components/Editor/stateUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
bracketMatching,
indentOnInput,
syntaxHighlighting,
defaultHighlightStyle

Check warning on line 21 in client/modules/IDE/components/Editor/stateUtils.js

View workflow job for this annotation

GitHub Actions / Test and lint code base

'defaultHighlightStyle' is defined but never used
} from '@codemirror/language';
import {
autocompletion,
Expand Down Expand Up @@ -56,6 +56,7 @@

import p5JavaScript from './p5JavaScript';
import tidyCodeWithPrettier from './tidier';
import { highlightStyle } from './highlightStyle';

// ----- TODOS -----
// - JSON linter
Expand Down Expand Up @@ -323,7 +324,7 @@
highlightActiveLineGutter(),
highlightSpecialChars(),
highlightSelectionMatches(),
syntaxHighlighting(defaultHighlightStyle, { fallback: true }), // Might need to replace highlight style
syntaxHighlighting(highlightStyle),
// Selection extensions
drawSelection(),
rectangularSelection(),
Expand Down
67 changes: 67 additions & 0 deletions client/styles/abstracts/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,34 @@ $dark: #333; // primary
$darker: #1C1C1C;
$darkest: #000;

// Light highlight styles
$p5-light-brown: #7A5A3A;
$p5-light-black: #333333;
$p5-light-pink: #D52889;
$p5-light-gray: #666;
$p5-light-blue: #0B7CA9;
$p5-light-orange: #A06801;
$p5-light-lightgray: $middle-gray;
$p5-light-green: #47820A;

// Dark highlight styles
$p5-dark-pink: #DE4A9B;
$p5-dark-gray: #9B9B9B;
$p5-dark-lightblue: #0F9DD7;
$p5-dark-white: #FDFDFD;
$p5-dark-orange: #EE9900;
$p5-dark-green: #58a10b;
$p5-dark-goldbrown: #b58318;

// Contrast highlight styles
$p5-contrast-white: #FDFDFD;
$p5-contrast-lightgray: #C1C1C1;
$p5-contrast-blue: #00FFFF;
$p5-contrast-green: #2DE9B6;
$p5-contrast-yellow: #F5DC23;
$p5-contrast-orange: #FFA95D;
$p5-contrast-pink: #FFA9D9;

$themes: (
light: (
logo-color: $p5js-pink,
Expand Down Expand Up @@ -130,6 +158,19 @@ $themes: (
admonition-border: #22C8ED,
admonition-background: #E4F8FF,
admonition-text: #075769,

highlight-style-comment-color: $p5-light-lightgray,
highlight-style-variable-color: $p5-light-blue,
highlight-style-string-color: $p5-light-green,
highlight-style-regexp-color: $p5-light-orange,
highlight-style-number-color: $p5-light-black,
highlight-style-atom-color: $p5-light-pink,
highlight-style-keyword-color: $p5-light-brown,
highlight-style-operator-color: $p5-light-brown,
highlight-style-def-color: $p5-light-blue,
highlight-style-tag-color: $p5-light-pink,
highlight-style-property-color: $p5-light-black,
highlight-style-attribute-color: $p5-light-black,
),
dark: (
logo-color: $p5js-pink,
Expand Down Expand Up @@ -229,6 +270,19 @@ $themes: (
admonition-border: #22C8ED,
admonition-background: #105A7F,
admonition-text: #FFFFFF,

highlight-style-comment-color: $p5-dark-gray,
highlight-style-variable-color: $p5-dark-lightblue,
highlight-style-string-color: $p5-dark-green,
highlight-style-regexp-color: $p5-dark-orange,
highlight-style-number-color: $p5-dark-white,
highlight-style-atom-color: $p5-dark-pink,
highlight-style-keyword-color: $p5-dark-goldbrown,
highlight-style-operator-color: $p5-dark-goldbrown,
highlight-style-def-color: $p5-dark-lightblue,
highlight-style-tag-color: $p5-dark-pink,
highlight-style-property-color: $p5-dark-white,
highlight-style-attribute-color: $p5-dark-lightblue,
),
contrast: (
logo-color: $yellow,
Expand Down Expand Up @@ -328,6 +382,19 @@ $themes: (
admonition-border: #22C8ED,
admonition-background: #000000,
admonition-text: #ffffff,

highlight-style-comment-color: $p5-contrast-lightgray,
highlight-style-variable-color: $p5-contrast-white,
highlight-style-string-color: $p5-contrast-green,
highlight-style-regexp-color: $p5-contrast-green,
highlight-style-number-color: $p5-contrast-pink,
highlight-style-atom-color: $p5-contrast-pink,
highlight-style-keyword-color: $p5-contrast-yellow,
highlight-style-operator-color: $p5-contrast-lightgray,
highlight-style-def-color: $p5-contrast-blue,
highlight-style-tag-color: $p5-contrast-orange,
highlight-style-property-color: $p5-contrast-white,
highlight-style-attribute-color: $p5-contrast-white,
)
);

Expand Down
Loading
Loading