Skip to content
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

feat: add support for svg icons #74

Merged
merged 14 commits into from
Jun 29, 2020
Merged

feat: add support for svg icons #74

merged 14 commits into from
Jun 29, 2020

Conversation

carloslancha
Copy link
Contributor

@carloslancha carloslancha commented Jun 25, 2020

https://issues.liferay.com/browse/IFI-1829

We need to use SVG icons as we discussed on slack

In this pr we're generating needed icon classes for all the different states and adding required support for rtl and ltr.

icon states

Striked out ckeditor icons:
image

"rtr": "indent-more"
},
"redo": {
"ltr": "redo",
Copy link
Contributor

Choose a reason for hiding this comment

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

Are you sure these are directional? It kinda makes sense... but I'd love to get some reading about it :D

Copy link
Contributor Author

Choose a reason for hiding this comment

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

CKEditor have it as directional (automatically uses .cke-ltr or .cke-rtl classes`). I assumed it was correct.

"find": "search",
"find": {
"ltr": "search",
"rtl": "search"
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this mean to be a different search? Or if they're the same, why separate rtl and ltr?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same, CKEditor have it as directional so we need to specify the icon for both directions. Probably we'll need to specify other icon, something like search-rtl

"anchor": "flag-full",
"anchor": {
"ltr": "flag-full"
},
"blockquote": "quote-right",
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this one be directional as well? :D

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is but we don't have the rtl icon yet. I can use the same until we have it or just leave it blank.

@@ -4,36 +4,59 @@
"align-image-center": "align-image-center",
"align-image-left": "align-image-left",
"align-image-right": "align-image-right",
"anchor": "flag-full",
"anchor": {
"ltr": "flag-full"
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here... why just ltr?

I just have no idea what this is supposed to do, it just feels weird :D

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same as the others

}`;

iconsCSSContent += `${activeIconCSS} ${defaultIconCSS} ${disableIconCSS} ${hoverIconCSS} ${focusIconCSS}`;
*/
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we still saving all these comments? :D

Not sure if this is something you want to keep... but if you do, one option is to create a bogus commit adding it and one removing it, so you will have it in the git history :D

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ups, no, I have it already in the history, just forgot to remove it, thx

ck.sh Outdated
@@ -59,7 +59,7 @@ case "$COMMAND" in
cd ckeditor-dev

# Convert svg icons to png
Copy link
Contributor

Choose a reason for hiding this comment

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

I assume this comment is no longer acurate?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Upsy

@carloslancha carloslancha changed the title feat: sf feat: add support for svg icons Jun 25, 2020
@carloslancha
Copy link
Contributor Author

carloslancha commented Jun 26, 2020

About rtl icons:

CKEditor automatically adds to the css the classes for all the icons in ltr (just using .cke_button .cke_button__name_icon) and some for rtl(adding .cke_rtl .cke_button .cke_button_name_icon).

There are some of those rlt icons that maybe we don't want to mirror. Material Design for example has some guidelines about it.

  • Search icon: Lens handle is usually at the right side because majority of users are right-handed, also in RTL-writing countries.

  • Undo / Redo: These icons refers to time, clockwise (right -> redo) and counterclockwise (left > undo). In Google's case they use a circular icon that could be associated better with the clock, our icons are not exactly circular but I think that still could be associated in the same way.

  • Anchor / Flag: Nothing about this but I guess we can follow the same principle as the search icon. (Already listed as rtl in our icons excel)

Anyway, not an expert, maybe @drakonux can provide more info :)

@carloslancha
Copy link
Contributor Author

carloslancha commented Jun 26, 2020

Forgot to mention that even if we don't want to mirror some of those icons we need to specify the rtl icon using the same one as ltr just because CKEditor works in that way.

@jbalsas
Copy link
Contributor

jbalsas commented Jun 26, 2020

LGTM, @carloslancha!

Just one question... could you highlight which of the icons in the gif are ours and which ones are ckeditor's?

@carloslancha
Copy link
Contributor Author

@jbalsas updated description

Comment on lines 39 to 45
const activeIconCSS = `${directionClass}.cke_hidpi .cke_button.cke_button_on .cke_button__${cKEditorIcon}_icon,
${directionClass} .cke_button.cke_button_on .cke_button__${cKEditorIcon}_icon {
background: url("data:image/svg+xml;charset=utf8,${encodeSvgData(
svgData,
activeColor
)}") !important;
}`;
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I'd format these so that the output is consistently indented:

	const activeIconCSS = `
		${directionClass}.cke_hidpi .cke_button.cke_button_on .cke_button__${cKEditorIcon}_icon,
		${directionClass} .cke_button.cke_button_on .cke_button__${cKEditorIcon}_icon {
			background: url("data:image/svg+xml;charset=utf8,${encodeSvgData(
				svgData,
				activeColor
			)}") !important;
		}
	`;

(The way you have it, you have 0 indent on first line, then it jumps to two tabs of indent)

)}") !important;
}`;

return `${activeIconCSS} ${defaultIconCSS} ${disableIconCSS} ${hoverIconCSS} ${focusIconCSS}`;
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe?

return [
    activeIconCSS,
    defaultIconCSS,
    disableIconCSS,
    hoverIconCSS,
    focusIconCSS,
].join('\n\n');

.replace(/(<svg[^>]*)( fill="[^"]+")/, '\1')
.replace(/<svg/, `<svg fill="${color}"`)
.replace(/"/g, "'") // Use single quotes instead of double to avoid encoding.
.replace(/>\s{1,}</g, '><')
Copy link
Contributor

Choose a reason for hiding this comment

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

{1,} is just +, isn't it? Why not use that?

ck.sh Outdated
@@ -58,8 +58,8 @@ case "$COMMAND" in

cd ckeditor-dev

# Convert svg icons to png
node ../support/svgToPng.js skins/moono-lexicon/icons/icons.json skins/moono-lexicon/icons
# Generate svg icons CSS Classes
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Consistent capitalization? (ie. "svg" vs "CSS")

@carloslancha
Copy link
Contributor Author

@wincent formated

@carloslancha carloslancha merged commit 5b9e146 into liferay:master Jun 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants