Skip to content

Commit

Permalink
Merge pull request #3 from copiest/feat/react
Browse files Browse the repository at this point in the history
feat: react 패키지 추가
  • Loading branch information
appear authored Jun 9, 2024
2 parents 7a1840a + 2260e25 commit 35f5487
Show file tree
Hide file tree
Showing 13 changed files with 1,198 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/wet-days-occur.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@copiest/react": patch
---

feat: react 패키지 추가
21 changes: 21 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: CI
on:
pull_request:
branches:
- '**'

jobs:
Build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: '20.x'
- name: setup pnpm and install dependencies
uses: pnpm/action-setup@v3
with:
version: 9.1.4
run_install: true
- run: pnpm run build
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,5 @@ dist
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*

.turbo
14 changes: 9 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
{
"name": "@copiest/frontend-libraries",
"name": "copiest-frontend-libraries",
"description": "copiest 공통 라이브러리",
"private": true,
"version": "0.0.0",
"description": "",
"repository": {
"type": "git",
"url": "https://github.com/copiest/frontend-libraries.git"
},
"scripts": {
"build": "turbo run build",
"release:canary": "pnpm build && changeset version --snapshot && pnpm publish --tag canary --no-git-checks"
"build": "turbo run build"
},
"keywords": [],
"author": "@copiest",
"packageManager": "pnpm@9.1.4",
"devDependencies": {
"turbo": "^1.13.3",
"@changesets/cli": "^2.27.5"
"@changesets/cli": "^2.27.5",
"@types/react": "^18",
"@types/react-dom": "^18",
"tsup": "^8.0.2",
"typescript": "^5.4.5"
}
}
33 changes: 33 additions & 0 deletions packages/react/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"name": "@copiest/react",
"version": "0.0.0",
"description": "copiest 공통 react",
"main": "./src/index.ts",
"exports": {
".": {
"require": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
},
"import": {
"types": "./dist/index.d.mts",
"default": "./dist/index.mjs"
}
}
},
"scripts": {
"build": "tsc && tsup"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"react": "^18.3.1"
},
"peerDependencies": {
"react": ">=17.0.0"
},
"publishConfig": {
"access": "public"
}
}
2 changes: 2 additions & 0 deletions packages/react/src/hooks/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './useToggle'
export * from './useBoolean'
19 changes: 19 additions & 0 deletions packages/react/src/hooks/useBoolean.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { useCallback, useState } from 'react';

export const useBooleanState = (defaultValue = false): readonly [boolean, () => void, () => void, () => void] => {
const [bool, setBool] = useState(defaultValue);

const setTrue = useCallback(() => {
setBool(true);
}, []);

const setFalse = useCallback(() => {
setBool(false);
}, []);

const toggle = useCallback(() => {
setBool(b => !b);
}, []);

return [bool, setTrue, setFalse, toggle] as const;
};
11 changes: 11 additions & 0 deletions packages/react/src/hooks/useToggle.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { useCallback, useState } from 'react';

export function useToggle(defaultValue = false): readonly [boolean, () => void] {
const [state, setState] = useState(defaultValue);

const toggle = useCallback(() => {
setState(prev => !prev);
}, []);

return [state, toggle] as const;
}
1 change: 1 addition & 0 deletions packages/react/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './hooks'
8 changes: 8 additions & 0 deletions packages/react/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"rootDir": "./src",
"outDir": "./dist"
},
"include": ["src"]
}
14 changes: 14 additions & 0 deletions packages/react/tsup.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { defineConfig } from 'tsup';

export default defineConfig({
name: 'tsup',
target: 'node16',
format: ['cjs', 'esm'],
outDir: 'dist',
splitting: false,
entry: ['./src/index.ts'],
dts: {
resolve: true,
entry: './src/index.ts',
},
});
Loading

0 comments on commit 35f5487

Please sign in to comment.