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.

Hierarchy

=======
  • Defined in basic/styles.ts:10
  • >>>>>>> origin/dev =======
  • Defined in basic/styles.ts:10
  • >>>>>>> dev =======
  • Defined in components/styles.ts:17
  • >>>>>>> dev =======
  • Defined in components/styles.ts:17
  • >>>>>>> dev =======
  • Defined in components/styles.ts:18
  • >>>>>>> dev:docs/classes/index.Style.html =======
  • Defined in components/styles.ts:18
  • >>>>>>> dev

    Properties

    tag: string

    The html tag it is supposed to represent.

    =======
  • Defined in basic/styles.ts:14
  • >>>>>>> origin/dev =======
  • Defined in basic/styles.ts:14
  • >>>>>>> dev =======
  • Defined in components/component.ts:30
  • =======
  • Defined in components/component.ts:30
  • >>>>>>> dev =======
  • Defined in components/component.ts:30
  • >>>>>>> dev:docs/classes/index.Style.html =======
  • Defined in components/component.ts:30
  • >>>>>>> dev
    attribute: {
        [key: string]: string;
    }

    HTMl attributes in the form of key value pairs.

    Type declaration

    • [key: string]: string
    children: Component[]

    An array of Component which would be rendered as child elements of the current element

    props: any
    cssClasses: {
        [key: string]: {
            [key: string]: string;
        };
    }

    The CSS classes and their properties.

    Type declaration

    • [key: string]: {
          [key: string]: string;
      }
      • [key: string]: string
    >>>>>>> dev =======
  • Defined in components/styles.ts:21
  • >>>>>>> dev =======
  • Defined in components/styles.ts:22
  • >>>>>>> dev:docs/classes/index.Style.html =======
  • Defined in components/styles.ts:22
  • >>>>>>> dev
    url: string = ""

    URL to an external source file.

    =======
  • Defined in basic/styles.ts:19
  • >>>>>>> origin/dev =======
  • Defined in basic/styles.ts:19
  • >>>>>>> dev =======
  • Defined in components/styles.ts:26
  • >>>>>>> dev =======
  • Defined in components/styles.ts:26
  • >>>>>>> dev =======
  • Defined in components/styles.ts:27
  • >>>>>>> dev:docs/classes/index.Style.html =======
  • Defined in components/styles.ts:27
  • >>>>>>> dev
    type: string = ""

    Type of the CSS attachment. Either inline or external. Note: inline attachments are supported under Attributes, and Style functions under Component.

    =======
  • Defined in basic/styles.ts:25
  • >>>>>>> origin/dev =======
  • Defined in basic/styles.ts:25
  • >>>>>>> dev =======
  • Defined in components/styles.ts:32
  • =======
  • Defined in components/styles.ts:32
  • >>>>>>> dev =======
  • Defined in components/styles.ts:33
  • >>>>>>> dev:docs/classes/index.Style.html =======
  • Defined in components/styles.ts:33
  • >>>>>>> dev

    Methods

    • Get the tag name

      Returns

      the tag of the component

      Example

      var tag = myComponent.getTag(); // a div component
      console.log(tag); // div

      Returns string

    • Get the attributes of the component

      Returns

      Object containing all the attributes of the component

      Example

      var myComponent = new Component("div",{"id":"my-component"});

      var attributes = myComponent.getAttributes(); // a div component
      console.log(attributes); // {"id":"my-component"};

      Returns {
          [key: string]: string;
      }

      • [key: string]: string
    • Sets or Creates a new attribute on the component

      Example


      var myComponent = new Component("p");
      myComponent.setAttribute("class", "my-component para lg:mx-5 sm:mx-1");
      myComponent.setAttribute("id","my-unique-id");

      Parameters

      • name: string

        nmae of the attribute to set

      • value: string

        the value of the attribute to set

      Returns void

    • Get the value of the attribute at the specified name

      Returns

      the value of the attribute

      Parameters

      • name: string

        the value of the attribute to get

      Returns undefined | string

    • Add a new child to the component

      Example

       var component1 = new Component("div"); // parent component
      var component2 = new Component("p"); // child component
      component1.addChild(component2);

      Deprecated

      Use addChildren instead

      Parameters

      • child: Component

        Add a child to the component. Child can be of any level of inheritance of component.

      Returns void

    • Add multiple children to the component

      Example

       var component1 = new Component("div"); // parent component
      var component2 = new Component("p"); // child component
      component1.addChildren(component2);

      Parameters

      • Rest ...childrenToAdd: Component[]

        A destructured list of components to add as children

      Returns void

    • Remove the child from the parent. Note if the child is not refrenced anywhere but only by the parent, then remove it will delete it.

      Parameters

      • child: Component

        The children component to remove as a child

      Returns void

    • Add multiple classes to the list of classes

      Example

       var myComponent = new Component("div");
      myComponent.addClasses("mx-5"); // class = "mx-5"
      myComponent.addClasses("my-1"); // class = "my-1" "mx-5"

      Parameters

      • Rest ...classNames: string[]

        the destructured string array of class names to add to the component

      Returns void

    • Adds a new CSS class with the specified properties.

      Parameters

      • className: string

        The name of the CSS class to add.

      • properties: {
            [key: string]: string;
        }

        The properties to associate with the new CSS class.

        • [key: string]: string

      Returns void

    • Updates the properties of an existing CSS class.

      Parameters

      • className: string

        The name of the CSS class to update.

      • properties: {
            [key: string]: string;
        }

        The updated properties to associate with the CSS class.

        • [key: string]: string

      Returns void

    • Removes an existing CSS class.

      Parameters

      • className: string

        The name of the CSS class to remove.

      Returns void

    • Adds the given properties to the specified class. If the class does not exist, it will be created.

      Parameters

      • className: string

        The name of the class to add properties to.

      • properties: {
            [key: string]: string;
        }

        An object containing the properties to add, where the key is the property name and the value is the property value.

        • [key: string]: string

      Returns void

    • Removes the given properties from the specified class. If the class no longer has any properties, it will be removed.

      Parameters

      • className: string

        The name of the class to remove properties from.

      • properties: {
            [key: string]: string;
        }

        An object containing the properties to remove, where the key is the property name and the value is the property value.

        • [key: string]: string

      Returns void

    • Updates the given properties of the specified class. If the class does not exist, it will be created.

      Parameters

      • className: string

        The name of the class to update properties of.

      • properties: {
            [key: string]: string;
        }

        An object containing the properties to update, where the key is the property name and the value is the property value.

        • [key: string]: string

      Returns void

    • Gets the properties of an existing CSS class.

      Returns

      The properties of the specified CSS class, or undefined if the CSS class does not exist.

      Parameters

      • className: string

        The name of the CSS class to get the properties of.

      Returns undefined | {
          [key: string]: string;
      }

    • Exports the CSS classes and their properties as a string. Returns a