npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@uifabricshared/themed-settings

v0.12.0

Published

Package which drives custom cacheable settings for a component

Downloads

5,142

Readme

Custom settings package

This package provides a simple library for adding the ability to customize components via settings.

ISettingsEntry<TSettings, TTheme>

Settings are specified by using ISettingsEntry. This can be one of several types which will be handled as follows:

| Type | Action | | ---------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | string | This is interpreted as the name of an entry to load from the theme. Because the theming system is injected this will be done via a callback function. | | TSettings | This will be a reference to a IComponentSettings object to merge with the other values. Note that this should not be mutated as the mutations may not be reflected once values are cached. | | (theme) => TSettings | A function which takes a theme and returns a settings object. This will be resolved once per theme with the results cached. |

Note that this module imposes a limitation that the settings can't depend upon props directly. This can be implemented using the _overrides on settings objects in an indirect manner.

getThemedSettings

This is the primary worker routine which resolves a stack of settings, applies any overrides if applicable, and caches the result. Subsequent calls with the same key + override combination will use the cached results.

export function getThemedSettings<TSettings extends IComponentSettings, TTheme>(
  customSettings: ISettingsEntry<TSettings, TTheme>[],
  theme: TTheme,
  cache: object,
  key: string,
  hasOverride?: IOverrideLookup,
  getFromTheme?: IGetSettingsFromTheme<TSettings, TTheme>
): { settings: TSettings | undefined; key: string }

Parameters are used as follows:

| Parameter | Usage | | ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | customSettings | The array of settings entries to merge together | | theme | Theme used for looking up named settings | | cache | An object used to cache results. This should be component specific to avoid collisions. | | key | A string to use to key the cache entries. The settings block with no overrides applied will be under cache[key]. Overrides will be appended to build up a longer key in that case. | | hasOverride | An IOverrideLookup to use for figuring out which overrides to apply. If unspecified overrides will not be applied. | | getFromTheme | A function used to look up a named entry from a theme |

The resulting settings structure and the built up key are returned as the result of this function.

getBaseThemedSettings

This is as getThemedSettings except that it doesn't resolve overrides. As a result the key does not need to be returned as it will just match key.