Skip to content

Commit

Permalink
Merge pull request #55 from utilitycss/feat/add-word-break-module
Browse files Browse the repository at this point in the history
feat: add word-break module
  • Loading branch information
sylvesteraswin authored Jul 21, 2021
2 parents 1b3b1dd + 6de6fa7 commit 414f612
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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) <[email protected]>",
"repository": "utilitycss/utility",
Expand Down
1 change: 1 addition & 0 deletions src/modules/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
50 changes: 50 additions & 0 deletions src/modules/word-break.ts
Original file line number Diff line number Diff line change
@@ -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<ConfigVariables>;

// 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<ConfigVariables> = (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;

0 comments on commit 414f612

Please sign in to comment.