Skip to content

Commit

Permalink
Creating example
Browse files Browse the repository at this point in the history
  • Loading branch information
andrelmlins committed May 31, 2020
1 parent 6734575 commit e2bde88
Show file tree
Hide file tree
Showing 12 changed files with 370 additions and 54 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
dist
dist
build
1 change: 1 addition & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "singleQuote": true }
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2020 N.A.D.A.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
22 changes: 22 additions & 0 deletions docs/App.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<template>
<row :gutter="12" :columns="24">
<column :xs="12" :sm="6" :lg="4">
<p>teste</p>
</column>
<column :xs="12" :sm="6" :lg="4">
<p>teste</p>
</column>
<column :xs="12" :sm="6" :lg="4">
<p>teste</p>
</column>
<column :xs="12" :sm="6" :lg="4">
<p>teste</p>
</column>
<column :xs="12" :sm="6" :lg="4">
<p>teste</p>
</column>
<column :xs="12" :sm="6" :lg="4">
<p>teste</p>
</column>
</row>
</template>
11 changes: 11 additions & 0 deletions docs/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import Vue from 'vue';
import { Row, Column } from '../src';
import App from './App.vue';

Vue.component('row', Row);
Vue.component('column', Column);

new Vue({
el: '#app',
render: h => h(App)
});
8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,22 @@
"module": "dist/vue-grid-responsive.esm.js",
"unpkg": "dist/vue-grid-responsive.min.js",
"scripts": {
"build": "rollup -c"
"build": "rollup -c",
"dev": "rollup -c -w",
"start": "sirv public"
},
"devDependencies": {
"@babel/core": "^7.10.2",
"@babel/preset-env": "^7.10.2",
"rollup": "^2.12.0",
"rollup-plugin-babel": "^4.4.0",
"rollup-plugin-commonjs": "^10.1.0",
"rollup-plugin-livereload": "^1.3.0",
"rollup-plugin-node-resolve": "^5.2.0",
"rollup-plugin-replace": "^2.2.0",
"rollup-plugin-terser": "^6.1.0",
"rollup-plugin-vue": "^5.1.6",
"sirv-cli": "^0.4.6",
"vue": "^2.6.11",
"vue-template-compiler": "^2.6.11"
}
Expand Down
16 changes: 16 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1" />

<title>Vue Grid Responsive</title>

<link rel="icon" type="image/png" href="/favicon.png" />
<script defer src="/build/bundle.js"></script>
</head>

<body>
<div id="app"></div>
</body>
</html>
98 changes: 74 additions & 24 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,58 +1,108 @@
import babel from "rollup-plugin-babel";
import resolve from "rollup-plugin-node-resolve";
import commonjs from "rollup-plugin-commonjs";
import vue from "rollup-plugin-vue";
import pkg from "./package.json";
import babel from 'rollup-plugin-babel';
import resolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import livereload from 'rollup-plugin-livereload';
import { terser } from 'rollup-plugin-terser';
import vue from 'rollup-plugin-vue';
import replace from 'rollup-plugin-replace';
import pkg from './package.json';

export default [
const app = {
input: 'docs/main.js',
output: {
sourcemap: true,
format: 'iife',
name: 'app',
file: 'public/build/bundle.js'
},
plugins: [
vue(),
babel({ exclude: 'node_modules/**' }),
resolve({ mainFields: ['module', 'jsnext', 'main', 'browser'] }),
commonjs(),
serve(),
livereload('public'),
terser(),
replace({
'process.env.NODE_ENV': JSON.stringify('development'),
'process.env.VUE_ENV': JSON.stringify('browser')
})
],
watch: {
clearScreen: false
}
};

const library = [
{
input: "src/index.js",
input: 'src/index.js',
plugins: [
vue(),
babel({ exclude: "node_modules/**" }),
resolve({ mainFields: ["module", "jsnext", "main", "browser"] }),
babel({ exclude: 'node_modules/**' }),
resolve({ mainFields: ['module', 'jsnext', 'main', 'browser'] }),
commonjs()
],
output: {
exports: "named",
name: "VueGridResponsive",
exports: 'named',
name: 'VueGridResponsive',
file: pkg.unpkg,
format: "iife",
format: 'iife',
sourcemap: true
},
watch: {
include: "src/**"
include: 'src/**'
}
},
{
input: "./src/index.js",
input: './src/index.js',
plugins: [
vue(),
babel({ exclude: "node_modules/**" }),
resolve({ mainFields: ["module", "jsnext", "main", "browser"] }),
babel({ exclude: 'node_modules/**' }),
resolve({ mainFields: ['module', 'jsnext', 'main', 'browser'] }),
commonjs()
],
output: {
name: "VueGridResponsive",
name: 'VueGridResponsive',
file: pkg.module,
format: "es",
format: 'es',
sourcemap: true
}
},
{
input: "./src/index.js",
input: './src/index.js',
plugins: [
vue(),
babel({ exclude: "node_modules/**" }),
resolve({ mainFields: ["module", "jsnext", "main", "browser"] }),
babel({ exclude: 'node_modules/**' }),
resolve({ mainFields: ['module', 'jsnext', 'main', 'browser'] }),
commonjs()
],
output: {
exports: "named",
name: "VueGridResponsive",
exports: 'named',
name: 'VueGridResponsive',
file: pkg.main,
format: "umd",
format: 'umd',
sourcemap: true
}
}
];

function serve() {
let started = false;

return {
writeBundle() {
if (!started) {
started = true;

require('child_process').spawn('npm', ['run', 'start', '--', '--dev'], {
stdio: ['ignore', 'inherit', 'inherit'],
shell: true
});
}
}
};
}

const config = process.env.ROLLUP_WATCH ? app : library;

export default config;
35 changes: 16 additions & 19 deletions src/Column.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<script>
export default {
name: "Column",
name: 'Col',
data() {
let styleGeneral = this.createStyleSize();
Expand All @@ -26,40 +26,37 @@ export default {
sm: Number,
md: Number,
lg: Number,
xl: Number,
localColumns: {
type: Number,
default: 12
}
xl: Number
},
methods: {
getValue(breakpoint) {
if (breakpoint > this.localColumns) {
breakpoint = this.localColumns;
const localColumns = this.$parent.columns;
if (breakpoint > localColumns) {
breakpoint = localColumns;
}
return breakpoint ? `${(breakpoint / this.localColumns) * 100}%` : false;
return breakpoint ? `${(breakpoint / localColumns) * 100}%` : false;
},
createClassSize() {
let newClass = "col-xs ";
let newClass = 'col-xs ';
newClass += this.sm ? "col-sm " : "";
newClass += this.md ? "col-md " : "";
newClass += this.lg ? "col-lg " : "";
newClass += this.xl ? "col-xl " : "";
newClass += this.sm ? 'col-sm ' : '';
newClass += this.md ? 'col-md ' : '';
newClass += this.lg ? 'col-lg ' : '';
newClass += this.xl ? 'col-xl ' : '';
return newClass;
},
createStyleSize() {
let newStyle = "";
let newStyle = '';
newStyle += this.xs
? `--xsWidthSGR:${this.getValue(this.xs)}; `
: `--xsWidthSGR:100%; `;
newStyle += this.sm ? `--smWidthSGR:${this.getValue(this.sm)}; ` : "";
newStyle += this.md ? `--mdWidthSGR:${this.getValue(this.md)}; ` : "";
newStyle += this.lg ? `--lgWidthSGR:${this.getValue(this.lg)}; ` : "";
newStyle += this.xl ? `--xlWidthSGR:${this.getValue(this.xl)}; ` : "";
newStyle += this.sm ? `--smWidthSGR:${this.getValue(this.sm)}; ` : '';
newStyle += this.md ? `--mdWidthSGR:${this.getValue(this.md)}; ` : '';
newStyle += this.lg ? `--lgWidthSGR:${this.getValue(this.lg)}; ` : '';
newStyle += this.xl ? `--xlWidthSGR:${this.getValue(this.xl)}; ` : '';
return newStyle;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Row.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<script>
export default {
name: "Row",
name: 'Row',
data() {
return {
styleGeneral: this.createGutter(this.gutter)
Expand All @@ -23,7 +23,7 @@ export default {
createGutter(gutter) {
return gutter
? `--paddingSGR:${gutter / 2}px;--marginSGR:-${gutter / 2}px`
: "--paddingSGR:0;--marginSGR:0";
: '--paddingSGR:0;--marginSGR:0';
}
}
};
Expand Down
4 changes: 2 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export { default as Row } from "./Row.vue";
export { default as Column } from "./Column.vue";
export { default as Row } from './Row.vue';
export { default as Column } from './Column.vue';
Loading

0 comments on commit e2bde88

Please sign in to comment.