Skip to content

Commit fdfddab

Browse files
authored
Merge pull request #145 from code-hike/next
New version
2 parents 3544015 + 4d4298e commit fdfddab

File tree

287 files changed

+35355
-8873
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

287 files changed

+35355
-8873
lines changed

.github/workflows/release.yml

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
6+
jobs:
7+
release:
8+
runs-on: ubuntu-latest
9+
if: "!contains(github.event.head_commit.message, 'ci skip') && !contains(github.event.head_commit.message, 'skip ci')"
10+
steps:
11+
- uses: actions/checkout@v2
12+
with:
13+
fetch-depth: 10 # 👈 Required to retrieve git history
14+
15+
- name: Prepare repository
16+
run: git fetch --unshallow --tags
17+
18+
- name: Use Node.js 14.x
19+
uses: actions/setup-node@v1
20+
with:
21+
node-version: 14.x
22+
23+
- name: Cache node modules
24+
uses: actions/cache@v1
25+
with:
26+
path: node_modules
27+
key: yarn-deps-${{ hashFiles('yarn.lock') }}
28+
restore-keys: |
29+
yarn-deps-${{ hashFiles('yarn.lock') }}
30+
31+
- name: Create Release
32+
env:
33+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
34+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
35+
run: |
36+
yarn install --frozen-lockfile 2>&1 | grep -v '^[warning|info]'
37+
yarn build
38+
yarn release
39+
# - name: Publish to Chromatic
40+
# uses: chromaui/action@v1
41+
# with:
42+
# token: ${{ secrets.GITHUB_TOKEN }}
43+
# projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
44+
# workingDir: packages/storybook

.gitignore

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
node_modules
22
.next
33
todo.md
4+
current.md
45
dist
56
yarn-error.log
6-
site/out
7+
.prettierignore
8+
.env
9+
.vscode
10+
storybook-static
11+
packages/playground/out
12+
packages/starter

.gitmodules

-12
This file was deleted.

.gitpod.yml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# This configuration file was automatically generated by Gitpod.
2+
# Please adjust to your needs (see https://www.gitpod.io/docs/config-gitpod-file)
3+
# and commit this file to your remote git repository to share the goodness with others.
4+
5+
tasks:
6+
- init: yarn install && yarn run build
7+
command: yarn run playground
8+
9+

.prettierignore

-1
This file was deleted.

demos/hooks-talk-demo

-1
This file was deleted.

demos/nextjs-post-demo

-1
This file was deleted.

demos/swr-minidocs-demo

-1
This file was deleted.

demos/the-x-in-mdx

-1
This file was deleted.

lerna.json

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"version": "0.3.0-next.0",
3+
"npmClient": "yarn",
4+
"packages": ["packages/*"],
5+
"useWorkspaces": true,
6+
"command": {
7+
"publish": {
8+
"verifyAccess": false
9+
}
10+
}
11+
}

LICENSE renamed to license

File renamed without changes.

netlify.toml

-3
This file was deleted.

package.json

+22-20
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,31 @@
33
"workspaces": {
44
"packages": [
55
"packages/*",
6-
"demos/*",
7-
"storybook",
8-
"site"
6+
"external/*"
97
]
108
},
119
"scripts": {
12-
"dev": "yarn workspace xmdx dev",
13-
"mbrowser": "yarn workspace @code-hike/mini-browser",
14-
"mframe": "yarn workspace @code-hike/mini-frame",
15-
"mterminal": "yarn workspace @code-hike/mini-terminal",
16-
"meditor": "yarn workspace @code-hike/mini-editor",
17-
"scroller": "yarn workspace @code-hike/scroller",
18-
"player": "yarn workspace @code-hike/player",
19-
"sim-user": "yarn workspace @code-hike/sim-user",
20-
"storybook": "yarn workspace storybook",
21-
"site": "yarn workspace site",
22-
"ch-build": "yarn workspace @code-hike/build",
23-
"watch-packages": "yarn mframe watch & yarn mterminal watch & yarn scroller watch & yarn sim-user watch & yarn player watch & yarn mbrowser watch & yarn meditor watch",
24-
"build-packages": "yarn mframe build && yarn mterminal build && yarn scroller build && yarn sim-user build && yarn player build && yarn mbrowser build && yarn meditor build",
25-
"build-site": "yarn build-packages && yarn workspace site export"
10+
"build": "lerna run --stream x -- build",
11+
"watch": "lerna run --since HEAD --exclude-dependents --parallel x -- watch",
12+
"watch-all": "lerna run --parallel x -- watch",
13+
"storybook": "lerna run --scope storybook start --stream",
14+
"playground": "lerna run --scope @*/playground dev --stream",
15+
"docs": "lerna run build-docs --stream",
16+
"build-playground": "lerna run --scope @*/playground build --stream",
17+
"release": "auto shipit"
2618
},
27-
"dependencies": {
28-
"@emotion/core": "10.0.7",
29-
"theme-ui": "0.2.31"
19+
"devDependencies": {
20+
"auto": "^10.18.7",
21+
"lerna": "^4.0.0",
22+
"prettier": "^2.5.1"
23+
},
24+
"repository": "code-hike/codehike",
25+
"author": "pomber <[email protected]>",
26+
"auto": {
27+
"plugins": [
28+
"npm",
29+
"released"
30+
],
31+
"onlyPublishWithReleaseLabel": true
3032
}
3133
}
File renamed without changes.

packages/build/build.js

-13
This file was deleted.

packages/build/package.json

-15
This file was deleted.

packages/build/rollup.config.js

-50
This file was deleted.

packages/player/package.json renamed to packages/classer/package.json

+12-13
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,29 @@
11
{
2-
"name": "@code-hike/player",
3-
"version": "0.2.1",
4-
"main": "dist/index.js",
2+
"name": "@code-hike/classer",
3+
"version": "0.3.0-next.0",
4+
"main": "dist/index.cjs.js",
55
"typings": "dist/index.d.ts",
66
"module": "dist/index.esm.js",
77
"files": [
88
"dist"
99
],
1010
"scripts": {
11-
"build": "ch-build",
12-
"watch": "ch-build --watch"
11+
"x": "x"
1312
},
1413
"devDependencies": {
15-
"@code-hike/build": "0.0.1",
16-
"@types/react": "^16.9.38",
17-
"react": "^16.13.1"
14+
"@code-hike/script": "0.0.1",
15+
"@types/react": "^17.0.2",
16+
"react": "^17.0.2"
1817
},
19-
"dependencies": {},
2018
"peerDependencies": {
21-
"react": ">=16.8"
19+
"react": "^16.8.3 || ^17 || ^18"
2220
},
23-
"keywords": [
24-
"react"
25-
],
2621
"homepage": "https://codehike.org",
2722
"repository": "code-hike/codehike",
23+
"publishConfig": {
24+
"access": "public"
25+
},
26+
"author": "Rodrigo Pombo",
2827
"license": "MIT",
2928
"funding": {
3029
"type": "opencollective",

packages/classer/readme.md

+106
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
> Classer is a tool from [Code Hike](https://codehike.org)
2+
3+
A little package to make React component libraries interoperable with most styling solutions. ([See this twitter thread explaining why this is useful](https://twitter.com/pomber/status/1362125599607820290))
4+
5+
You write your library code like this:
6+
7+
```jsx
8+
// foo-library code
9+
import { useClasser } from "@code-hike/classer"
10+
11+
export function Foo({ classes }) {
12+
const c = useClasser("foo", classes)
13+
return (
14+
<div className={c("container")}>
15+
<h1 className={c("title")}>Hello</h1>
16+
<p className={c("description")}>World</p>
17+
<img
18+
className={c("img")}
19+
src="https://placekitten.com/200/200"
20+
/>
21+
</div>
22+
)
23+
}
24+
```
25+
26+
And the library consumers use it like this in their apps:
27+
28+
```jsx
29+
import { Foo } from "foo-library"
30+
31+
const classes = {
32+
"foo-title": "my-app-blue",
33+
"foo-img": "rounded-corners some-border",
34+
}
35+
36+
function MyApp() {
37+
return <Foo classes={classes} />
38+
}
39+
```
40+
41+
`MyApp` renders this HTML:
42+
43+
```html
44+
<div class="foo-container">
45+
<h1 class="foo-title my-app-blue">Hello</h1>
46+
<p class="foo-description">World</p>
47+
<img
48+
class="foo-img rounded-corners some-border"
49+
src="https://placekitten.com/200/200"
50+
/>
51+
</div>
52+
```
53+
54+
Examples:
55+
56+
- [With Emotion](https://codesandbox.io/s/classer-emotion-b7go0)
57+
- [With Tailwind](https://codesandbox.io/s/classer-tailwind-wfs1d)
58+
59+
## Context
60+
61+
You can also do this (to avoid passing `classes` to nested components):
62+
63+
```jsx
64+
// foo-library code
65+
import {
66+
useClasser,
67+
ClasserProvider,
68+
} from "@code-hike/classer"
69+
70+
export function Foo({ classes }) {
71+
return (
72+
<ClasserProvider classes={classes}>
73+
<FirstChild />
74+
<SecondChild />
75+
</ClasserProvider>
76+
)
77+
}
78+
79+
function FirstChild() {
80+
const c = useClasser("foo-first")
81+
return <h1 className={c("title")}>Hi</h1>
82+
}
83+
84+
function SecondChild() {
85+
const c = useClasser("foo-second")
86+
return <h1 className={c("title")}>Ho</h1>
87+
}
88+
```
89+
90+
```jsx
91+
import { Foo } from "./foo-library"
92+
import styles from "./app.module.css"
93+
94+
const classes = {
95+
"foo-title": styles.myTitle,
96+
"foo-img": styles.myImage,
97+
}
98+
99+
function MyApp() {
100+
return <Foo classes={classes} />
101+
}
102+
```
103+
104+
## License
105+
106+
MIT

0 commit comments

Comments
 (0)