Skip to content
This repository has been archived by the owner on Apr 9, 2024. It is now read-only.

Commit

Permalink
fix(styleMap): Support numbers as keys on 'styleMap' objects (#88)
Browse files Browse the repository at this point in the history
  • Loading branch information
markdalgleish authored Jan 31, 2020
1 parent defbf43 commit 1fd5f1f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
10 changes: 5 additions & 5 deletions packages/treat/src/builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,14 +159,14 @@ export function style(
}
}

type StyleMapParam<ClassName extends string> = ThemedStyle<
StyleMap<ClassName, Style>,
type StyleMapParam<StyleName extends string | number> = ThemedStyle<
StyleMap<StyleName, Style>,
ThemeOrAny
>;
export function styleMap<ClassName extends string>(
stylesheet: StyleMapParam<ClassName>,
export function styleMap<StyleName extends string | number>(
stylesheet: StyleMapParam<StyleName>,
localDebugName?: string,
): StylesMap<ClassName> {
): StylesMap<StyleName> {
const classRefs: { [className: string]: ClassRef } = {};
const createLocalName = (classIdentifier: string) => {
if (localDebugName) {
Expand Down
9 changes: 6 additions & 3 deletions packages/treat/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ export type Style = StyleWithSelectors & MediaQueries<StyleWithSelectors>;

export type GlobalStyle = CSSProperties & MediaQueries<CSSProperties>;

export type StyleMap<ClassName extends string, StyleType> = Record<
ClassName,
export type StyleMap<StyleName extends string | number, StyleType> = Record<
StyleName,
StyleType
>;

Expand All @@ -54,7 +54,10 @@ export interface TreatTheme<Tokens> {

export type ClassRef = string;

export type StylesMap<ClassName extends string> = Record<ClassName, ClassRef>;
export type StylesMap<StyleName extends string | number> = Record<
StyleName,
ClassRef
>;

type TreatModuleValue =
| string
Expand Down

0 comments on commit 1fd5f1f

Please sign in to comment.