index.wxs 641B

123456789101112131415161718192021222324252627282930
  1. /* eslint-disable */
  2. var object = require('../wxs/object.wxs');
  3. var style = require('../wxs/style.wxs');
  4. function kebabCase(word) {
  5. var newWord = word
  6. .replace(getRegExp("[A-Z]", 'g'), function (i) {
  7. return '-' + i;
  8. })
  9. .toLowerCase()
  10. .replace(getRegExp("^-"), '');
  11. return newWord;
  12. }
  13. function mapThemeVarsToCSSVars(themeVars) {
  14. var cssVars = {};
  15. object.keys(themeVars).forEach(function (key) {
  16. var cssVarsKey = '--' + kebabCase(key);
  17. cssVars[cssVarsKey] = themeVars[key];
  18. });
  19. return style(cssVars);
  20. }
  21. module.exports = {
  22. kebabCase: kebabCase,
  23. mapThemeVarsToCSSVars: mapThemeVarsToCSSVars,
  24. };