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

t/ckeditor5-ui/144: Migrated the package from SASS to PostCSS #114

Merged
merged 23 commits into from
Nov 30, 2017

Conversation

oleq
Copy link
Member

@oleq oleq commented Nov 22, 2017

Suggested merge commit message (convention)

Other: Migrated the theme from SASS to PostCSS (see ckeditor/ckeditor5#5304).

BREAKING CHANGE: The styles are no longer developed in SASS which means various .scss files (including variables, mixins, etc.) became unavailable. Please refer to the Theme Customization guide to learn more about migration to PostCSS.

* For licensing, see LICENSE.md.
*/

@custom-selector :--ck-reset-all
Copy link
Contributor

Choose a reason for hiding this comment

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

It's the only one case of used @custom-selector postcss plugin - getpostcssconfig.js in all stylesheets, do we really need it?

Copy link
Member Author

Choose a reason for hiding this comment

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

A good point. Probably it's better to get rid of it.

@custom-selector :--ck-reset-all
.ck-reset_all,
.ck-reset_all *,
.ck-reset_all a,
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it necessary here to use 1-1 CSS specificity for <a> and <textarea> elements?

As we talked it was an issue with CK4 (IE10 maybe?) because UA override, but as I checked Chrome and Firefox and there is no override situation.

Copy link
Member Author

Choose a reason for hiding this comment

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

Probably it's a legacy code because I copied it straight from v4.


.ck-placeholder::before {
cursor: text;
color: #c2c2c2;
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we should use a variable here?


svg.ck-icon {
width: calc(var(--ck-line-height-base) * 1em);
height: calc(var(--ck-line-height-base) * 1em);
Copy link
Contributor

Choose a reason for hiding this comment

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

I see --ck-font-size-normal: 1em, is it worthy to change it?

Copy link
Member Author

Choose a reason for hiding this comment

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

What do you mean?

Copy link
Contributor

@dkonopka dkonopka Nov 24, 2017

Choose a reason for hiding this comment

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

I was thinking about changing 1em to variable:

width: calc(var(--ck-line-height-base) * var(--ck-font-size-normal));

background: var(--ck-color-input-background);
border: 1px solid var(--ck-color-input-border);
padding: var(--ck-spacing-small) var(--ck-spacing-medium);
min-width: 21em;
Copy link
Contributor

Choose a reason for hiding this comment

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

Like earlier: maybe variable for min-width?

*/
&.ck-tooltip_s {
bottom: calc(-1 * var(--ck-tooltip-arrow-size));
transform: translateY( 100% );
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's speed up that transform: with translate3d( 0, 100%, 0);

Copy link
Member Author

Choose a reason for hiding this comment

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

I wouldn't be so sure about it. It needs to be checked because I experienced some issues in the past developing tooltips.

Copy link
Contributor

@dkonopka dkonopka Nov 24, 2017

Choose a reason for hiding this comment

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

Thinking again and you are right this is about tooltip "triangle" and maybe it isn't worth to use hardware acceleration (GPU) caused by will-change/translate3d property.

Anyway, we need to remember that sometimes we will need to use will-change/translate3d - see this issue with firefox blurred icons.


& .ck-tooltip__text::after {
top: calc(-1 * var(--ck-tooltip-arrow-size));
transform: translateX( -50% );
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's speed up that transform: with translate3d( -50%, 0, 0);

Copy link
Member Author

Choose a reason for hiding this comment

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

*/
&.ck-tooltip_n {
top: calc(-1 * var(--ck-tooltip-arrow-size));
transform: translateY( -100% );
Copy link
Contributor

Choose a reason for hiding this comment

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

-> translate3d.

Copy link
Member Author

Choose a reason for hiding this comment

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

--ck-font-size-normal: 1em;
--ck-font-size-big: 1.4em;
--ck-font-size-large: 1.8em;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

We are setting levels of property with calc in theme/ckeditor5-ui/globals/_spacing.css maybe we should use it here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Probably a good idea.

Copy link
Member Author

Choose a reason for hiding this comment

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

OTTH I noticed that while spacings multiply .8em, which is not super-easy, fonts are related to 1em, which is pretty straightforward. Changing it to calc would be

--ck-font-size-big: 1.4em;

vs

--ck-font-size-big: calc(var(--some-base-size) * 1.4));

which looks bloated. I don't think it's a good idea.

@@ -0,0 +1,82 @@
/*
Copy link
Contributor

@dkonopka dkonopka Nov 23, 2017

Choose a reason for hiding this comment

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

Why did you decide to make a folder for tooltip.css instead of placing it directly into /components?

Is there any reason? Because I see e.g: /components/panel/balloonpanel.css & /components/panel/stickypanel.css and understand that it needs a folder.

Copy link
Member Author

Choose a reason for hiding this comment

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

Check out the structure of theme in ckeditor5-ui. AFAIR the tooltip has a mixin and thus it has been defined as a directory (multiple files). The theme must follow such pattern if it is to be loaded properly.

TBH, now that I think about it, I think each component in ckeditor5-ui should have its own directory because if one day it gets a mixin or whatever, we wouldn't need to fix a structure of N–themes to reflect ckeditor5-ui and make them work with the theme importer. If you know what I mean :P

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, I see this and it's clear to me 👍

padding: var(--ck-spacing-large);

&:focus {
/*https://github.com/ckeditor/ckeditor5-link/issues/90*/
Copy link
Contributor

@dkonopka dkonopka Nov 23, 2017

Choose a reason for hiding this comment

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

Lack of space after /* and before */ + line 28 & 35.

*/

blockquote {
border-left: solid 5px #CCC;
Copy link
Contributor

Choose a reason for hiding this comment

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

Like in code.css we can use variable here too: --ck-color-blockquote-border.

text-align: center;

& > img {
/*Center the image if its width is smaller than content's width.*/
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing spaces in the comment.

& .image-style-align-left,
& .image-style-align-center,
& .image-style-align-right {
max-width: var(--ck-image-max-width);
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure but for center aligned imagemax-width should be 50%?

Copy link
Member Author

Choose a reason for hiding this comment

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

Check out the current code in SASS. I think I just copy–pasted it.

Copy link
Contributor

Choose a reason for hiding this comment

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

True, just wondering why centered style of image indicate max-width: 50% 🤔


&.ck-balloon-panel_with-arrow {
&:before,
&:after {
Copy link
Contributor

Choose a reason for hiding this comment

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

We should use a double-colon instead of one for pseudoelements.


/* https://github.com/ckeditor/ckeditor5-theme-lark/issues/111 */
.ck-toolbar-container.ck-editor-toolbar-container[class*="arrow_n"] {
&:after {
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing double-colon here and line 65 too.

& .ck-progress-bar {
height: 2px;
width: 0;
background: #6ab5f9;
Copy link
Contributor

@dkonopka dkonopka Nov 24, 2017

Choose a reason for hiding this comment

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

Would be nice to make variable here --ck-image-upload-progressbar-line-background

&.ck-infinite-progress::before {
width: var(--ck-image-upload-progress-line-width);
height: 2px;
background: rgba(0, 0, 0, 0.1);
Copy link
Contributor

Choose a reason for hiding this comment

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

Would be nice to make variable here --ck-image-upload-progress-line-background

*/

.ck-heading_heading1 {
font-size: 1.5em;
Copy link
Contributor

@dkonopka dkonopka Nov 24, 2017

Choose a reason for hiding this comment

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

What do you think to use here variable (--ck-font-size-normal: 1em;) and make it:

font-size: calc(var(--ck-font-size-normal) * 1.5);

and apply it to heading2 and heading3 too?

border-bottom-right-radius: 0;
}

/* https://github.com/ckeditor/ckeditor5-editor-classic/issues/62 */
Copy link
Contributor

@dkonopka dkonopka Nov 24, 2017

Choose a reason for hiding this comment

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

Something is wrong with that url (I mean it is not that issue).


--ck-color-button-action-background: #1ABC9C;
--ck-color-button-action-border: #49d2b7;
--ck-color-button-action-focus-background: #17a98c;
Copy link
Contributor

@dkonopka dkonopka Nov 27, 2017

Choose a reason for hiding this comment

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

As we talked we can't use postcss plugin for colors with functions like darken/lighten so maybe should we use hsl format? It be easier to understand & modify shades of color.

--ck-color-button-action-background: hsl( 168, 76%, 42% )
--ck-color-button-action-focus-background: hsl( 168, 76%, 38% )

Copy link
Member Author

Choose a reason for hiding this comment

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

That's a great idea. And what's more, you can use variables and calc to shift the color.

:root {
  --lightness-shift: 30%;
}

#first {
  background: hsl(120,100%, 50%);
}

#second {
  background: hsl(120,100%, calc(50% - var(--lightness-shift)));
}

Copy link
Member Author

Choose a reason for hiding this comment

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

...which may be broken in Firefox (and IE11?). Needs research.

Copy link
Contributor

@dkonopka dkonopka Nov 29, 2017

Choose a reason for hiding this comment

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

Perfect solution! I forgot about changing the shade of colour by a variable in HSL.

HSL is full supported since IE8+ so no worries here.

And we don't need any postcss color plugin 🎉

Copy link
Member Author

Choose a reason for hiding this comment

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

Pity we won't be able to use calc() with var(). I checked that out, it does not work in FF and IE11.

Copy link
Member Author

Choose a reason for hiding this comment

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

Still, hsl sounds like a plan.

@oleq oleq merged commit efc6004 into master Nov 30, 2017
@oleq oleq deleted the t/ckeditor5-ui/144 branch November 30, 2017 16:32
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants