Skip to content

Commit a612eb6

Browse files
chore(release): 1.0.0-alpha.2
# [1.0.0-alpha.2](v1.0.0-alpha.1...v1.0.0-alpha.2) (2021-10-29) ### Bug Fixes * fix broken tests ([0a015eb](0a015eb)) ### Features * require a styles instance as the first argument for hookks ([254bf73](254bf73)) ### BREAKING CHANGES * Requires that the user provide a style instance as the first argument for hooks. Also removes `DashProvider` and `useDash` utilities.
1 parent 0a015eb commit a612eb6

File tree

3 files changed

+60
-47
lines changed

3 files changed

+60
-47
lines changed

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
# [1.0.0-alpha.2](https://github.com/dash-ui/react/compare/v1.0.0-alpha.1...v1.0.0-alpha.2) (2021-10-29)
2+
3+
### Bug Fixes
4+
5+
- fix broken tests ([0a015eb](https://github.com/dash-ui/react/commit/0a015ebe934b3d4f3b2aa1df916acdd45dd1c892))
6+
7+
### Features
8+
9+
- require a styles instance as the first argument for hookks ([254bf73](https://github.com/dash-ui/react/commit/254bf73790e74c43b6a882e283cd356bb9c5c163))
10+
11+
### BREAKING CHANGES
12+
13+
- Requires that the user provide a style instance as the first argument for hooks.
14+
Also removes `DashProvider` and `useDash` utilities.
15+
116
# [1.0.0-alpha.1](https://github.com/dash-ui/react/compare/v0.9.1...v1.0.0-alpha.1) (2021-10-29)
217

318
### Features

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@dash-ui/react",
3-
"version": "1.0.0-alpha.1",
3+
"version": "1.0.0-alpha.2",
44
"description": "React components and hooks for dash-ui",
55
"license": "MIT",
66
"author": "Jared Lunde <[email protected]> (https://jaredLunde.com)",

types/index.d.ts

Lines changed: 44 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -7,56 +7,39 @@ import type {
77
Styles,
88
} from "@dash-ui/styles";
99
import * as React from "react";
10-
/**
11-
* A hook for consuming dash context from the provider
12-
*/
13-
export declare function useDash(): DashContextValue;
14-
export interface DashContextValue {
15-
/**
16-
* A `styles()` instance
17-
*/
18-
styles: Styles;
19-
}
20-
/**
21-
* The Dash context provider. Use this to control the `styles()` instance
22-
* your app is using.
23-
*
24-
* @param root0
25-
* @param root0.styles
26-
* @param root0.children
27-
*/
28-
export declare function DashProvider({
29-
styles,
30-
children,
31-
}: DashProviderProps): JSX.Element;
32-
export interface DashProviderProps {
33-
/**
34-
* A `styles()` instance. Defaults to the default instance in `@dash-ui/styles`
35-
*/
36-
styles?: Styles;
37-
children?: React.ReactNode;
38-
}
3910
/**
4011
* A component for creating an inline `<style>` tag that is unmounted when
4112
* the component unmounts.
4213
*
4314
* @param root0
4415
* @param root0.css
16+
* @param root0.styles
4517
*/
46-
export declare function Inline({ css: input }: InlineProps): JSX.Element | null;
47-
export interface InlineProps {
18+
export declare function Inline<
19+
Tokens extends DashTokens,
20+
Themes extends DashThemes
21+
>({ styles, css: input }: InlineProps<Tokens, Themes>): JSX.Element | null;
22+
export interface InlineProps<
23+
Tokens extends DashTokens,
24+
Themes extends DashThemes
25+
> {
26+
/**
27+
* A Dash `styles` instance
28+
*/
29+
styles: Styles<Tokens, Themes>;
4830
/**
4931
* The CSS you want to inline in the DOM.
5032
*
5133
* @example
5234
* const Component => <Inline css={({color}) => `html { color: ${color.text}; }`}/>
5335
*/
54-
css: string | StyleCallback | StyleObject;
36+
css: string | StyleCallback<Tokens, Themes> | StyleObject;
5537
}
5638
/**
5739
* A hook for inserting transient global styles into the DOM. These styles
5840
* will be injected when the hook mounts and flushed when the hook unmounts.
5941
*
42+
* @param styles - A Dash `styles` instance
6043
* @param value - Global CSS to inject into the DOM and flush when the hook unmounts
6144
* @param deps - A dependency array that will force the hook to re-insert global styles
6245
* @example
@@ -73,57 +56,72 @@ export interface InlineProps {
7356
* )
7457
* }
7558
*/
76-
export declare function useGlobal(
77-
value: string | StyleCallback | StyleObject | null | 0 | undefined | false,
59+
export declare function useGlobal<
60+
Tokens extends DashTokens,
61+
Themes extends DashThemes
62+
>(
63+
styles: Styles<Tokens, Themes>,
64+
value:
65+
| string
66+
| StyleCallback<Tokens, Themes>
67+
| StyleObject
68+
| null
69+
| 0
70+
| undefined
71+
| false,
7872
deps?: React.DependencyList
7973
): void;
8074
/**
8175
* A hook for inserting transient CSS tokens into the DOM. These tokens
8276
* will be injected when the hook mounts and flushed when the hook unmounts.
8377
*
78+
* @param styles - A Dash `styles` instance
8479
* @param value - CSS tokens to inject into the DOM and flush when the hook unmounts
8580
* @param deps - A dependency array that will force the hook to re-insert tokens
8681
* @example
8782
* const Component = () => {
8883
* const [userFontSize, setUserFontSize] = React.useState('100%')
8984
*
9085
* useTokens(
86+
* styles,
9187
* {fontSize: userFontSize},
9288
* [userFontSize]
9389
* )
9490
* }
9591
*/
96-
export declare function useTokens(
97-
value: DeepPartial<DashTokens> | Falsy,
92+
export declare function useTokens<
93+
Tokens extends DashTokens,
94+
Themes extends DashThemes
95+
>(
96+
styles: Styles<Tokens, Themes>,
97+
value: Parameters<Styles<Tokens, Themes>["insertTokens"]>[0] | Falsy,
9898
deps?: React.DependencyList
9999
): void;
100100
/**
101101
* A hook for inserting transient CSS theme tokens into the DOM. These tokens
102102
* will be injected when the hook mounts and flushed when the hook unmounts.
103103
*
104+
* @param styles - A Dash `styles` instance
104105
* @param value - Themes to inject into the DOM and flush when the hook unmounts
105106
* @param deps - A dependency array that will force the hook to re-insert themes
106107
* @example
107108
* const Component = () => {
108109
* const [color, setColor] = React.useState('aliceblue')
109110
*
110111
* useThemes(
112+
* styles,
111113
* {
112114
* dark: {color}
113115
* },
114116
* [color]
115117
* )
116118
* }
117119
*/
118-
export declare function useThemes(
119-
value: DeepPartial<DashThemes> | Falsy,
120+
export declare function useThemes<
121+
Tokens extends DashTokens,
122+
Themes extends DashThemes
123+
>(
124+
styles: Styles<Tokens, Themes>,
125+
value: Parameters<Styles<Tokens, Themes>["insertThemes"]>[0] | Falsy,
120126
deps?: React.DependencyList
121127
): void;
122-
declare type DeepPartial<T> = T extends (...args: any[]) => any
123-
? T
124-
: T extends Record<string, any>
125-
? {
126-
[P in keyof T]?: DeepPartial<T[P]>;
127-
}
128-
: T;
129-
export {};

0 commit comments

Comments
 (0)