Skip to content

Commit

Permalink
Example of component with theming
Browse files Browse the repository at this point in the history
I'm not sure if this is the correct/best way to do this but at least for
this simple example it works fine.
  • Loading branch information
apaatsio committed Nov 13, 2016
1 parent 8d152ee commit 8d5ebb3
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/components/MyTable/MyTable.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import React from 'react'
import theme from './MyTable.scss'

const MyTable = () => (
<table className={theme.table}>
<tbody>
<tr>
<td>1</td>
<td>2</td>
</tr>
<tr>
<td>3</td>
<td>4</td>
</tr>
<tr>
<td>5</td>
<td>6</td>
</tr>
<tr>
<td>7</td>
<td>8</td>
</tr>
<tr>
<td>9</td>
<td>10</td>
</tr>
</tbody>
</table>
)

export default MyTable
19 changes: 19 additions & 0 deletions src/components/MyTable/MyTable.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
.table {

td {
width: 50px;
padding: 10px;
text-align: center;
}

tr:nth-child(odd) {
td {
background-color: lawngreen;
}
}
tr:nth-child(even) {
td {
background-color: deeppink;
}
}
}
3 changes: 3 additions & 0 deletions src/components/MyTable/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import MyTable from './MyTable'

export default MyTable
4 changes: 4 additions & 0 deletions src/routes/Home/components/HomeView.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import DuckImage from '../assets/Duck.jpg'
import './HomeView.scss'
import { Button, Chip } from 'react-toolbox'

import MyTable from '../../../components/MyTable'

export const HomeView = () => (
<div>
<h4>Welcome!</h4>
Expand All @@ -17,6 +19,8 @@ export const HomeView = () => (
/>
<br/>
<Chip>Test chip</Chip>
<br/>
<MyTable/>
</div>
)

Expand Down

0 comments on commit 8d5ebb3

Please sign in to comment.