Skip to content

Commit 142778f

Browse files
committed
Add jsdoc
1 parent da0b2e6 commit 142778f

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

packages/theming/src/utils/getColor.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,27 @@ type ColorParameters = {
149149
variable?: string;
150150
};
151151

152+
/**
153+
* Get a color value from the theme. Variable lookup takes precedence, followed
154+
* by `dark` and `light` object values. If none of these are provided, `hue`,
155+
* `shade`, `offset`, and `transparency` are used as fallbacks to determine the
156+
* color.
157+
*
158+
* @param {Object} [options.theme] Provides values used to resolve the desired color
159+
* @param {string} [options.variable] A variable key (i.e. `'background.default'`) used to resolve a color value for the theme color base
160+
* @param {Object} [options.dark] An object with `hue`, `shade`, `offset`, and `transparency` values to be used in dark mode
161+
* @param {Object} [options.light] An object with `hue`, `shade`, `offset`, and `transparency` values to be used in light mode
162+
* @param {string} [options.hue] A `theme.palette` hue or one of the following `theme.colors` keys:
163+
* - `'primaryHue'` = `theme.colors.primaryHue`
164+
* - `'dangerHue'` = `theme.colors.dangerHue`
165+
* - `'warningHue'` = `theme.colors.warningHue`
166+
* - `'successHue'` = `theme.colors.successHue`
167+
* - `'neutralHue'` = `theme.colors.neutralHue`
168+
* - `'chromeHue'` = `theme.colors.chromeHue`
169+
* @param {number} [options.shade] A hue shade
170+
* @param {number} [options.offset] A positive or negative value to adjust the shade
171+
* @param {number} [options.transparency] An alpha-channel value between 0 and 1
172+
*/
152173
export const getColor = memoize(
153174
({ dark, hue, light, offset, shade, theme, transparency, variable }: ColorParameters) => {
154175
let retVal;

0 commit comments

Comments
 (0)