Skip to content

Commit

Permalink
feat: 🎸 add sheet addon typings
Browse files Browse the repository at this point in the history
  • Loading branch information
streamich committed Jul 21, 2018
1 parent fe0345c commit 2b86cc2
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
5 changes: 5 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {CreateNano} from './types/nano';
import {RuleAddon} from './types/addon/rule';
import {UnitsAddon} from './types/addon/units';
import {DruleAddon} from './types/addon/drule';
import {SheetAddon} from './types/addon/sheet';

export * from './types/nano';

Expand All @@ -17,6 +18,10 @@ declare module 'nano-css/addon/rdule' {
export const addon: DruleAddon;
}

declare module 'nano-css/addon/sheet' {
export const addon: SheetAddon;
}

declare module 'nano-css/addon/units' {
export const addon: UnitsAddon;
}
22 changes: 22 additions & 0 deletions types/addon/sheet.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import {CssLikeObject} from '../common';
import {NanoRenderer} from '../nano';

export interface SheetPatch {
/**
* Creates a collection of CSS rules.
*
* ```js
* const classes = sheet({
* wrapper: {
* border: '1px solid red',
* },
* button: {
* color: 'red',
* },
* });
* ```
*/
sheet: (cssMap: {[s: string]: CssLikeObject}, block?: string) => {[s: string]: string};
}

export type SheetAddon = <T extends NanoRenderer>(nano: T) => T & SheetPatch;
8 changes: 6 additions & 2 deletions types/nano.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import {CssLikeObject} from './common';
import {RulePatch} from './addon/rule';
import {DrulePatch} from './addon/drule';
import {UnitsPatch} from './addon/units';
import {SheetPatch} from './addon/sheet';

/*
interface NanoRenderer extends Partial<IUnits> {
sheet?: (cssMap: {[s: string]: ICssLikeObject}, block?: string) => {[s: string]: string};
dsheet?: (cssMap: {[s: string]: ICssLikeObject}, block?: string) => {[s: string]: TDynamicCss};
jsx?: (
type: THyperscriptType,
Expand Down Expand Up @@ -45,7 +45,11 @@ interface NanoRenderer extends Partial<IUnits> {
}
*/

export interface NanoRenderer extends Partial<RulePatch>, Partial<UnitsPatch>, Partial<DrulePatch> {
export interface NanoRenderer
extends Partial<RulePatch>,
Partial<UnitsPatch>,
Partial<DrulePatch>,
Partial<SheetPatch> {
/**
* Equals to `true` if in browser environment.
*/
Expand Down

0 comments on commit 2b86cc2

Please sign in to comment.