Skip to content

Commit

Permalink
feat(docz-theme-default): use typescript instead of javascript
Browse files Browse the repository at this point in the history
  • Loading branch information
pedronauck committed Apr 15, 2018
1 parent ae597af commit 4de326a
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 24 deletions.
3 changes: 3 additions & 0 deletions packages/playgrodd-theme-default/.librc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"external": ["react", "react-dom", "react-router-dom"]
}
9 changes: 4 additions & 5 deletions packages/playgrodd-theme-default/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,21 @@
"main": "dist/index.js",
"umd:main": "dist/index.umd.js",
"module": "dist/index.m.js",
"source": "src/index.jsx",
"source": "src/index.tsx",
"scripts": {
"dev": "libundler watch",
"build": "libundler build -s",
"build:prod": "yarn run build -p --hash --gzip"
},
"dependencies": {
"react": "^16.2.0",
"react-dom": "^16.2.0"
},
"peerDependencies": {
"playgrodd": "^0.0.1",
"react": "^16.2.0",
"react-dom": "^16.2.0",
"react-router-dom": "^4.2.2"
},
"peerDependencies": {
"playgrodd": "^0.0.1"
},
"devDependencies": {
"@babel/core": "7.0.0-beta.42",
"@babel/preset-env": "^7.0.0-beta.42",
Expand Down
18 changes: 18 additions & 0 deletions packages/playgrodd-theme-default/src/components/List.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import React from 'react'
import { Link } from 'react-router-dom'

import { Docs } from 'playgrodd'

export const List = () => (
<Docs>
{docs => (
<ul>
{docs.map(doc => (
<li key={doc.id}>
<Link to={doc.route}>{doc.name}</Link>
</li>
))}
</ul>
)}
</Docs>
)
22 changes: 22 additions & 0 deletions packages/playgrodd-theme-default/src/components/View.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import React, { Fragment } from 'react'

import { Preview } from 'playgrodd'

export const View = () => (
<Preview>
{({ id, name, docDescription, sections }) => (
<Fragment key={id}>
<h2>{name}</h2>
{docDescription && <p>{docDescription}</p>}
{sections &&
sections.length > 0 &&
sections.map(section => (
<Fragment key={section.id}>
<h3>{section.title}</h3>
<div>{section.render()}</div>
</Fragment>
))}
</Fragment>
)}
</Preview>
)
19 changes: 0 additions & 19 deletions packages/playgrodd-theme-default/src/index.jsx

This file was deleted.

13 changes: 13 additions & 0 deletions packages/playgrodd-theme-default/src/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import React, { Fragment } from 'react'
import { createTheme } from 'playgrodd'

import { List } from './components/List'
import { View } from './components/View'

export const Theme = createTheme(() => (
<Fragment>
<h1>Default theme</h1>
<List />
<View />
</Fragment>
))
12 changes: 12 additions & 0 deletions packages/playgrodd-theme-default/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "dist/main",
"rootDir": "src",
"skipLibCheck": true,
"types": ["node"],
"typeRoots": ["node_modules/@types"]
},
"include": ["src/**/*"],
"exclude": ["node_modules/**"]
}

0 comments on commit 4de326a

Please sign in to comment.