How to use the style-value-types.color.test function in style-value-types

To help you get started, we’ve selected a few style-value-types examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Popmotion / popmotion / packages / popmotion / src / action / vector.ts View on Github external
const getActionCreator = (prop: any) => {
  // Pattern matching would be quite lovely here
  if (typeof prop === 'number') {
    return createAction;
  } else if (Array.isArray(prop)) {
    return createArrayAction;
  } else if (isUnitProp(prop)) {
    return createUnitAction;
  } else if (color.test(prop)) {
    return createColorAction;
  } else if (complex.test(prop)) {
    return createComplexAction;
  } else if (typeof prop === 'object') {
    return createObjectAction;
  } else {
    return createAction;
  }
};
github Popmotion / popmotion / packages / popcorn / src / utils / interpolate.ts View on Github external
function detectMixerFactory(v: T): MixerFactory {
  if (typeof v === 'number') {
    return mixNumber;
  } else if (typeof v === 'string') {
    if (color.test(v)) {
      return mixColor;
    } else {
      return mixComplex;
    }
  } else if (Array.isArray(v)) {
    return mixArray;
  } else if (typeof v === 'object') {
    return mixObject;
  }
}
github Popmotion / popmotion / packages / popcorn / src / utils / mix-complex.ts View on Github external
const blendValue = from.map((fromThis, i) => {
    const toThis = to[i];

    if (isNum(fromThis)) {
      return (v: number) => mix(fromThis, toThis as number, v);
    } else if (color.test(fromThis)) {
      return mixColor(fromThis, toThis as HSLA | RGBA | string);
    } else {
      return mixComplex(fromThis as string, toThis as string);
    }
  });