@tailwind-adjuster/tailwind 0.1.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,11 @@
1
+ import type { RadiusValue, ShadowValue } from "@tailwind-adjuster/core";
2
+ export declare function toTailwindSpacing(prefix: string, px: number): string;
3
+ export declare function toTailwindSize(prefix: string, px: number): string;
4
+ export declare function toTailwindRadius(radius: RadiusValue): string;
5
+ export declare function toTailwindShadow(shadow: ShadowValue): string;
6
+ export declare const defaultTailwindMapper: {
7
+ spacing: typeof toTailwindSpacing;
8
+ size: typeof toTailwindSize;
9
+ radius: typeof toTailwindRadius;
10
+ shadow: typeof toTailwindShadow;
11
+ };
package/dist/index.js ADDED
@@ -0,0 +1,70 @@
1
+ const spacingScale = new Map([
2
+ [0, "0"],
3
+ [1, "px"],
4
+ [2, "0.5"],
5
+ [4, "1"],
6
+ [6, "1.5"],
7
+ [8, "2"],
8
+ [10, "2.5"],
9
+ [12, "3"],
10
+ [14, "3.5"],
11
+ [16, "4"],
12
+ [20, "5"],
13
+ [24, "6"],
14
+ [28, "7"],
15
+ [32, "8"],
16
+ [36, "9"],
17
+ [40, "10"],
18
+ [44, "11"],
19
+ [48, "12"],
20
+ [56, "14"],
21
+ [64, "16"],
22
+ [80, "20"],
23
+ [96, "24"],
24
+ [112, "28"],
25
+ [128, "32"],
26
+ [144, "36"],
27
+ [160, "40"],
28
+ [176, "44"],
29
+ [192, "48"],
30
+ [208, "52"],
31
+ [224, "56"],
32
+ [240, "60"],
33
+ [256, "64"],
34
+ [288, "72"],
35
+ [320, "80"],
36
+ [384, "96"],
37
+ ]);
38
+ export function toTailwindSpacing(prefix, px) {
39
+ const rounded = Math.round(px);
40
+ const negative = rounded < 0;
41
+ const absolute = Math.abs(rounded);
42
+ const token = spacingScale.get(absolute);
43
+ const body = token ? `${prefix}-${token}` : `${prefix}-[${absolute}px]`;
44
+ return negative ? `-${body}` : body;
45
+ }
46
+ export function toTailwindSize(prefix, px) {
47
+ const rounded = Math.max(0, Math.round(px));
48
+ const token = spacingScale.get(rounded);
49
+ return token ? `${prefix}-${token}` : `${prefix}-[${rounded}px]`;
50
+ }
51
+ export function toTailwindRadius(radius) {
52
+ if (radius === "none")
53
+ return "rounded-none";
54
+ if (radius === "md")
55
+ return "rounded";
56
+ return `rounded-${radius}`;
57
+ }
58
+ export function toTailwindShadow(shadow) {
59
+ if (shadow === "none")
60
+ return "";
61
+ if (shadow === "md")
62
+ return "shadow";
63
+ return `shadow-${shadow}`;
64
+ }
65
+ export const defaultTailwindMapper = {
66
+ spacing: toTailwindSpacing,
67
+ size: toTailwindSize,
68
+ radius: toTailwindRadius,
69
+ shadow: toTailwindShadow,
70
+ };
package/package.json ADDED
@@ -0,0 +1,45 @@
1
+ {
2
+ "name": "@tailwind-adjuster/tailwind",
3
+ "version": "0.1.0-alpha.0",
4
+ "description": "Tailwind scale mapping helpers for Tailwind Adjuster.",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/hirohirohotate-sketch/tailwind-adjuster.git",
10
+ "directory": "packages/tailwind"
11
+ },
12
+ "bugs": {
13
+ "url": "https://github.com/hirohirohotate-sketch/tailwind-adjuster/issues"
14
+ },
15
+ "homepage": "https://github.com/hirohirohotate-sketch/tailwind-adjuster#readme",
16
+ "keywords": [
17
+ "tailwindcss",
18
+ "react",
19
+ "visual-editor",
20
+ "layout",
21
+ "developer-tools"
22
+ ],
23
+ "publishConfig": {
24
+ "access": "public",
25
+ "tag": "alpha"
26
+ },
27
+ "main": "./dist/index.js",
28
+ "types": "./dist/index.d.ts",
29
+ "exports": {
30
+ ".": {
31
+ "types": "./dist/index.d.ts",
32
+ "import": "./dist/index.js",
33
+ "default": "./dist/index.js"
34
+ }
35
+ },
36
+ "dependencies": {
37
+ "@tailwind-adjuster/core": "0.1.0-alpha.0"
38
+ },
39
+ "files": [
40
+ "dist"
41
+ ],
42
+ "scripts": {
43
+ "build": "node -e \"const fs=require('fs'); fs.rmSync('dist',{recursive:true,force:true}); fs.rmSync('tsconfig.tsbuildinfo',{force:true})\" && tsc -p tsconfig.json"
44
+ }
45
+ }