From 2ff803ff9187fc4837a79924435f2d98f8a3bdda Mon Sep 17 00:00:00 2001 From: feitzi Date: Mon, 19 Sep 2016 20:14:41 +0200 Subject: [PATCH] refactored: randomColor to randomcolor --- randomColor/randomColor.d.ts | 2 +- randomcolor/randomcolor-tests.ts | 40 ++++++++++++++++++++++++++++++++ randomcolor/randomcolor.d.ts | 28 ++++++++++++++++++++++ 3 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 randomcolor/randomcolor-tests.ts create mode 100644 randomcolor/randomcolor.d.ts diff --git a/randomColor/randomColor.d.ts b/randomColor/randomColor.d.ts index 1c52f39be1..a92af51453 100644 --- a/randomColor/randomColor.d.ts +++ b/randomColor/randomColor.d.ts @@ -23,6 +23,6 @@ interface randomColorOptions { declare var randomColor: RandomColor.RandomColorStatic; -declare module 'randomColor' { +declare module 'randomcolor' { export = randomColor; } \ No newline at end of file diff --git a/randomcolor/randomcolor-tests.ts b/randomcolor/randomcolor-tests.ts new file mode 100644 index 0000000000..69b617615e --- /dev/null +++ b/randomcolor/randomcolor-tests.ts @@ -0,0 +1,40 @@ +/// + +// Returns a hex code for an attractive color +randomColor(); + +// Returns an array of ten green colors +randomColor({ + count: 10, + hue: 'green' +}); + +// Returns a hex code for a light blue +randomColor({ + luminosity: 'light', + hue: 'blue' +}); + +// Returns a hex code for a 'truly random' color +randomColor({ + luminosity: 'random', + hue: 'random' +}); + +// Returns a bright color in RGB +randomColor({ + luminosity: 'bright', + format: 'rgb' // e.g. 'rgb(225,200,20)' +}); + +// Returns a dark RGB color with random alpha +randomColor({ + luminosity: 'dark', + format: 'rgba' // e.g. 'rgba(9, 1, 107, 0.6482447960879654)' +}); + +// Returns a light HSL color with random alpha +randomColor({ + luminosity: 'light', + format: 'hsla' // e.g. 'hsla(27, 88.99%, 81.83%, 0.6450211517512798)' +}); \ No newline at end of file diff --git a/randomcolor/randomcolor.d.ts b/randomcolor/randomcolor.d.ts new file mode 100644 index 0000000000..a92af51453 --- /dev/null +++ b/randomcolor/randomcolor.d.ts @@ -0,0 +1,28 @@ +// Type definitions for randomColor 0.4.1 +// Project: https://github.com/davidmerfield/randomColor +// Definitions by: Mathias Feitzinger +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare namespace RandomColor { + + interface RandomColorStatic { + + () : string; + + (options : randomColorOptions): string; +} + +interface randomColorOptions { + hue? : string; + luminosity? : string; + count? : string | number; + seed?: string; + format?: string; + } +} + +declare var randomColor: RandomColor.RandomColorStatic; + +declare module 'randomcolor' { + export = randomColor; +} \ No newline at end of file