mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
Add @styled-system/core typings (#45332)
* Added @styled-system/core typings * fixed path in tsconfig * added csstype to package.json * changed project url
This commit is contained in:
parent
738491c9cb
commit
a586263e89
50
types/styled-system__core/index.d.ts
vendored
Normal file
50
types/styled-system__core/index.d.ts
vendored
Normal file
@ -0,0 +1,50 @@
|
||||
// Type definitions for @styled-system/core 5.1
|
||||
// Project: https://github.com/styled-system/styled-system
|
||||
// Definitions by: Leo Toneff <https://github.com/bragle>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 3.1
|
||||
|
||||
import * as CSS from 'csstype';
|
||||
|
||||
export function get(obj: any, ...paths: Array<string | number>): any;
|
||||
|
||||
export type ObjectOrArray<T, K extends keyof any = keyof any> = T[] | Record<K, T | Record<K, T> | T[]>;
|
||||
|
||||
export type Scale = ObjectOrArray<number | string>;
|
||||
|
||||
export interface styleFn {
|
||||
(...args: any[]): any;
|
||||
|
||||
config?: object;
|
||||
propNames?: string[];
|
||||
cache?: object;
|
||||
}
|
||||
|
||||
export interface ConfigStyle {
|
||||
/** The CSS property to use in the returned style object (overridden by `properties` if present). */
|
||||
property?: keyof CSS.Properties;
|
||||
/**
|
||||
* An array of multiple properties (e.g. `['marginLeft', 'marginRight']`) to which this style's value will be
|
||||
* assigned (overrides `property` when present).
|
||||
*/
|
||||
properties?: Array<keyof CSS.Properties>;
|
||||
/** A string referencing a key in the `theme` object. */
|
||||
scale?: string;
|
||||
/** A fallback scale object for when there isn't one defined in the `theme` object. */
|
||||
defaultScale?: Scale;
|
||||
/** A function to transform the raw value based on the scale. */
|
||||
transform?: (value: any, scale?: Scale) => any;
|
||||
}
|
||||
|
||||
export interface Config {
|
||||
/** Property name exposed for use in components */
|
||||
[customStyleName: string]: ConfigStyle | boolean;
|
||||
}
|
||||
|
||||
export function compose(...parsers: styleFn[]): styleFn;
|
||||
|
||||
export function system(styleDefinitions: Config): styleFn;
|
||||
|
||||
export function createParser(config: ConfigStyle): styleFn;
|
||||
|
||||
export function createStyleFunction(args: ConfigStyle): styleFn;
|
||||
6
types/styled-system__core/package.json
Normal file
6
types/styled-system__core/package.json
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"csstype": "^2.6.10"
|
||||
}
|
||||
}
|
||||
19
types/styled-system__core/styled-system__core-tests.ts
Normal file
19
types/styled-system__core/styled-system__core-tests.ts
Normal file
@ -0,0 +1,19 @@
|
||||
import { compose, system, get } from '@styled-system/core';
|
||||
|
||||
// Test that the system definition is correct.
|
||||
// https://github.com/styled-system/styled-system/blob/master/packages/core/src/index.js#L131
|
||||
const customFontStyles = system({
|
||||
fontWeight: {
|
||||
property: 'fontWeight',
|
||||
properties: ['fontWeight'],
|
||||
scale: 'fontWeights',
|
||||
defaultScale: [200, 400, 600],
|
||||
transform: (n, scale) => get(scale, n),
|
||||
},
|
||||
letterSpacing: true,
|
||||
});
|
||||
|
||||
const CustomFontGroup = compose(
|
||||
customFontStyles,
|
||||
customFontStyles
|
||||
);
|
||||
19
types/styled-system__core/tsconfig.json
Normal file
19
types/styled-system__core/tsconfig.json
Normal file
@ -0,0 +1,19 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": ["es6"],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": ["../"],
|
||||
"paths": {
|
||||
"@styled-system/core": ["styled-system__core"]
|
||||
},
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": ["index.d.ts", "styled-system__core-tests.ts"]
|
||||
}
|
||||
1
types/styled-system__core/tslint.json
Normal file
1
types/styled-system__core/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user