Skip to content

Commit

Permalink
feat(language): add asset and inspector language
Browse files Browse the repository at this point in the history
  • Loading branch information
AmyOrz committed Mar 15, 2019
1 parent 2f49251 commit 9ef009d
Show file tree
Hide file tree
Showing 28 changed files with 947 additions and 207 deletions.
69 changes: 69 additions & 0 deletions public/css/index.css

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
.component-title{
font-size:14px;
margin-left:5%;
&:hover{
color: #00c1de;
cursor: pointer;
}
}
hr{
border: 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
.item-header{
margin-left:5px;
width:40%;
&:hover{
color: #00c1de;
cursor: pointer;
}
}
.item-content{
width:60%;
Expand Down
4 changes: 4 additions & 0 deletions public/sass/components/ui/_componentBox.scss
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@
height:30px;
line-height: 30px;
font-size:15px;
&:hover{
color: #00c1de;
cursor: pointer;
}
}
.header-close{
flex:initial;
Expand Down
4 changes: 4 additions & 0 deletions public/sass/utils/_inspectorItemMixin.scss
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
display: flex;
align-items: center;
margin-left:15px;
&:hover{
color: #00c1de;
cursor: pointer;
}
}
.item-content{
flex:initial;
Expand Down
33 changes: 20 additions & 13 deletions src/core/atom_component/floatInput/FloatInput.re
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@ type action =

module Method = {
let _change = event => {
let inputVal = ReactDOMRe.domElementToObj(
ReactEventRe.Form.target(event),
)##value;
let inputVal =
ReactDOMRe.domElementToObj(ReactEventRe.Form.target(event))##value;

switch (inputVal) {
| "" => Change(Some(""))
Expand Down Expand Up @@ -208,7 +207,7 @@ module Method = {
} :
();

let renderLabel = ((send, state), label, onDragDropFunc) =>
let renderLabel = ((send, state), label, title, onDragDropFunc) =>
switch (label) {
| None => ReasonReact.null
| Some(label) =>
Expand All @@ -218,8 +217,14 @@ module Method = {
onMouseMove=(event => handleDragOver(event, (send, state)))
onMouseUp=(
event => handleDragDrop(event, (send, state), onDragDropFunc)
)>
(DomHelper.textEl(label))
)
title={
switch (title) {
| None => ""
| Some(title) => title
}
}>
{DomHelper.textEl(label)}
</div>
};

Expand All @@ -228,14 +233,14 @@ module Method = {
<input
className="input-component float-input"
type_="text"
value=(
value={
switch (state.inputValue) {
| None => ""
| Some(value) => value
}
)
onChange=(_e => send(_change(_e)))
onBlur=(_e => send(Blur))
}
onChange={_e => send(_change(_e))}
onBlur={_e => send(Blur)}
/>
</div>;
};
Expand All @@ -255,12 +260,13 @@ let reducer = ((onChangeFunc, onBlurFunc), canBeZero, action, state) =>
let render =
(
label,
title,
(onBlurFunc, onDragDropFunc),
{state, handle, send}: ReasonReact.self('a, 'b, 'c),
) =>
<article className="inspector-item wonder-float-input">
(Method.renderLabel((send, state), label, onDragDropFunc))
(Method.renderContent((send, state)))
{Method.renderLabel((send, state), label, title, onDragDropFunc)}
{Method.renderContent((send, state))}
</article>;

let make =
Expand All @@ -271,6 +277,7 @@ let make =
~label: option(string)=?,
~onChange: option(float => unit)=?,
~onBlur: option(float => unit)=?,
~title: option(string)=?,
_children,
) => {
...component,
Expand All @@ -290,5 +297,5 @@ let make =
}
},
reducer: reducer((onChange, onBlur), canBeZero),
render: self => render(label, (onBlur, onDragDrop), self),
render: self => render(label, title, (onBlur, onDragDrop), self),
};
40 changes: 25 additions & 15 deletions src/core/atom_component/floatInput/ThreeFloatInput.re
Original file line number Diff line number Diff line change
Expand Up @@ -80,35 +80,44 @@ let reducer =
let render =
(
(uiState, dispatchFunc),
(gameObjectComponent, label, canBeZero),
(gameObjectComponent, label, canBeZero, title),
(changeXFunc, changeYFunc, changeZFunc),
{state, send}: ReasonReact.self('a, 'b, 'c),
) =>
<article className="inspector-item wonder-three-float-input">
<div className="item-header"> (DomHelper.textEl(label)) </div>
<div
className="item-header"
title={
switch (title) {
| None => ""
| Some(title) => title
}
}>
{DomHelper.textEl(label)}
</div>
<div className="item-content">
<FloatInput
label="X"
defaultValue=(state.x |> StringService.floatToString)
onChange=(changeXFunc(gameObjectComponent))
onBlur=(value => send(BlurX(value)))
onDragDrop=(value => send(DragDropX(value)))
defaultValue={state.x |> StringService.floatToString}
onChange={changeXFunc(gameObjectComponent)}
onBlur={value => send(BlurX(value))}
onDragDrop={value => send(DragDropX(value))}
canBeZero
/>
<FloatInput
label="Y"
defaultValue=(state.y |> StringService.floatToString)
onChange=(changeYFunc(gameObjectComponent))
onBlur=(value => send(BlurY(value)))
onDragDrop=(value => send(DragDropY(value)))
defaultValue={state.y |> StringService.floatToString}
onChange={changeYFunc(gameObjectComponent)}
onBlur={value => send(BlurY(value))}
onDragDrop={value => send(DragDropY(value))}
canBeZero
/>
<FloatInput
label="Z"
defaultValue=(state.z |> StringService.floatToString)
onChange=(changeZFunc(gameObjectComponent))
onBlur=(value => send(BlurZ(value)))
onDragDrop=(value => send(DragDropZ(value)))
defaultValue={state.z |> StringService.floatToString}
onChange={changeZFunc(gameObjectComponent)}
onBlur={value => send(BlurZ(value))}
onDragDrop={value => send(DragDropZ(value))}
canBeZero
/>
</div>
Expand All @@ -127,6 +136,7 @@ let make =
~blurEventFunc,
~dragDropFunc,
~canBeZero,
~title: option(string)=?,
_children,
) => {
...component,
Expand All @@ -145,7 +155,7 @@ let make =
render: self =>
render(
(uiState, dispatchFunc),
(gameObjectComponent, label, canBeZero),
(gameObjectComponent, label, canBeZero, title),
(changeXFunc, changeYFunc, changeZFunc),
self,
),
Expand Down
31 changes: 20 additions & 11 deletions src/core/atom_component/select/Select.re
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ module Method = {
let renderContent = (options, state) =>
options
|> Js.Array.map(({key, value}) =>
<option key=value value=(key |> string_of_int)>
(DomHelper.textEl(value))
<option key=value value={key |> string_of_int}>
{DomHelper.textEl(value)}
</option>
);
};
Expand All @@ -35,22 +35,30 @@ let reducer = (onChange, action) =>
)
};

let render = (label, options, {state, send}: ReasonReact.self('a, 'b, 'c)) =>
let render =
(label, options, title, {state, send}: ReasonReact.self('a, 'b, 'c)) =>
<article key="Select" className="inspector-item">
(
{
switch (label) {
| None => ReasonReact.null
| Some(label) =>
<div className="item-header">
<span className=""> (DomHelper.textEl(label)) </span>
<div
className="item-header"
title={
switch (title) {
| None => ""
| Some(title) => title
}
}>
<span className=""> {DomHelper.textEl(label)} </span>
</div>
}
)
}
<div className="item-content">
<select
onChange=(e => send(Method.change(e)))
value=(state.selectedKey |> string_of_int)>
(ReasonReact.array(Method.renderContent(options, state)))
onChange={e => send(Method.change(e))}
value={state.selectedKey |> string_of_int}>
{ReasonReact.array(Method.renderContent(options, state))}
</select>
</div>
</article>;
Expand All @@ -61,10 +69,11 @@ let make =
~options: array(optionItem),
~selectedKey: int,
~onChange: int => unit,
~title: option(string)=?,
_children,
) => {
...component,
initialState: () => {selectedKey: selectedKey},
reducer: reducer(onChange),
render: self => render(label, options, self),
render: self => render(label, options, title, self),
};
14 changes: 11 additions & 3 deletions src/core/atom_component/stringInput/StringInput.re
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,20 @@ let reducer = ((onChangeFunc, onBlurFunc), canBeNull, action, state) =>
| Blur => Method.handleBlurAction(state, canBeNull, onBlurFunc)
};

let render = (label, {state, send}: ReasonReact.self('a, 'b, 'c)) =>
let render = (label, title, {state, send}: ReasonReact.self('a, 'b, 'c)) =>
<article className="inspector-item">
{
switch (label) {
| None => ReasonReact.null
| Some(value) =>
<div className="item-header">
<div
className="item-header"
title={
switch (title) {
| None => ""
| Some(title) => title
}
}>
<span className="component-label"> {DomHelper.textEl(value)} </span>
</div>
}
Expand All @@ -90,6 +97,7 @@ let make =
(
~defaultValue: option(string)=?,
~label: option(string)=?,
~title: option(string)=?,
~onChange: option(string => unit)=?,
~onBlur: option(string => unit)=?,
~canBeNull: option(bool)=?,
Expand All @@ -102,5 +110,5 @@ let make =
| Some(value) => {inputValue: value, originalName: value}
},
reducer: reducer((onChange, onBlur), canBeNull),
render: self => render(label, self),
render: self => render(label, title, self),
};
Original file line number Diff line number Diff line change
Expand Up @@ -45,28 +45,22 @@ let _renderSelectNav =
<div
className="content-section"
onClick={_e => Method.addMaterial((uiState, dispatchFunc), (), ())}>
<div className="section-header">
{
DomHelper.textEl(
LanguageUtils.getAssetLanguageDataByType(
"asset-material",
languageType,
),
)
}
</div>
<div className="section-header"> {DomHelper.textEl("Material")} </div>
</div>
</div>;

let _renderRemoveItem =
(
uiState: AppStore.appState,
dispatchFunc,
languageType,
{state, send}: ReasonReact.self('a, 'b, 'c),
) =>
<div
className="asset-header-item"
title="remove asset"
title={
LanguageUtils.getAssetLanguageDataByType("asset-remove", languageType)
}
onClick={
_e =>
CurrentNodeIdAssetEditorService.couldRemoveCurrentNode
Expand Down Expand Up @@ -96,7 +90,9 @@ let render =
<article key="assetHeader" className="wonder-asset-header">
<div
className="asset-header-item"
title="add asset"
title={
LanguageUtils.getAssetLanguageDataByType("asset-add", languageType)
}
onClick={_e => send(ToggleShowNav)}>
<div className="item-canBeClick">
<img src="./public/img/add.png" />
Expand All @@ -107,9 +103,16 @@ let render =
ReasonReact.null
}
</div>
{_renderRemoveItem(uiState, dispatchFunc, self)}
{_renderRemoveItem(uiState, dispatchFunc, languageType, self)}
<div className="asset-header-item">
<div className="item-canBeClick" title="load asset">
<div
className="item-canBeClick"
title={
LanguageUtils.getAssetLanguageDataByType(
"asset-load",
languageType,
)
}>
<img src="./public/img/load.png" />
<input
className="asset-fileLoad"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ let render =
({state, send}: ReasonReact.self('a, 'b, 'c)) as self,
) =>
<article className="inspector-item">
<div className="item-header"> {DomHelper.textEl(label)} </div>
<div className="item-header" title> {DomHelper.textEl(label)} </div>
<div className="item-content item-color">
<div
className="color-hex"
style={ReactDOMRe.Style.make(~background=state.colorHex, ())}
onClick={_e => send(ShowColorPick)}
/>
<div title className="color-select" onClick={_e => send(ShowColorPick)}>
<div className="color-select" onClick={_e => send(ShowColorPick)}>
<img src="./public/img/color.png" />
</div>
</div>
Expand Down
Loading

0 comments on commit 9ef009d

Please sign in to comment.