Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

T/11: Implemented CSS variables as highlight color property #13

Merged
merged 14 commits into from Feb 27, 2018
Merged

Conversation

dkonopka
Copy link
Contributor

@dkonopka dkonopka commented Feb 26, 2018

Suggested merge commit message (convention)

Other: Changed the way of defining highlight marker and pen colors. Now by default, it is possible with CSS variables. Closes ckeditor/ckeditor5#2596.

@dkonopka dkonopka requested a review from oleq February 26, 2018 14:17
@coveralls
Copy link

coveralls commented Feb 26, 2018

Coverage Status

Coverage remained the same at 100.0% when pulling bd7ed79 on t/11 into b87b797 on master.

@dkonopka dkonopka changed the title Implemented CSS variables as highlight color property T/11: Implemented CSS variables as highlight color property Feb 26, 2018
*/

:root {
--ck-marker-yellow: #fdfd77;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefix it with --ck-highlight-(marker|pen)- to stick to the convention we use.

src/highlight.js Outdated
* type: 'marker'
* }
*
* @typedef {Object} module:highlight/highlight~HighlightOption
* @property {String} title The user-readable title of the option.
* @property {String} model The unique attribute value in the model.
* @property {String} color The color used for the highlighter. It should match the `class` CSS definition.
* @property {String} color The name of CSS variable used for the highlighter. It should match the `class` CSS definition.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is wrong for 2 reasons:

  • We must still allow developers to use colors in hex/rgba/hsl.
  • Even if the above wasn't true, we have an entire var() statement instead of the name of the variable.

We should make it clear that all hex/rgba/hsl/var() are possible.

src/highlight.js Outdated
* ]
*
* There are two types of highlighters available:
* - `'marker'` - rendered as a `<mark>` element, styled with the `background-color`,
* - `'pen'` - rendered as a `<mark>` element, styled with the font `color`.
*
* **Note**: A style sheet with CSS classes is required for the configuration to work properly.
* The highlight feature does not provide the actual styles by itself.
* The highlight feature does provide actual stylesheet with default colors.
*
* **Note**: It is recommended that the `color` value should correspond to the class in the content
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We must explain here that we already do that thanks to var() but if you define colors with hex/rgba/hsl, you must take care of that by yourself.

src/highlight.js Outdated
* ]
*
* There are two types of highlighters available:
* - `'marker'` - rendered as a `<mark>` element, styled with the `background-color`,
* - `'pen'` - rendered as a `<mark>` element, styled with the font `color`.
*
* **Note**: A style sheet with CSS classes is required for the configuration to work properly.
* The highlight feature does not provide the actual styles by itself.
* The highlight feature does provide actual stylesheet with default colors.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/does provide actual stylesheet/provides the style sheet/

{ model: 'blueMarker', class: 'marker-blue', title: 'Blue marker', color: '#72cdfd', type: 'marker' },
{ model: 'redPen', class: 'pen-red', title: 'Red pen', color: '#e91313', type: 'pen' },
{ model: 'greenPen', class: 'pen-green', title: 'Green pen', color: '#118800', type: 'pen' }
{ model: 'yellowMarker', class: 'marker-yellow', title: 'Yellow Marker', color: 'var(--ck-marker-yellow)', type: 'marker' },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's not a single word in the documentation that the highlight feature comes with a style sheet, which defines a couple of markers and pens using CSS variables (a link to this page will be necessary too, it's a new thing around the web).

This must be clear, probably a new sub-section under Configuring the highlight options.

Copy link
Contributor Author

@dkonopka dkonopka Feb 27, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, I'll add example with configuring other than default colors 👍

@oleq
Copy link
Member

oleq commented Feb 27, 2018

Some errors in JSDoc

JSDoc started...
Incorrect link: features/highlight#inline
	at /Users/oleq/CK/5/ckeditor5/packages/ckeditor5-highlight/src/highlight.js (line 41)

Incorrect link: features/highlight#inline
	at /Users/oleq/CK/5/ckeditor5/packages/ckeditor5-highlight/src/highlight.js (line 87)

@dkonopka
Copy link
Contributor Author

dkonopka commented Feb 27, 2018

@oleq Oh, I see there is no way to link Features section of Docs in highlight.js via {@link features...}.

Is it enough to say users to check our example in docs.ckeditor.com Feature/Highlight and/or link here https://docs.ckeditor.com/ckeditor5/latest/features/highlight.html?

@oleq
Copy link
Member

oleq commented Feb 27, 2018

Such link is volatile so it's not a good idea. There's no way to validate it in the future and tell if it actually works and see if it references the right page.

The API docs must be self-explanatory. If they link outside, it usually indicates they are not good enough. Please, try rewording the docs to make them understandable and keep in mind that API docs are about the API and should not do the job of the guides.

@oleq oleq merged commit ea1f261 into master Feb 27, 2018
@oleq oleq deleted the t/11 branch February 27, 2018 14:29
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
3 participants