Skip to content

Commit 21a6727

Browse files
committed
another attempt at importing cssing
Signed-off-by: Daniel Sieradski <[email protected]> # Conflicts: # README.md
1 parent 5b911c0 commit 21a6727

File tree

11 files changed

+272
-70
lines changed

11 files changed

+272
-70
lines changed

.eslintrc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module.exports = {
33
env: {
44
node: true
55
},
6-
extends: ['plugin:vue/essential', 'eslint:recommended', '@vue/prettier'],
6+
extends: ['plugin:vue/essential', 'eslint:recommended', '@vue/prettier', 'plugin:import/errors', 'plugin:import/warnings'],
77
parserOptions: {
88
parser: 'babel-eslint'
99
},

README.md

Lines changed: 121 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,92 +1,81 @@
11
# gridjs-vue
22

3-
![gridjs-vue](https://user-images.githubusercontent.com/2541728/84843482-ffc31c00-b015-11ea-95e8-dc6fb3931ad5.png)
3+
<center><img src="https://user-images.githubusercontent.com/2541728/84843482-ffc31c00-b015-11ea-95e8-dc6fb3931ad5.png" alt="gridjs-vue logo" /></center>
44

5+
<<<<<<< HEAD
56
A [Vue.js](https://vuejs.org) wrapper component for [Grid.js](https://gridjs.io)
67

78
### 🏠 [Homepage](https://gridjs.io)
9+
=======
10+
A Vue wrapper component for [Grid.js](https://gridjs.io).
11+
>>>>>>> e1c00e6... another attempt at importing cssing
812
913
## Install
1014

1115
```sh
12-
yarn install gridjs-vue || npm install gridjs-vue
16+
npm install gridjs-vue
1317
```
1418

15-
## Component Registration
19+
### Component Registration
1620

17-
### Global Registration
21+
#### Local Registration
1822

19-
```js
20-
/* in `main.js` or wherever you specify your global components */
21-
import Grid from 'gridjs-vue'
23+
```html
24+
<script>
25+
import Grid from 'gridjs-vue'
2226
23-
Vue.use(Grid)
27+
export default {
28+
components: {
29+
Grid
30+
}
31+
}
32+
</script>
2433
```
2534

26-
### Local Registration
35+
#### Global Registration
2736

28-
```vue
29-
<script>
37+
```js
38+
/* in `main.js` or wherever you specify your global components */
3039
import Grid from 'gridjs-vue'
3140

32-
export default {
33-
components: {
34-
Grid
35-
}
36-
}
37-
</script>
41+
Vue.use(Grid)
3842
```
3943

4044
## Usage
4145

42-
Pass `cols` and either `rows`, `from`, or `server` as a data source. Everything else is optional.
46+
Pass `cols` (an array of column headers) and either `rows`, `from`, or `server` as a data source to the component. Everything else is optional.
4347

4448
Refer to [Grid.js documentation](https://gridjs.io/docs/config/) for specific configuration options.
4549

46-
```vue
50+
### Basic Example
51+
52+
```html
4753
<template>
48-
<grid
49-
:auto-width="autoWidth"
50-
:cols="cols"
51-
:from="from"
52-
:language="language"
53-
:pagination="pagination"
54-
:rows="rows"
55-
:search="search"
56-
:server="server"
57-
:sort="sort"
58-
:width="width"
59-
></grid>
54+
<grid :cols="cols" :rows="rows"></grid>
6055
</template>
6156

6257
<script>
63-
import Grid from 'gridjs-vue'
64-
65-
export default {
66-
name: 'MyTable',
67-
components: {
68-
Grid
69-
},
70-
data() {
71-
return {
72-
autoWidth: true / false, // boolean to automatically set table width
73-
cols: ['column 1', 'column 2'], // array containing strings of column headers
74-
from: '.my-element', // string of HTML table selector
75-
language: {}, // localization dictionary object
76-
pagination: true / false || {}, // boolean or pagination settings object
77-
rows: ['row 1: col 1', 'row 1: col 2'] // array containing row data
78-
search: true / false || {}, // boolean or search settings object
79-
server: {}, // server settings object
80-
sort: true / false || {}, // boolean or sort settings object
81-
theme: 'mermaid', // string with name of theme or 'none' to disable
82-
width: '100%' // string with css width value
58+
import Grid from 'gridjs-vue'
59+
60+
export default {
61+
name: 'Cars',
62+
components: {
63+
Grid
64+
},
65+
data() {
66+
return {
67+
cols: ['Make', 'Model', 'Year', 'Color'],
68+
rows: [
69+
['Ford', 'Fusion', '2011', 'Silver'],
70+
['Chevrolet', 'Cruz', '2018', 'White']
71+
]
72+
}
8373
}
8474
}
85-
}
8675
</script>
8776
```
8877

89-
### Default settings
78+
### Default Options
9079

9180
```json
9281
{
@@ -104,6 +93,85 @@ export default {
10493
}
10594
```
10695

96+
### Extended Options
97+
98+
```html
99+
<template>
100+
<grid
101+
:auto-width="autoWidth"
102+
:cols="cols"
103+
:from="from"
104+
:language="language"
105+
:pagination="pagination"
106+
:rows="rows"
107+
:search="search"
108+
:server="server"
109+
:sort="sort"
110+
:width="width"
111+
></grid>
112+
</template>
113+
114+
<script>
115+
import Grid from 'gridjs-vue'
116+
117+
export default {
118+
name: 'MyTable',
119+
components: {
120+
Grid
121+
},
122+
data() {
123+
return {
124+
// REQUIRED:
125+
126+
// An array containing strings of column headers
127+
cols: ['col 1', 'col 2'],
128+
129+
// AND EITHER an array containing row data
130+
rows: [
131+
['row 1 col 1', 'row 1 col 2'],
132+
['row 2 col 1', 'row 2 col 2']
133+
],
134+
135+
// OR a string of an HTML table selector to import
136+
from: '.my-element'
137+
138+
// OR a server settings object
139+
server() ({
140+
url: 'https://api.com/search?q=my%20query',
141+
then: res => res.data.map(col => [col1.data, col2.data]),
142+
handle: res => res.status === 404
143+
? { data: [] } : res.ok
144+
? res.json() : new Error('Something went wrong')
145+
}),
146+
147+
// OPTIONAL:
148+
149+
// Boolean to automatically set table width
150+
autoWidth: true / false,
151+
152+
// Localization dictionary object
153+
language: {},
154+
155+
// Boolean or pagination settings object
156+
pagination: true / false || {},
157+
158+
// Boolean or search settings object
159+
search: true / false || {},
160+
161+
// Boolean or sort settings object
162+
sort: true / false || {},
163+
164+
// String with name of theme or 'none' to disable
165+
theme: 'mermaid',
166+
167+
// String with css width value
168+
width: '100%',
169+
}
170+
}
171+
}
172+
</script>
173+
```
174+
107175
## 🤝 Contributing
108176

109177
Originally authored by [Daniel Sieradski](https://twitter.com/self_agency).

dist/index.esm.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)