UNPKG

@sujalchoudhari/solaris-ui

Version:

A UI framework to create HTML pages with just JavaScript.

105 lines (104 loc) 4.13 kB
import Component from "./component"; /** * Style * ----- * A representation of Style tag. * * @author Ansh Sharma * * TODO: * - Instead of using classes from public/style/index.css * every component will have its own exportCss function. * - These generated classes will be dumped into the `build/[name]/style/` folder. * - Style folder will be created for each page or for each style component. * - And included into head of page that contains that style component. */ export default class Style extends Component { /** * The CSS classes and their properties. */ cssClasses: { [key: string]: { [key: string]: string; }; }; /** * URL to an external source file. */ url: string; /** * Type of the CSS attachment. Either inline or external. * Note: inline attachments are supported under Attributes, and Style functions under Component. */ type: string; /** * Create a new instance of Style. * @param type The type of the CSS attachment. Either inline or external. * @param url URL to an external source file. Optional. * @param cssClasseses The CSS classes and their properties. */ constructor(type: "infile" | "external", url?: string, cssClasseses?: { [key: string]: { [key: string]: string; }; }); /** * Adds a new CSS class with the specified properties. * @param className The name of the CSS class to add. * @param properties The properties to associate with the new CSS class. */ addClass(className: string, properties: { [key: string]: string; }): void; /** * Updates the properties of an existing CSS class. * @param className The name of the CSS class to update. * @param properties The updated properties to associate with the CSS class. */ updateClass(className: string, properties: { [key: string]: string; }): void; /** * Removes an existing CSS class. * @param className The name of the CSS class to remove. */ removeClass(className: string): void; /** * Adds the given properties to the specified class. If the class does not exist, it will be created. * @param className The name of the class to add properties to. * @param properties An object containing the properties to add, where the key is the property name and the value is the property value. */ addClassProperty(className: string, properties: { [key: string]: string; }): void; /** * Removes the given properties from the specified class. If the class no longer has any properties, it will be removed. * @param className The name of the class to remove properties from. * @param properties An object containing the properties to remove, where the key is the property name and the value is the property value. */ removeClassProperty(className: string, properties: { [key: string]: string; }): void; /** * Updates the given properties of the specified class. If the class does not exist, it will be created. * @param className The name of the class to update properties of. * @param properties An object containing the properties to update, where the key is the property name and the value is the property value. */ updateClassProperty(className: string, properties: { [key: string]: string; }): void; /** * Gets the properties of an existing CSS class. * @param className The name of the CSS class to get the properties of. * @returns The properties of the specified CSS class, or undefined if the CSS class does not exist. */ getClassProperties(className: string): { [key: string]: string; } | undefined; /** * Exports the CSS classes and their properties as a string. * Returns a <style> tag if the type is inline, otherwise returns the CSS classes and their properties as a string. * @returns A string representation of the CSS classes and their properties. */ toString(): string; }