mirror of
https://github.com/yangshun/tech-interview-handbook.git
synced 2025-07-14 18:05:55 +08:00
feat: scaffold monorepo
This commit is contained in:
8
packages/ui/.eslintrc.js
Normal file
8
packages/ui/.eslintrc.js
Normal file
@ -0,0 +1,8 @@
|
||||
module.exports = {
|
||||
root: true,
|
||||
extends: ['tih'],
|
||||
parserOptions: {
|
||||
tsconfigRootDir: __dirname,
|
||||
project: ['./tsconfig.json'],
|
||||
},
|
||||
};
|
30
packages/ui/package.json
Normal file
30
packages/ui/package.json
Normal file
@ -0,0 +1,30 @@
|
||||
{
|
||||
"name": "@tih/ui",
|
||||
"version": "0.0.0",
|
||||
"private": true,
|
||||
"license": "MIT",
|
||||
"sideEffects": false,
|
||||
"main": "./dist/index.js",
|
||||
"module": "./dist/index.mjs",
|
||||
"types": "./dist/index.d.ts",
|
||||
"files": [
|
||||
"dist/**"
|
||||
],
|
||||
"scripts": {
|
||||
"build": "tsup src/index.tsx --format esm,cjs --dts --external react",
|
||||
"clean": "rm -rf dist",
|
||||
"tsc": "tsc",
|
||||
"dev": "tsup src/index.tsx --format esm,cjs --watch --dts --external react",
|
||||
"lint": "eslint src/**/*.ts* --fix"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@tih/tsconfig": "*",
|
||||
"@types/react": "^18.0.21",
|
||||
"@types/react-dom": "^18.0.6",
|
||||
"eslint": "^8.24.0",
|
||||
"eslint-config-tih": "*",
|
||||
"react": "^18.2.0",
|
||||
"tsup": "^6.2.3",
|
||||
"typescript": "^4.8.3"
|
||||
}
|
||||
}
|
42
packages/ui/src/CounterButton.tsx
Normal file
42
packages/ui/src/CounterButton.tsx
Normal file
@ -0,0 +1,42 @@
|
||||
import * as React from 'react';
|
||||
|
||||
export function CounterButton() {
|
||||
const [count, setCount] = React.useState(0);
|
||||
return (
|
||||
<div
|
||||
style={{
|
||||
background: `rgba(0,0,0,0.05)`,
|
||||
borderRadius: `8px`,
|
||||
fontWeight: 500,
|
||||
padding: '1.5rem',
|
||||
}}>
|
||||
<p style={{ margin: '0 0 1.5rem 0' }}>
|
||||
This component is from{' '}
|
||||
<code
|
||||
style={{
|
||||
background: `rgba(0,0,0,0.1)`,
|
||||
borderRadius: '0.25rem',
|
||||
padding: '0.2rem 0.3rem',
|
||||
}}>
|
||||
@tih/ui
|
||||
</code>
|
||||
</p>
|
||||
<div>
|
||||
<button
|
||||
style={{
|
||||
background: 'black',
|
||||
border: 'none',
|
||||
borderRadius: '0.25rem',
|
||||
color: 'white',
|
||||
cursor: 'pointer',
|
||||
display: 'inline-block',
|
||||
padding: '0.5rem 1rem',
|
||||
}}
|
||||
type="button"
|
||||
onClick={() => setCount((c) => c + 1)}>
|
||||
Count: {count}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
15
packages/ui/src/NewTabLink.tsx
Normal file
15
packages/ui/src/NewTabLink.tsx
Normal file
@ -0,0 +1,15 @@
|
||||
import * as React from 'react';
|
||||
export function NewTabLink({
|
||||
children,
|
||||
href,
|
||||
...other
|
||||
}: {
|
||||
children: React.ReactNode;
|
||||
href: string;
|
||||
}) {
|
||||
return (
|
||||
<a href={href} rel="noreferrer" target="_blank" {...other}>
|
||||
{children}
|
||||
</a>
|
||||
);
|
||||
}
|
2
packages/ui/src/index.tsx
Normal file
2
packages/ui/src/index.tsx
Normal file
@ -0,0 +1,2 @@
|
||||
export { CounterButton } from './CounterButton';
|
||||
export { NewTabLink } from './NewTabLink';
|
8
packages/ui/tsconfig.json
Normal file
8
packages/ui/tsconfig.json
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"lib": ["dom", "ES2015"]
|
||||
},
|
||||
"extends": "@tih/tsconfig/react-library.json",
|
||||
"include": ["."],
|
||||
"exclude": ["dist", "build", "node_modules"]
|
||||
}
|
Reference in New Issue
Block a user