Skip to content

Commit 2b86cc2

Browse files
committed
feat: 🎸 add sheet addon typings
1 parent fe0345c commit 2b86cc2

File tree

3 files changed

+33
-2
lines changed

3 files changed

+33
-2
lines changed

‎index.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import {CreateNano} from './types/nano';
22
import {RuleAddon} from './types/addon/rule';
33
import {UnitsAddon} from './types/addon/units';
44
import {DruleAddon} from './types/addon/drule';
5+
import {SheetAddon} from './types/addon/sheet';
56

67
export * from './types/nano';
78

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

21+
declare module 'nano-css/addon/sheet' {
22+
export const addon: SheetAddon;
23+
}
24+
2025
declare module 'nano-css/addon/units' {
2126
export const addon: UnitsAddon;
2227
}

‎types/addon/sheet.d.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import {CssLikeObject} from '../common';
2+
import {NanoRenderer} from '../nano';
3+
4+
export interface SheetPatch {
5+
/**
6+
* Creates a collection of CSS rules.
7+
*
8+
* ```js
9+
* const classes = sheet({
10+
* wrapper: {
11+
* border: '1px solid red',
12+
* },
13+
* button: {
14+
* color: 'red',
15+
* },
16+
* });
17+
* ```
18+
*/
19+
sheet: (cssMap: {[s: string]: CssLikeObject}, block?: string) => {[s: string]: string};
20+
}
21+
22+
export type SheetAddon = <T extends NanoRenderer>(nano: T) => T & SheetPatch;

‎types/nano.d.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ import {CssLikeObject} from './common';
22
import {RulePatch} from './addon/rule';
33
import {DrulePatch} from './addon/drule';
44
import {UnitsPatch} from './addon/units';
5+
import {SheetPatch} from './addon/sheet';
56

67
/*
78
interface NanoRenderer extends Partial<IUnits> {
8-
sheet?: (cssMap: {[s: string]: ICssLikeObject}, block?: string) => {[s: string]: string};
99
dsheet?: (cssMap: {[s: string]: ICssLikeObject}, block?: string) => {[s: string]: TDynamicCss};
1010
jsx?: (
1111
type: THyperscriptType,
@@ -45,7 +45,11 @@ interface NanoRenderer extends Partial<IUnits> {
4545
}
4646
*/
4747

48-
export interface NanoRenderer extends Partial<RulePatch>, Partial<UnitsPatch>, Partial<DrulePatch> {
48+
export interface NanoRenderer
49+
extends Partial<RulePatch>,
50+
Partial<UnitsPatch>,
51+
Partial<DrulePatch>,
52+
Partial<SheetPatch> {
4953
/**
5054
* Equals to `true` if in browser environment.
5155
*/

0 commit comments

Comments
 (0)