How to use hyphenate-style-name - 9 common examples

To help you get started, we’ve selected a few hyphenate-style-name 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 necolas / react-native-web / packages / react-native-web / src / exports / StyleSheet / compile.js View on Github external
.map(property => {
      const value = domStyle[property];
      const prop = hyphenateStyleName(property);
      // The prefixer may return an array of values:
      // { display: [ '-webkit-flex', 'flex' ] }
      // to represent "fallback" declarations
      // { display: -webkit-flex; display: flex; }
      if (Array.isArray(value)) {
        return value.map(v => `${prop}:${v}`).join(';');
      } else {
        return `${prop}:${value}`;
      }
    })
    // Once properties are hyphenated, this will put the vendor
github contra / react-responsive / src / toQuery.js View on Github external
const keyVal = (k, v) => {
  const realKey = hyphenate(k)

  // px shorthand
  if (typeof v === 'number') {
    v = `${v}px`
  }
  if (v === true) {
    return realKey
  }
  if (v === false) {
    return negate(realKey)
  }
  return `(${realKey}: ${v})`
}
github nathanmarks / stylishly / packages / stylishly / src / utils / css.js View on Github external
return Object.keys(declaration).reduce((css, property, index, properties) => {
    let value = declaration[property];
    const hyphenatedProperty = hyphenateStyleName(property);
    if (Array.isArray(value)) {
      value = value.join(';' + hyphenatedProperty + ':');
    }
    if (index !== properties.length - 1) {
      value = value + ';';
    }
    return css + hyphenatedProperty + ':' + value;
  }, '');
}
github cssinjs / jss / packages / jss-plugin-camel-case / src / index.js View on Github external
function convertCase(style) {
  const converted = {}

  for (const prop in style) {
    const key = prop.indexOf('--') === 0 ? prop : hyphenate(prop)

    converted[key] = style[prop]
  }

  if (style.fallbacks) {
    if (Array.isArray(style.fallbacks)) converted.fallbacks = style.fallbacks.map(convertCase)
    else converted.fallbacks = convertCase(style.fallbacks)
  }

  return converted
}
github nathanmarks / stylishly / src / plugins / camelCase.js View on Github external
(result, val, key) => {
          result[hyphenateStyleName(key)] = val;
        },
        {}
github necolas / react-native-web / packages / react-native-web / src / exports / StyleSheet / createRuleBlock.js View on Github external
const createDeclarationString = (prop, val) => {
  const name = hyphenateStyleName(prop);
  const value = normalizeValue(prop, val);
  if (Array.isArray(val)) {
    return val.map(v => `${name}:${v}`).join(';');
  }
  return `${name}:${value}`;
};
github necolas / react-native-web / packages / react-native-web / src / vendor / react-dom / setValueForStyles / index.js View on Github external
for (let styleName in styles) {
    if (!styles.hasOwnProperty(styleName)) {
      continue;
    }
    const isCustomProperty = styleName.indexOf('--') === 0;
    if (process.env.NODE_ENV !== 'production') {
      if (!isCustomProperty) {
        warnValidStyle(styleName, styles[styleName], getStack);
      }
    }
    const styleValue = dangerousStyleValue(styleName, styles[styleName], isCustomProperty);
    if (styleName === 'float') {
      styleName = 'cssFloat';
    }
    if (isCustomProperty) {
      const name = isCustomProperty ? styleName : hyphenateStyleName(styleName);
      style.setProperty(name, styleValue);
    } else {
      style[styleName] = styleValue;
    }
  }
}
github unihooks / unihooks / src / useMedia.js View on Github external
return keys.reduce((result, key) => {
    result[hyphenate(key)] = obj[key]
    return result
  }, {})
}

hyphenate-style-name

Hyphenates a camelcased CSS property name

BSD-3-Clause
Latest version published 5 months ago

Package Health Score

72 / 100
Full package analysis

Popular hyphenate-style-name functions