-
-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support border animation property and editor
- Loading branch information
Showing
21 changed files
with
537 additions
and
204 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
import { CLICK, LOAD } from "../../../util/Event"; | ||
import { editor } from "../../../editor/editor"; | ||
import UIElement, { EVENT } from "../../../util/UIElement"; | ||
import BorderValueEditor from "./BorderValueEditor"; | ||
import Border from "../../../editor/css-property/Border"; | ||
|
||
const borderTypeList = ["border", "border-top", "border-right", "border-bottom", "border-left"] | ||
const borderTypeTitle = { | ||
"border": 'Border', | ||
"border-top": 'Top', | ||
"border-right": 'Right', | ||
"border-bottom": 'Bottom', | ||
"border-left": 'Left' | ||
} | ||
|
||
|
||
export default class BorderEditor extends UIElement { | ||
|
||
components() { | ||
return { | ||
BorderValueEditor | ||
} | ||
} | ||
|
||
initState() { | ||
|
||
var borders = Border.parseStyle(this.props.value) | ||
var direction = Object.keys(borders)[0] || 'border' | ||
|
||
return { | ||
direction, | ||
borders | ||
} | ||
} | ||
|
||
updateData(obj) { | ||
this.setState(obj, false); | ||
this.parent.trigger(this.props.onchange, this.props.key, this.getValue(), this.props.params); | ||
} | ||
|
||
getValue() { | ||
return Border.join(this.state.borders) | ||
} | ||
|
||
setValue(value) { | ||
this.state.borders = Border.parseStyle(value); | ||
this.refresh(); | ||
} | ||
|
||
refresh () { | ||
this.load(); | ||
|
||
} | ||
|
||
|
||
[LOAD('$editorArea')] () { | ||
return borderTypeList.map(type => { | ||
var label = borderTypeTitle[type] || type; | ||
return /*html*/` | ||
<div> | ||
<BorderValueEditor ref='$${type}' label='${label}' key="${type}" value="${this.state.borders[type]}" onchange="changeKeyValue" /> | ||
</div> | ||
` | ||
}) | ||
} | ||
|
||
template() { | ||
return /*html*/` | ||
<div class="border-editor"> | ||
<div class='header'> | ||
<div></div> | ||
<label>Width</label> | ||
<label>Style</label> | ||
<label>Color</label> | ||
</div> | ||
<div class='editor-area' ref='$editorArea'> | ||
</div> | ||
</div> | ||
`; | ||
} | ||
|
||
|
||
[EVENT('changeKeyValue')] (key, value) { | ||
var borders = this.state.borders; | ||
borders[key] = value; | ||
|
||
this.updateData({ borders }) | ||
} | ||
|
||
} |
Oops, something went wrong.