web_lib

Common web application libraries
git clone https://radroots.dev/git/web_lib.git
Log | Files | Refs | LICENSE

tokens.ts (1218B)


      1 import type {
      2     TailwindThemeConfig,
      3     TailwindThemeNamespace,
      4     ThemeLayoutEntry,
      5     ThemeVariable
      6 } from "./types.js";
      7 
      8 export const with_prefix = (
      9     prefix: string,
     10     source: ThemeLayoutEntry
     11 ): ThemeLayoutEntry =>
     12     Object.fromEntries(
     13         Object.entries(source).map(([key, value]) => [`${prefix}${key}`, value])
     14     );
     15 
     16 const to_theme_variables = (
     17     namespace: TailwindThemeNamespace,
     18     scale: ThemeLayoutEntry
     19 ): ThemeVariable[] =>
     20     Object.entries(scale).map(([name, value]) => ({
     21         namespace,
     22         name,
     23         value
     24     }));
     25 
     26 export const build_theme_layout_variables = (
     27     config: TailwindThemeConfig
     28 ): ThemeVariable[] => [
     29         ...to_theme_variables("height", config.height),
     30         ...to_theme_variables("width", config.width),
     31         ...to_theme_variables("min-height", config.min_height),
     32         ...to_theme_variables("max-height", config.max_height),
     33         ...to_theme_variables("min-width", config.min_width),
     34         ...to_theme_variables("max-width", config.max_width),
     35         ...to_theme_variables("padding", config.padding),
     36         ...to_theme_variables("translate", config.translate),
     37         ...to_theme_variables("spacing", config.spacing)
     38     ];