Skip to content

Commit c9c2b82

Browse files
committed
add module css
1 parent 9eb9bde commit c9c2b82

File tree

5 files changed

+23
-20
lines changed

5 files changed

+23
-20
lines changed

src/input/Input.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22
import {JSON, request} from "./api";
3-
import './Input.css'
3+
import styles from './Input.module.css'
44

55
export class Input extends React.Component {
66
constructor(props) {
@@ -34,10 +34,11 @@ export class Input extends React.Component {
3434
}
3535

3636
render() {
37+
console.log(styles);
3738
return (
38-
<form className="form" onSubmit={this.handleSubmit}>
39-
<input className="input" type="text" value={this.state.value} onChange={this.handleChange}/>
40-
<button className="btn" onClick={this.handleSubmit}>Go!</button>
39+
<form className={styles.form} onSubmit={this.handleSubmit}>
40+
<input className={styles.input} type="text" value={this.state.value} onChange={this.handleChange}/>
41+
<button className={styles.btn} onClick={this.handleSubmit}>Go!</button>
4142
</form>
4243
)
4344
}
File renamed without changes.

src/tree/Json.js

+9-8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import classnames from 'classnames';
22
import React from 'react';
3+
import styles from './Json.module.css';
34
import {JsonObject} from "./JsonObject";
4-
import './Json.css'
55

66
export class Json extends React.Component {
77
constructor(props) {
@@ -26,7 +26,8 @@ export class Json extends React.Component {
2626
const {json} = this.props;
2727
const {folded} = this.state;
2828

29-
const dotsClass = classnames({hid: !folded});
29+
const dotsClass = classnames({[styles.hid]: !folded});
30+
console.log(dotsClass);
3031
if (!json) {
3132
return null;
3233
}
@@ -42,10 +43,10 @@ export class Json extends React.Component {
4243
const {folded} = this.state;
4344

4445
const keyClass = classnames({
45-
key: true,
46-
'key-minus': !folded,
47-
'key-foldable': isFoldable,
48-
'key-empty': !keyName
46+
[styles.key]: true,
47+
[styles.keyMinus]: !folded,
48+
[styles.keyFoldable]: isFoldable,
49+
[styles.keyEmpty]: !keyName
4950
});
5051
return <span className={keyClass} onClick={this.fold.bind(this)}>{keyName ? `${keyName}:` : ''}</span>
5152
}
@@ -56,11 +57,11 @@ export class Json extends React.Component {
5657
return <span></span>
5758
}
5859
const {folded} = this.state;
59-
const jsonClass = classnames({hid: folded});
60+
const jsonClass = classnames({[styles.hid]: folded});
6061

6162

6263
return (
63-
<div className={`json ${className || ''}`}>
64+
<div className={`${styles.json} ${className || ''}`}>
6465
{this.renderKey()}
6566
{this.renderFoldedData()}
6667
<JsonObject className={jsonClass} json={json}/>

src/tree/Json.css renamed to src/tree/Json.module.css

+4-3
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,16 @@
2222
color: rgba(0, 0, 0, .5);
2323
}
2424

25-
.key-empty{
25+
.keyEmpty {
2626
margin: 0;
2727
}
28-
.key-foldable:before {
28+
29+
.keyFoldable:before {
2930
content: '+';
3031
text-align: center;
3132
}
3233

33-
.key-foldable.key-minus:before {
34+
.keyFoldable.keyMinus:before {
3435
content: '-';
3536
}
3637

src/tree/JsonObject.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22
import {Json} from "./Json";
3-
import './Json.css'
3+
import styles from './Json.module.css';
44

55
export class JsonObject extends React.Component {
66
renderArray(json) {
@@ -13,11 +13,11 @@ export class JsonObject extends React.Component {
1313
return (
1414
<span className={className}>
1515
[
16-
<div className="json">
16+
<div className={styles.json}>
1717
{
1818
json.map((el, i) => {
1919
const lastElement = i === json.length - 1;
20-
return (<span className="json" key={i}>
20+
return (<span className={styles.json} key={i}>
2121
<Json json={el} showComma={!lastElement}/>
2222
</span>)
2323
})
@@ -35,9 +35,9 @@ export class JsonObject extends React.Component {
3535
return (
3636
<span className={className}>
3737
&#123;
38-
<div className="json">
38+
<div className={styles.json}>
3939
{Object.keys(json).map((keyName, i) => {
40-
const lastElement = i !== keysArr.length - 1;
40+
const lastElement = i === keysArr.length - 1;
4141
const el = json[keyName];
4242

4343
return (

0 commit comments

Comments
 (0)