Skip to content

Commit

Permalink
Merge pull request #1 from kanzitelli/improvements
Browse files Browse the repository at this point in the history
Improvements
  • Loading branch information
kanzitelli authored Sep 27, 2021
2 parents 055628e + d388181 commit c3bcaec
Show file tree
Hide file tree
Showing 9 changed files with 1,764 additions and 46 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules/
*.log
lib/
lib/
*.env
3 changes: 2 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules/
src/
src/
*.env
7 changes: 7 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
singleQuote: true,
trailingComma: 'all',
printWidth: 100,
bracketSpacing: false,
arrowParens: 'avoid',
};
15 changes: 15 additions & 0 deletions .release-it.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"non-interactive": true,
"git": {
"requireCleanWorkingDir": false
},
"npm": {
"publish": false
},
"src": {
"tagName": "v${version}"
},
"github": {
"release": true
}
}
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
<img src="https://xxx-files.ggc.team/oss/if-component/if-component-readme.png" width="100%" title="Logo">

### Install it

```🤏
yarn add @kanzitelli/if-component
```

### Use it

```tsx
import { If } from '@kanzitelli/if-component';
import {If} from '@kanzitelli/if-component';

class OrdersScreen = () => {
return (
Expand All @@ -19,3 +21,13 @@ class OrdersScreen = () => {
)
}
```

### TS lib starter

```bash
> git clone https://github.com/kanziteli/if-component rn-lib
> cd rn-lib && rm -rf .git
> yarn
```

Don't forget to change your lib's name in `package.json` and check other scripts.
24 changes: 17 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
{
"name": "@kanzitelli/if-component",
"version": "0.0.1",
"description": "🤏 the tiniest missing component for React (Native). just fun experiment",
"version": "0.0.2",
"description": "The tiniest missing component for React (Native). Can be used as a TS starter for building components or libraries.",
"author": "Batyr (dev@batyr.io)",
"main": "lib/index.js",
"scripts": {
"build": "cd src && tsc && cp ../package.json ../lib/ && echo Build completed!",
"clean": "rm -rf ./node_modules ./package-lock.json && yarn"
"clean": "rm -rf ./node_modules ./package-lock.json && yarn",
"lint": "eslint . --ext .js,.jsx,.ts,.tsx",
"format:check": "prettier --check ./src",
"format:write": "prettier --write ./src",
"release:github": "yarn build && dotenv release-it",
"release:npm": "yarn build && npm publish --access public",
"release:npm:private": "yarn build && npm publish"
},
"keywords": [
"react",
Expand All @@ -17,10 +23,14 @@
"react": ">= 16.x.x"
},
"devDependencies": {
"@types/node": "^14.14.25",
"@types/react": "^17.0.1",
"ts-node": "^9.1.1",
"typescript": "^4.1.4"
"@react-native-community/eslint-config": "^3.0.1",
"@types/node": "^16.10.1",
"@types/react": "^17.0.24",
"dotenv-cli": "^4.0.0",
"eslint": "^7.32.0",
"prettier": "^2.4.1",
"ts-node": "^10.2.1",
"typescript": "^4.4.3"
},
"license": "MIT"
}
10 changes: 5 additions & 5 deletions src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
type IfProps = {
export type IfProps = {
_: boolean;
_then: JSX.Element;
_else?: JSX.Element;
}
export const If = ({_,_then,_else}: IfProps) => (_ ? _then : _else || null);
_then: JSX.Element | React.FC<any>;
_else?: JSX.Element | React.FC<any>;
};
export const If = ({_, _then, _else}: IfProps) => (_ ? (typeof _then === 'function' ? _then({}) : _then) : (typeof _else === 'function' ? _else({}) : _else) || null);
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"dom"
],
"declaration": true,
"jsx": "react-native",
"outDir": "lib",
"rootDir": "src",
"strict": true,
Expand Down
Loading

0 comments on commit c3bcaec

Please sign in to comment.