0.12.0 • Published 27 days ago

@uifabricshared/themed-settings v0.12.0

Weekly downloads
82
License
MIT
Repository
github
Last release
27 days ago

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:

TypeAction
stringThis 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.
TSettingsThis 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) => TSettingsA 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:

ParameterUsage
customSettingsThe array of settings entries to merge together
themeTheme used for looking up named settings
cacheAn object used to cache results. This should be component specific to avoid collisions.
keyA 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.
hasOverrideAn IOverrideLookup to use for figuring out which overrides to apply. If unspecified overrides will not be applied.
getFromThemeA 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.

0.12.0

27 days ago

0.11.1

2 months ago

0.10.2

9 months ago

0.11.0

6 months ago

0.10.1

11 months ago

0.10.0

11 months ago

0.9.3

1 year ago

0.9.2

1 year ago

0.9.1

2 years ago

0.9.0

2 years ago

0.8.3

2 years ago

0.8.1

2 years ago

0.8.0

2 years ago

0.8.2

2 years ago

0.7.2

3 years ago

0.7.1

3 years ago

0.7.0

3 years ago

0.6.2

3 years ago

0.6.1

3 years ago

0.6.0

3 years ago

0.5.0

4 years ago

0.4.74

4 years ago

0.4.73

4 years ago

0.4.72

4 years ago

0.4.71

4 years ago

0.4.70

4 years ago

0.4.69

4 years ago

0.4.68

4 years ago

0.4.67

4 years ago

0.4.66

4 years ago

0.4.65

4 years ago

0.4.64

4 years ago

0.4.63

4 years ago

0.4.62

4 years ago

0.4.61

4 years ago

0.4.60

4 years ago

0.4.59

4 years ago

0.4.58

4 years ago

0.4.57

4 years ago

0.4.55

4 years ago

0.4.56

4 years ago

0.4.54

4 years ago

0.4.53

4 years ago

0.4.52

4 years ago

0.4.51

4 years ago

0.4.50

4 years ago

0.4.48

4 years ago

0.4.49

4 years ago

0.4.47

4 years ago

0.4.46

4 years ago

0.4.44

4 years ago

0.4.45

4 years ago

0.4.43

4 years ago

0.4.42

4 years ago

0.4.41

4 years ago

0.4.40

4 years ago

0.4.39

4 years ago

0.4.38

4 years ago

0.4.37

4 years ago

0.4.36

4 years ago

0.4.35

4 years ago

0.4.34

4 years ago

0.4.33

4 years ago

0.4.32

4 years ago

0.4.31

4 years ago

0.4.30

4 years ago

0.4.29

4 years ago

0.4.28

4 years ago

0.4.27

4 years ago

0.4.21

4 years ago

0.4.26

4 years ago

0.4.24

4 years ago

0.4.25

4 years ago

0.4.22

4 years ago

0.4.23

4 years ago

0.4.20

4 years ago

0.4.19

4 years ago

0.4.18

4 years ago

0.4.17

4 years ago

0.4.16

4 years ago

0.4.15

4 years ago

0.4.14

4 years ago

0.4.13

4 years ago

0.4.12

4 years ago

0.4.11

4 years ago

0.4.9

4 years ago

0.4.10

4 years ago

0.4.8

4 years ago

0.4.7

4 years ago

0.4.5

4 years ago

0.4.6

4 years ago

0.4.4

4 years ago

0.4.3

4 years ago

0.4.2

4 years ago

0.4.0

4 years ago

0.3.12

4 years ago

0.3.11

4 years ago

0.3.10

4 years ago

0.3.9

4 years ago

0.3.8

4 years ago

0.3.7

4 years ago

0.3.6

4 years ago

0.3.5

4 years ago

0.3.4

4 years ago

0.3.3

4 years ago

0.3.2

4 years ago

0.3.1

4 years ago

0.3.0

4 years ago

0.2.4

5 years ago

0.2.3

5 years ago

0.2.2

5 years ago