UNPKG

@thi.ng/hiccup

Version:

HTML/SVG/XML serialization of nested data structures, iterables & closures

49 lines 1.48 kB
/** * Takes a space separated string of existing CSS class names and merges it with * `val`, which is either another string or string array of class names, an * object of booleans or an `IDeref` evaluating to either. Returns updated class * string. * * @remarks * If `val` evaluates to a string, it will be appended to `existing`. * * If `val` is an array, it will be joined as space-separated string and * concatenated to the existing one. * * If `val` is an object, its keys are used as class names and their values * indicate if the class should be added or removed from the existing set. * * @example * ```ts tangle:../export/merge-classes.ts * import { mergeClasses } from "@thi.ng/hiccup"; * * console.log( * mergeClasses("foo bar", { foo: false, baz: true }) * ); * // "bar baz" * * console.log( * mergeClasses("foo", ["bar", "baz"]) * ); * // "foo bar baz" * * console.log( * mergeClasses("foo bar", "baz") * ); * // "foo bar baz" * ``` * * @param existing - * @param val - */ export declare const mergeClasses: (existing: string | SVGAnimatedString, val: any) => string; /** * Takes an attrib object and optional element ID and CSS class names from Emmet-style * hiccup tag, then transforms and merges definitions, returns attribs. * * @param attribs - * @param id - * @param classes - */ export declare const mergeEmmetAttribs: (attribs: any, id?: string, classes?: string) => any; //# sourceMappingURL=attribs.d.ts.map