Skip to content

Commit

Permalink
Fix namespace + beautify
Browse files Browse the repository at this point in the history
  • Loading branch information
utokusa committed Feb 1, 2021
1 parent 92c10ad commit 1c48624
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 56 deletions.
104 changes: 50 additions & 54 deletions packages/react-juce/src/components/TextInput.tsx
Original file line number Diff line number Diff line change
@@ -1,104 +1,100 @@
import React, { PropsWithChildren } from 'react';
import React, { PropsWithChildren } from "react";

export interface InputEvent {
value: string
value: string;
}

export interface ChangeEvent {
value: string
value: string;
}

export interface TextInputProps {
value?: string,

color?: string,
fontSize?: number,
fontStyle?: number,
fontFamily?: string,
justification?: number,
'kerning-factor'?: number,

placeholder?: string,
'placeholder-color'?: string,
maxlength?: number,
readonly?: boolean,
'outline-color'?: string,
'focused-outline-color'?: string,
'highlighted-text-color'?: string,
'highlight-color'?: string,
'caret-color'?: string,

onChange?: (e: ChangeEvent) => void,
onInput?: (e: InputEvent) => void,
value?: string;

color?: string;
fontSize?: number;
fontStyle?: number;
fontFamily?: string;
justification?: number;
"kerning-factor"?: number;

placeholder?: string;
"placeholder-color"?: string;
maxlength?: number;
readonly?: boolean;
"outline-color"?: string;
"focused-outline-color"?: string;
"highlighted-text-color"?: string;
"highlight-color"?: string;
"caret-color"?: string;

onChange?: (e: ChangeEvent) => void;
onInput?: (e: InputEvent) => void;
}

/**
* TextInput component imitates web's `<input type="text">`.
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/text
* So it supports props like `placeholder`, `maxlength`, `onInput`, etc...
*
* TextInput also supports React's controlled components model:
* https://reactjs.org/docs/uncontrolled-components.html.
* If the user supplies a `value` prop,
* then it never renders anything into that text editor other than
* the string supplied by that `value` prop.
*/
* TextInput component imitates web's `<input type="text">`.
* https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/text
* So it supports props like `placeholder`, `maxlength`, `onInput`, etc...
*
* TextInput also supports React's controlled components model:
* https://reactjs.org/docs/uncontrolled-components.html.
* If the user supplies a `value` prop,
* then it never renders anything into that text editor other than
* the string supplied by that `value` prop.
*/
export function TextInput(props: PropsWithChildren<TextInputProps | any>) {
return React.createElement('TextInput', props, props.children);
return React.createElement("TextInput", props, props.children);
}

/*
// ================================================
// Example code
import React, { Component } from 'react';
import React, { Component } from "react";
import {
Text,
TextInput,
View,
} from 'react-juce';
import { Text, TextInput, View } from "react-juce";
class App extends Component {
constructor(props) {
super(props);
this._onInput = this._onInput.bind(this);
this.state = {
textValue: '',
}
textValue: "",
};
}
_onInput(event) {
console.log(`onInput: ${event.value}`);
this.setState({textValue: event.value});
this.setState({ textValue: event.value });
}
render() {
return (
<View>
<TextInput
value={this.state.textValue}
placeholder="init message"
onInput={this._onInput}
{...styles.text_input}
/>
value={this.state.textValue}
placeholder="init message"
onInput={this._onInput}
{...styles.text_input}
/>
</View>
);
}
}
const styles = {
text_input: {
backgroundColor: 'ff303030',
color: 'ff66FDCF',
backgroundColor: "ff303030",
color: "ff66FDCF",
fontSize: 15.0,
fontFamily: 'Menlo',
fontFamily: "Menlo",
fontStyle: Text.FontStyleFlags.bold,
'placeholder-color': 'ffaaaaaa',
"placeholder-color": "ffAAAAAA",
height: 30,
width: 200,
}
},
};
export default App;
Expand Down
2 changes: 1 addition & 1 deletion react_juce/core/TextInputView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include "TextInputView.h"
#include "TextView.h"

namespace blueprint
namespace reactjuce
{
namespace detail
{
Expand Down
2 changes: 1 addition & 1 deletion react_juce/core/TextInputView.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

#include "View.h"

namespace blueprint
namespace reactjuce
{
//==============================================================================
/** The TextInputView class is a core view for text editor
Expand Down

0 comments on commit 1c48624

Please sign in to comment.