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

Don't set fill for icons that set declare it #207

Merged
merged 2 commits into from
Nov 22, 2018

Conversation

michaeldjeffrey
Copy link
Contributor

@michaeldjeffrey michaeldjeffrey commented Nov 2, 2018

Only override the fill for elements that don't declare one.
Closes ckeditor/ckeditor5#3420

Only override the fill for elements that don't declare one.
Fixes #206
@michaeldjeffrey
Copy link
Contributor Author

Closed because I'm a doofus and named the branch incorrectly

@michaeldjeffrey
Copy link
Contributor Author

Wait no, I'm extra dumb. 207 is the PR ticket. I didn't sleep well. sigh

Copy link
Member

@oleq oleq left a comment

Choose a reason for hiding this comment

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

Before we can merge this patch, we need to do 2 things:

  • Clean-up existing icons. There are nearly 50 uses of fill="..." attribute in SVG icons across the project. If we merged this PR, which narrows the feature to fill–less nodes only, the dynamic icon colors wouldn't work anymore for all those icons. This is a regression we must avoid.
  • We must verify what multi–color icons look like after this fix. And I'm speaking mainly about highlight icons which are configurable.
    image

theme/ckeditor5-ui/components/icon/icon.css Outdated Show resolved Hide resolved
@michaeldjeffrey
Copy link
Contributor Author

I made a pen with most (I think all) icons from the ckeditor repos https://codepen.io/michaeldjeffrey/pen/YRGWLZ

Regarding icons like Highlight. The colors are set by setting the style attribute to use the css variable. If a fill attribute is also provided on an icon like that it will be ignored.

Something I noticed in making that codepen, some of the icons like copyformatting/cursors/cursor-disabled.svg are supposed to have colors in them, but the fill is overridden.

Other icons of note. The icons/table.svg declares its fill on the path, so it's using the new rule it's color would be defined unless overridden in css. But the companion icons to that icons/table-column.svg and friends declare a fill on the <g> so their fill is ignored anyways. It seems to truly respect an fill attribute, there would have to be a rule that doesn't set the fill color of anything that has a parent that sets a fill color.

I guess a couple options would be:

  • Removing any fill declaration that appears to be there as a text color.
  • Move fill attributes on <g> to each item inside.

What would you like to see from me to move this forward?

@oleq
Copy link
Member

oleq commented Nov 15, 2018

To start off, I noticed that you mixed CKEditor 4 and CKEditor 5 icons. They are two different projects and ckeditor-dev/** is a main v4 repository folder. There is no copyformatting feature in v5.

Just to let you know, we already have a manual test that agregates all icons in the project:

image

Having configured the development environment, you can run it using npm run manual -- --files theme-lark. You can use it for testing and development, which feels like a more complete tool when compared to your pen.


Back to the issue, I think we could get rid of the fill="" attribute across the project if we decided to merge this PR. OTOH, that would make them useless if someone used them in some other way than what we do in the project (because they would become transparent). Should we care about that? (cc @Reinmar @dkonopka).

@Reinmar
Copy link
Member

Reinmar commented Nov 15, 2018

that would make them useless if someone used them in some other way than what we do in the project (because they would become transparent). Should we care about that?

If someone used our SVG files in other places, not styled with our .ck-icon class, yes? I think it's ok – our way of using those icons (with a color applied via CSS) is the way to use them. They don't have fill cause they are colorable. Sounds reasonable to me.

@dkonopka
Copy link
Contributor

dkonopka commented Nov 15, 2018

(because they would become transparent)

I was suprised, but it isn't actually true. Even clean .html file will fill by default svg with #000000, same with software like Sketch or Adobe Illustrator.

To sum up I'm 👍 for removing it. By the way we could decide if we are using width/height or viewBox property for our <svg> files.

screen shot 2018-11-15 at 14 04 58

@oleq
Copy link
Member

oleq commented Nov 15, 2018

And whatever convention we agree upon, let's write it down in https://ckeditor.com/docs/ckeditor5/latest/framework/guides/contributing/development-environment.html#svg-icons.

@oleq
Copy link
Member

oleq commented Nov 15, 2018

I pushed changes to the SVG icons in various repos. The changes are as follows:

  • removed fill attrs,
  • removed width and height, leaving just the viewBox,
  • removed useless <g>,
  • removed useless fill-rule attrs.

You can check them by using mgit update in a root branch https://github.com/ckeditor/ckeditor5/compare/t/ckeditor5-theme-lark/206?expand=1 and test with the patch introduced in this PR.

Note: Since I automated my work with regexps and svgo, the changes must be thoroughly reviewed and verified in all browsers.

cc @dkonopka

@oleq oleq requested a review from dkonopka November 16, 2018 09:17
This was referenced Nov 19, 2018
@oleq
Copy link
Member

oleq commented Nov 19, 2018

Other PRs in a human-readable format:

Have fun, @dkonopka 😛

@oleq
Copy link
Member

oleq commented Nov 19, 2018

BTW, this change saves us ~2.5kB of code.

@Reinmar
Copy link
Member

Reinmar commented Nov 20, 2018

How did you clean those svg files? Did you use some tool? Is it documented in the dev env guide?

@oleq
Copy link
Member

oleq commented Nov 20, 2018

How did you clean those svg files? Did you use some tool? Is it documented in the dev env guide?

On my TODO.

@Reinmar
Copy link
Member

Reinmar commented Nov 20, 2018

Let's keep this PR open until we have the docs too 😈

@oleq
Copy link
Member

oleq commented Nov 21, 2018

@Reinmar Waiting in ckeditor/ckeditor5#1361.

@Reinmar Reinmar merged commit 6c690a9 into ckeditor:master Nov 22, 2018
@oleq
Copy link
Member

oleq commented Nov 22, 2018

Thanks, @michaeldjeffrey for your contribution! Let us know if everything is OK now.

@michaeldjeffrey
Copy link
Contributor Author

Thanks for running with this. Much appreciated.

oleq added a commit to ckeditor/ckeditor5-ui that referenced this pull request Oct 10, 2019
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.

Custom Icons can't use fill color attributes
4 participants