Skip to content

Commit

Permalink
Support grid gap editor
Browse files Browse the repository at this point in the history
  • Loading branch information
easylogic committed Dec 6, 2019
1 parent 78c5147 commit 5cccaf3
Show file tree
Hide file tree
Showing 10 changed files with 103 additions and 21 deletions.
2 changes: 0 additions & 2 deletions src/csseditor/editor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,6 @@ export default class CSSEditor extends UIElement {
}

[EVENT('refreshAll')] () {
// this.refs.$middle.toggleClass('open-right', editor.openRightPanel);

this.emit('refreshProjectList');
this.trigger('refreshAllSelectProject');
}
Expand Down
6 changes: 3 additions & 3 deletions src/csseditor/i18n/locales/ko_KR.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ export default {

'timeline.value.editor.value': '값',
'timeline.value.editor.time': '시간',
'timeline.value.editor.timing': '시간곡선',
'timeline.value.editor.timing': '타이밍 함수',

'svgfilter.popup.title': 'SVG 필터',

Expand Down Expand Up @@ -333,7 +333,7 @@ export default {
'flex.layout.editor.align-items': '아이템 정렬',
'flex.layout.editor.align-content': '컨텐츠 정렬',

'flex.layout.item.property.title': '레이아웃 아이템',
'flex.layout.item.property.title': '플렉스 아이템 설정',
'flex.layout.item.property.grow': '공간 비율',
'flex.layout.item.property.shrink': '축소 비율',
'flex.layout.item.property.basis': '초기 크기',
Expand All @@ -352,7 +352,7 @@ export default {
'grid.box.editor.count': '반복',
'grid.box.editor.value': '크기',

'grid.layout.item.property.title': '레이아웃 아이템',
'grid.layout.item.property.title': '그리드 아이템 설정',
'grid.layout.item.property.column': '열',
'grid.layout.item.property.row': '행',
'grid.layout.item.property.start': '시작',
Expand Down
77 changes: 77 additions & 0 deletions src/csseditor/ui/property-editor/GridGapEditor.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import UIElement, { EVENT } from "../../../util/UIElement";
import { LOAD } from "../../../util/Event";
import { Length } from "../../../editor/unit/Length";
import RangeEditor from "./RangeEditor";


export default class GridGapEditor extends UIElement {

components() {
return {
RangeEditor
}
}

initState() {
return {
label: this.props.label,
value: this.parseValue(this.props.value)
}
}

setValue (value) {
this.setState({
list: this.parseValue(value)
})
}

parseValue (value) {
return Length.parse(value);
}

getValue () {
return this.state.value
}

modifyData() {
this.parent.trigger(this.props.onchange, this.props.key, this.getValue())
}

makeItem () {
return /*html*/`
<div class='item'>
<div class='value'>
<RangeEditor
label='${this.state.label}'
ref='$value'
key="value"
value="${this.state.value}"
units='px,em,%'
onchange="changeKeyValue" />
</div>
</div>
`
}

[LOAD('$list')] () {
return this.makeItem();
}

template () {
return /*html*/`
<div class='grid-gap-editor' ref='$body' >
<div class='grid-gap-editor-item'>
<div ref='$list'></div>
</div>
</div>
`
}


[EVENT('changeKeyValue')] (key, value) {

this.state.value = value;

this.modifyData();
}
}
8 changes: 4 additions & 4 deletions src/csseditor/ui/property-editor/GridLayoutEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { CSS_TO_STRING, STRING_TO_CSS } from "../../../util/functions/func";
import SelectIconEditor from "./SelectIconEditor";
import { editor } from "../../../editor/editor";
import GridBoxEditor from "./GridBoxEditor";
import icon from "../icon/icon";
import GridGapEditor from "./GridGapEditor";

const i18n = editor.initI18n('grid.layout.editor')

Expand All @@ -14,7 +14,7 @@ export default class GridLayoutEditor extends UIElement {
return {
SelectIconEditor,
GridBoxEditor,

GridGapEditor,
}
}

Expand Down Expand Up @@ -52,8 +52,8 @@ export default class GridLayoutEditor extends UIElement {
/>
</div>
<div class='grid-layout-item'>
<div class='label'><label>${i18n('column.gap')}</label></div>
<GridGapEditor
label='${i18n('column.gap')}'
key='grid-column-gap'
value="${this.state['grid-column-gap'] || ''}"
onchange='changeKeyValue'
Expand All @@ -69,8 +69,8 @@ export default class GridLayoutEditor extends UIElement {
/>
</div>
<div class='grid-layout-item'>
<div class='label'><label>${i18n('row.gap')}</label></div>
<GridGapEditor
label='${i18n('row.gap')}'
key='grid-row-gap'
value="${this.state['grid-row-gap'] || ''}"
onchange='changeKeyValue'
Expand Down
2 changes: 2 additions & 0 deletions src/csseditor/ui/property-editor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,11 @@ import FlexLayoutItemEditor from "./FlexLayoutItemEditor";
import GridBoxEditor from "./GridBoxEditor";
import GridLayoutItemEditor from "./GridLayoutItemEditor";
import NumberInputEditor from "./NumberInputEditor";
import GridGapEditor from "./GridGapEditor";


export default {
GridGapEditor,
NumberInputEditor,
GridLayoutItemEditor,
GridBoxEditor,
Expand Down
3 changes: 1 addition & 2 deletions src/csseditor/ui/property/PositionProperty.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ export default class PositionProperty extends BaseProperty {
[key]: value
})

this.emit('refreshSelectionStyleView');
// this.emit('change.property', key)
this.emit('refreshSelectionStyleView');
}
}
15 changes: 6 additions & 9 deletions src/csseditor/ui/view/ElementView.js
Original file line number Diff line number Diff line change
Expand Up @@ -552,9 +552,9 @@ export default class ElementView extends UIElement {
const {x, y, width, height} = $el.offsetRect();

it.reset({
x: Length.px(x),
y: Length.px(y),
width: Length.px(width),
x: Length.px(x),
y: Length.px(y),
width: Length.px(width),
height: Length.px(height)
})

Expand All @@ -564,15 +564,12 @@ export default class ElementView extends UIElement {

// svg 객체 path, polygon 은 크기가 바뀌면 내부 path도 같이 scale up/down 이 되어야 하는데
// 이건 어떻게 적용하나 ....
this.trigger('refreshSelectionStyleView', it, true);


this.trigger('refreshSelectionStyleView', it, true);
}

this.trigger('refreshElementBoundSize', it);
})

}
}

}
}
}
5 changes: 5 additions & 0 deletions src/csseditor/ui/view/SelectionToolView.js
Original file line number Diff line number Diff line change
Expand Up @@ -826,6 +826,11 @@ export default class SelectionToolView extends SelectionToolBind {
if (item.is('component')) {
this.emit('refreshStyleView', item);
}

if (item.hasLayout()) {
this.trigger('refreshElementBoundSize', item);
}

});
}

Expand Down
4 changes: 4 additions & 0 deletions src/scss/csseditor/property/property-view.scss
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@
}

label {
vertical-align: middle;
padding-right: 10px;
svg {
width: 16px;
height: 16px;
Expand All @@ -91,6 +93,7 @@

input {
vertical-align: middle;
height: 20px;
}
}

Expand Down Expand Up @@ -153,6 +156,7 @@

.direction-buttons {
display: flex;
padding-top: 2px;

@each $selectDirection in normal, alternate, reverse, alternate-reverse {
&[data-selected-direction="#{$selectDirection}"] [data-value="#{$selectDirection}"] {
Expand Down
2 changes: 1 addition & 1 deletion src/scss/csseditor/selection-view.scss
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@

.x {
transform: rotateX(90deg) translateZ(0px);
border: 3px solid $selected-color;
border: 3px solid blue;
}

.y {
Expand Down

0 comments on commit 5cccaf3

Please sign in to comment.