Skip to content
This repository has been archived by the owner on Jan 24, 2025. It is now read-only.

Commit

Permalink
chore(docz-theme-default): improve default template
Browse files Browse the repository at this point in the history
  • Loading branch information
pedronauck committed Apr 20, 2018
1 parent 3f8216b commit d9cc235
Show file tree
Hide file tree
Showing 9 changed files with 241 additions and 63 deletions.
1 change: 1 addition & 0 deletions examples/basic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"react": "^16.3.1",
"react-dom": "^16.3.1",
"react-emotion": "^9.1.1",
"react-markdown": "^3.3.0",
"react-router-dom": "^4.2.2"
},
"devDependencies": {
Expand Down
1 change: 0 additions & 1 deletion examples/basic/src/components/Alert.doc.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { Alert } from './Alert'

doc('Alert')
.category('Components')
.description('This component is used to show alerts')
.section('Basic usage', () => <Alert>Some message</Alert>)
.section('Using different kinds', () => (
<Fragment>
Expand Down
6 changes: 0 additions & 6 deletions examples/basic/src/design.doc.jsx

This file was deleted.

17 changes: 15 additions & 2 deletions examples/basic/src/index.doc.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
import React from 'react'
import { doc } from 'docz-react'
import Markdown from 'react-markdown'

const description = `
## Introduction
A design system can help establish a common vocabulary between everyone in an organization. That’s why I’ve spent a great deal of time coming up with structure and naming for Vue Design System that would make sense. To start opening it up, let’s go through each layer in detail and what the terms mean:
- *Principles* are the foundation of the whole system. They form the basis of a good product and help the team with decision making. They are there to guide you and your team when working with the myriad parts of the system and help you do better and more informed decisions.
- *Design* Tokens are the atoms of the system as Salesforce describes them. In Vue Design System they are used instead of hard coded values to ensure a better consistency across any platform.
- *Elements* utilize decisions made on the token level. A simple example of an element would be a button, a link, or an input. Anything that cannot be broken down further. I use the name ‘element’ since everything in Vue and React world is nowadays ‘a component.’ Using that term for anything else would be confusing.
- *Patterns* are UI Patterns that fall on the more complex side of the spectrum. So for example things like a date picker, a data table, or a visualization. Patterns utilize both elements and tokens. If you wonder whether something should be called an element or a pattern, ask yourself this question: “Can this be broken down into smaller pieces?” If the answer is yes, it should most likely be a pattern in Vue Design System.
- *Templates* exist to document the layout and structure of a section. I am not calling these pages since semantically that would be incorrect. While they can be pages, that’s not their only functionality. Templates consist of the three things mentioned above: tokens, elements, and patterns.
`

doc('Overview')
.order(1)
.route('/')
.section(() => <div>This is just the Home page!</div>)
.order(1)
.description(<Markdown source={description} />)
3 changes: 1 addition & 2 deletions packages/docz-theme-default/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"prismjs": "^1.14.0",
"react": "^16.3.1",
"react-dom": "^16.3.1",
"react-helmet": "^5.2.0",
"react-feather": "^1.1.0",
"react-router-dom": "^4.2.2"
},
"peerDependencies": {
Expand All @@ -34,7 +34,6 @@
"devDependencies": {
"@babel/core": "7.0.0-beta.44",
"@babel/plugin-proposal-class-properties": "^7.0.0-beta.44",
"@babel/plugin-proposal-export-namespace-from": "^7.0.0-beta.44",
"@babel/preset-env": "^7.0.0-beta.44",
"@babel/preset-react": "^7.0.0-beta.44",
"babel-plugin-emotion": "^9.1.0"
Expand Down
43 changes: 33 additions & 10 deletions packages/docz-theme-default/src/components/Doc.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { Component } from 'react'
import * as Icon from 'react-feather'
import styled from 'react-emotion'

import { Highlight } from './Highlight'
Expand All @@ -12,17 +13,39 @@ const Container = styled('div')`
`

const Title = styled('h2')`
position: relative;
font-size: 48px;
font-weight: 400;
font-weight: 200;
margin: 0;
&:before {
position: absolute;
content: '';
bottom: 0;
left: 0;
width: 10%;
height: 4px;
background: ${colors.PURPLE};
}
`

const IconLink = styled(Icon.Link)`
margin-right: 10px;
`

const Filepath = styled('div')`
display: flex;
align-items: center;
margin: 15px 0 0;
color: ${colors.GRAY_MEDIUM};
`

const Description = styled('p')`
margin: 0 0 10px;
margin: 20px 0 10px;
`

const Section = styled('div')`
margin-top: 50px;
margin-top: 40px;
`

const Render = styled('div')`
Expand All @@ -34,6 +57,7 @@ const Render = styled('div')`
`

const CodeButton = styled('button')`
cursor: pointer;
position: absolute;
bottom: 0;
right: 0;
Expand All @@ -48,10 +72,6 @@ const CodeButton = styled('button')`
transform: translate(1px, 100%);
`

const Filepath = styled('code')`
color: ${colors.GRAY_MEDIUM};
`

class DocSection extends Component {
constructor(props) {
super(props)
Expand All @@ -78,7 +98,7 @@ class DocSection extends Component {
<div>{section.render()}</div>
)}
<CodeButton onClick={this.handleToggleCode}>
{showingCode ? 'Hide' : 'Show'} code
<Icon.Code width={15} />
</CodeButton>
</Render>
</Section>
Expand All @@ -99,14 +119,17 @@ export class Doc extends Component {
this.setState({ showingCode: !this.state.showingCode })

render() {
const { id, name, filepath, description, sections } = this.props
const { id, name, filepath, body, description, sections } = this.props
const { showingCode } = this.state

return (
<Container key={id}>
<Title>{name}</Title>
<Filepath>
<IconLink size={15} />
<code>{filepath}</code>
</Filepath>
{description && <Description>{description}</Description>}
<Filepath>{filepath}</Filepath>
{sections &&
sections.length > 0 &&
sections.map(section => (
Expand Down
1 change: 1 addition & 0 deletions packages/docz-theme-default/src/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import './styles'
import * as React from 'react'

import { injectGlobal } from 'emotion'
import { Helmet } from 'react-helmet'
import { BrowserRouter } from 'react-router-dom'
import { theme } from 'docz-react'

Expand Down
9 changes: 4 additions & 5 deletions packages/docz/src/Doc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export interface DocObj {
readonly route: string
readonly id: string | undefined
readonly order: number
readonly description: string | null
readonly description: string | undefined
readonly filepath: string | undefined
readonly category: string | undefined
readonly sections: Section[]
Expand All @@ -36,17 +36,16 @@ export interface Entry {

export class Doc {
private _name: string
private _route: string
private _id: string | undefined
private _order: number
private _description: string | undefined
private _filepath: string | undefined
private _category: string | undefined
private _description: string | null
private _sections: Section[]
private _route: string
private _order: number

constructor(name: string) {
this._name = name
this._description = null
this._sections = []
this._route = `/${kebabcase(name)}`
this._order = 0
Expand Down
Loading

0 comments on commit d9cc235

Please sign in to comment.