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

Commit

Permalink
docs: add migration guide and v1 readme changes
Browse files Browse the repository at this point in the history
  • Loading branch information
pedronauck committed Feb 25, 2019
1 parent 69b4cbe commit 6f4b8f1
Show file tree
Hide file tree
Showing 3 changed files with 179 additions and 13 deletions.
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
**/*.mdx
MIGRATION_GUIDE.md
168 changes: 168 additions & 0 deletions MIGRATION_GUIDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
# v1 Migration Guide

The v1 release was one of our big releases and a lot of breaking changes was introduced. So, there's few apis that changed and you need to update your code if you're coming from previous versions. It's not a big deal, but you need to follow this guide in order to get Docz running properly on your project.

## Spectrum instead of Discord

Together with the v1, now you're moving from our old discord server to the [new Spectrum](https://spectrum.chat/docz).

### You're our guess, please, enter on [our community](https://spectrum.chat/docz) 🙏🏻

## Update React to use Hooks

We made a [huge improvement](https://github.com/pedronauck/docz/commit/f57f987df0536b3b65a26f1b0e8a8f8f00d63800) on docz using the new react hooks. So, the biggest requirement is that you need `react` and `react-dom` with the version `>= 16.8.0`, because that's the version that has hooks released and stable. So, just update your React version, it's fully retro compatible.

## Removing render props data components

In the oldest version of docz, we're using render props as data components in order to get data from the docz database and use it on themes. Now, all this render props became a hook. This is a huge improvement, since it's so easier to use them.

#### `<Docs>` now is `useDocs()`

With this hook you can get all mdx entries used on docz.

```jsx
// old
<Docs>
{({ docs, menus }) => /* do something */}
</Docs>

// new
const docs = useDocs()
```

#### `<ThemeConfig>` now is `useConfig()`

Get information about the configuration of your project.

```jsx
// old
<ThemeConfig>
{(config) => /* do something */}
</ThemeConfig>

// new
const config = useConfig()
```

#### New `useMenus()`

If you want just the menu information you can use this hook.

```js
const menus = useMenus({ query: 'some search' })
```

#### New `useComponents()`

Get all components map passed into `<ComponentsProvider>`

```jsx
const components = useComponents()
```

## Removing order deprecated field

Since [v0.12.4](https://github.com/pedronauck/docz/releases/tag/v0.12.4) we launched `menu` property to create and sort your menu, and the `ordering` frontmatter field was deprecated. So, now we're removing this property. If you wanna see more information about the `menu` order property, you can take a look at the `Ordering` session on our website.

## Use `<Props>` instead of `<PropsTable>`

Another change that we've made in this version is that now we have a `<Props>` component instead of `<PropsTable>`. So, the `<PropsTable>` component doesn't exist anymore and the new one don't have more a table format, instead of that, it's just a list with the props and their values. So, it became more simple and flexible to be stylized.

#### The old way

```jsx
import { PropsTable } from 'docz'
import MyComponent from './my-components'

<PropsTable of={MyComponent} />
```

### The new way

```jsx
import { Props } from 'docz'
import MyComponent from './my-components'

<Props of={MyComponent} />
```

## Remove hash router support

In the newest version of docz, because of some performance and bundle issues, now we are using `@reach/router` instead of `react-router`. So, how `@reach/router` doesn't have a official support for hash router yet and you have a lot of good free services to host your site instead of use Github pages - and get all benefits of browser history, of course - we decided to deprecated the hash router support.

## Creating and using docz themes

The process to create themes for docz it's very similar, there's not a big changes here, but you need to know about few changes that we made.

- The first one, is you don't have `DocPreview` anymore, instead of that, was introduced `ComponentsProvider` component.
- The second one, is the `render` field passed in the components mapper now is `playground`.
- And the last one, is now you need to pass a children for your theme.

#### The old way

```jsx
import React from 'react'
import { theme, DocPreview } from 'docz'
import * as components from './my-components'

const Theme = () => (
<DocPreview
components={{
page: components.Page,
notFound: components.NotFound,
render: components.Render,
props: components.Props,
h1: components.H1,
h2: components.H2,
h3: components.H3,
h4: components.H4,
h5: components.H5,
h6: components.H6,
ul: components.List,
loading: components.Loading,
table: components.Table,
pre: components.Pre,
inlineCode: components.Code,
}}
/>
)

const themeConfig = {
/* your theme config */
}
export default theme(themeConfig)(Theme)
```

#### The new way

```jsx
import React from 'react'
import { theme, ComponentsProvider } from 'docz'
import * as components from './my-components'

const map = {
page: components.Page,
notFound: components.NotFound,
playground: components.Playground,
h1: components.H1,
h2: components.H2,
h3: components.H3,
h4: components.H4,
h5: components.H5,
h6: components.H6,
ul: components.List,
loading: components.Loading,
table: components.Table,
pre: components.Pre,
inlineCode: components.Code,
}

const Theme = ({ children }) => (
<ComponentsProvider components={map}>{children}</ComponentsProvider>
)

const themeConfig = {
/* your theme config */
}
export default theme(themeConfig)(Theme)
```
23 changes: 10 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@
<img src="https://badgen.net/npm/v/docz" alt="">
<img src="https://badgen.net/badge/license/MIT/blue" alt="">
<img src="https://badgen.net/npm/dt/docz" alt="">
<a href="https://discord.gg/YQE4MbD">
<img src="https://img.shields.io/badge/chat-on%20discord-7289da.svg" alt="Chat">
</a>
<a href="http://feedback.docz.site/roadmap">
<img src="https://img.shields.io/badge/check-our%20roadmap-5362F5.svg" alt="Chat">
</a>
Expand All @@ -29,6 +26,10 @@
</a>
</p>

## ✅️ &nbsp; v1 Migration Guide

This documentation it's about our new v1. If you need to migrate your docz project, please read our [Migration Guide](/MIGRATION_GUIDE.md)

## 🎩 &nbsp; Features

- 🧘 **Zero config and easy.** Don't worry about complex configurations steps.
Expand All @@ -38,14 +39,6 @@
- 🎛 **Pluggable.** With plugins, you can manipulate a lot of things through the docz flow and data.
- 🔐 **Typescript Support.** We have a full support for your type definitions.

## 🚀 &nbsp; Roadmap

We still have a _long road to go_, this is just the beginning. So to further improve **docz** we've created a roadmap that you can see the next features and improvements. **Give us your feedback**:

<a href="http://feedback.docz.site/roadmap" target="_blank">
<img src="https://cdn-std.dprcdn.net/files/acc_649651/ogSCYY" alt="Docz Roadmap" width="300">
</a>

## 🤔 &nbsp; Why?

Libraries that make our life easier coming up every day. Styleguides and design system are growing so fast. Today, tools that allow us to be quick and effective are really necessary. We can't lose time with tasks that should be trivial for us. Thinking about that **docz** came out.
Expand Down Expand Up @@ -84,12 +77,16 @@ Documenting our things is one of the most important and heavy processes when you
- **[React Hotkey Tooltip](https://react-hotkey-tooltip.netlify.com/#/)** - A global Hotkey provider with built in tooltip for React
- **[Sajari React SDK](https://sajari-sdk-react.netlify.com/)** - Library of React Components for the Sajari

## ⚠️ &nbsp; Warning

Since our new v1, you need `react` and `react-dom` with `>= 16.8.0` installed.

## 📟 &nbsp; Install and Usage

Simplicity is one of our core principles. Therefore, getting started with **docz** is something really easy and quick. First of all, you will need to install **docz** and some theme on your project using your favorite package manager (we'll asume yarn for this example):

```bash
$ yarn add docz docz-theme-default --dev
$ yarn add docz@next docz-theme-default@next --dev
```

Then create some `.mdx` anywhere inside your project:
Expand Down Expand Up @@ -139,7 +136,7 @@ This project exists thanks to all the people who contribute. [[Contribute](CONTR

## 💭 &nbsp; Needing Help?

If you need some help you can chat with us on [our Discord server](https://discord.gg/Qec87en), you have a great team to help you:
If you need some help you can chat with us on [our Spectrum Community](https://spectrum.chat/docz), you have a great team to help you:

<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
<!-- prettier-ignore -->
Expand Down

0 comments on commit 6f4b8f1

Please sign in to comment.