-
-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Desktop: Remove cm-strong css color specification #5732
Conversation
cm-strong should inherit `color` from parent
Strong should only make text bolder
@@ -498,10 +498,6 @@ function CodeMirror(props: NoteBodyEditorProps, ref: any) { | |||
padding-left: .2em; | |||
} | |||
|
|||
div.CodeMirror span.cm-strong { | |||
color: ${theme.colorBright}; | |||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we remove this I'm not clear where it would get the styling from now?
@@ -49,9 +49,6 @@ export default function(theme: any, options: Options = null) { | |||
padding-bottom: ${formatCssSize(theme.bodyPaddingBottom)}; | |||
padding-top: ${formatCssSize(theme.bodyPaddingTop)}; | |||
} | |||
strong { | |||
color: ${theme.colorBright}; | |||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here? We set it like this so that it takes the colour from the theme but if we remove it, then what colour would it be? Just black?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ii's color will be situational and taken from its immediate parent. Most of the time it will take from body (color: ${theme.color};) meaning it will be black in light theme and white in dark theme and so on for other theme.
But it should not have its own color because when strong is inside some other tags like ==**Text**==
we want it to have mark
color. Mark change the background-color so it has the responsibility to make sure the text is readable. While strong and italic do no change background-color and so it should not change color and inherit color from its parent instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I see your point, but colorBright can be different from the parent. In some theme I think it's bright green for example, while normal text is white. If the mark background color makes the text unreadable then that's where the problem is - the theme needs to be fixed so that the colorBright and mark color work properly together.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure you can temporary fix this issue by assigning a specific color to strong or simply add more css, but it will keep the entanglement and increase the techincal debt to downstream (plugin, users,...). The inline text formats (strong, italic, underline,...) have very specific specifications or "promises" by doing more than they should it unnecessary confuses end-user. To support my case i link to some closed and open issues in which the bold color is "off" or users wonder why strong text has different color than normal color.
I understand that some may want bold text to have bright color to emphasis it more but that should be done by end-user not default behaviors. This issue will keep appearing again and again if not addressed.
That being said, it is not impossible to fix it downstream for now so feel free to think about it and decide it yourself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, yes I kind of agree with you, but then it's bigger issue: we'd need to get rid of the colorBright property entirely and of course making sure we're not breaking any UI, editor or theme doing so.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't have to bundle <strong>
and colorBright problem together, at least for now. A search in code base https://github.com/laurent22/joplin/search?p=1&q=colorBright shows that colorBright is only used in two (technically three) places:
- Strong element for CodeMirror and Markdown-it
- And GotoAnything plugin.
But even if there is not explicitly use of colorBright
in the core codebase we can keep colorBright as a convenient/reliable variable for downstream (plugin, users). Remove it now can cause significant changes for end-user as we don't know how they are using it.
You can open the discussion about remove colorBright
again when significant changes in GUI/theme structure is undergoing. For now it's best to keep this PR atomic and just disentangle <strong>
from colorBright which is unlikely will break anything.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes but if we merge this PR, colorBright is almost not used at all anywhere, which is why it should be removed entirely. If it's used in a plugin so be it, I don't think it would be a major breaking change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can remove colorBright completely from the code base if you're fine with it. Although I worry it will break someone's setup and they will create an issue to complain about it.
I completely remove
I initially create this PR just for the first component but now it changes two (and quite a lot of files) so I log it here for future reference. |
Could you try to add |
Also there's a falling test https://github.com/laurent22/joplin/runs/4423691010?check_suite_focus=true#step:9:545 |
I fixed the failing test and mark the search fragments (with |
Indeed that makes sense. Thanks for the update. |
Current version assign strong tag and cm-strong element with a specific color (color: ${theme.colorBright};) which entangle the renderers' behaviors.
**==Emphasis Text==**
and==**Emphasis Text**==
rendered differently.Unless there is a specific reason that i don't know of, when it comes to css it is better to achieve the same effect with as less code as possible so we should trust that cm-strong will inherit the correct color from it's parent.
I didn't found the same issue with italic.