Skip to content

Commit 15f703f

Browse files
author
David Zukowski
committed
refactor(App): reorganize counter components
1 parent 44ee06c commit 15f703f

File tree

12 files changed

+32
-57
lines changed

12 files changed

+32
-57
lines changed

src/components/Counter/Counter.scss

Lines changed: 0 additions & 12 deletions
This file was deleted.

src/components/Counter/index.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

src/components/Header/Header.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import React from 'react'
22
import { IndexLink, Link } from 'react-router'
3-
import classes from './Header.scss'
3+
import './Header.scss'
44

55
export const Header = () => (
66
<div>
77
<h1>React Redux Starter Kit</h1>
8-
<IndexLink to='/' activeClassName={classes.activeRoute}>
8+
<IndexLink to='/' activeClassName='route--active'>
99
Home
1010
</IndexLink>
1111
{' · '}
12-
<Link to='/counter' activeClassName={classes.activeRoute}>
12+
<Link to='/counter' activeClassName='route--active'>
1313
Counter
1414
</Link>
1515
</div>

src/components/Header/Header.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.activeRoute {
1+
.route--active {
22
font-weight: bold;
33
text-decoration: underline;
44
}

src/layouts/CoreLayout/CoreLayout.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import React from 'react'
22
import Header from '../../components/Header'
3-
import classes from './CoreLayout.scss'
3+
import './CoreLayout.scss'
44
import '../../styles/core.scss'
55

66
export const CoreLayout = ({ children }) => (
77
<div className='container text-center'>
88
<Header />
9-
<div className={classes.mainContainer}>
9+
<div className='core-layout__viewport'>
1010
{children}
1111
</div>
1212
</div>
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
.mainContainer {
2-
padding-top:20px;
1+
.core-layout__viewport {
2+
padding-top: 4rem;
33
}

src/components/Counter/Counter.js renamed to src/routes/Counter/components/Counter.js

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,8 @@
11
import React from 'react'
2-
import classes from './Counter.scss'
32

43
export const Counter = (props) => (
5-
<div>
6-
<h2 className={classes.counterContainer}>
7-
Counter:
8-
{' '}
9-
<span className={classes['counter--green']}>
10-
{props.counter}
11-
</span>
12-
</h2>
4+
<div style={{ margin: '0 auto' }} >
5+
<h2>Counter: {props.counter}</h2>
136
<button className='btn btn-default' onClick={props.increment}>
147
Increment
158
</button>

src/routes/Counter/containers/CounterContainer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { increment, doubleAsync } from '../modules/counter'
66
wiring in the actions and state necessary to render a presentational
77
component - in this case, the counter: */
88

9-
import Counter from 'components/Counter'
9+
import Counter from '../components/Counter'
1010

1111
/* Object of action creators (can also be function that returns object).
1212
Keys will be passed as props to presentational components. Here we are

src/styles/core.scss

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,21 @@
1-
:global {
2-
@import 'base';
3-
@import '~normalize.css/normalize';
1+
@import 'base';
2+
@import '~normalize.css/normalize';
43

5-
// Some best-practice CSS that's useful for most apps
6-
// Just remove them if they're not what you want
7-
html {
8-
box-sizing: border-box;
9-
}
10-
11-
html,
12-
body {
13-
margin: 0;
14-
padding: 0;
15-
height: 100%;
16-
}
4+
// Some best-practice CSS that's useful for most apps
5+
// Just remove them if they're not what you want
6+
html {
7+
box-sizing: border-box;
8+
}
179

18-
*,
19-
*:before,
20-
*:after {
21-
box-sizing: inherit;
22-
}
10+
html,
11+
body {
12+
margin: 0;
13+
padding: 0;
14+
height: 100%;
2315
}
16+
17+
*,
18+
*:before,
19+
*:after {
20+
box-sizing: inherit;
21+
}

tests/components/Header/Header.spec.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import React from 'react'
22
import { Header } from 'components/Header/Header'
3-
import classes from 'components/Header/Header.scss'
43
import { IndexLink, Link } from 'react-router'
54
import { shallow } from 'enzyme'
65

@@ -20,15 +19,15 @@ describe('(Component) Header', () => {
2019
describe('Navigation links...', () => {
2120
it('Should render a Link to Home route', () => {
2221
expect(_wrapper.contains(
23-
<IndexLink activeClassName={classes.activeRoute} to='/'>
22+
<IndexLink activeClassName='route--active' to='/'>
2423
Home
2524
</IndexLink>
2625
)).to.be.true
2726
})
2827

2928
it('Should render a Link to Counter route', () => {
3029
expect(_wrapper.contains(
31-
<Link activeClassName={classes.activeRoute} to='/counter'>
30+
<Link activeClassName='route--active' to='/counter'>
3231
Counter
3332
</Link>
3433
)).to.be.true

0 commit comments

Comments
 (0)