Skip to content

Instantly share code, notes, and snippets.

@pixelbacon
Created December 20, 2018 14:55
Show Gist options
  • Save pixelbacon/ba6e92aec8786b92469ed5544a5a814f to your computer and use it in GitHub Desktop.
Save pixelbacon/ba6e92aec8786b92469ed5544a5a814f to your computer and use it in GitHub Desktop.
vue-responsive-components helper
import _ from 'lodash';
const cssName = nameStr => _.lowerFirst(nameStr);
export default cssName;
import Vue from 'vue';
import { ResponsiveMixin } from 'vue-responsive-components';
import cssName from '@/lib/cssName';
Vue.mixin(ResponsiveMixin);
// Helper previous mixin
const responsiveHelper = {
created() {
this.cssName = cssName(this.$options.name);
this.responsive = {
[`${this.cssName}--xs`]: el => el.width < 600,
[`${this.cssName}--sm`]: el => el.width >= 600 && el.width < 960,
[`${this.cssName}--md`]: el => el.width >= 960 && el.width < 1264,
[`${this.cssName}--lg`]: el => el.width >= 1264 && el.width < 1600,
[`${this.cssName}--xl`]: el => el.width >= 1600,
};
},
data: () => ({
cssName: null,
responsive: null,
}),
};
Vue.mixin(responsiveHelper);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment