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

chore: document for svg icon setting #348

Merged
merged 11 commits into from
Mar 6, 2020
Prev Previous commit
Next Next commit
feat: complate default icon code
  • Loading branch information
jinwoo-kim-nhn committed Feb 27, 2020
commit e1ea3715c82d88d8fb42b0061674ab2ae57f6036
6 changes: 6 additions & 0 deletions src/css/icon.styl
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,11 @@
.active svg > use.normal,
.enabled svg > use.normal
display: none;
.help svg > use.disabled,
.help.enabled svg > use.normal
display: block;
.help.enabled svg > use.disabled
display: none;

.{prefix}-controls:hover
z-index: 3;
48 changes: 32 additions & 16 deletions src/js/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import snippet from 'tui-code-snippet';
import {HELP_MENUS} from './consts';
import util from './util';
import mainContainer from './ui/template/mainContainer';
import {controls, partition} from './ui/template/controls';
import controls from './ui/template/controls';

import Theme from './ui/theme/theme';
import Shape from './ui/shape';
Expand Down Expand Up @@ -161,7 +161,6 @@ class Ui {
* @ignore
*/
changeHelpButtonEnabled(buttonType, enableStatus) {
console.log(buttonType, this._buttonElements[buttonType]);
const buttonClassList = this._buttonElements[buttonType].classList;

buttonClassList[enableStatus ? 'add' : 'remove']('enabled');
Expand Down Expand Up @@ -226,7 +225,6 @@ class Ui {
// submenu ui instance
this[menuName] = new SubComponentClass(this._subMenuElement, {
locale: this._locale,
iconStyle: this.theme.getStyle('submenu.icon'),
svgIconMaker: this.theme.makeMenSvgIconSet.bind(this.theme),
menuBarPosition: this.options.menuBarPosition,
usageStatistics: this.options.usageStatistics
Expand Down Expand Up @@ -281,14 +279,23 @@ class Ui {
'load': this._selectedElement.querySelectorAll('.tui-image-editor-load-btn')
};

this._makeHelpMenu();
this._addHelpMenus();
}

_makeHelpMenu() {
// const helpMenuWithPartition = [...HELP_MENUS.slice(0, 3), '', ...HELP_MENUS.slice(4), ''];
/**
* Add help menu
* @private
*/
_addHelpMenus() {
const helpMenuWithPartition = [...HELP_MENUS.slice(0, 3), '', ...HELP_MENUS.slice(3), ''];

snippet.forEach(helpMenuWithPartition, menuName => {
if (!menuName) {
this._makeMenuPartitionElement();

return;
}

snippet.forEach(HELP_MENUS, menuName => {
// console.log('MENUNAME', menuName);
this._makeMenuElement(menuName, ['normal', 'disabled', 'hover'], 'help');
if (menuName) {
this._buttonElements[menuName] = this._menuElement.querySelector(`.tie-btn-${menuName}`);
Expand All @@ -297,18 +304,27 @@ class Ui {
}

/**
* Make menu ui dom element
* @param {string} menuName - menu name
* Make menu partition element
* @private
*/
_makeMenuElement(menuName, useIconTypes = ['normal', 'active', 'hover'], menuType = 'normal') {
if (!menuName) {
console.log('ss');
this._menuElement.appendChild(partition());
_makeMenuPartitionElement() {
const partitionElement = document.createElement('li');
const partitionInnerElement = document.createElement('div');
partitionElement.className = 'tui-image-editor-item';
partitionInnerElement.className = 'tui-image-editor-icpartition';
partitionElement.appendChild(partitionInnerElement);

return;
}
this._menuElement.appendChild(partitionElement);
}

/**
* Make menu button element
* @param {string} menuName - menu name
* @param {Array} useIconTypes - Possible values are \['normal', 'active', 'hover', 'disabled'\]
* @param {string} menuType - 'normal' or 'help'
* @private
*/
_makeMenuElement(menuName, useIconTypes = ['normal', 'active', 'hover'], menuType = 'normal') {
const btnElement = document.createElement('li');
const menuItemHtml = this.theme.makeMenSvgIconSet(useIconTypes, menuName);

Expand Down
3 changes: 1 addition & 2 deletions src/js/ui/crop.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@ import templateHtml from './template/submenu/crop';
* @ignore
*/
class Crop extends Submenu {
constructor(subMenuElement, {locale, iconStyle, svgIconMaker, menuBarPosition, usageStatistics}) {
constructor(subMenuElement, {locale, svgIconMaker, menuBarPosition, usageStatistics}) {
super(subMenuElement, {
locale,
name: 'crop',
iconStyle,
svgIconMaker,
menuBarPosition,
templateHtml,
Expand Down
3 changes: 1 addition & 2 deletions src/js/ui/draw.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@ const DRAW_OPACITY = 0.7;
* @ignore
*/
class Draw extends Submenu {
constructor(subMenuElement, {locale, iconStyle, svgIconMaker, menuBarPosition, usageStatistics}) {
constructor(subMenuElement, {locale, svgIconMaker, menuBarPosition, usageStatistics}) {
super(subMenuElement, {
locale,
name: 'draw',
iconStyle,
svgIconMaker,
menuBarPosition,
templateHtml,
Expand Down
3 changes: 1 addition & 2 deletions src/js/ui/filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,10 @@ const COLORPICKER_INSTANCE_NAMES = [
* @ignore
*/
class Filter extends Submenu {
constructor(subMenuElement, {locale, iconStyle, menuBarPosition, usageStatistics}) {
constructor(subMenuElement, {locale, menuBarPosition, usageStatistics}) {
super(subMenuElement, {
locale,
name: 'filter',
iconStyle,
menuBarPosition,
templateHtml,
usageStatistics
Expand Down
3 changes: 1 addition & 2 deletions src/js/ui/flip.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@ import templateHtml from './template/submenu/flip';
* @ignore
*/
class Flip extends Submenu {
constructor(subMenuElement, {locale, iconStyle, svgIconMaker, menuBarPosition, usageStatistics}) {
constructor(subMenuElement, {locale, svgIconMaker, menuBarPosition, usageStatistics}) {
super(subMenuElement, {
locale,
name: 'flip',
iconStyle,
svgIconMaker,
menuBarPosition,
templateHtml,
Expand Down
3 changes: 1 addition & 2 deletions src/js/ui/icon.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@ import {defaultIconPath} from '../consts';
* @ignore
*/
class Icon extends Submenu {
constructor(subMenuElement, {locale, iconStyle, svgIconMaker, menuBarPosition, usageStatistics}) {
constructor(subMenuElement, {locale, svgIconMaker, menuBarPosition, usageStatistics}) {
super(subMenuElement, {
locale,
name: 'icon',
iconStyle,
svgIconMaker,
menuBarPosition,
templateHtml,
Expand Down
3 changes: 1 addition & 2 deletions src/js/ui/mask.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@ import templateHtml from './template/submenu/mask';
* @ignore
*/
class Mask extends Submenu {
constructor(subMenuElement, {locale, iconStyle, svgIconMaker, menuBarPosition, usageStatistics}) {
constructor(subMenuElement, {locale, svgIconMaker, menuBarPosition, usageStatistics}) {
super(subMenuElement, {
locale,
name: 'mask',
iconStyle,
svgIconMaker,
menuBarPosition,
templateHtml,
Expand Down
3 changes: 1 addition & 2 deletions src/js/ui/rotate.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@ const COUNTERCLOCKWISE = -30;
* @ignore
*/
class Rotate extends Submenu {
constructor(subMenuElement, {locale, iconStyle, svgIconMaker, menuBarPosition, usageStatistics}) {
constructor(subMenuElement, {locale, svgIconMaker, menuBarPosition, usageStatistics}) {
super(subMenuElement, {
locale,
name: 'rotate',
iconStyle,
svgIconMaker,
menuBarPosition,
templateHtml,
Expand Down
3 changes: 1 addition & 2 deletions src/js/ui/shape.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@ const SHAPE_DEFAULT_OPTION = {
* @ignore
*/
class Shape extends Submenu {
constructor(subMenuElement, {locale, iconStyle, svgIconMaker, menuBarPosition, usageStatistics}) {
constructor(subMenuElement, {locale, svgIconMaker, menuBarPosition, usageStatistics}) {
super(subMenuElement, {
locale,
name: 'shape',
iconStyle,
svgIconMaker,
menuBarPosition,
templateHtml,
Expand Down
3 changes: 1 addition & 2 deletions src/js/ui/submenuBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Submenu {
* @param {*} templateHtml - template for SubMenuElement
* @param {boolean} [usageStatistics=false] - template for SubMenuElement
*/
constructor(subMenuElement, {locale, name, iconStyle, svgIconMaker, menuBarPosition, templateHtml, usageStatistics}) {
constructor(subMenuElement, {locale, name, svgIconMaker, menuBarPosition, templateHtml, usageStatistics}) {
this.subMenuElement = subMenuElement;
this.menuBarPosition = menuBarPosition;
this.toggleDirection = menuBarPosition === 'top' ? 'down' : 'up';
Expand All @@ -23,7 +23,6 @@ class Submenu {
this._makeSubMenuElement({
locale,
name,
iconStyle,
svgIconMaker,
templateHtml
});
Expand Down
8 changes: 1 addition & 7 deletions src/js/ui/template/controls.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const controls = ({locale, biImage, loadButtonStyle, downloadButtonStyle}) => (`
export default ({locale, biImage, loadButtonStyle, downloadButtonStyle}) => (`
<div class="tui-image-editor-controls">
<div class="tui-image-editor-controls-logo">
<img src="${biImage}" />
Expand All @@ -16,9 +16,3 @@ export const controls = ({locale, biImage, loadButtonStyle, downloadButtonStyle}
</div>
</div>
`);

export const partition = () => (`
<li class="tui-image-editor-item">
<div class="tui-image-editor-icpartition"></div>
</li>
`);
7 changes: 0 additions & 7 deletions src/js/ui/template/style.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,6 @@ export default ({
.tui-image-editor-container .tui-image-editor-header-logo > img {
${biSize}
}
.tui-image-editor-container .tui-image-editor-controls .help svg > use.disabled,
.tui-image-editor-container .tui-image-editor-controls .help.enabled svg > use.normal {
display: block;
}
.tui-image-editor-container .tui-image-editor-controls .help.enabled svg > use.disabled {
display: none;
}
.tui-image-editor-menu use.normal.use-default {
fill-rule: evenodd;
fill: ${menuIconStyle.normal.color};
Expand Down
6 changes: 3 additions & 3 deletions src/js/ui/template/submenu/crop.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @param {Locale} locale - Translate text
* @param {Object} normal - iconStyle
* @param {Object} active - iconStyle
* @param {Object} submenuInfo - submenu info for make template
* @param {Locale} locale - Translate text
* @param {Function} svgIconMaker - svg icon generator
* @returns {string}
*/
export default ({locale, svgIconMaker}) => (`
Expand Down
6 changes: 3 additions & 3 deletions src/js/ui/template/submenu/draw.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @param {Locale} locale - Translate text
* @param {Object} normal - iconStyle
* @param {Object} active - iconStyle
* @param {Object} submenuInfo - submenu info for make template
* @param {Locale} locale - Translate text
* @param {Function} svgIconMaker - svg icon generator
* @returns {string}
*/
export default ({locale, svgIconMaker}) => (`
Expand Down
6 changes: 3 additions & 3 deletions src/js/ui/template/submenu/flip.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @param {Locale} locale - Translate text
* @param {Object} normal - iconStyle
* @param {Object} active - iconStyle
* @param {Object} submenuInfo - submenu info for make template
* @param {Locale} locale - Translate text
* @param {Function} svgIconMaker - svg icon generator
* @returns {string}
*/
export default ({locale, svgIconMaker}) => (`
Expand Down
6 changes: 3 additions & 3 deletions src/js/ui/template/submenu/icon.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @param {Locale} locale - Translate text
* @param {Object} normal - iconStyle
* @param {Object} active - iconStyle
* @param {Object} submenuInfo - submenu info for make template
* @param {Locale} locale - Translate text
* @param {Function} svgIconMaker - svg icon generator
* @returns {string}
*/
export default ({locale, svgIconMaker}) => (`
Expand Down
6 changes: 3 additions & 3 deletions src/js/ui/template/submenu/mask.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @param {Locale} locale - Translate text
* @param {Object} normal - iconStyle
* @param {Object} active - iconStyle
* @param {Object} submenuInfo - submenu info for make template
* @param {Locale} locale - Translate text
* @param {Function} svgIconMaker - svg icon generator
* @returns {string}
*/
export default ({locale, svgIconMaker}) => (`
Expand Down
6 changes: 3 additions & 3 deletions src/js/ui/template/submenu/rotate.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @param {Locale} locale - Translate text
* @param {Object} normal - iconStyle
* @param {Object} active - iconStyle
* @param {Object} submenuInfo - submenu info for make template
* @param {Locale} locale - Translate text
* @param {Function} svgIconMaker - svg icon generator
* @returns {string}
*/
export default ({locale, svgIconMaker}) => (`
Expand Down
6 changes: 3 additions & 3 deletions src/js/ui/template/submenu/shape.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @param {Locale} locale - Translate text
* @param {Object} normal - iconStyle
* @param {Object} active - iconStyle
* @param {Object} submenuInfo - submenu info for make template
* @param {Locale} locale - Translate text
* @param {Function} svgIconMaker - svg icon generator
* @returns {string}
*/
export default ({locale, svgIconMaker}) => (`
Expand Down
6 changes: 3 additions & 3 deletions src/js/ui/template/submenu/text.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @param {Locale} locale - Translate text
* @param {Object} normal - iconStyle
* @param {Object} active - iconStyle
* @param {Object} submenuInfo - submenu info for make template
* @param {Locale} locale - Translate text
* @param {Function} svgIconMaker - svg icon generator
* @returns {string}
*/
export default ({locale, svgIconMaker}) => (`
Expand Down
3 changes: 1 addition & 2 deletions src/js/ui/text.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@ import {defaultTextRangeValus} from '../consts';
* @ignore
*/
class Text extends Submenu {
constructor(subMenuElement, {locale, iconStyle, svgIconMaker, menuBarPosition, usageStatistics}) {
constructor(subMenuElement, {locale, svgIconMaker, menuBarPosition, usageStatistics}) {
super(subMenuElement, {
locale,
name: 'text',
iconStyle,
svgIconMaker,
menuBarPosition,
templateHtml,
Expand Down
Loading