@iconify/tailwind
Advanced tools
Comparing version 1.1.1 to 1.1.2
@@ -137,2 +137,3 @@ import { Config } from 'tailwindcss/types/config'; | ||
scale?: number; | ||
square?: boolean; | ||
prefixes?: IconifyPluginListOptions; | ||
@@ -139,0 +140,0 @@ customise?: (content: string, name: string, prefix: string) => string; |
@@ -10,3 +10,3 @@ /** | ||
* @license MIT | ||
* @version 1.1.1 | ||
* @version 1.1.2 | ||
*/ | ||
@@ -173,2 +173,16 @@ 'use strict'; | ||
function makeIconSquare(icon) { | ||
if (icon.width !== icon.height) { | ||
const max = Math.max(icon.width, icon.height); | ||
return { | ||
...icon, | ||
width: max, | ||
height: max, | ||
left: icon.left - (max - icon.width) / 2, | ||
top: icon.top - (max - icon.height) / 2 | ||
}; | ||
} | ||
return icon; | ||
} | ||
function getCommonCSSRules(options) { | ||
@@ -208,10 +222,3 @@ const result = { | ||
if (options.forceSquare) { | ||
const max = Math.max(icon.width, icon.height); | ||
icon = { | ||
...icon, | ||
width: max, | ||
height: max, | ||
left: icon.left - (max - icon.width) / 2, | ||
top: icon.top - (max - icon.height) / 2 | ||
}; | ||
icon = makeIconSquare(icon); | ||
} else { | ||
@@ -362,3 +369,5 @@ result["width"] = calculateSize("1em", icon.width / icon.height); | ||
} | ||
catch { } | ||
catch { | ||
// | ||
} | ||
// Try `@iconify/json` | ||
@@ -371,3 +380,5 @@ try { | ||
} | ||
catch { } | ||
catch { | ||
// | ||
} | ||
} | ||
@@ -395,3 +406,5 @@ /** | ||
} | ||
catch { } | ||
catch { | ||
// | ||
} | ||
} | ||
@@ -662,2 +675,6 @@ /** | ||
const iconSelector = options.iconSelector || '.{prefix}--{name}'; | ||
// Make icons square | ||
const square = options.square !== false; | ||
// Scale | ||
const scale = options.scale ?? 1; | ||
options.prefixes?.forEach((item) => { | ||
@@ -725,3 +742,3 @@ let prefix; | ||
varName, | ||
forceSquare: true, | ||
forceSquare: square, | ||
}); | ||
@@ -732,2 +749,6 @@ // Generate selector | ||
.replace('{name}', name); | ||
// Scale non-square icons | ||
if (!square && scale > 0 && scale !== 1 && iconRules.width) { | ||
iconRules.width = calculateSize(iconRules.width, scale); | ||
} | ||
// Add to rules | ||
@@ -734,0 +755,0 @@ rules[selector] = iconRules; |
@@ -5,3 +5,3 @@ { | ||
"author": "Vjacheslav Trushkin <cyberalien@gmail.com> (https://iconify.design)", | ||
"version": "1.1.1", | ||
"version": "1.1.2", | ||
"license": "MIT", | ||
@@ -22,10 +22,10 @@ "main": "./dist/plugin.js", | ||
"devDependencies": { | ||
"@iconify-json/line-md": "^1.1.37", | ||
"@iconify-json/line-md": "^1.1.38", | ||
"@iconify-json/mdi-light": "^1.1.10", | ||
"@microsoft/api-extractor": "^7.43.1", | ||
"@microsoft/api-extractor": "^7.47.2", | ||
"@rollup/plugin-node-resolve": "^15.2.3", | ||
"@rollup/plugin-replace": "^5.0.5", | ||
"@rollup/plugin-replace": "^5.0.7", | ||
"@types/jest": "^29.5.12", | ||
"@types/jsdom": "^21.1.6", | ||
"@types/node": "^18.19.31", | ||
"@types/jsdom": "^21.1.7", | ||
"@types/node": "^18.19.41", | ||
"@typescript-eslint/eslint-plugin": "^5.62.0", | ||
@@ -36,6 +36,6 @@ "eslint": "^8.57.0", | ||
"rollup": "^3.29.4", | ||
"tailwindcss": "^3.4.3", | ||
"ts-jest": "^29.1.2", | ||
"typescript": "^5.4.5", | ||
"@iconify/utils": "^2.1.23" | ||
"tailwindcss": "^3.4.6", | ||
"ts-jest": "^29.2.3", | ||
"typescript": "^5.5.3", | ||
"@iconify/utils": "^2.1.25" | ||
}, | ||
@@ -42,0 +42,0 @@ "scripts": { |
31243
6
954