Skip to content

Commit

Permalink
Support border animation property and editor
Browse files Browse the repository at this point in the history
  • Loading branch information
easylogic committed Sep 19, 2019
1 parent 7c3f992 commit d03170e
Show file tree
Hide file tree
Showing 21 changed files with 537 additions and 204 deletions.
186 changes: 74 additions & 112 deletions docs/bundle.css
Original file line number Diff line number Diff line change
Expand Up @@ -3359,78 +3359,43 @@ html, body {
padding-right: 5px;
vertical-align: middle;
}
.csseditor[data-theme=dark] .border-item .border-direction {
position: relative;
display: block;
padding: 2px 10px;
}
.csseditor[data-theme=dark] .border-item .border-direction[data-selected-value=all] button[data-value=all] {
opacity: 1;
}
.csseditor[data-theme=dark] .border-item .border-direction[data-selected-value=top] button[data-value=top] {
opacity: 1;
}
.csseditor[data-theme=dark] .border-item .border-direction[data-selected-value=right] button[data-value=right] {
opacity: 1;
}
.csseditor[data-theme=dark] .border-item .border-direction[data-selected-value=bottom] button[data-value=bottom] {
opacity: 1;
}
.csseditor[data-theme=dark] .border-item .border-direction[data-selected-value=left] button[data-value=left] {
opacity: 1;
}
.csseditor[data-theme=dark] .border-item .border-direction button {
padding: 0px;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
border: 3px solid #ccc;
box-sizing: border-box;
cursor: pointer;
opacity: 0.7;
outline: none;
display: inline-block;
vertical-align: middle;
width: 20px;
height: 20px;
margin-right: 10px;
background-color: #2f3538;
}
.csseditor[data-theme=dark] .border-item .border-direction button[data-value=all] {
border: 3px solid #fc554f;
}
.csseditor[data-theme=dark] .border-item .border-direction button[data-value=top] {
border-top: 3px solid #fc554f;
}
.csseditor[data-theme=dark] .border-item .border-direction button[data-value=right] {
border-right: 3px solid #fc554f;
}
.csseditor[data-theme=dark] .border-item .border-direction button[data-value=bottom] {
border-bottom: 3px solid #fc554f;
}
.csseditor[data-theme=dark] .border-item .border-direction button[data-value=left] {
border-left: 3px solid #fc554f;
.csseditor[data-theme=dark] .border-editor .header {
display: grid;
grid-template-columns: repeat(4, 1fr);
grid-column-gap: 2px;
text-align: center;
}
.csseditor[data-theme=dark] .border-item .editor-area {
.csseditor[data-theme=dark] .border-editor > .editor-area {
padding: 5px 0px;
}
.csseditor[data-theme=dark] .border-item .input-group {
.csseditor[data-theme=dark] .border-editor > .editor-area > div > label {
padding: 2px 0px;
text-transform: uppercase;
font-weight: bold;
text-shadow: 0px 0px 2px #111111;
}
.csseditor[data-theme=dark] .border-editor .input-group {
display: grid;
grid-template-rows: repeat(3, 1fr);
}
.csseditor[data-theme=dark] .border-item .input-field {
.csseditor[data-theme=dark] .border-editor .input-field {
display: grid;
grid-template-columns: 1fr 3fr;
grid-column-gap: 4px;
vertical-align: middle;
}
.csseditor[data-theme=dark] .border-item .input-field input {
.csseditor[data-theme=dark] .border-editor .input-field input {
width: 100%;
vertical-align: middle;
}
.csseditor[data-theme=dark] .border-item .input-field .input-ui {
.csseditor[data-theme=dark] .border-editor .input-field .input-ui {
vertical-align: middle;
}
.csseditor[data-theme=dark] .border-value-editor {
display: grid;
grid-template-columns: repeat(4, 1fr);
grid-column-gap: 2px;
}
.csseditor[data-theme=dark] .border-slice-item {
display: grid;
grid-template-columns: 50px 1fr;
Expand Down Expand Up @@ -5215,6 +5180,22 @@ html, body {
.csseditor[data-theme=dark] .color-view-editor .remove {
display: none;
}
.csseditor[data-theme=dark] .color-single-editor {
height: 19px;
text-align: center;
width: 100%;
}
.csseditor[data-theme=dark] .color-single-editor .preview {
height: 100%;
}
.csseditor[data-theme=dark] .color-single-editor .preview .mini-view {
height: 100%;
}
.csseditor[data-theme=dark] .color-single-editor .preview .mini-view .color-view {
cursor: pointer;
height: 100%;
border-radius: 3px;
}
.csseditor[data-theme=dark] .range-editor {
display: grid;
grid-template-columns: 1fr;
Expand Down Expand Up @@ -10918,78 +10899,43 @@ html, body {
padding-right: 5px;
vertical-align: middle;
}
.csseditor[data-theme=light] .border-item .border-direction {
position: relative;
display: block;
padding: 2px 10px;
}
.csseditor[data-theme=light] .border-item .border-direction[data-selected-value=all] button[data-value=all] {
opacity: 1;
}
.csseditor[data-theme=light] .border-item .border-direction[data-selected-value=top] button[data-value=top] {
opacity: 1;
}
.csseditor[data-theme=light] .border-item .border-direction[data-selected-value=right] button[data-value=right] {
opacity: 1;
}
.csseditor[data-theme=light] .border-item .border-direction[data-selected-value=bottom] button[data-value=bottom] {
opacity: 1;
}
.csseditor[data-theme=light] .border-item .border-direction[data-selected-value=left] button[data-value=left] {
opacity: 1;
}
.csseditor[data-theme=light] .border-item .border-direction button {
padding: 0px;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
border: 3px solid #ccc;
box-sizing: border-box;
cursor: pointer;
opacity: 0.7;
outline: none;
display: inline-block;
vertical-align: middle;
width: 20px;
height: 20px;
margin-right: 10px;
background-color: white;
}
.csseditor[data-theme=light] .border-item .border-direction button[data-value=all] {
border: 3px solid #4b61ce;
}
.csseditor[data-theme=light] .border-item .border-direction button[data-value=top] {
border-top: 3px solid #4b61ce;
}
.csseditor[data-theme=light] .border-item .border-direction button[data-value=right] {
border-right: 3px solid #4b61ce;
}
.csseditor[data-theme=light] .border-item .border-direction button[data-value=bottom] {
border-bottom: 3px solid #4b61ce;
}
.csseditor[data-theme=light] .border-item .border-direction button[data-value=left] {
border-left: 3px solid #4b61ce;
.csseditor[data-theme=light] .border-editor .header {
display: grid;
grid-template-columns: repeat(4, 1fr);
grid-column-gap: 2px;
text-align: center;
}
.csseditor[data-theme=light] .border-item .editor-area {
.csseditor[data-theme=light] .border-editor > .editor-area {
padding: 5px 0px;
}
.csseditor[data-theme=light] .border-item .input-group {
.csseditor[data-theme=light] .border-editor > .editor-area > div > label {
padding: 2px 0px;
text-transform: uppercase;
font-weight: bold;
text-shadow: 0px 0px 2px #e7e7e7;
}
.csseditor[data-theme=light] .border-editor .input-group {
display: grid;
grid-template-rows: repeat(3, 1fr);
}
.csseditor[data-theme=light] .border-item .input-field {
.csseditor[data-theme=light] .border-editor .input-field {
display: grid;
grid-template-columns: 1fr 3fr;
grid-column-gap: 4px;
vertical-align: middle;
}
.csseditor[data-theme=light] .border-item .input-field input {
.csseditor[data-theme=light] .border-editor .input-field input {
width: 100%;
vertical-align: middle;
}
.csseditor[data-theme=light] .border-item .input-field .input-ui {
.csseditor[data-theme=light] .border-editor .input-field .input-ui {
vertical-align: middle;
}
.csseditor[data-theme=light] .border-value-editor {
display: grid;
grid-template-columns: repeat(4, 1fr);
grid-column-gap: 2px;
}
.csseditor[data-theme=light] .border-slice-item {
display: grid;
grid-template-columns: 50px 1fr;
Expand Down Expand Up @@ -12774,6 +12720,22 @@ html, body {
.csseditor[data-theme=light] .color-view-editor .remove {
display: none;
}
.csseditor[data-theme=light] .color-single-editor {
height: 19px;
text-align: center;
width: 100%;
}
.csseditor[data-theme=light] .color-single-editor .preview {
height: 100%;
}
.csseditor[data-theme=light] .color-single-editor .preview .mini-view {
height: 100%;
}
.csseditor[data-theme=light] .color-single-editor .preview .mini-view .color-view {
cursor: pointer;
height: 100%;
border-radius: 3px;
}
.csseditor[data-theme=light] .range-editor {
display: grid;
grid-template-columns: 1fr;
Expand Down
Binary file modified docs/bundle.css.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion docs/main.js

Large diffs are not rendered by default.

Binary file modified docs/main.js.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion src/csseditor/ui/control/Inspector.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export default class Inspector extends UIElement {
<BoxModelProperty />
<BackgroundColorProperty />
<BackgroundImageProperty />
<BorderProperty />
<BorderNewProperty />
<BorderRadiusProperty />
<!-- effect -->
Expand Down
91 changes: 91 additions & 0 deletions src/csseditor/ui/property-editor/BorderEditor.js
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 })
}

}
Loading

0 comments on commit d03170e

Please sign in to comment.