Skip to content

Commit

Permalink
Move styles to SCSS Modules
Browse files Browse the repository at this point in the history
Fixes: #4
  • Loading branch information
TBBle committed Aug 30, 2018
1 parent 72baf6d commit 948a20a
Show file tree
Hide file tree
Showing 17 changed files with 41 additions and 37 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,14 @@ The deployed version will appear at <https://www.tbble.org/monte-carlo-stefano/>

This project was bootstrapped with [Create React App](https://github.com/facebookincubator/create-react-app).

It currently depends on the [react-scripts 2.0.0 alpha releases](https://www.npmjs.com/package/react-scripts/v/next) for features such as CSS Modules and Sass integration.

You can find the originally-provided guide [here](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md).

### [Sass: Syntactically Awesome Style Sheets](https://sass-lang.com)

This project uses SCSS to define style sheets, see the [guide](https://sass-lang.com/guide).

### [CSS Modules](https://github.com/css-modules/css-modules)

This project uses CSS Modules to connect ReactJS components to their style.
12 changes: 6 additions & 6 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { Component } from 'react';
import './App.css';
import styles from './App.module.scss';
import ProjectDisplay from './ProjectDisplay';
import EpicDisplay from './EpicDisplay';

Expand Down Expand Up @@ -45,14 +45,14 @@ class App extends Component {
];

return (
<div className="App">
<header className="App-header">
<h1 className="App-title">Stefano's Monte Carlo thing</h1>
<div className={styles.App}>
<header className={styles.header}>
<h1 className={styles.title}>Stefano's Monte Carlo thing</h1>
</header>
<div className="App-left">
<div className={styles.left}>
<ProjectDisplay epics={EPICS} />
</div>
<div className="App-right">
<div className={styles.right}>
<EpicDisplay epics={EPICS} />
</div>
</div>
Expand Down
10 changes: 5 additions & 5 deletions src/App.css → src/App.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,26 @@
text-align: center;
}

.App-header {
.header {
background-color: #222;
padding: 20px;
color: white;
}

.App-title {
.title {
font-size: 1.5em;
}

.App-intro {
.intro {
font-size: large;
}

.App-left {
.left {
float: left;
border: 2px black solid;
}

.App-right {
.right {
float: right;
border: 2px black solid;
}
4 changes: 2 additions & 2 deletions src/Epic.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { Component } from 'react';
import { percentile, round } from './data';
import './Epic.css';
import styles from './Epic.module.scss';

function renderPercentiles(results) {
return (
Expand Down Expand Up @@ -46,7 +46,7 @@ class Epic extends Component {

render() {
return (
<tr className={this.props.selected ? 'Epic Epic-Selected' : 'Epic'}>
<tr className={this.props.selected ? styles.selected : undefined}>
<td>{this.props.epic.size}</td>
{this.renderPERT()}
{this.renderGaussian()}
Expand Down
2 changes: 1 addition & 1 deletion src/Epic.css → src/Epic.module.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
.Epic-Selected {
.selected {
font-weight: bold;
}
2 changes: 1 addition & 1 deletion src/EpicDisplay.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class EpicDisplay extends Component {
const selectedResults = results[selected];

return (
<div className="EpicDisplay">
<div>
<Graph
label={'Epic: ' + selectedEpics.size}
results={selectedResults}
Expand Down
4 changes: 2 additions & 2 deletions src/EpicList.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { Component } from 'react';
import './EpicList.css';
import styles from './EpicList.module.scss';
import Epic from './Epic';

class EpicList extends Component {
Expand All @@ -17,7 +17,7 @@ class EpicList extends Component {
});

return (
<div className="EpicList">
<div className={styles.epicList}>
<h2>Epics</h2>
<table>
<thead>
Expand Down
10 changes: 3 additions & 7 deletions src/EpicList.css → src/EpicList.module.scss
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
.EpicList {
.epicList {
border: 1px black solid;
}

.EpicList tr th {
.epicList tr th {
border: 1px black solid;
}

.EpicList tr td {
.epicList tr td {
border: 1px black dotted;
}

.error {
color: red;
}
6 changes: 3 additions & 3 deletions src/Graph.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { Component } from 'react';
import ReactEcharts from 'echarts-for-react';
import { round, percentile } from './data';

import './Graph.css';
import styles from './Graph.module.scss';

function tooltipValueFormatter(params) {
return params.seriesName + ': ' + params.value[1] + '%';
Expand All @@ -26,7 +26,7 @@ function tooltipFormatter(paramsList) {
class Graph extends Component {
render() {
return (
<div className="Graph">
<div className={styles.graph}>
<p>Rendering {this.props.label}</p>
<ReactEcharts style={{ height: '600px' }} option={this.getOption()} />
</div>
Expand Down Expand Up @@ -130,7 +130,7 @@ class Graph extends Component {
const count = values.length;
return [...new Set(values)].map(x => [
x,
values.filter(y => y === x).length * 100 / count,
(values.filter(y => y === x).length * 100) / count,
]);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Graph.css → src/Graph.module.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
.Graph {
.graph {
border: 1px black solid;
}
6 changes: 2 additions & 4 deletions src/Project.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { Component } from 'react';
import { percentile, round } from './data';
import './Project.css';
import styles from './Project.module.scss';

function renderPercentiles(results) {
return (
Expand Down Expand Up @@ -29,9 +29,7 @@ class Project extends Component {
epicCounts.push(<td key={index}>{count}</td>);
});
return (
<tr
className={this.props.selected ? 'Project Project-Selected' : 'Project'}
>
<tr className={this.props.selected ? styles.selected : undefined}>
<td>{project.id}</td>
{epicCounts}
{this.renderPERTPercentiles()}
Expand Down
2 changes: 1 addition & 1 deletion src/Project.css → src/Project.module.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
.Project-Selected {
.selected {
font-weight: bold;
}
2 changes: 1 addition & 1 deletion src/ProjectDisplay.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class ProjectDisplay extends Component {
: null;

return (
<div className="ProjectDisplay">
<div>
<Graph
label={'Project ' + selectedProjects.id}
results={selectedResults}
Expand Down
4 changes: 2 additions & 2 deletions src/ProjectList.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { Component } from 'react';
import './ProjectList.css';
import styles from './ProjectList.module.scss';
import Project from './Project';

class ProjectList extends Component {
Expand All @@ -23,7 +23,7 @@ class ProjectList extends Component {
);
});
return (
<div className="ProjectList">
<div className={styles.ProjectList}>
<h2>Projects</h2>
<table>
<thead>
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import ReactDOM from 'react-dom';
import ReactModal from 'react-modal';
import './index.css';
import './index.scss';
import App from './App';
import registerServiceWorker from './registerServiceWorker';

Expand Down
File renamed without changes.

0 comments on commit 948a20a

Please sign in to comment.