mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-23 00:01:36 +00:00
[web] options: add some styling, minor fixes
This commit is contained in:
parent
babd967eb8
commit
183079f731
@ -16,11 +16,16 @@ BooleanOption.PropTypes = {
|
|||||||
}
|
}
|
||||||
function BooleanOption({ value, onChange, ...props }) {
|
function BooleanOption({ value, onChange, ...props }) {
|
||||||
return (
|
return (
|
||||||
<input type="checkbox"
|
<div className="checkbox">
|
||||||
checked={value}
|
<label>
|
||||||
onChange={e => onChange(e.target.checked)}
|
<input type="checkbox"
|
||||||
{...props}
|
checked={value}
|
||||||
/>
|
onChange={e => onChange(e.target.checked)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
Enable
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,6 +42,14 @@ function StringOption({ value, onChange, ...props }) {
|
|||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
function Optional(Component) {
|
||||||
|
return function ({ onChange, ...props }) {
|
||||||
|
return <Component
|
||||||
|
onChange={x => onChange(x ? x : null)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
NumberOption.PropTypes = {
|
NumberOption.PropTypes = {
|
||||||
value: PropTypes.number.isRequired,
|
value: PropTypes.number.isRequired,
|
||||||
@ -81,7 +94,7 @@ function StringSequenceOption({ value, onChange, ...props }) {
|
|||||||
return <textarea
|
return <textarea
|
||||||
rows={height}
|
rows={height}
|
||||||
value={value.join("\n")}
|
value={value.join("\n")}
|
||||||
onChange={e => onChange(e.target.value.split("\n"))}
|
onChange={e => onChange(e.target.value.split("\n").filter(x => x.trim()))}
|
||||||
{...props}
|
{...props}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
@ -90,24 +103,28 @@ const Options = {
|
|||||||
"bool": BooleanOption,
|
"bool": BooleanOption,
|
||||||
"str": StringOption,
|
"str": StringOption,
|
||||||
"int": NumberOption,
|
"int": NumberOption,
|
||||||
"optional str": StringOption,
|
"optional str": Optional(StringOption),
|
||||||
"sequence of str": StringSequenceOption,
|
"sequence of str": StringSequenceOption,
|
||||||
}
|
}
|
||||||
|
|
||||||
function PureOption({ choices, type, value, onChange }) {
|
function PureOption({ choices, type, value, onChange, name }) {
|
||||||
|
let Opt, props = {}
|
||||||
if (choices) {
|
if (choices) {
|
||||||
return <ChoicesOption
|
Opt = ChoicesOption;
|
||||||
value={value}
|
props.choices = choices
|
||||||
onChange={onChange}
|
} else {
|
||||||
choices={choices}
|
Opt = Options[type]
|
||||||
onKeyDown={stopPropagation}
|
|
||||||
/>
|
|
||||||
}
|
}
|
||||||
const Opt = Options[type]
|
if (Opt !== BooleanOption) {
|
||||||
|
props.className = "form-control"
|
||||||
|
}
|
||||||
|
|
||||||
return <Opt
|
return <Opt
|
||||||
|
name={name}
|
||||||
value={value}
|
value={value}
|
||||||
onChange={onChange}
|
onChange={onChange}
|
||||||
onKeyDown={stopPropagation}
|
onKeyDown={stopPropagation}
|
||||||
|
{...props}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
export default connect(
|
export default connect(
|
||||||
|
@ -4,7 +4,7 @@ import * as modalAction from "../../ducks/ui/modal"
|
|||||||
import Option from "./Option"
|
import Option from "./Option"
|
||||||
|
|
||||||
function PureOptionHelp({help}){
|
function PureOptionHelp({help}){
|
||||||
return <div className="small text-muted">{help}</div>;
|
return <div className="help-block small">{help}</div>;
|
||||||
}
|
}
|
||||||
const OptionHelp = connect((state, {name}) => ({
|
const OptionHelp = connect((state, {name}) => ({
|
||||||
help: state.options[name].help,
|
help: state.options[name].help,
|
||||||
@ -42,12 +42,12 @@ class PureOptionModal extends Component {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="modal-body">
|
<div className="modal-body">
|
||||||
<div className="container-fluid">
|
<div className="form-horizontal">
|
||||||
{
|
{
|
||||||
options.map(name =>
|
options.map(name =>
|
||||||
<div key={name} className="row">
|
<div key={name} className="form-group">
|
||||||
<div className="col-xs-6">
|
<div className="col-xs-6">
|
||||||
{name}
|
<label htmlFor={name}>{name}</label>
|
||||||
<OptionHelp name={name}/>
|
<OptionHelp name={name}/>
|
||||||
</div>
|
</div>
|
||||||
<div className="col-xs-6">
|
<div className="col-xs-6">
|
||||||
|
Loading…
Reference in New Issue
Block a user