Skip to content

Commit

Permalink
feat(theme): new component to nest themable components
Browse files Browse the repository at this point in the history
  • Loading branch information
jaketrent committed Oct 27, 2017
1 parent 2dbb905 commit 839fbeb
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 0 deletions.
11 changes: 11 additions & 0 deletions packages/theme/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"presets": [
"react",
"stage-2",
["env", {
"targets": {
"browsers": ["last 2 versions", "ie >= 10"]
}
}]
]
}
3 changes: 3 additions & 0 deletions packages/theme/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
__specs__
src
.babelrc
1 change: 1 addition & 0 deletions packages/theme/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock=false
3 changes: 3 additions & 0 deletions packages/theme/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
const React = require('./dist/react')

module.exports = { React }
33 changes: 33 additions & 0 deletions packages/theme/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"name": "@pluralsight/ps-design-system-theme",
"version": "1.0.0",
"description": "Design System component for theming",
"main": "index.js",
"scripts": {
"build": "babel src --out-dir dist --ignore spec.js --copy-files",
"build:watch": "npm run build -- --watch",
"prepublish": "npm run build",
"test": "jest",
"test:watch": "npm run test -- --watchAll",
"test:updateSnapshot": "npm run test -- --updateSnapshot"
},
"keywords": [],
"author": "jaketrent",
"license": "Apache-2.0",
"repository": "pluralsight/design-system",
"peerDependencies": {
"@pluralsight/ps-design-system-normalize": "^3.0.24",
"glamor": "^2.20.0",
"react": ">=0.15.0 < 17.0.0"
},
"dependencies": {
"prop-types": "^15.5.10"
},
"devDependencies": {
"babel-cli": "^6.24.1",
"babel-preset-env": "^1.4.0",
"babel-preset-react": "^6.24.1",
"babel-preset-stage-2": "^6.24.1",
"jest": "^20.0.4"
}
}
1 change: 1 addition & 0 deletions packages/theme/react.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('./dist/react')
26 changes: 26 additions & 0 deletions packages/theme/src/react/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import PropTypes from 'prop-types'
import React from 'react'

export const names = { dark: 'dark', light: 'light' }

class Theme extends React.Component {
getChildContext() {
return { themeName: this.props.name }
}
render() {
return this.props.children
}
}
Theme.childContextTypes = {
themeName: PropTypes.string.isRequired
}
Theme.propTypes = {
name: PropTypes.string.isRequired
}
Theme.defaultProps = {
name: names.dark
}

Theme.names = names

export default Theme

0 comments on commit 839fbeb

Please sign in to comment.