Skip to content

Commit

Permalink
chore: update types details
Browse files Browse the repository at this point in the history
  • Loading branch information
johnchourajr committed May 27, 2024
1 parent d6f0213 commit 9f7e2a2
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 20 deletions.
2 changes: 1 addition & 1 deletion jsr.json
Original file line number Diff line number Diff line change
@@ -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"],
Expand Down
17 changes: 3 additions & 14 deletions src/defaults.ts
Original file line number Diff line number Diff line change
@@ -1,82 +1,71 @@
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",
lineHeight: 1,
},
};

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",
letterSpacing: "0.15em",
},

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",
Expand Down
8 changes: 5 additions & 3 deletions src/tailwind-plugin/buenTypeTailwind.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, any>, 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
Expand Down
24 changes: 22 additions & 2 deletions src/types.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -8,9 +23,14 @@ export type TypeDefinition = {
clamp?: [number, number];
};

export type TypeDefAndId = TypeDefinition & { id: string };
export type TypeDefinitions = Record<string, TypeDefinition>;

export type TypeDefinitionHeadlines = Record<
DefaultHeadlineTypes,
TypeDefinition
>;

export type TypeDefinitions = Record<string, TypeDefinition | TypeDefAndId>;
export type TypeDefinitionTexts = Record<DefaultTextTypes, TypeDefinition>;

export type CustomTypeDefinitions = {
customHeadlines?: Record<string, TypeDefinition>;
Expand Down

0 comments on commit 9f7e2a2

Please sign in to comment.