Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stash2 #2

Open
dlrandy opened this issue Oct 12, 2017 · 4 comments
Open

stash2 #2

dlrandy opened this issue Oct 12, 2017 · 4 comments

Comments

@dlrandy
Copy link
Owner

dlrandy commented Oct 12, 2017

https://medium.freecodecamp.org/requiring-modules-in-node-js-everything-you-need-to-know-e7fbd119be8

@dlrandy
Copy link
Owner Author

dlrandy commented Oct 16, 2017

var a = 123; function a(){console.log('a');} typeof a;
"number"

@dlrandy
Copy link
Owner Author

dlrandy commented Oct 17, 2017

@define-mixin themify $property, $value {
@each $theme in light, dark {
.theme-$(theme) &,
.theme-$(theme)& {
$(property): themed($(theme), $(value));//这里家引号会有问题的坑
}
}
}

.App {
text-align: center;
@add-mixin themify background, textColor;
}

.App-logo {
animation: App-logo-spin infinite 20s linear;
height: 80px;
}
//===================================
module.exports = {
light: {
textColor: 'red'
},
dark: {
textColor: 'green'
}
}
//========================================

plugins: () => [
require('postcss-flexbugs-fixes'),
require('postcss-mixins'),
require('postcss-each'),
require('postcss-functions')({
functions: {
themed: function (theme, key) {
console.log(themes,theme, key);
return themes[theme][key];
}
}
}),
require('precss')(),
require('postcss-cssnext')(),

@dlrandy
Copy link
Owner Author

dlrandy commented Oct 17, 2017

            require('postcss-mixins')({
              mixins: {
                themify: function(mixin, property, key){
                  return ['light', 'dark'].map(function(theme){
                    return {
                      [`.theme-${theme} &, &.theme-${theme}`]: {
                          [property]: themes[theme][key]
                      }
                    }
                  })
                }
              }
            }),

@define-mixin themify $property, $value {
@each $theme in light, dark {
.theme-$(theme) &,
&.theme-$(theme) {
$(property): themed($(theme), $(value));
}
}
}

@dlrandy
Copy link
Owner Author

dlrandy commented Oct 18, 2017

above return array, so it has a & index issue.following is right:

require('postcss-mixins')({
mixins: {
themify: function (mixin, property, key) {
let objArr = ['light', 'dark'].map(function (theme) {
return {
[.theme-${theme} &, &.theme-${theme}]: {
[property]: themes[theme][key]
}
}
});
return Object.assign({}, ...objArr);
}
}
}),

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant