From 6de6fa7d0a0485b31f2fee49a7e817f8d5ba0233 Mon Sep 17 00:00:00 2001 From: Sylvester Aswin Stanley Date: Wed, 21 Jul 2021 15:49:06 +0200 Subject: [PATCH] feat: add word-break module --- package.json | 2 +- src/modules/index.ts | 1 + src/modules/word-break.ts | 50 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 src/modules/word-break.ts diff --git a/package.json b/package.json index e000a77..86b5795 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@utilitycss/utility", - "version": "1.2.0", + "version": "1.2.1", "description": "Generator for Utility CSS frameworks", "author": "Andrea Moretti (@axyz) ", "repository": "utilitycss/utility", diff --git a/src/modules/index.ts b/src/modules/index.ts index 5e0ec25..60ffb22 100644 --- a/src/modules/index.ts +++ b/src/modules/index.ts @@ -33,5 +33,6 @@ export { default as verticalAlign } from "./vertical-align"; export { default as visibility } from "./visibility"; export { default as whiteSpace } from "./white-space"; export { default as width } from "./width"; +export { default as wordBreak } from "./word-break"; export { default as useSelect } from "./user-select"; export { default as zIndex } from "./z-index"; diff --git a/src/modules/word-break.ts b/src/modules/word-break.ts new file mode 100644 index 0000000..cb832ac --- /dev/null +++ b/src/modules/word-break.ts @@ -0,0 +1,50 @@ +import applyRules from "../util/applyRules"; + +import { GetRules, Meta, Module } from "../types"; + +export type WordBreakSupportedTypes = { + [key in keyof typeof defaultNames]?: string; +}; + +export type WordBreakModuleType = Module; + +// eslint-disable-next-line @typescript-eslint/no-empty-interface +export interface ConfigVariables {} + +const defaultNames = { + "wob:i": "wob:i", + "wob:in": "wob:in", + "wob:r": "wob:r", + "wob:u": "wob:u", + "wob:n": "wob:n", + "wob:k": "wob:k", + "wob:ba": "wob:ba", + "wob:bw": "wob:bw", +}; + +const getRules: GetRules = (names) => ({ + "wob:i": { name: names["wob:i"], key: "word-break", value: "initial" }, + "wob:in": { name: names["wob:in"], key: "word-break", value: "inherit" }, + "wob:r": { name: names["wob:r"], key: "word-break", value: "revert" }, + "wob:u": { name: names["wob:u"], key: "word-break", value: "unset" }, + "wob:n": { name: names["wob:n"], key: "word-break", value: "normal" }, + "wob:k": { name: names["wob:k"], key: "word-break", value: "keep-all" }, + "wob:ba": { name: names["wob:ba"], key: "word-break", value: "break-all" }, + "wob:bw": { name: names["wob:bw"], key: "word-break", value: "break-word" }, +}); + +const meta: Meta = { + module: "word-break", +}; + +const cssModule: WordBreakModuleType = (config) => (globalConfig) => { + return applyRules({ + config, + globalConfig, + defaultNames, + getRules, + meta: Object.assign({}, meta, config && config.meta), + }); +}; + +export default cssModule;