Skip to content

Commit

Permalink
feat: 🎸 add keyframes() addon typings
Browse files Browse the repository at this point in the history
  • Loading branch information
streamich committed Jul 21, 2018
1 parent 94c11ac commit 4615452
Show file tree
Hide file tree
Showing 4 changed files with 44 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 @@ -5,6 +5,7 @@ import {DruleAddon} from './types/addon/drule';
import {SheetAddon} from './types/addon/sheet';
import {AtomsAddon} from './types/addon/atoms';
import {SheetPreset} from './types/preset/sheet';
import {KeyframesAddon} from './types/addon/keyframes';

export * from './types/nano';

Expand Down Expand Up @@ -34,6 +35,10 @@ declare module 'nano-css/addon/atoms' {
export const addon: AtomsAddon;
}

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

// Presets

declare module 'nano-css/preset/sheet' {
Expand Down
35 changes: 35 additions & 0 deletions types/addon/keyframes.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import {CssLikeObject} from '../common';
import {NanoRenderer} from '../nano';

export interface KeyframesPatch {
/**
* @param frames Map of keyframes.
* @param block Optional semantic name.
*
* Returns a generated animation name.
*
* ```js
* const animationName = nano.keyframes({
* from: {
* left: '0%',
* },
* to: {
* left: '100%',
* },
* });
* ```
*
* You need to install [`keyframes()` addon]()https://github.com/streamich/nano-css/blob/master/docs/keyframes.md) to use this method.
*
* ```js
* import {create} from 'nano-css';
* import {addon as addonKeyframes} from 'nano-css/addon/keyframes';
*
* const nano = create();
* addonKeyframes(nano);
* ```
*/
keyframes: (frames: object, block?: string) => string;
}

export type KeyframesAddon = <T extends NanoRenderer>(nano: T) => T & KeyframesPatch;
2 changes: 1 addition & 1 deletion types/addon/rule.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export interface RulePatch {
*
* ```js
* import {create} from 'nano-css';
* import {addon as addonRule} from 'nano-css';
* import {addon as addonRule} from 'nano-css/addon/rule';
*
* const nano = create();
* addonRule(nano);
Expand Down
4 changes: 3 additions & 1 deletion types/nano.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {RulePatch} from './addon/rule';
import {DrulePatch} from './addon/drule';
import {UnitsPatch} from './addon/units';
import {SheetPatch} from './addon/sheet';
import {KeyframesPatch} from './addon/keyframes';

/*
interface NanoRenderer extends Partial<IUnits> {
Expand Down Expand Up @@ -49,7 +50,8 @@ export interface NanoRenderer
extends Partial<RulePatch>,
Partial<UnitsPatch>,
Partial<DrulePatch>,
Partial<SheetPatch> {
Partial<SheetPatch>,
Partial<KeyframesPatch> {
/**
* Equals to `true` if in browser environment.
*/
Expand Down

0 comments on commit 4615452

Please sign in to comment.