Skip to content

Commit

Permalink
v0.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexandreBonaventure committed Nov 20, 2017
1 parent 692820a commit 30c4cf4
Show file tree
Hide file tree
Showing 5 changed files with 101 additions and 2 deletions.
33 changes: 33 additions & 0 deletions dist/vue-mq.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,37 @@ function transformValuesFromBreakpoints(breakpoints, values, currentBreakpoint)
return result
}

function selectBreakpoints(breakpoints, currentBreakpoint) {
var index = breakpoints.findIndex(function (b) { return b === currentBreakpoint; });
return breakpoints.slice(index)
}

// USAGE
// mq-layout(mq="lg")
// p I’m lg
var component = {
props: {
mq: {
required: true,
type: String,
}
},
computed: {
plusModifier: function plusModifier() { return this.mq.slice(-1) === '+' },
activeBreakpoints: function activeBreakpoints() {
var breakpoints = Object.keys(this.$mqAvailableBreakpoints);
var mq = this.plusModifier ? this.mq.slice(0, -1) : this.mq;
return this.plusModifier
? selectBreakpoints(breakpoints, mq)
: [this.mq]
}
},
render: function render(h, props) {
var shouldRenderChildren = this.activeBreakpoints.includes(this.$mq);
return shouldRenderChildren ? h('div', this.$slots.default) : h()
},
};

var DEFAULT_BREAKPOINT = {
sm: 450,
md: 1250,
Expand Down Expand Up @@ -167,6 +198,8 @@ var install = function (Vue, ref) {
},
}
});
Vue.prototype.$mqAvailableBreakpoints = breakpoints;
Vue.component('MqLayout', component);
};

var index = { install: install };
Expand Down
33 changes: 33 additions & 0 deletions dist/vue-mq.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,37 @@ function transformValuesFromBreakpoints(breakpoints, values, currentBreakpoint)
return result
}

function selectBreakpoints(breakpoints, currentBreakpoint) {
var index = breakpoints.findIndex(function (b) { return b === currentBreakpoint; });
return breakpoints.slice(index)
}

// USAGE
// mq-layout(mq="lg")
// p I’m lg
var component = {
props: {
mq: {
required: true,
type: String,
}
},
computed: {
plusModifier: function plusModifier() { return this.mq.slice(-1) === '+' },
activeBreakpoints: function activeBreakpoints() {
var breakpoints = Object.keys(this.$mqAvailableBreakpoints);
var mq = this.plusModifier ? this.mq.slice(0, -1) : this.mq;
return this.plusModifier
? selectBreakpoints(breakpoints, mq)
: [this.mq]
}
},
render: function render(h, props) {
var shouldRenderChildren = this.activeBreakpoints.includes(this.$mq);
return shouldRenderChildren ? h('div', this.$slots.default) : h()
},
};

var DEFAULT_BREAKPOINT = {
sm: 450,
md: 1250,
Expand Down Expand Up @@ -165,6 +196,8 @@ var install = function (Vue, ref) {
},
}
});
Vue.prototype.$mqAvailableBreakpoints = breakpoints;
Vue.component('MqLayout', component);
};

var index = { install: install };
Expand Down
33 changes: 33 additions & 0 deletions dist/vue-mq.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,37 @@ function transformValuesFromBreakpoints(breakpoints, values, currentBreakpoint)
return result
}

function selectBreakpoints(breakpoints, currentBreakpoint) {
var index = breakpoints.findIndex(function (b) { return b === currentBreakpoint; });
return breakpoints.slice(index)
}

// USAGE
// mq-layout(mq="lg")
// p I’m lg
var component = {
props: {
mq: {
required: true,
type: String,
}
},
computed: {
plusModifier: function plusModifier() { return this.mq.slice(-1) === '+' },
activeBreakpoints: function activeBreakpoints() {
var breakpoints = Object.keys(this.$mqAvailableBreakpoints);
var mq = this.plusModifier ? this.mq.slice(0, -1) : this.mq;
return this.plusModifier
? selectBreakpoints(breakpoints, mq)
: [this.mq]
}
},
render: function render(h, props) {
var shouldRenderChildren = this.activeBreakpoints.includes(this.$mq);
return shouldRenderChildren ? h('div', this.$slots.default) : h()
},
};

var DEFAULT_BREAKPOINT = {
sm: 450,
md: 1250,
Expand Down Expand Up @@ -171,6 +202,8 @@ var install = function (Vue, ref) {
},
}
});
Vue.prototype.$mqAvailableBreakpoints = breakpoints;
Vue.component('MqLayout', component);
};

var index = { install: install };
Expand Down
2 changes: 1 addition & 1 deletion dist/vue-mq.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vue-mq",
"version": "0.0.1",
"version": "0.1.0",
"description": "Handle media queries easily & build responsive design with Vue",
"main": "dist/vue-mq.js",
"module": "dist/vue-mq.esm.js",
Expand Down

0 comments on commit 30c4cf4

Please sign in to comment.