monokai-pro-vscode icon indicating copy to clipboard operation
monokai-pro-vscode copied to clipboard

React Custom Elements vs HTML Elements (Same Colour)

Open AndrewJacobVlietstra opened this issue 4 years ago • 5 comments

Hello, I love using this colour theme every day working on HTML/CSS and JavaScript for my day job. I recently started learning React and I have one gripe when working with React and that's that the custom components/elements you make in the JS file is the same colour as built-in HTML elements.

I believe the main difference separating the scopes of built-in HTML and custom components when using the inspector tool is that the custom components have a support.class.component.js textmate scope. (See picture Below)

react-html

It would be awesome if these could be different colours, like the custom components could be an aqua colour or something. It just kinda sucks to see a bunch of red when you have a lot of custom components and HTML going on in your editor and its a little tough to spot your custom components sometimes.

Thanks for your time!

AndrewJacobVlietstra avatar Jul 15 '21 03:07 AndrewJacobVlietstra

So I ended up solving the problem myself, all you have to do go to Users->"Your Username"->.vscode->extensions and in there open the monokai pro folder, go into "themes", and edit the monokai pro json file in vscode or something.

Using the token inspector tool I searched up the scope of the jsx custom components which is "entity.name.tag support.class.component" and then made a new rule object separating regular "entity.name.tag" which are the built-in html elements from the react custom components. And made the colour a nice greeny aqua (See below)

modified-monokai-pro-colors

Here is what the json file looks like, with the rules I changed up.

modified-theme-json

This is pretty awesome, so if you have a favourite colour theme you like you can stick with it and just change the things you want using the inspector tool, finding those scopes in the json theme file and changing up the colours or adding new rules to separate scopes and add colours to more specific scopes!

AndrewJacobVlietstra avatar Jul 15 '21 20:07 AndrewJacobVlietstra

Thanks! I implemented this for myself too. I chose the Monokia Green (#a9dc76) for custom components to try and keep in line with the rest of the theme.

I wanted to try and fix this on a branch, but the json files don't seem to be in this repo

All the theme colors are here if you want to have a play and see which you like best https://kolormark.com/brands/monokai

BillyOgilvie avatar Sep 07 '21 12:09 BillyOgilvie

@AndrewJacobVlietstra do you mind pasting in the two lines you added here?

mikestecker avatar Nov 19 '21 20:11 mikestecker

@AndrewJacobVlietstra do you mind pasting in the two lines you added here?

Yea for sure, here are the two lines, hope this helps!

{ "scope": ["entity.name.tag"], "settings": { "name": "Built-in HTML", "foreground": "#ff6188" } }, { "scope": ["entity.name.tag.js.jsx support.class.component.js.jsx", "entity.name.tag support.class.component", "source.vue support.class.component"], "settings": { "name": "Custom Component", "foreground": "#00fab5" } },

AndrewJacobVlietstra avatar Nov 19 '21 20:11 AndrewJacobVlietstra

@AndrewJacobVlietstra do you mind pasting in the two lines you added here?

Yea for sure, here are the two lines, hope this helps!

{ "scope": ["entity.name.tag"], "settings": { "name": "Built-in HTML", "foreground": "#ff6188" } }, { "scope": ["entity.name.tag.js.jsx support.class.component.js.jsx", "entity.name.tag support.class.component", "source.vue support.class.component"], "settings": { "name": "Custom Component", "foreground": "#00fab5" } },

Awesome, thanks for this!

I actually just discovered you can override the theme settings without having to edit the theme. You can do this directly in your settings.json file:

"editor.tokenColorCustomizations": {
    "[Monokai Pro (Filter Spectrum)]": {
      "textMateRules": [
        {
          "scope": ["entity.name.tag"],
          "settings": { "foreground": "#ff6188" }
        },
        {
          "scope": [
            "entity.name.tag.js.jsx support.class.component.js.jsx",
            "entity.name.tag support.class.component",
            "source.vue support.class.component"
          ],
          "settings": { "foreground": "#00fab5" }
        }
      ]
    }
  },

Just change out [Monokai Pro (Filter Spectrum)] for whatever version you are using.

mikestecker avatar Nov 19 '21 21:11 mikestecker

"[Monokai Pro (Filter Spectrum)]": {

I am sorry but I cannot figure this out. If my version is v1.2.0 what exactly do I write in this line?

So far I tried the following combinations "[Monokai Pro 1.2.0]": { "[Monokai Pro v1.2.0]": { "[Monokai Pro (1.2.0)]": { "[Monokai Pro (v1.2.0)]": { and others...

faforus avatar Mar 16 '23 12:03 faforus

@faforus Should be autocompleted. Have you installed it and set it as theme in settings.json?

johannesschaffer avatar May 20 '23 11:05 johannesschaffer

I have it installed and working, I cannot however change the color as described above. The person above explains to 'Just change out [Monokai Pro (Filter Spectrum)] for whatever version you are using.' but whatever I type in there has no effect. Color does not change.

faforus avatar May 22 '23 08:05 faforus

Like I said, you shouldn't need to try out / type in various combinations of name and version. VSCode should autocomplete available themes.

johannesschaffer avatar May 22 '23 12:05 johannesschaffer

Oh, thank you, it does work like a charm!

faforus avatar May 22 '23 14:05 faforus

Great! It would probably be helpful for others as reference, if you posted your working code snippet here...

johannesschaffer avatar May 22 '23 14:05 johannesschaffer

Here is the modified second line of the code that mikestecker provided that works in my case. "[Monokai Pro]": { The version is simply Monokai Pro without any version numbers.

faforus avatar May 22 '23 14:05 faforus