Skip to content

Commit

Permalink
feat: 🎸 add TypeScript definitiosn for some missing addons
Browse files Browse the repository at this point in the history
  • Loading branch information
streamich committed Mar 22, 2019
1 parent 224ee56 commit 6611aac
Show file tree
Hide file tree
Showing 11 changed files with 73 additions and 51 deletions.
5 changes: 5 additions & 0 deletions addon/amp.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import {NanoRenderer} from '../types/nano';

export interface AmpAddon {}

export function addon(nano: NanoRenderer);
5 changes: 5 additions & 0 deletions addon/array.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import {NanoRenderer} from '../types/nano';

export interface ArrayAddon {}

export function addon(nano: NanoRenderer);
8 changes: 8 additions & 0 deletions addon/cache.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import {NanoRenderer} from '../types/nano';
import {CssLikeObject} from '../types/common';

export interface CacheAddon {
cache(css: CssLikeObject): string;
}

export function addon(nano: NanoRenderer);
8 changes: 8 additions & 0 deletions addon/dsheet.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import {NanoRenderer} from '../types/nano';
import {CssLikeObject} from '../types/common';

export interface DsheetAddon {
dsheet(map: object, block?: string): object;
}

export function addon(nano: NanoRenderer);
5 changes: 5 additions & 0 deletions addon/extract.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import {NanoRenderer} from '../types/nano';

export interface ExtractAddon {}

export function addon(nano: NanoRenderer);
8 changes: 8 additions & 0 deletions addon/global.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import {NanoRenderer} from '../types/nano';
import {CssLikeObject} from '../types/common';

export interface GlobalAddon {
global(css: CssLikeObject);
}

export function addon(nano: NanoRenderer);
8 changes: 8 additions & 0 deletions addon/googleFont.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import {NanoRenderer} from '../types/nano';
import {CssLikeObject} from '../types/common';

export interface GoogleFontAddon {
googleFont(font: string, weights: number | string | (number | string)[], subsets: string | string[]);
}

export function addon(nano: NanoRenderer);
7 changes: 7 additions & 0 deletions addon/hydrate.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import {NanoRenderer} from '../types/nano';

export interface HydrateAddon {
hydrate(sh: HTMLStyleElement);
}

export function addon(nano: NanoRenderer);
49 changes: 1 addition & 48 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,50 +1,3 @@
import {CreateNano} from './types/nano';
import {UnitsAddon} from './types/addon/units';
import {DruleAddon} from './types/addon/drule';
import {SheetAddon} from './types/addon/sheet';
import {AtomsAddon} from './types/addon/atoms';
import {EmmetAddon} from './types/addon/emmet';
import {SheetPreset} from './types/preset/sheet';
import {KeyframesAddon} from './types/addon/keyframes';

export * from './types/nano';

declare module 'nano-css' {
export const create: CreateNano;
}

// Addons

declare module 'nano-css/addon/rule' {
export const addon: RuleAddon;
}

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;
}

declare module 'nano-css/addon/atoms' {
export const addon: AtomsAddon;
}

declare module 'nano-css/addon/emmet' {
export const addon: EmmetAddon;
}

declare module 'nano-css/addon/keyframes' {
export const addon: KeyframesAddon;
}

// Presets

declare module 'nano-css/preset/sheet' {
export const preset: SheetPreset;
}
export const create: CreateNano;
2 changes: 1 addition & 1 deletion types/demo.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {create} from './nano';
import {create} from '..';

const nano = create();

Expand Down
19 changes: 17 additions & 2 deletions types/nano.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ import {EmmetAddon} from '../addon/emmet';
import {SheetAddon} from '../addon/sheet';
import {UnitsAddon} from '../addon/units';
import {KeyframesAddon} from '../addon/keyframes';
import {AmpAddon} from '../addon/amp';
import {ArrayAddon} from '../addon/array';
import {CacheAddon} from '../addon/cache';
import {DsheetAddon} from '../addon/dsheet';
import {ExtractAddon} from '../addon/extract';
import {GlobalAddon} from '../addon/global';
import {GoogleFontAddon} from '../addon/googleFont';
import {HydrateAddon} from '../addon/hydrate';

export type Addons = RuleAddon &
SheetAddon &
Expand All @@ -17,7 +25,15 @@ export type Addons = RuleAddon &
DecoratorAddon &
EmmetAddon &
CSSOMAddon &
VCSSOMAddon;
VCSSOMAddon &
ArrayAddon &
CacheAddon &
DsheetAddon &
ExtractAddon &
GlobalAddon &
GoogleFontAddon &
HydrateAddon &
AmpAddon;

/**
* nano-css main object.
Expand Down Expand Up @@ -123,4 +139,3 @@ export interface NanoOptions {
}

export type CreateNano = (options?: NanoOptions) => NanoRenderer;
export const create: CreateNano;

1 comment on commit 6611aac

@streamich
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Build version: 4.0.0-fix-cssom.107 🤞 fix-cssom on CircleCI 🎉

Please sign in to comment.