From 35f0b3bdf9a61e2eb1b41f09adc7bf8e077d037c Mon Sep 17 00:00:00 2001 From: Allan Pope Date: Fri, 14 Feb 2020 02:42:19 +0100 Subject: [PATCH] Add @theme-ui/color (#42358) * Add types using polished and the renamed functions * run prettier --- types/theme-ui__color/index.d.ts | 17 +++++++++ types/theme-ui__color/package.json | 6 ++++ .../theme-ui__color/theme-ui__color-tests.ts | 36 +++++++++++++++++++ types/theme-ui__color/tsconfig.json | 27 ++++++++++++++ types/theme-ui__color/tslint.json | 1 + 5 files changed, 87 insertions(+) create mode 100644 types/theme-ui__color/index.d.ts create mode 100644 types/theme-ui__color/package.json create mode 100644 types/theme-ui__color/theme-ui__color-tests.ts create mode 100644 types/theme-ui__color/tsconfig.json create mode 100644 types/theme-ui__color/tslint.json diff --git a/types/theme-ui__color/index.d.ts b/types/theme-ui__color/index.d.ts new file mode 100644 index 0000000000..1afe74142e --- /dev/null +++ b/types/theme-ui__color/index.d.ts @@ -0,0 +1,17 @@ +// Type definitions for @theme-ui/color 0.3 +// Project: https://github.com/system-ui/theme-ui +// Definitions by: Allan Pope +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 3.5 + +export * from 'polished'; +// A few polished functions have been renamed in theme-ui +// If these are updated in polished, then the code below can be deleted +import { + adjustHue as rotate, + rgba as alpha, + setHue as hue, + setLightness as lightness, + setSaturation as saturation, +} from 'polished'; +export { alpha, hue, lightness, rotate, saturation }; diff --git a/types/theme-ui__color/package.json b/types/theme-ui__color/package.json new file mode 100644 index 0000000000..2a60d696c4 --- /dev/null +++ b/types/theme-ui__color/package.json @@ -0,0 +1,6 @@ +{ + "private": true, + "dependencies": { + "polished": "^3.4.1" + } +} diff --git a/types/theme-ui__color/theme-ui__color-tests.ts b/types/theme-ui__color/theme-ui__color-tests.ts new file mode 100644 index 0000000000..ddef1da74f --- /dev/null +++ b/types/theme-ui__color/theme-ui__color-tests.ts @@ -0,0 +1,36 @@ +import { + darken, + lighten, + rotate, + hue, + saturation, + lightness, + desaturate, + saturate, + shade, + tint, + transparentize, + alpha, + mix, + complement, + invert, + grayscale, +} from '@theme-ui/color'; + +darken(0.2, '#000'); +lighten(0.2, '#000'); +rotate(0.2, '#000'); +hue(0.2, '#000'); +saturation(0.2, '#000'); +lightness(0.2, '#000'); +desaturate(0.1, '#000'); +saturate(0.1, '#000'); +shade('20%', '#000'); +tint('20%', '#000'); +transparentize(0.2, '#000'); +alpha('#000', 0.2); +mix(0.25, '#000', '#FFF'); +complement('#000'); +complement('#000'); +invert('#000'); +grayscale('#000'); diff --git a/types/theme-ui__color/tsconfig.json b/types/theme-ui__color/tsconfig.json new file mode 100644 index 0000000000..1169f21398 --- /dev/null +++ b/types/theme-ui__color/tsconfig.json @@ -0,0 +1,27 @@ +{ + "compilerOptions": { + "jsx": "preserve", + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictFunctionTypes": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "paths": { + "@theme-ui/color": ["theme-ui__color"] + }, + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "theme-ui__color-tests.ts" + ] +} diff --git a/types/theme-ui__color/tslint.json b/types/theme-ui__color/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/theme-ui__color/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }