-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7335ad5
commit 2ce22bc
Showing
14 changed files
with
205 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,57 @@ | ||
import { ModeSettings } from '@jikan0/ui'; | ||
import { | ||
ModeSelectorSettingsViewActions, | ||
ModeSelectorSettingsViewValue, | ||
ModeSelectorSettingViewModeActions | ||
} from '@jikan0/ui'; | ||
import React from 'react'; | ||
import { Text, View } from 'react-native'; | ||
import { useForm } from 'react-hook-form'; | ||
import { Button, SafeAreaView, Text, TextInput, View } from 'react-native'; | ||
import { Controller, useForm } from 'react-hook-form'; | ||
import { flow } from 'effect'; | ||
import RNPickerSelect from 'react-native-picker-select'; | ||
import { useOnAction } from '@jikan0/ui-react-utils'; | ||
import * as ui from '@jikan0/ui'; | ||
|
||
|
||
export type Props = { | ||
settings: ModeSettings | ||
settings: ModeSelectorSettingsViewValue | ||
onAction: (action: ui.Event) => void | ||
actions: ModeSelectorSettingsViewActions | ||
} | ||
|
||
const simpleSettings: React.FC<{settings: ModeSettings['settings']['simple']}> = ({settings}) => | ||
const SimpleSettings: React.FC<Props> = ({settings, onAction, actions}) => | ||
{ | ||
const {register, handleSubmit} = useForm({ | ||
defaultValues: settings | ||
}); | ||
return ( | ||
<View> | ||
|
||
</View> | ||
const onSubmit = (data: unknown) => console.log(data) | ||
|
||
const makeOnChange = | ||
( | ||
makeAction: ModeSelectorSettingViewModeActions<'simple'>[keyof ModeSelectorSettingViewModeActions<'simple'>] | ||
) => | ||
(n: number) => { | ||
const v = BigInt(n); | ||
onAction(makeAction(v)); | ||
}; | ||
|
||
return ( | ||
<SafeAreaView> | ||
<View> | ||
<Text>Rounds:</Text> | ||
<RNPickerSelect | ||
value={Number(settings.rounds)} | ||
onValueChange={makeOnChange(actions.simple.setRounds)} | ||
items={Array.from( | ||
{ length: 50 }, | ||
(_, i) => i + 1 | ||
).map((i) => ({ label: String(i), value: i }))} | ||
/> | ||
</View> | ||
</SafeAreaView> | ||
) | ||
} | ||
|
||
export const view: React.FC<Props> = ({settings: {selected, settings}}) => | ||
export const Component: React.FC<Props> = (props) => | ||
<View> | ||
<View>Settings</View> | ||
<View><Text>Mode: {selected}</Text></View> | ||
<View><Text>Settings</Text></View> | ||
<View><Text>Mode: {props.settings.mode}</Text></View> | ||
{props.settings.mode === 'simple' && <SimpleSettings {...props}/>} | ||
</View> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"extends": ["../.eslintrc.json"], | ||
"ignorePatterns": ["!**/*"], | ||
"overrides": [ | ||
{ | ||
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"], | ||
"rules": {} | ||
}, | ||
{ | ||
"files": ["*.ts", "*.tsx"], | ||
"rules": {} | ||
}, | ||
{ | ||
"files": ["*.js", "*.jsx"], | ||
"rules": {} | ||
}, | ||
{ | ||
"files": ["*.json"], | ||
"parser": "jsonc-eslint-parser", | ||
"rules": { | ||
"@nx/dependency-checks": "error" | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# ui-react-utils | ||
|
||
This library was generated with [Nx](https://nx.dev). | ||
|
||
## Building | ||
|
||
Run `nx build ui-react-utils` to build the library. | ||
|
||
## Running unit tests | ||
|
||
Run `nx test ui-react-utils` to execute the unit tests via [Jest](https://jestjs.io). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/* eslint-disable */ | ||
export default { | ||
displayName: 'ui-react-utils', | ||
preset: '../jest.preset.js', | ||
testEnvironment: 'node', | ||
transform: { | ||
'^.+\\.[tj]s$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.spec.json' }], | ||
}, | ||
moduleFileExtensions: ['ts', 'js', 'html'], | ||
coverageDirectory: '../coverage/ui-react-utils', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"name": "@jikan0/ui-react-utils", | ||
"version": "0.0.1", | ||
"dependencies": { | ||
"tslib": "^2.3.0" | ||
}, | ||
"type": "commonjs", | ||
"main": "./src/index.js", | ||
"typings": "./src/index.d.ts" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"name": "ui-react-utils", | ||
"$schema": "../node_modules/nx/schemas/project-schema.json", | ||
"sourceRoot": "ui-react-utils/src", | ||
"projectType": "library", | ||
"targets": { | ||
"build": { | ||
"executor": "@nx/js:tsc", | ||
"outputs": ["{options.outputPath}"], | ||
"options": { | ||
"outputPath": "dist/ui-react-utils", | ||
"main": "ui-react-utils/src/index.ts", | ||
"tsConfig": "ui-react-utils/tsconfig.lib.json", | ||
"assets": ["ui-react-utils/*.md"] | ||
} | ||
}, | ||
"lint": { | ||
"executor": "@nx/eslint:lint" | ||
}, | ||
"test": { | ||
"executor": "@nx/jest:jest", | ||
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"], | ||
"options": { | ||
"jestConfig": "ui-react-utils/jest.config.ts" | ||
} | ||
} | ||
}, | ||
"tags": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './lib/ui-react-utils'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import * as ui from '@jikan0/ui'; | ||
import { useCallback } from 'react'; | ||
|
||
export const useOnAction = ({ | ||
setUiState, | ||
uiState, | ||
}: { | ||
setUiState: (state: ui.State) => void; | ||
uiState: ui.State; | ||
}) => | ||
useCallback( | ||
(action: ui.Action) => setUiState(ui.reduce(action)(uiState)), | ||
[setUiState, uiState] | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"extends": "../tsconfig.base.json", | ||
"compilerOptions": { | ||
"module": "commonjs", | ||
"forceConsistentCasingInFileNames": true, | ||
"strict": true, | ||
"noImplicitOverride": true, | ||
"noPropertyAccessFromIndexSignature": true, | ||
"noImplicitReturns": true, | ||
"noFallthroughCasesInSwitch": true | ||
}, | ||
"files": [], | ||
"include": [], | ||
"references": [ | ||
{ | ||
"path": "./tsconfig.lib.json" | ||
}, | ||
{ | ||
"path": "./tsconfig.spec.json" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"compilerOptions": { | ||
"outDir": "../dist/out-tsc", | ||
"declaration": true, | ||
"types": ["node"] | ||
}, | ||
"include": ["src/**/*.ts"], | ||
"exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"compilerOptions": { | ||
"outDir": "../dist/out-tsc", | ||
"module": "commonjs", | ||
"types": ["jest", "node"] | ||
}, | ||
"include": [ | ||
"jest.config.ts", | ||
"src/**/*.test.ts", | ||
"src/**/*.spec.ts", | ||
"src/**/*.d.ts" | ||
] | ||
} |