forked from hygraph/rich-text
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: rich text react renderer * chore: migrate to monorepo * docs: add initial documentation * chore: rename children to content * chore: add .editorconfig * chore: add lint-staged and commitlint * style: run prettier * refactor: rename underlined to underline * refactor: remove style prop from link * test: add initial tests * chore: update repo on changeset config
- Loading branch information
1 parent
acaee01
commit 056bc0d
Showing
54 changed files
with
19,958 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Changesets | ||
|
||
Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works | ||
with multi-package repos, or single-package repos to help you version and publish your code. You can | ||
find the full documentation for it [in our repository](https://github.com/changesets/changesets). | ||
|
||
We have a quick list of common questions to get you started engaging with this project in | ||
[our documentation](https://github.com/changesets/changesets/blob/master/docs/common-questions.md). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json", | ||
"changelog": [ | ||
"@changesets/changelog-github", | ||
{ "repo": "graphcms/rich-text-renderer" } | ||
], | ||
"commit": false, | ||
"linked": [], | ||
"access": "public", | ||
"baseBranch": "main", | ||
"updateInternalDependencies": "patch", | ||
"ignore": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# EditorConfig is awesome: https://EditorConfig.org | ||
|
||
# top-most EditorConfig file | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 2 | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
module.exports = { | ||
extends: [ | ||
'react-app', | ||
'prettier/@typescript-eslint', | ||
'plugin:prettier/recommended', | ||
], | ||
plugins: ['testing-library', 'jest-dom'], | ||
settings: { | ||
react: { | ||
version: '999.999.999', | ||
}, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# Contribution guidelines | ||
|
||
## Getting started | ||
|
||
First off, we would like to thank you for taking the time to contribute and make this a better project! | ||
|
||
Here we have a set of instructions and guidelines to reduce misunderstandings and make the process of contributing to the Rich Text project as smooth as possible. We hope this guide makes the contribution process clear and answers any questions you may have. | ||
|
||
## Local Development | ||
|
||
### Prerequisites | ||
|
||
- [Node.js](http://nodejs.org/) >= v12 must be installed. | ||
- [Yarn](https://yarnpkg.com/en/docs/install) | ||
|
||
There are 2 packages: | ||
|
||
- `@graphcms/rich-text-react-renderer` - Rich text React renderer | ||
- `@graphcms/rich-text-types` - TypeScript definition for the Rich Text field | ||
|
||
You can install all the dependencies in the root directory. Since the monorepo uses Lerna and Yarn Workspaces, npm CLI is not supported (only yarn). | ||
|
||
```sh | ||
yarn install | ||
``` | ||
|
||
This will install all dependencies in each project, build them, and symlink them via Lerna. | ||
|
||
## Development workflow | ||
|
||
In one terminal, run tsdx watch in parallel: | ||
|
||
```sh | ||
yarn start | ||
``` | ||
|
||
This builds each package to `<packages>/<package>/dist` and runs the project in watch mode so any edits you save inside `<packages>/<package>/src` cause a rebuild to `<packages>/<package>/dist`. The results will stream to to the terminal. | ||
|
||
### Using the example/playground | ||
|
||
You can play with local packages in the Parcel-powered example/playground. | ||
|
||
```sh | ||
yarn start:app | ||
``` | ||
|
||
This will start the example/playground on `localhost:1234`. If you have lerna running watch in parallel mode in one terminal, and then you run parcel, your playground will hot reload when you make changes to any imported module whose source is inside of `packages/*/src/*`. Note that to accomplish this, each package's `start` command passes TDSX the `--noClean` flag. This prevents Parcel from exploding between rebuilds because of File Not Found errors. | ||
|
||
Important Safety Tip: When adding/altering packages in the playground, use `alias` object in package.json. This will tell Parcel to resolve them to the filesystem instead of trying to install the package from NPM. It also fixes duplicate React errors you may run into. | ||
|
||
## Why all these rules? | ||
|
||
We try to enforce these rules for the following reasons: | ||
|
||
- Automatically generating changelog; | ||
- Communicating in a better way the nature of changes; | ||
- Triggering build and publish processes; | ||
- Automatically determining a semantic version bump (based on the types of commits); | ||
- Making it easier for people to contribute, by allowing them to explore a more structured commit history. | ||
|
||
## Pull Requests | ||
|
||
When opening a pull request, please be sure to update any relevant documentation in the READMEs or write some additional tests to ensure functionality. Also include a high-level list of changes. | ||
|
||
## Changesets | ||
|
||
This repository uses [changesets][] to do versioning. What that means for contributors is that you need to add a changeset by running `yarn changeset` which contains what packages should be bumped, their associated semver bump types, and some markdown which will be inserted into changelogs. | ||
|
||
[yarn workspaces]: https://yarnpkg.com/en/docs/workspaces | ||
[changesets]: https://github.com/atlassian/changesets |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
examples: | ||
- example/* | ||
- example/**/* | ||
|
||
react: | ||
- packages/react/* | ||
- packages/react/**/* | ||
|
||
types: | ||
- packages/types/* | ||
- packages/types/**/* | ||
|
||
repo: | ||
- ./* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
name: Lint | ||
|
||
on: [pull_request] | ||
|
||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Use Node.js 12.x | ||
uses: actions/setup-node@v1 | ||
with: | ||
version: 12.x | ||
|
||
- name: Install deps and build (with cache) | ||
uses: bahmutov/npm-install@v1 | ||
|
||
- name: Lint | ||
run: yarn lint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: Unit Test | ||
|
||
on: [push] | ||
|
||
jobs: | ||
test: | ||
name: Build and test on Node ${{ matrix.node }} and ${{ matrix.os }} | ||
|
||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
node: ['12.x', '14.x'] | ||
os: [ubuntu-latest] | ||
|
||
steps: | ||
- name: Checkout repo | ||
uses: actions/checkout@v2 | ||
|
||
- name: Use Node ${{ matrix.node }} | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: ${{ matrix.node }} | ||
|
||
- name: Install deps and build (with cache) | ||
uses: bahmutov/npm-install@v1 | ||
|
||
- name: Test | ||
run: yarn test --ci --coverage --maxWorkers=2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
name: Release | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
release: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Use Node.js 12.x | ||
uses: actions/setup-node@v1 | ||
with: | ||
version: 12.x | ||
|
||
- name: Install deps and build (with cache) | ||
uses: bahmutov/npm-install@v1 | ||
|
||
- name: Create Release Pull Request or Publish to npm | ||
uses: changesets/action@master | ||
with: | ||
publish: yarn release | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
|
||
- name: Publishing canary releases to npm registry | ||
if: steps.changesets.outputs.published != 'true' | ||
run: | | ||
git checkout main | ||
yarn version:canary | ||
yarn release:canary | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
name: size | ||
on: [pull_request] | ||
jobs: | ||
size: | ||
runs-on: ubuntu-latest | ||
env: | ||
CI_JOB_NUMBER: 1 | ||
steps: | ||
- uses: actions/checkout@v1 | ||
- uses: andresz1/size-limit-action@v1 | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
*.log | ||
.DS_Store | ||
node_modules | ||
dist | ||
|
||
node_modules | ||
package-lock.json | ||
yarn.lock | ||
!/yarn.lock | ||
coverage/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/sh | ||
. "$(dirname "$0")/_/husky.sh" | ||
|
||
npx --no-install commitlint --edit "$1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/sh | ||
. "$(dirname "$0")/_/husky.sh" | ||
|
||
npx lint-staged |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"**/*.{ts,tsx}": [ | ||
"yarn lint --fix", | ||
"yarn format" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"printWidth": 80, | ||
"semi": true, | ||
"singleQuote": true, | ||
"trailingComma": "es5" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Rich Text Renderer | ||
|
||
Render GraphCMS Rich Text documents in your application easily. | ||
|
||
## ✨ Packages | ||
|
||
- [rich-text-react-renderer](./packages/react): Render Rich Text content from GraphCMS in React applications; | ||
- [rich-text-types](./packages/types): TypeScript definitions for the GraphCMS Rich Text field type. | ||
|
||
## 🤝 Contributing | ||
|
||
Thanks for being interested in contributing! We're so glad you want to help! All types of contributions are welcome, such as bug fixes, issues, or feature requests. Also, don't forget to check the roadmap. See [`CONTRIBUTING.md`](./.github/CONTRIBUTING.md) for ways to get started. | ||
|
||
## 📝 License | ||
|
||
Licensed under the [MIT License](./LICENSE.md). | ||
|
||
--- | ||
|
||
Made with 💜 by GraphCMS 👋 [join our community](https://slack.graphcms.com/)! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = { extends: ['@commitlint/config-conventional'] }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
node_modules | ||
.cache | ||
dist |
Oops, something went wrong.