Skip to content

Commit 7a0231b

Browse files
refactor: restructure workspace
0 parents  commit 7a0231b

File tree

309 files changed

+16522
-0
lines changed

Some content is hidden

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

309 files changed

+16522
-0
lines changed

.eslintignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/lib
2+
/workshop/.workshop-scopes.ts
3+
/workshop/public

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/lib
2+
/node_modules
3+
/workshop/public

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2016 - 2020 Sanity.io
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# @sanity/ui
2+
3+
The Sanity UI components.
4+
5+
```sh
6+
npm install @sanity/ui
7+
8+
# Install peer dependencies
9+
npm install react react-dom styled-components
10+
```
11+
12+
[![npm version](https://img.shields.io/npm/v/@sanity/ui.svg?style=flat-square)](https://www.npmjs.com/package/@sanity/ui)
13+
14+
## Usage
15+
16+
```jsx
17+
import {Button, studioTheme, ThemeProvider} from '@sanity/ui'
18+
import React from 'react'
19+
import ReactDOM from 'react-dom'
20+
21+
ReactDOM.render(
22+
<ThemeProvider theme={studioTheme}>
23+
<Button>Hello, world</Button>
24+
</ThemeProvider>,
25+
document.getElementById('root')
26+
)
27+
```
28+
29+
## License
30+
31+
MIT-licensed. See LICENSE.

jest.config.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = {
2+
preset: 'ts-jest',
3+
setupFilesAfterEnv: ['<rootDir>/test/setupTests.ts'],
4+
modulePathIgnorePatterns: ['<rootDir>/lib/'],
5+
}

package.json

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
{
2+
"name": "@sanity/ui",
3+
"version": "0.33.21",
4+
"main": "lib/cjs/index.js",
5+
"module": "lib/esm/index.js",
6+
"files": [
7+
"/lib"
8+
],
9+
"license": "MIT",
10+
"sideEffects": false,
11+
"scripts": {
12+
"build": "run-s build:esbuild build:dts copy:dts:* clean:dts",
13+
"build:esbuild": "node -r esbuild-register scripts/build.ts",
14+
"build:dts": "tsc --emitDeclarationOnly --outDir lib/dts --project tsconfig.lib.json --rootDir src",
15+
"clean": "rimraf lib workshop/public",
16+
"clean:dts": "rimraf lib/dts",
17+
"copy:dts:cjs": "cpx 'lib/dts/**/*.{d.ts,d.ts.map}' lib/cjs",
18+
"copy:dts:es": "cpx 'lib/dts/**/*.{d.ts,d.ts.map}' lib/esm",
19+
"dev": "(cd workshop && vite)",
20+
"lint": "eslint . --ext .js,.jsx,.mjs,.ts,.tsx",
21+
"prebuild": "yarn clean",
22+
"workshop:build": "(cd workshop && rimraf public && NODE_ENV=production vite build)",
23+
"workshop:start": "http-server -a localhost -c-0 -p 9009 -s -P http://localhost:9009/index.html? workshop/public",
24+
"test": "jest",
25+
"type-check": "tsc -b",
26+
"watch": "run-p watch:*",
27+
"watch:cjs": "tsc --preserveWatchOutput -w --module CommonJS --outDir lib/cjs --project tsconfig.lib.json --rootDir src --target ES5",
28+
"watch:es": "tsc --preserveWatchOutput -w --module ES6 --outDir lib/esm --project tsconfig.lib.json --rootDir src --target ES6"
29+
},
30+
"dependencies": {
31+
"@juggle/resize-observer": "^3.3.1",
32+
"@popperjs/core": "^2.9.2",
33+
"@reach/auto-id": "^0.15.0",
34+
"@sanity/color": "^2.0.16",
35+
"@sanity/icons": "^1.0.7",
36+
"framer-motion": "^4.1.14",
37+
"popper-max-size-modifier": "^0.2.0",
38+
"react-is": "^17.0.2",
39+
"react-popper": "^2.2.5",
40+
"react-refractor": "^2.1.4"
41+
},
42+
"devDependencies": {
43+
"@types/refractor": "^3.0.0",
44+
"@types/styled-components": "^5.1.9",
45+
"@vitejs/plugin-react-refresh": "^1.3.3",
46+
"chokidar": "^3.5.1",
47+
"react": "^17.0.2",
48+
"react-dom": "^17.0.2",
49+
"styled-components": "^5.3.0",
50+
"vite": "^2.3.0"
51+
},
52+
"peerDependencies": {
53+
"react": "^16.9 || ^17",
54+
"react-dom": "^16.9 || ^17",
55+
"styled-components": "^5.2"
56+
},
57+
"repository": {
58+
"type": "git",
59+
"url": "git+https://github.com/sanity-io/design.git"
60+
},
61+
"bugs": {
62+
"url": "https://github.com/sanity-io/design/issues"
63+
},
64+
"keywords": [
65+
"sanity",
66+
"ui",
67+
"components"
68+
],
69+
"author": "Sanity.io <hello@sanity.io>",
70+
"homepage": "https://www.sanity.io/",
71+
"publishConfig": {
72+
"access": "public"
73+
}
74+
}

scripts/build.ts

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import path from 'path'
2+
import esbuild from 'esbuild'
3+
import globby from 'globby'
4+
5+
const rootPath = path.resolve(__dirname, '..')
6+
7+
const define = {
8+
'process.env.NODE_ENV': JSON.stringify('production'),
9+
}
10+
11+
async function _findEntryPoints() {
12+
const files = await globby([
13+
path.resolve(rootPath, 'src/**/*.ts'),
14+
path.resolve(rootPath, 'src/**/*.tsx'),
15+
])
16+
17+
return files.filter((file) => {
18+
return (
19+
!file.includes('__fixtures__') &&
20+
!file.endsWith('.workshop.tsx') &&
21+
!file.endsWith('.test.ts') &&
22+
!file.endsWith('.test.tsx')
23+
)
24+
})
25+
}
26+
27+
function _buildCjs(entryPoints: string[]) {
28+
return esbuild.build({
29+
format: 'cjs',
30+
target: 'es2015',
31+
define,
32+
bundle: false,
33+
outdir: path.resolve(rootPath, 'lib/cjs'),
34+
sourcemap: 'external',
35+
loader: {'.js': 'jsx'},
36+
entryPoints,
37+
})
38+
}
39+
40+
function _buildEs(entryPoints: string[]) {
41+
return esbuild.build({
42+
format: 'esm',
43+
target: 'es2015',
44+
define,
45+
bundle: false,
46+
outdir: path.resolve(rootPath, 'lib/esm'),
47+
sourcemap: 'external',
48+
loader: {'.js': 'jsx'},
49+
entryPoints,
50+
})
51+
}
52+
53+
async function _build() {
54+
const entryPoints = await _findEntryPoints()
55+
56+
return Promise.all([_buildCjs(entryPoints), _buildEs(entryPoints)])
57+
}
58+
59+
_build().catch((err) => {
60+
console.error(err)
61+
process.exit(1)
62+
})

0 commit comments

Comments
 (0)