Options
All
  • Public
  • Public/Protected
  • All
Menu

Index

Type aliases

IKeyMap

IKeyMap: object

Represents the type mapping used for the map_* functions

Type declaration

  • [key: string]: any

IStorageDefaults

IStorageDefaults: object

Represents the object with defaults allowed to be used via make_memory_storage

Type declaration

  • [key: string]: string

Variables

Const IS_BROWSER

IS_BROWSER: boolean = typeof window !== "undefined"

Represents if the current context is in-Browser

Functions

format_css_declaration

  • format_css_declaration(key: string, value: any): string
  • Returns the key and value stringified to a CSS Property Declaration, e.g. color:red

    import {format_css_declaration} from "svelte-commons/lib/util/shared";
    
    const key = "color";
    const value = "red";
    
    const declaration = format_css_declaration(key, value);
    
    console.log(declaration); // logs: `color:red`

    Parameters

    • key: string
    • value: any

    Returns string

format_css_reference

  • format_css_reference(key: string, default_value?: any, func?: string): string
  • Returns the key stringified into a CSS Variable reference, e.g. var(--primary-color)

    import {format_css_reference} from "svelte-commons/lib/util/shared";
    
    const key = "primary-color";
    const default_value = "blue";
    
    const reference = format_css_reference(key, default_value);
    
    console.log(reference); // logs: `var(--primary-color, blue)`

    Parameters

    • key: string
    • Default value default_value: any = null
    • Default value func: string = "var"

    Returns string

format_css_variable

  • format_css_variable(key: string, value: any): string
  • Returns the key and value stringified into a CSS Variable Declaration, e.g. --primary-color:red

    import {format_css_variable} from "svelte-commons/lib/util/shared";
    
    const key = "primary-color";
    const value = "red";
    
    const variable = format_css_variable(key, value);
    
    console.log(variable); // logs: `--primary-color:red`

    Parameters

    • key: string
    • value: any

    Returns string

make_memory_storage

  • Represents an in-memory reimplementation of a Web Storage API

    import {make_memory_storage} from "svelte-commons/lib/util/shared";
    
    const storage = make_memory_storage();
    
    // Save data to Storage
    storage.setItem("key", "value");
    
    // Get saved data from Storage
    let data = storage.getItem("key");
    
    // Remove saved data from Storage
    storage.removeItem("key");
    
    // Remove all saved data from Storage
    storage.clear();

    Parameters

    Returns Storage

map_classes

  • map_classes(mapping: IKeyMap, delimiter?: string): string
  • Returns a key-value mapping of CSS Classes transformed into a single spaced string, e.g. btn btn-primary

    import {map_classes} from "svelte-commons/lib/util/shared";
    
    const data = {
        btn: "true",
        "btn-%s": "primary",
        btn_outline: false
    };
    
    const classes = map_classes(data);
    
    console.log(classes); // logs: `btn btn-primary`

    Parameters

    • mapping: IKeyMap
    • Default value delimiter: string = " "

    Returns string

map_style

  • map_style(mapping: IKeyMap, delimiter?: string): string
  • Returns a key-value mapping of CSS Properties transformed into a single semi-colon ; string, e.g. background-color:black;color:white;

    import {map_style} from "svelte-commons/lib/util/shared";
    
    const data = {
        background_color: "white",
        color: "black"
    };
    
    const style = map_style(data);
    
    console.log(style); // logs: `background-color:white;color:black;`

    Parameters

    • mapping: IKeyMap
    • Default value delimiter: string = ";"

    Returns string

map_variables

  • map_variables(mapping: IKeyMap, delimiter?: string): string
  • Returns a key-value mapping of CSS Variables transformed into a single semi-colon ; string, e.g. --background:black;--foreground:white;

    import {map_variables} from "svelte-commons/lib/util/shared";
    
    const data = {
        theme_background: "white",
        theme_foreground: "black"
    };
    
    const variables = map_variables(data);
    
    console.log(variables); // logs: `--theme-background:white;--theme-foreground:black;`

    Parameters

    • mapping: IKeyMap
    • Default value delimiter: string = ";"

    Returns string

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Type alias with type parameter
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method

Generated using TypeDoc