Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.1",
"version": "1.2.2",
"description": "Generator for Utility CSS frameworks",
"author": "Andrea Moretti (@axyz) <axyzxp@gmail.com>",
"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 @@ -14,6 +14,7 @@ export { default as height } from "./height";
export { default as letterSpacing } from "./letter-spacing";
export { default as lineHeight } from "./line-height";
export { default as listStyle } from "./list-style";
export { default as objectFit } from "./object-fit";
export { default as opacity } from "./opacity";
export { default as outline } from "./outline";
export { default as overflow } from "./overflow";
Expand Down
52 changes: 52 additions & 0 deletions src/modules/object-fit.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import applyRules from "../util/applyRules";

import { GetRules, Meta, Module } from "../types";

export type ObjectFitSupportedTypes = {
[key in keyof typeof defaultNames]?: string;
};

export type ObjectFitModuleType = Module<ConfigVariables>;

// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface ConfigVariables {}

const defaultNames = {
"ob:contain": "ob:contain",
"ob:cover": "ob:cover",
"ob:fill": "ob:fill",
"ob:none": "ob:none",
"ob:scaleDown": "ob:scaleDown",
};

const getRules: GetRules<ConfigVariables> = (names) => ({
"ob:contain": {
name: names["ob:contain"],
key: "object-fit",
value: "contain",
},
"ob:cover": { name: names["ob:cover"], key: "object-fit", value: "cover" },
"ob:fill": { name: names["ob:fill"], key: "object-fit", value: "fill" },
"ob:none": { name: names["ob:none"], key: "object-fit", value: "none" },
"ob:scaleDown": {
name: names["ob:scaleDown"],
key: "object-fit",
value: "scale-down",
},
});

const meta: Meta = {
module: "object-fit",
};

const cssModule: ObjectFitModuleType = (config) => (globalConfig) => {
return applyRules({
config,
globalConfig,
defaultNames,
getRules,
meta: Object.assign({}, meta, config && config.meta),
});
};

export default cssModule;