razor icon indicating copy to clipboard operation
razor copied to clipboard

Improve contrast for C# content inside attributes.

Open javiercn opened this issue 3 years ago • 7 comments

The difference between a C# value inside an attribute and a string value is minimal. Consider the following example: image image

The only hint is the "minimal" purple @ in the attribute. Compared to the amount of text, it makes it really hard for the eyesight to differentiate between the two. We should explore using a color with higher contrast to make this difference more obvious.

/cc @danroth27

javiercn avatar Jul 01 '22 10:07 javiercn

@danroth27 do you have any input on this?

allisonchou avatar Jul 07 '22 22:07 allisonchou

Razor coloring is tricky because there are so many different token types all mixed together. C# in Razor is colored as C#, which I don't think we want to change. We could try fiddling with how HTML attributes are colored to try to distinguish them more from C# values.

@mikadumont Thoughts?

danroth27 avatar Jul 08 '22 16:07 danroth27

@danroth27 are you suggesting changing the default HTML coloring? Or only changing that in Razor files?

NTaylorMullen avatar Jul 08 '22 17:07 NTaylorMullen

In general, I like the idea that HTML coloring in Razor is the same as what it is in a normal HTML file. Same idea with C#, CSS, etc. So, if we can find a color for HTML attributes that is visually distinct from C# expressions and still looks in vanilla HTML that seems ideal.

danroth27 avatar Jul 08 '22 17:07 danroth27

@ToddGrun / @jimmylewis any thoughts?

NTaylorMullen avatar Jul 08 '22 17:07 NTaylorMullen

I'm all for improving the readability here. I'd even say we should look at changing the color for HTML attributes anyway, because it's so close to the color for text image

Of course, my default was to consider the color used in VS Code, image but that looks pretty similar to what C# uses for strings, so we end up with something ugly like image

That said, I have some concerns about all the cases where this could come up. We can change HTML attributes, but should we also be changing the HTML text color? image

That one's a gotcha... it's actually not classified at all! Maybe C# could change its color as well?
image

jimmylewis avatar Jul 08 '22 18:07 jimmylewis

Of course, my default was to consider the color used in VS Code,

This was my first thought as well and I think it's a reasonable improvement despite the overlap with C# strings. To distinguish from C# strings, maybe go with something a bit more yellow or red?

danroth27 avatar Jul 08 '22 20:07 danroth27