Skip to content

Commit

Permalink
JSS Styles rework (#139)
Browse files Browse the repository at this point in the history
Replace SASS with JSS.
  • Loading branch information
nfour authored and brendo committed Jun 27, 2017
1 parent ff85059 commit b9ca5dc
Show file tree
Hide file tree
Showing 83 changed files with 1,277 additions and 985 deletions.
1 change: 1 addition & 0 deletions .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"stage-2"
],
"plugins": [
"transform-decorators-legacy",
["transform-runtime", {
"helpers": true,
"polyfill": false,
Expand Down
4 changes: 2 additions & 2 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ module.exports = {
'node_modules'
],
moduleNameMapper: {
'balloon-css': '<rootDir>/src/__mocks__/styleMock.js',
'\\.(css|scss)$': '<rootDir>/src/__mocks__/styleMock.js',
'\\.styles$': '<rootDir>/src/__mocks__/stylesMock.js',
'\\.(css|scss)$': 'identity-obj-proxy',
'\\.(jpg|jpeg|png|gif|svg)$': '<rootDir>/src/__mocks__/fileMock.js'
},
moduleFileExtensions: [
Expand Down
9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,12 @@
},
"dependencies": {
"classnames": "^2.2.5",
"color": "^1.0.3",
"copy-to-clipboard": "^3.0.6",
"history": "^4.6.1",
"js-yaml": "^3.8.4",
"json-schema-ref-parser": "^3.1.2",
"jss": "^7.1.7",
"lodash": "^4.17.4",
"markdown-it": "^8.3.1",
"prop-types": "^15.5.8",
Expand All @@ -62,6 +64,7 @@
"react-document-title": "^2.0.2",
"react-dom": "^15.5.4",
"react-json-view": "^1.8.4",
"react-jss": "^6.1.1",
"react-router": "^4.1.1",
"react-router-dom": "^4.1.1",
"react-scrollable-anchor": "^0.4.2",
Expand All @@ -72,14 +75,14 @@
"babel-eslint": "^7.2.1",
"babel-jest": "^20.0.3",
"babel-loader": "^7.0.0",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-preset-env": "^1.5.2",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.23.0",
"babel-preset-stage-2": "^6.24.1",
"babel-regenerator-runtime": "^6.5.0",
"babel-runtime": "^6.23.0",
"balloon-css": "^0.4.0",
"css-loader": "^0.28.4",
"eslint": "^4.0.0",
"eslint-config-standard": "^10.2.1",
Expand All @@ -90,16 +93,16 @@
"eslint-plugin-react": "^7.0.1",
"eslint-plugin-standard": "^3.0.1",
"file-loader": "^0.11.2",
"font-loader": "^0.1.2",
"fs-extra": "^3.0.1",
"html-webpack-plugin": "^2.28.0",
"identity-obj-proxy": "^3.0.0",
"jest": "^20.0.4",
"json-loader": "^0.5.4",
"node-sass": "^4.5.1",
"react-addons-perf": "^15.4.2",
"react-dev-utils": "^3.0.0",
"react-test-renderer": "^15.5.4",
"rimraf": "^2.6.1",
"sass-loader": "^6.0.3",
"style-loader": "^0.18.2",
"transform-runtime": "^0.0.0",
"url-loader": "^0.5.9",
Expand Down
1 change: 0 additions & 1 deletion src/__mocks__/styleMock.js

This file was deleted.

3 changes: 3 additions & 0 deletions src/__mocks__/stylesMock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import React from 'react'

export const styles = (Target) => (props) => <Target {...{ ...props, classes: {} }} />
6 changes: 0 additions & 6 deletions src/base.scss

This file was deleted.

16 changes: 9 additions & 7 deletions src/components/BodyContent/BodyContent.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import React, { Component } from 'react'
import classNames from 'classnames'
import PropTypes from 'prop-types'

import BodySchema from '../BodySchema/BodySchema'
import BodySchemaSwitcher from '../BodySchemaSwitcher/BodySchemaSwitcher'
import Example from '../Example/Example'
import { styles } from './BodyContent.styles'

import './BodyContent.scss'

@styles
export default class BodyContent extends Component {
constructor (props) {
super(props)
Expand All @@ -21,11 +20,11 @@ export default class BodyContent extends Component {
}

render () {
const { schema, examples } = this.props
const { schema, examples, classes } = this.props
const { tab, index } = this.state

return (
<div className='body-content'>
<div className={classes.bodyContent}>
{schema && this.renderTabs(schema, examples)}
{tab === 'schema' && this.renderSchema(schema, index)}
{tab === 'example' && this.renderExamples(examples)}
Expand All @@ -35,8 +34,10 @@ export default class BodyContent extends Component {

renderTabs (includeSchema, includeExample) {
const currentTab = this.state.tab
const { classes } = this.props

return (
<div className='body-content-tabs'>
<div className={classes.tabs}>
{includeSchema && this.renderSchemaTab(currentTab)}
{includeExample && this.renderExamplesTab(currentTab)}
</div>
Expand Down Expand Up @@ -109,5 +110,6 @@ export default class BodyContent extends Component {

BodyContent.propTypes = {
schema: PropTypes.array,
examples: PropTypes.array
examples: PropTypes.array,
classes: PropTypes.object
}
27 changes: 0 additions & 27 deletions src/components/BodyContent/BodyContent.scss

This file was deleted.

31 changes: 31 additions & 0 deletions src/components/BodyContent/BodyContent.styles.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { createSheet } from '../../theme'

export const styles = createSheet(() => ({
'bodyContent': {
display: 'table',
width: '100%',
border: '2px solid black',
padding: '10px',
boxSizing: 'border-box'
},

'tabs': {
position: 'relative',
top: '2px',

'& > div': {
display: 'inline-block',
padding: '10px 20px 10px 0',
borderLeft: 'none',
cursor: 'pointer',

'&$active': {
fontWeight: 'bold',
borderBottom: 'none',
textDecoration: 'underline'
}
}
},

'active': {}
}))
15 changes: 8 additions & 7 deletions src/components/BodySchema/BodySchema.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ import React, { Component } from 'react'
import createFragment from 'react-addons-create-fragment'
import classNames from 'classnames'
import PropTypes from 'prop-types'

import Property from '../Property/Property'
import { styles } from './BodySchema.styles'

import './BodySchema.scss'

@styles
export default class BodySchema extends Component {
constructor (props) {
super(props)
Expand All @@ -19,16 +18,15 @@ export default class BodySchema extends Component {
}

render () {
const { properties, styleVariation } = this.props
const { properties, styleVariation, classes } = this.props

if (!properties) {
return null
}

const { expandedProp } = this.state

return (
<table className={classNames('body-schema', `body-schema--${styleVariation}`)}>
<table className={classNames(classes.bodySchema, classes[styleVariation])}>
<tbody>
{properties.map((property, i) => {
const isLast = (properties.length === i + 1)
Expand Down Expand Up @@ -79,11 +77,13 @@ export default class BodySchema extends Component {
const { styleVariation } = this.props
const nextStyleVariation = (styleVariation === 'even') ? 'odd' : 'even'

// FIXME: this is not componentized
return (
<tr className='body-schema-subset'>
<td colSpan='100'>
{isArray && <div>Array [</div>}
<BodySchema
{...this.props}
key={`${property.name}-properties`}
properties={property.properties}
styleVariation={nextStyleVariation}
Expand Down Expand Up @@ -117,5 +117,6 @@ BodySchema.propTypes = {
styleVariation: PropTypes.oneOf([
'odd',
'even'
])
]),
classes: PropTypes.object
}
27 changes: 0 additions & 27 deletions src/components/BodySchema/BodySchema.scss

This file was deleted.

17 changes: 17 additions & 0 deletions src/components/BodySchema/BodySchema.styles.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { createSheet } from '../../theme'

export const styles = createSheet(() => ({
'bodySchema': {
width: '100%',
borderSpacing: '0',
padding: '10px 50px 10px 20px',
boxSizing: 'border-box'
},

'even': {
backgroundColor: 'rgb(27, 37, 52)'
},
'odd': {
backgroundColor: 'rgb(14, 24, 39)'
}
}))
13 changes: 7 additions & 6 deletions src/components/BodySchemaSwitcher/BodySchemaSwitcher.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React, { Component } from 'react'
import PropTypes from 'prop-types'
import { styles } from './BodySchemaSwitcher.styles'

import './BodySchemaSwitcher.scss'

@styles
export default class BodySchemaSwitcher extends Component {
constructor (props) {
super(props)
Expand All @@ -17,12 +17,12 @@ export default class BodySchemaSwitcher extends Component {
}

render () {
const { options } = this.props
const { options, classes } = this.props

return (
<form className='body-schema-switcher-form'>
<form>
<label>This schema can be fulfilled by multiple options: </label>
<select onChange={this.handleChange}>
<select className={classes.select} onChange={this.handleChange}>
{options.map(
(option, i) => <option key={i} value={i}>{`Option ${i + 1}`}</option>
)}
Expand All @@ -34,5 +34,6 @@ export default class BodySchemaSwitcher extends Component {

BodySchemaSwitcher.propTypes = {
options: PropTypes.array.isRequired,
onChange: PropTypes.func
onChange: PropTypes.func,
classes: PropTypes.object
}
8 changes: 0 additions & 8 deletions src/components/BodySchemaSwitcher/BodySchemaSwitcher.scss

This file was deleted.

12 changes: 12 additions & 0 deletions src/components/BodySchemaSwitcher/BodySchemaSwitcher.styles.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { createSheet } from '../../theme'

export const styles = createSheet(() => ({
'select': {
background: 'transparent',
color: 'white',
border: '1px solid white',
borderRadius: '5px',
marginLeft: '15px',
fontSize: 'medium'
}
}))
11 changes: 7 additions & 4 deletions src/components/ContentContainer/ContentContainer.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
import React, { Component } from 'react'
import PropTypes from 'prop-types'
import { styles } from './ContentContainer.styles'

import './ContentContainer.scss'

@styles
export default class ContentContainer extends Component {
render () {
const { classes } = this.props

return (
<div className='content-container'>
<div className={classes.contentContainer}>
{this.props.children}
</div>
)
}
}

ContentContainer.propTypes = {
children: PropTypes.any
children: PropTypes.any,
classes: PropTypes.object
}
5 changes: 0 additions & 5 deletions src/components/ContentContainer/ContentContainer.scss

This file was deleted.

7 changes: 7 additions & 0 deletions src/components/ContentContainer/ContentContainer.styles.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { createSheet } from '../../theme'

export const styles = createSheet(() => ({
'contentContainer': {
padding: '20px'
}
}))
Loading

0 comments on commit b9ca5dc

Please sign in to comment.