mazey
    Preparing search index...

    Function genStyleString

    • Generate the inline style string from the given parameters. The first parameter is the query selector, and the second parameter is the style array.

      Usage:

      const ret1 = genStyleString(".a", [ "color:red" ]);
      const ret2 = genStyleString("#b", [ "color:red", "font-size:12px" ]);
      console.log(ret1);
      console.log(ret2);

      Output:

      .a{color:red;}
      #b{color:red;font-size:12px;}
      

      Example: Combine genStyleString and addStyle to add multiple styles at once.

      import { genStyleString, addStyle } from "mazey";

      const xStyle = genStyleString(
      ".footer>.x-wish>a:first-child" +
      ",div.wish-flex>a[href^='https://github.com/chengchuu']" +
      ",.m-hide",
      [ "display: none" ]
      );
      const yStyle = genStyleString(
      ".footer>.y-wish:before",
      [
      `content: 'Copyright (c) chengchuu'`,
      "color: inherit",
      "padding-inline-start: var(--y-wish-1_5)",
      "padding-inline-end: var(--y-wish-1_5)",
      "padding-top: var(--y-wish-1)",
      "padding-bottom: var(--y-wish-1)",
      ]
      );
      addStyle(xStyle + yStyle, { id: "z-style" });

      Output:

      <style id="z-style">.footer>.x-wish>a:first-child,div.wish-flex>a[href^='https://github.com/chengchuu'],.m-hide{display: none;}.footer>.y-wish:before{content: 'Copyright (c) chengchuu';color: inherit;padding-inline-start: var(--y-wish-1_5);padding-inline-end: var(--y-wish-1_5);padding-top: var(--y-wish-1);padding-bottom: var(--y-wish-1);}</style>
      

      Parameters

      • selector: string
      • styleArray: string[]

      Returns string

      The inline style string.