Skip to content

Commit e1c00e6

Browse files
committed
another attempt at importing cssing
1 parent 16801f2 commit e1c00e6

File tree

11 files changed

+269
-73
lines changed

11 files changed

+269
-73
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: 118 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,92 +1,75 @@
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-
A [Vue.js](https://vuejs.org) wrapper component for [Grid.js](https://grid.io)
6-
7-
### 🏠 [Homepage](https://gridjs.io)
5+
A Vue wrapper component for [Grid.js](https://gridjs.io).
86

97
## Install
108

119
```sh
12-
yarn install gridjs-vue || npm install gridjs-vue
10+
npm install gridjs-vue
1311
```
1412

15-
## Component Registration
13+
### Component Registration
1614

17-
### Global Registration
15+
#### Local Registration
1816

19-
```js
20-
/* in `main.js` or wherever you specify your global components */
21-
import Grid from 'gridjs-vue'
17+
```html
18+
<script>
19+
import Grid from 'gridjs-vue'
2220
23-
Vue.use(Grid)
21+
export default {
22+
components: {
23+
Grid
24+
}
25+
}
26+
</script>
2427
```
2528

26-
### Local Registration
29+
#### Global Registration
2730

28-
```vue
29-
<script>
31+
```js
32+
/* in `main.js` or wherever you specify your global components */
3033
import Grid from 'gridjs-vue'
3134

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

4038
## Usage
4139

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

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

46-
```vue
44+
### Basic Example
45+
46+
```html
4747
<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>
48+
<grid :cols="cols" :rows="rows"></grid>
6049
</template>
6150

6251
<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
52+
import Grid from 'gridjs-vue'
53+
54+
export default {
55+
name: 'Cars',
56+
components: {
57+
Grid
58+
},
59+
data() {
60+
return {
61+
cols: ['Make', 'Model', 'Year', 'Color'],
62+
rows: [
63+
['Ford', 'Fusion', '2011', 'Silver'],
64+
['Chevrolet', 'Cruz', '2018', 'White']
65+
]
66+
}
8367
}
8468
}
85-
}
8669
</script>
8770
```
8871

89-
### Default settings
72+
### Default Options
9073

9174
```json
9275
{
@@ -104,6 +87,85 @@ export default {
10487
}
10588
```
10689

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

109171
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)