diff --git a/jsr.json b/jsr.json index 78bfa60..f9906ce 100644 --- a/jsr.json +++ b/jsr.json @@ -1,6 +1,6 @@ { "name": "@buen/type", - "version": "1.0.3", + "version": "1.0.4", "exports": "./src/index.ts", "publish": { "include": ["src/**/*.ts", "README.md"], diff --git a/src/defaults.ts b/src/defaults.ts index a203375..0aaa968 100644 --- a/src/defaults.ts +++ b/src/defaults.ts @@ -1,43 +1,37 @@ -import { TypeDefinitions } from "./types.ts"; +import { TypeDefinitionHeadlines, TypeDefinitionTexts } from "./types.ts"; -export const DEFAULT_HEADLINE: TypeDefinitions = { +export const DEFAULT_HEADLINE: TypeDefinitionHeadlines = { "display-xxl": { - id: "headline-display-xxl", fontWeight: "bold", clamp: [6, 12], letterSpacing: "0em", lineHeight: 1, }, "display-xl": { - id: "headline-display-xl", fontWeight: "bold", clamp: [4.5, 9], letterSpacing: "0em", lineHeight: 1, }, "display-lg": { - id: "headline-display-lg", fontWeight: "bold", clamp: [3.5, 5], letterSpacing: "0em", lineHeight: 1, }, "display-md": { - id: "headline-display-md", fontWeight: "bold", clamp: [3, 4], letterSpacing: "0em", lineHeight: 1, }, "display-sm": { - id: "headline-display-sm", fontWeight: "bold", clamp: [1.5, 2], letterSpacing: "0.1em", lineHeight: 1, }, "display-xs": { - id: "headline-display-xs", fontWeight: "bold", clamp: [1, 1], letterSpacing: "0.1em", @@ -45,23 +39,20 @@ export const DEFAULT_HEADLINE: TypeDefinitions = { }, }; -export const DEFAULT_TEXT: TypeDefinitions = { +export const DEFAULT_TEXT: TypeDefinitionTexts = { title: { - id: "text-title", fontSize: "1.5rem", lineHeight: 1.25, fontWeight: "normal", letterSpacing: "0.1em", }, paragraph: { - id: "text-paragraph", fontSize: "1.25rem", lineHeight: 1.35, fontWeight: "normal", letterSpacing: "0.05em", }, string: { - id: "text-string", fontSize: ".9rem", lineHeight: 1.25, fontWeight: "normal", @@ -69,14 +60,12 @@ export const DEFAULT_TEXT: TypeDefinitions = { }, body: { - id: "text-body", fontSize: "0.8rem", lineHeight: 1.25, fontWeight: "normal", letterSpacing: "0.15em", }, caption: { - id: "text-caption", fontSize: "0.65rem", lineHeight: 1.25, fontWeight: "normal", diff --git a/src/tailwind-plugin/buenTypeTailwind.ts b/src/tailwind-plugin/buenTypeTailwind.ts index fcf75d8..1c90b6b 100644 --- a/src/tailwind-plugin/buenTypeTailwind.ts +++ b/src/tailwind-plugin/buenTypeTailwind.ts @@ -3,11 +3,13 @@ import { CustomTypeDefinitions, TypeDefinition } from "../types.ts"; import { createRemClamp } from "../utils/createRemClamp.ts"; import { typedKeys } from "../utils/typedKeys.ts"; -// Type definition for the addUtilities function parameter -interface AddUtilities { +type AddUtilities = { (utilities: Record, options?: any): void; -} +}; +/** + * A module that converts an object of headlines and text definitions into Tailwind CSS utilities. + */ export const buenTypeTailwind = function ( { addUtilities }: { addUtilities: AddUtilities }, customDefinitions?: CustomTypeDefinitions diff --git a/src/types.ts b/src/types.ts index f25269b..45fb8ba 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,3 +1,18 @@ +export type DefaultHeadlineTypes = + | "display-xxl" + | "display-xl" + | "display-lg" + | "display-md" + | "display-sm" + | "display-xs"; + +export type DefaultTextTypes = + | "title" + | "paragraph" + | "string" + | "body" + | "caption"; + export type TypeDefinition = { fontFamily?: string; fontWeight?: string | number; @@ -8,9 +23,14 @@ export type TypeDefinition = { clamp?: [number, number]; }; -export type TypeDefAndId = TypeDefinition & { id: string }; +export type TypeDefinitions = Record; + +export type TypeDefinitionHeadlines = Record< + DefaultHeadlineTypes, + TypeDefinition +>; -export type TypeDefinitions = Record; +export type TypeDefinitionTexts = Record; export type CustomTypeDefinitions = { customHeadlines?: Record;