@maggioli-design-system/design-tokens
Version:
This is the Design Token library of Maggioli Design System, here you'll find all the visual data used around the libraries.
46 lines (45 loc) • 2.14 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.cssVarsTypographyFormat = void 0;
const handlebars_1 = __importDefault(require("handlebars"));
const fs_1 = __importDefault(require("fs"));
const path_1 = __importDefault(require("path"));
const package_json_1 = require("../../../package.json");
const helpers_1 = require("../helpers");
const templatePath = path_1.default.resolve(__dirname, './template.hbs');
const template = handlebars_1.default.compile(fs_1.default.readFileSync(templatePath).toString());
const ifTailwind4Border = (property, options) => {
/* exclude number and default value
keep prop as sm, md...
*/
return isNaN(Number(property)) ? options.fn(this) : options.inverse(this);
};
// Register every helper used by ./template.hbs so this format is self-contained
// and not dependent on another module registering them first on the shared
// Handlebars singleton.
handlebars_1.default.registerHelper('kebabCase', helpers_1.kebabCase);
handlebars_1.default.registerHelper('ifTailwindFontSizeProp', helpers_1.ifTailwindFontSizeProp);
handlebars_1.default.registerHelper('tailwindFontSize', helpers_1.tailwindFontSize);
handlebars_1.default.registerHelper('pixelToRem', helpers_1.pixelToRem);
handlebars_1.default.registerHelper('safeString', helpers_1.safeString);
handlebars_1.default.registerHelper('ifTailwind4Border', ifTailwind4Border);
/**
* Classic-CSS counterpart of `css/tailwind-theme-typography`: emits the same
* typography (and related) custom properties inside a plain `:root {}` block
* instead of Tailwind v4's `@theme {}`, so they can be consumed without a
* Tailwind toolchain.
*/
exports.cssVarsTypographyFormat = {
name: 'css/vars-typography',
formatter: ({ dictionary, platform }) => {
return template({
properties: dictionary.properties,
date: new Date().toUTCString(),
options: platform,
version: package_json_1.version,
});
},
};