Skip to content

Commit

Permalink
Merge pull request #9 from novemberfiveco-engineering/master
Browse files Browse the repository at this point in the history
Create seperate type files.
  • Loading branch information
jerson authored Jun 26, 2019
2 parents 0ed3b92 + c824614 commit 0059941
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 23 deletions.
28 changes: 28 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
declare module 'react-native-palette-full' {
export enum ISwatchType {
vibrant = 'Vibrant',
vibrantDark = 'Vibrant Dark',
vibrantLight = 'Vibrant Light',
muted = 'Video',
mutedDark = 'Muted Dark',
mutedLight = 'Muted Light',
}

export interface ISwatch {
color: string;
}

export interface IPalette {
[key: string]: ISwatch;
}

export default class Palette {
static getNamedSwatchesFromUrl(url: string): IPalette;

static getAllSwatchesFromUrl(url: string): ISwatch[];

static getNamedSwatches(path: string): IPalette;

static getAllSwatches(path: string): ISwatch[];
}
}
25 changes: 4 additions & 21 deletions index.ts → index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,24 @@ import { NativeModules } from 'react-native';

const { RNPalette } = NativeModules;

export enum ISwatchType {
vibrant = 'Vibrant',
vibrantDark = 'Vibrant Dark',
vibrantLight = 'Vibrant Light',
muted = 'Video',
mutedDark = 'Muted Dark',
mutedLight = 'Muted Light',
}

export interface ISwatch {
color: string;
}

export interface IPalette {
[key: string]: ISwatch;
}

const TAG = '[Palette]';
export default class Palette {
static getNamedSwatchesFromUrl(url: string): IPalette {
static getNamedSwatchesFromUrl(url) {
__DEV__ && console.debug(TAG, 'getNamedSwatchesFromUrl', url);
return RNPalette.getNamedSwatchesFromUrl(url);
}

static getAllSwatchesFromUrl(url: string): ISwatch[] {
static getAllSwatchesFromUrl(url) {
__DEV__ && console.debug(TAG, 'getAllSwatchesFromUrl', url);
return RNPalette.getAllSwatchesFromUrl(url);
}

static getNamedSwatches(path: string): IPalette {
static getNamedSwatches(path) {
__DEV__ && console.debug(TAG, 'getNamedSwatches', path);
return RNPalette.getNamedSwatches(path);
}

static getAllSwatches(path: string): ISwatch[] {
static getAllSwatches(path) {
__DEV__ && console.debug(TAG, 'getAllSwatches', path);
return RNPalette.getAllSwatches(path);
}
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"name": "react-native-palette-full",
"version": "1.0.8",
"version": "1.0.9",
"description": "",
"main": "index.ts",
"main": "index.js",
"types": "index.d.ts",
"repository": {
"type": "git",
"url": "https://github.com/jerson/react-native-palette-full"
Expand Down

0 comments on commit 0059941

Please sign in to comment.