Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"presets": [
"module:metro-react-native-babel-preset"
]
}
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ coverage
node_modules

.DS_Store
.env
.env
31 changes: 17 additions & 14 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
export interface IButton {
value: any;
component(): React.ReactNode;
value: any;
component(): React.ReactNode;
}

export interface withRadialActionMenu {
backgroundColor?: string;
buttonDiameter?: number;
buttons: IButton[];
menuDiameter?: number;
openDelay?: number;
spreadAngle?: number;
spreadRadius?: number;
vibrate?: boolean;
vibrateDuration?: number;
onClose?(value: IButton["value"]): void;
onOpen?(): void;
export interface withRadialActionMenuProps {
backgroundColor?: string;
buttonDiameter?: number;
buttons: IButton[];
menuDiameter?: number;
openDelay?: number;
spreadAngle?: number;
spreadRadius?: number;
vibrate?: boolean;
vibrateDuration?: number;
onClose?(value: IButton["value"]): void;
onOpen?(): void;
}

export const withRadialActionMenu = <P extends withRadialActionMenuProps>(
Component: React.ComponentType<P>
) => React.ComponentClass
18 changes: 18 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const { defaults: tsjPreset } = require('ts-jest/presets');

module.exports = {
...tsjPreset,
preset: 'react-native',
transform: {
...tsjPreset.transform,
'\\.js$': '<rootDir>/node_modules/react-native/jest/preprocessor.js',
},
globals: {
'ts-jest': {
babelConfig: true,
}
},
// This is the only part which you can keep
// from the above linked tutorial's config:
cacheDirectory: '.jest/cache',
};
12,570 changes: 6,430 additions & 6,140 deletions package-lock.json

Large diffs are not rendered by default.

62 changes: 18 additions & 44 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "react-native-radial-context-menu",
"version": "0.0.2",
"version": "0.1.0",
"description": "A react-native implementation of a radial action menu",
"scripts": {
"build": "tsc",
"clean": "rm -rf ./build",
"format": "prettier --trailing-comma es5 --write \"./src/**/*.ts?(x)\"",
"format": "prettier --trailing-comma --write \"./src/**/*.ts?(x)\"",
"lint": "tslint -c tslint.json \"./src/**/*.ts?(x)\"",
"prepare": "npm run clean && npm run build",
"start": "tsc -w",
Expand All @@ -27,52 +27,26 @@
"author": "John Flockton",
"license": "MIT",
"devDependencies": {
"@types/jest": "^23.3.8",
"@types/react": "^16.4.18",
"@types/react-native": "^0.57.7",
"@types/react-test-renderer": "^16.0.3",
"babel-jest": "^23.6.0",
"@types/jest": "^23.3.14",
"@types/react": "^16.9.35",
"@types/react-native": "^0.57.65",
"@types/react-test-renderer": "^16.9.2",
"babel-jest": "^26.0.1",
"babel-preset-react-native": "^4.0.1",
"jest": "^23.6.0",
"prettier": "^1.14.3",
"react": "^16.6.0",
"react-native": "^0.57.4",
"react-test-renderer": "^16.6.0",
"ts-jest": "^23.10.4",
"tslint": "^5.11.0",
"tslint-config-prettier": "^1.15.0",
"jest": "^26.0.1",
"prettier": "^1.19.1",
"react": "^16.13.1",
"react-native": "^0.62.2",
"react-test-renderer": "^16.13.1",
"ts-jest": "^26.0.0",
"tslint": "^5.20.1",
"tslint-config-prettier": "^1.18.0",
"tslint-react": "^3.6.0",
"typescript": "^3.1.4"
"typescript": "^3.9.3"
},
"peerDependencies": {
"react": "*",
"react-native": "*"
},
"babel": {
"presets": [
"react-native"
]
},
"jest": {
"preset": "react-native",
"globals": {
"ts-jest": {
"babelConfig": true
},
"window": {}
},
"moduleFileExtensions": [
"ts",
"tsx",
"js"
],
"transform": {
"\\.(ts|tsx)$": "ts-jest"
},
"testRegex": ".test.(ts|tsx)$",
"testPathIgnorePatterns": [
"<rootDir>/node_modules/"
],
"cacheDirectory": ".jest/cache"
}
}
"dependencies": {}
}
2 changes: 2 additions & 0 deletions src/components/Button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,15 @@ export class Button extends React.PureComponent<IButtonProps, IButtonState> {

Animated.spring(this.state.pan, {
toValue: { x, y },
useNativeDriver: false,
}).start();
};

private scaleAnimation = (toValue: number): void => {
Animated.spring(this.state.scale, {
speed: 20,
toValue,
useNativeDriver: false,
}).start();
};
}
6 changes: 5 additions & 1 deletion src/components/Menu/Menu.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ describe("Menu", () => {
{ component: () => <Text>2</Text>, value: "two" },
{ component: () => <Text>3</Text>, value: "three" },
],
coords: [{ x: 0, y: 0 }, { x: 0, y: 0 }, { x: 0, y: 0 }],
coords: [
{ x: 0, y: 0 },
{ x: 0, y: 0 },
{ x: 0, y: 0 },
],
menuDiameter: 80,
selected: 0,
vibrate: false,
Expand Down
3 changes: 2 additions & 1 deletion src/components/Menu/Menu.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as React from "react";
import { View } from "react-native";
import { Button, Circle } from "..";
import { Button } from "../Button";
import { Circle } from "../Circle";
import { styles } from "../../styles";
import { getSizeStyles } from "../../utils";

Expand Down
20 changes: 9 additions & 11 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
{
"compilerOptions": {
"target": "es5",
"skipLibCheck": true,
"target": "ESNEXT",
"module": "commonjs",
"jsx": "react-native",
"sourceMap": true,
"outDir": "build",
"lib": [
"dom",
"es7"
],
"jsx": "react-native",
"strict": true,
"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"skipLibCheck": true,
"allowSyntheticDefaultImports": true
}
}
"resolveJsonModule": true,
"forceConsistentCasingInFileNames": true
},
"exclude": ["./node_modules"]
}
8 changes: 2 additions & 6 deletions tslint.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
{
"extends": [
"tslint:recommended",
"tslint-react",
"tslint-config-prettier"
]
}
"extends": ["tslint:recommended", "tslint-react", "tslint-config-prettier"]
}