Skip to content

Commit 6734575

Browse files
committed
First commit
0 parents  commit 6734575

File tree

8 files changed

+2869
-0
lines changed

8 files changed

+2869
-0
lines changed

.babelrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"presets": [["@babel/preset-env", { "modules": false }]]
3+
}

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
dist

package.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"name": "vue-grid-responsive",
3+
"version": "0.1.0",
4+
"license": "MIT",
5+
"main": "dist/vue-grid-responsive.umd.js",
6+
"module": "dist/vue-grid-responsive.esm.js",
7+
"unpkg": "dist/vue-grid-responsive.min.js",
8+
"scripts": {
9+
"build": "rollup -c"
10+
},
11+
"devDependencies": {
12+
"@babel/core": "^7.10.2",
13+
"@babel/preset-env": "^7.10.2",
14+
"rollup": "^2.12.0",
15+
"rollup-plugin-babel": "^4.4.0",
16+
"rollup-plugin-commonjs": "^10.1.0",
17+
"rollup-plugin-node-resolve": "^5.2.0",
18+
"rollup-plugin-vue": "^5.1.6",
19+
"vue": "^2.6.11",
20+
"vue-template-compiler": "^2.6.11"
21+
}
22+
}

rollup.config.js

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import babel from "rollup-plugin-babel";
2+
import resolve from "rollup-plugin-node-resolve";
3+
import commonjs from "rollup-plugin-commonjs";
4+
import vue from "rollup-plugin-vue";
5+
import pkg from "./package.json";
6+
7+
export default [
8+
{
9+
input: "src/index.js",
10+
plugins: [
11+
vue(),
12+
babel({ exclude: "node_modules/**" }),
13+
resolve({ mainFields: ["module", "jsnext", "main", "browser"] }),
14+
commonjs()
15+
],
16+
output: {
17+
exports: "named",
18+
name: "VueGridResponsive",
19+
file: pkg.unpkg,
20+
format: "iife",
21+
sourcemap: true
22+
},
23+
watch: {
24+
include: "src/**"
25+
}
26+
},
27+
{
28+
input: "./src/index.js",
29+
plugins: [
30+
vue(),
31+
babel({ exclude: "node_modules/**" }),
32+
resolve({ mainFields: ["module", "jsnext", "main", "browser"] }),
33+
commonjs()
34+
],
35+
output: {
36+
name: "VueGridResponsive",
37+
file: pkg.module,
38+
format: "es",
39+
sourcemap: true
40+
}
41+
},
42+
{
43+
input: "./src/index.js",
44+
plugins: [
45+
vue(),
46+
babel({ exclude: "node_modules/**" }),
47+
resolve({ mainFields: ["module", "jsnext", "main", "browser"] }),
48+
commonjs()
49+
],
50+
output: {
51+
exports: "named",
52+
name: "VueGridResponsive",
53+
file: pkg.main,
54+
format: "umd",
55+
sourcemap: true
56+
}
57+
}
58+
];

src/Column.vue

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
<template>
2+
<div :style="styleGeneral" :class="classGeneral">
3+
<slot />
4+
</div>
5+
</template>
6+
7+
<script>
8+
export default {
9+
name: "Column",
10+
data() {
11+
let styleGeneral = this.createStyleSize();
12+
13+
if (this.xs || this.sm || this.md || this.lg || this.xl) {
14+
styleGeneral += `--colFlexSGR:0;`;
15+
} else {
16+
styleGeneral = `--colFlexSGR:1;`;
17+
}
18+
19+
return {
20+
classGeneral: `col ${this.createClassSize()}`,
21+
styleGeneral
22+
};
23+
},
24+
props: {
25+
xs: Number,
26+
sm: Number,
27+
md: Number,
28+
lg: Number,
29+
xl: Number,
30+
localColumns: {
31+
type: Number,
32+
default: 12
33+
}
34+
},
35+
methods: {
36+
getValue(breakpoint) {
37+
if (breakpoint > this.localColumns) {
38+
breakpoint = this.localColumns;
39+
}
40+
41+
return breakpoint ? `${(breakpoint / this.localColumns) * 100}%` : false;
42+
},
43+
createClassSize() {
44+
let newClass = "col-xs ";
45+
46+
newClass += this.sm ? "col-sm " : "";
47+
newClass += this.md ? "col-md " : "";
48+
newClass += this.lg ? "col-lg " : "";
49+
newClass += this.xl ? "col-xl " : "";
50+
51+
return newClass;
52+
},
53+
createStyleSize() {
54+
let newStyle = "";
55+
56+
newStyle += this.xs
57+
? `--xsWidthSGR:${this.getValue(this.xs)}; `
58+
: `--xsWidthSGR:100%; `;
59+
newStyle += this.sm ? `--smWidthSGR:${this.getValue(this.sm)}; ` : "";
60+
newStyle += this.md ? `--mdWidthSGR:${this.getValue(this.md)}; ` : "";
61+
newStyle += this.lg ? `--lgWidthSGR:${this.getValue(this.lg)}; ` : "";
62+
newStyle += this.xl ? `--xlWidthSGR:${this.getValue(this.xl)}; ` : "";
63+
64+
return newStyle;
65+
}
66+
}
67+
};
68+
</script>
69+
70+
<style scoped>
71+
.container {
72+
box-sizing: border-box;
73+
display: flex;
74+
flex-wrap: wrap;
75+
width: calc(100% + (var(--paddingSGR) * 2));
76+
margin: var(--marginSGR);
77+
}
78+
79+
.col {
80+
position: relative;
81+
box-sizing: border-box;
82+
flex-grow: var(--colFlexSGR);
83+
padding: var(--paddingSGR);
84+
}
85+
.col-xs {
86+
flex-basis: var(--xsWidthSGR);
87+
max-width: var(--xsWidthSGR);
88+
}
89+
90+
@media (min-width: 576px) {
91+
.col-sm {
92+
flex-basis: var(--smWidthSGR);
93+
max-width: var(--smWidthSGR);
94+
}
95+
}
96+
97+
@media (min-width: 768px) {
98+
.col-md {
99+
flex-basis: var(--mdWidthSGR);
100+
max-width: var(--mdWidthSGR);
101+
}
102+
}
103+
104+
@media (min-width: 992px) {
105+
.col-lg {
106+
flex-basis: var(--lgWidthSGR);
107+
max-width: var(--lgWidthSGR);
108+
}
109+
}
110+
111+
@media (min-width: 1200px) {
112+
.col-xl {
113+
max-width: var(--xlWidthSGR);
114+
}
115+
}
116+
</style>

src/Row.vue

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<template>
2+
<div :style="styleGeneral" class="container">
3+
<slot />
4+
</div>
5+
</template>
6+
7+
<script>
8+
export default {
9+
name: "Row",
10+
data() {
11+
return {
12+
styleGeneral: this.createGutter(this.gutter)
13+
};
14+
},
15+
props: {
16+
gutter: Number,
17+
columns: {
18+
type: Number,
19+
default: 12
20+
}
21+
},
22+
methods: {
23+
createGutter(gutter) {
24+
return gutter
25+
? `--paddingSGR:${gutter / 2}px;--marginSGR:-${gutter / 2}px`
26+
: "--paddingSGR:0;--marginSGR:0";
27+
}
28+
}
29+
};
30+
</script>
31+
32+
<style scoped>
33+
.container {
34+
box-sizing: border-box;
35+
display: flex;
36+
flex-wrap: wrap;
37+
width: calc(100% + (var(--paddingSGR) * 2));
38+
margin: var(--marginSGR);
39+
}
40+
</style>

src/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export { default as Row } from "./Row.vue";
2+
export { default as Column } from "./Column.vue";

0 commit comments

Comments
 (0)