Skip to content

Commit fc3ed30

Browse files
authored
improvement: Move inline styles to SCSS instead (#5578)
* fix: convert propStyle to propClass
1 parent 67627d7 commit fc3ed30

30 files changed

+282
-70
lines changed

src/core/components/array-model.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React, { Component } from "react"
22
import PropTypes from "prop-types"
33
import ImPropTypes from "react-immutable-proptypes"
44

5-
const propStyle = { color: "#999", fontStyle: "italic" }
5+
const propClass = "property"
66

77
export default class ArrayModel extends Component {
88
static propTypes = {
@@ -44,7 +44,7 @@ export default class ArrayModel extends Component {
4444
<ModelCollapse title={titleEl} expanded={ depth <= expandDepth } collapsedContent="[...]">
4545
[
4646
{
47-
properties.size ? properties.entrySeq().map( ( [ key, v ] ) => <Property key={`${key}-${v}`} propKey={ key } propVal={ v } propStyle={ propStyle } />) : null
47+
properties.size ? properties.entrySeq().map( ( [ key, v ] ) => <Property key={`${key}-${v}`} propKey={ key } propVal={ v } propClass={ propClass } />) : null
4848
}
4949
{
5050
!description ? (properties.size ? <div className="markdown"></div> : null) :

src/core/components/auth/error.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ export default class AuthError extends React.Component {
1515
let source = error.get("source")
1616

1717
return (
18-
<div className="errors" style={{ backgroundColor: "#ffeeee", color: "red", margin: "1em" }}>
19-
<b style={{ textTransform: "capitalize", marginRight: "1em"}} >{ source } { level }</b>
18+
<div className="errors">
19+
<b>{ source } { level }</b>
2020
<span>{ message }</span>
2121
</div>
2222
)

src/core/components/curl.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export default class Curl extends React.Component {
2020
<div>
2121
<h4>Curl</h4>
2222
<div className="copy-paste">
23-
<textarea onFocus={this.handleFocus} readOnly={true} className="curl" style={{ whiteSpace: "normal" }} value={curl}></textarea>
23+
<textarea onFocus={this.handleFocus} readOnly={true} className="curl" value={curl}></textarea>
2424
</div>
2525
</div>
2626
)

src/core/components/errors.jsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,10 @@ const ThrownErrorItem = ( { error, jumpToLine } ) => {
7272
<h4>{ (error.get("source") && error.get("level")) ?
7373
toTitleCase(error.get("source")) + " " + error.get("level") : "" }
7474
{ error.get("path") ? <small> at {error.get("path")}</small>: null }</h4>
75-
<span style={{ whiteSpace: "pre-line", "maxWidth": "100%" }}>
75+
<span className="message thrown">
7676
{ error.get("message") }
7777
</span>
78-
<div style={{ "text-decoration": "underline", "cursor": "pointer" }}>
78+
<div className="error-line">
7979
{ errorLine && jumpToLine ? <a onClick={jumpToLine.bind(null, errorLine)}>Jump to line { errorLine }</a> : null }
8080
</div>
8181
</div>
@@ -102,8 +102,8 @@ const SpecErrorItem = ( { error, jumpToLine } ) => {
102102
{ !error ? null :
103103
<div>
104104
<h4>{ toTitleCase(error.get("source")) + " " + error.get("level") }&nbsp;{ locationMessage }</h4>
105-
<span style={{ whiteSpace: "pre-line"}}>{ error.get("message") }</span>
106-
<div style={{ "text-decoration": "underline", "cursor": "pointer" }}>
105+
<span className="message">{ error.get("message") }</span>
106+
<div className="error-line">
107107
{ jumpToLine ? (
108108
<a onClick={jumpToLine.bind(null, error.get("line"))}>Jump to line { error.get("line") }</a>
109109
) : null }

src/core/components/headers.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from "react"
22
import PropTypes from "prop-types"
33
import Im from "immutable"
44

5-
const propStyle = { color: "#999", fontStyle: "italic" }
5+
const propClass = "header-example"
66

77
export default class Headers extends React.Component {
88
static propTypes = {
@@ -46,7 +46,7 @@ export default class Headers extends React.Component {
4646
<td className="header-col">{
4747
!description ? null : <Markdown source={ description } />
4848
}</td>
49-
<td className="header-col">{ type } { schemaExample ? <Property propKey={ "Example" } propVal={ schemaExample } propStyle={ propStyle } /> : null }</td>
49+
<td className="header-col">{ type } { schemaExample ? <Property propKey={ "Example" } propVal={ schemaExample } propClass={ propClass } /> : null }</td>
5050
</tr>)
5151
}).toArray()
5252
}

src/core/components/layout-utils.jsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,14 @@ export class Col extends React.Component {
7373
}
7474
}
7575

76+
if (hide) {
77+
classesAr.push("hidden")
78+
}
79+
7680
let classes = xclass(rest.className, ...classesAr)
7781

7882
return (
79-
<section {...rest} style={{display: hide ? "none": null}} className={classes}/>
83+
<section {...rest} className={classes}/>
8084
)
8185
}
8286

@@ -213,7 +217,7 @@ Link.propTypes = {
213217
className: PropTypes.string
214218
}
215219

216-
const NoMargin = ({children}) => <div style={{height: "auto", border: "none", margin: 0, padding: 0}}> {children} </div>
220+
const NoMargin = ({children}) => <div className="no-margin"> {children} </div>
217221

218222
NoMargin.propTypes = {
219223
children: PropTypes.node

src/core/components/layouts/base.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export default class BaseLayout extends React.Component {
5757
if (loadingStatus === "failedConfig") {
5858
const lastErr = errSelectors.lastError()
5959
const lastErrMsg = lastErr ? lastErr.get("message") : ""
60-
loadingMessage = <div className="info" style={{ maxWidth: "880px", marginLeft: "auto", marginRight: "auto", textAlign: "center" }}>
60+
loadingMessage = <div className="info failed-config">
6161
<div className="loading-container">
6262
<h4 className="title">Failed to load remote configuration.</h4>
6363
<p>{lastErrMsg}</p>

src/core/components/model-collapse.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ export default class ModelCollapse extends Component {
7171

7272
return (
7373
<span className={classes || ""}>
74-
{ title && <span onClick={this.toggleCollapsed} style={{ "cursor": "pointer" }}>{title}</span> }
75-
<span onClick={ this.toggleCollapsed } style={{ "cursor": "pointer" }}>
74+
{ title && <span onClick={this.toggleCollapsed} className="pointer">{title}</span> }
75+
<span onClick={ this.toggleCollapsed } className="pointer">
7676
<span className={ "model-toggle" + ( this.state.expanded ? "" : " collapsed" ) }></span>
7777
</span>
7878
{ this.state.expanded ? this.props.children :this.state.collapsedContent }

src/core/components/model.jsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,7 @@ export default class Model extends ImmutablePureComponent {
5353
if(!schema) {
5454
return <span className="model model-title">
5555
<span className="model-title__text">{ displayName || name }</span>
56-
<img src={require("core/../img/rolling-load.svg")} height={"20px"} width={"20px"} style={{
57-
marginLeft: "1em",
58-
position: "relative",
59-
bottom: "0px"
60-
}} />
56+
<img src={require("core/../img/rolling-load.svg")} height={"20px"} width={"20px"} />
6157
</span>
6258
}
6359

src/core/components/object-model.jsx

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ export default class ObjectModel extends Component {
7979
{
8080
<table className="model"><tbody>
8181
{
82-
!description ? null : <tr style={{ color: "#666", fontWeight: "normal" }}>
83-
<td style={{ fontWeight: "bold" }}>description:</td>
82+
!description ? null : <tr className="description">
83+
<td>description:</td>
8484
<td>
8585
<Markdown source={ description } />
8686
</td>
@@ -91,16 +91,22 @@ export default class ObjectModel extends Component {
9191
([key, value]) => {
9292
let isDeprecated = isOAS3() && value.get("deprecated")
9393
let isRequired = List.isList(requiredProperties) && requiredProperties.contains(key)
94-
let propertyStyle = { verticalAlign: "top", paddingRight: "0.2em" }
95-
if ( isRequired ) {
96-
propertyStyle.fontWeight = "bold"
94+
95+
let classNames = ["property-row"]
96+
97+
if (isDeprecated) {
98+
classNames.push("deprecated")
99+
}
100+
101+
if (isRequired) {
102+
classNames.push("required")
97103
}
98104

99-
return (<tr key={key} className={isDeprecated && "deprecated"}>
100-
<td style={ propertyStyle }>
101-
{ key }{ isRequired && <span style={{ color: "red" }}>*</span> }
105+
return (<tr key={key} className={classNames.join(" ")}>
106+
<td>
107+
{ key }{ isRequired && <span className="star">*</span> }
102108
</td>
103-
<td style={{ verticalAlign: "top" }}>
109+
<td>
104110
<Model key={ `object-${name}-${key}_${value}` } { ...otherProps }
105111
required={ isRequired }
106112
getComponent={ getComponent }
@@ -126,11 +132,11 @@ export default class ObjectModel extends Component {
126132

127133
const normalizedValue = !value ? null : value.toJS ? value.toJS() : value
128134

129-
return (<tr key={key} style={{ color: "#777" }}>
135+
return (<tr key={key} className="extension">
130136
<td>
131137
{ key }
132138
</td>
133-
<td style={{ verticalAlign: "top" }}>
139+
<td>
134140
{ JSON.stringify(normalizedValue) }
135141
</td>
136142
</tr>)

0 commit comments

Comments
 (0)