Skip to content

Commit c8d57cb

Browse files
committed
feat(docs): Filtering for API cards
1 parent b0d82f9 commit c8d57cb

File tree

9 files changed

+114
-47
lines changed

9 files changed

+114
-47
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,6 @@ Until Quasar reaches a 1.0 release (soon), breaking changes will be released wit
139139

140140
## License
141141

142-
Copyright (c) 2016-present Razvan Stoenescu
142+
Copyright (c) 2015-present Razvan Stoenescu
143143

144144
[MIT License](http://en.wikipedia.org/wiki/MIT_License)

docs/build/md-loader-utils.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ module.exports.getVueComponent = function (rendered, data, toc) {
1414
meta: {
1515
title: \`${data.title}\`
1616
},
17-
methods: {
18-
copyHeading
19-
},
2017
preFetch ({ store }) {
2118
store.commit('updateToc', ${toc})
19+
},
20+
methods: {
21+
copyHeading
2222
}
2323
}
2424
</script>`

docs/src/components/ApiRows.js

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,7 @@ export default {
220220
: child
221221
},
222222

223-
props (h) {
224-
const props = this.api.props
223+
props (h, props) {
225224
const child = []
226225

227226
for (let propName in props) {
@@ -233,8 +232,7 @@ export default {
233232
return child
234233
},
235234

236-
slots (h) {
237-
const slots = this.api.slots
235+
slots (h, slots) {
238236
const child = []
239237

240238
for (let slot in slots) {
@@ -249,8 +247,7 @@ export default {
249247
return child
250248
},
251249

252-
scopedSlots (h) {
253-
const scopedSlots = this.api.scopedSlots
250+
scopedSlots (h, scopedSlots) {
254251
const child = []
255252

256253
for (let slot in scopedSlots) {
@@ -262,8 +259,7 @@ export default {
262259
return child
263260
},
264261

265-
events (h) {
266-
const events = this.api.events
262+
events (h, events) {
267263
const child = []
268264

269265
for (let eventName in events) {
@@ -303,15 +299,14 @@ export default {
303299
return child
304300
},
305301

306-
methods (h) {
307-
const methods = this.api.methods
302+
methods (h, methods) {
308303
const child = []
309304

310305
for (let methodName in methods) {
311306
const method = methods[methodName]
312307

313308
const nodes = [
314-
this.getDiv(h, 12, 'Name', `@${methodName}${getMethodParams(method)}${getMethodReturnValue(method)}`),
309+
this.getDiv(h, 12, 'Name', `${methodName}${getMethodParams(method)}${getMethodReturnValue(method)}`),
315310
this.getDiv(h, 12, 'Description', method.desc)
316311
]
317312

@@ -356,24 +351,23 @@ export default {
356351
return child
357352
},
358353

359-
value (h) {
354+
value (h, value) {
360355
return [
361356
h('div', { staticClass: 'api-row row' }, [
362-
this.getDiv(h, 12, 'Type', getStringType(this.api.value.type))
363-
].concat(this.getProp(h, this.api.value, void 0, true)))
357+
this.getDiv(h, 12, 'Type', getStringType(value.type))
358+
].concat(this.getProp(h, value, void 0, true)))
364359
]
365360
},
366361

367-
arg (h) {
362+
arg (h, arg) {
368363
return [
369364
h('div', { staticClass: 'api-row row' }, [
370-
this.getDiv(h, 12, 'Type', getStringType(this.api.arg.type))
371-
].concat(this.getProp(h, this.api.arg, void 0, true)))
365+
this.getDiv(h, 12, 'Type', getStringType(arg.type))
366+
].concat(this.getProp(h, arg, void 0, true)))
372367
]
373368
},
374369

375-
modifiers (h) {
376-
const modifiers = this.api.modifiers
370+
modifiers (h, modifiers) {
377371
const child = []
378372

379373
for (let modifierName in modifiers) {
@@ -393,16 +387,15 @@ export default {
393387
return child
394388
},
395389

396-
injection (h) {
390+
injection (h, injection) {
397391
return [
398392
h('div', { staticClass: 'api-row row' }, [
399-
this.getDiv(h, 12, 'Name', this.api.injection)
393+
this.getDiv(h, 12, 'Name', injection)
400394
])
401395
]
402396
},
403397

404-
quasarConfOptions (h) {
405-
const conf = this.api.quasarConfOptions
398+
quasarConfOptions (h, conf) {
406399
const child = []
407400

408401
for (let def in conf.definition) {
@@ -429,6 +422,16 @@ export default {
429422
},
430423

431424
render (h) {
432-
return h('div', { staticClass: 'api-rows' }, this[this.which](h))
425+
const api = this.api[this.which]
426+
427+
const content = Object.keys(api).length !== 0
428+
? this[this.which](h, api)
429+
: [
430+
h('div', { staticClass: 'q-pa-md text-grey-7' }, [
431+
'No matching entries found. Please refine the filter.'
432+
])
433+
]
434+
435+
return h('div', { staticClass: 'api-rows' }, content)
433436
}
434437
}

docs/src/components/DocApi.vue

Lines changed: 61 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ q-card.doc-api.q-my-lg(v-if="ready")
66

77
q-separator
88

9-
div.bg-grey-2.text-grey-7.flex.items-center.no-wrap
9+
div.bg-grey-2.text-grey-7.flex.no-wrap
1010
q-tabs(v-model="currentTab", align="left", dense)
1111
q-tab(
1212
v-for="tab in tabs"
@@ -15,11 +15,25 @@ q-card.doc-api.q-my-lg(v-if="ready")
1515
:label="tab"
1616
)
1717

18+
q-input.col.q-mx-sm(
19+
ref="input",
20+
v-model="filter",
21+
dense,
22+
input-class="text-right",
23+
borderless,
24+
placeholder="Filter..."
25+
)
26+
q-icon.cursor-pointer(
27+
slot="append",
28+
:name="filter !== '' ? 'clear' : 'search'"
29+
@click="onFilterClick"
30+
)
31+
1832
q-separator
1933

2034
q-tab-panels(v-model="currentTab", animated)
2135
q-tab-panel(v-for="tab in tabs", :name="tab", :key="tab" class="q-pa-none")
22-
ApiRows(:which="tab", :api="api")
36+
ApiRows(:which="tab", :api="filteredApi")
2337
</template>
2438

2539
<script>
@@ -45,19 +59,63 @@ export default {
4559
return {
4660
ready: false,
4761
currentTab: null,
48-
filter: ''
62+
filter: '',
63+
filteredApi: {}
64+
}
65+
},
66+
67+
watch: {
68+
filter (val) {
69+
val = val.trim().toLowerCase()
70+
71+
if (val === '') {
72+
this.filteredApi = this.api
73+
return
74+
}
75+
76+
const api = {}
77+
78+
this.tabs.forEach(tab => {
79+
if (tab === 'injection') {
80+
api[tab] = this.api[tab]
81+
return
82+
}
83+
84+
api[tab] = {}
85+
const tabApi = this.api[tab]
86+
87+
Object.keys(tabApi).forEach(name => {
88+
if (
89+
(name.indexOf(val) > -1) ||
90+
(tabApi[name].desc !== void 0 && tabApi[name].desc.toLowerCase().indexOf(val) > -1)
91+
) {
92+
console.log(tabApi[name])
93+
api[tab][name] = tabApi[name]
94+
}
95+
})
96+
})
97+
98+
this.filteredApi = api
4999
}
50100
},
51101
52102
methods: {
53103
parseJson (name, { type, ...api }) {
54104
this.api = api
105+
this.filteredApi = api
55106
this.apiType = type
56107
57108
this.name = name
58109
this.type = `${type === 'plugin' ? 'Quasar' : 'Vue'} ${type.charAt(0).toUpperCase()}${type.substring(1)}`
59110
this.tabs = Object.keys(api)
60111
this.currentTab = this.tabs[0]
112+
},
113+
114+
onFilterClick () {
115+
if (this.filter !== '') {
116+
this.filter = ''
117+
}
118+
this.$refs.input.focus()
61119
}
62120
},
63121

docs/src/pages/quasar-plugins/addressbar-color.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,6 @@ export default {
5353
::: tip
5454
Calling `set()` with no parameters will use the primary color.
5555
:::
56+
57+
## API
58+
<doc-api file="AddressbarColor" />

docs/src/pages/quasar-plugins/cookies.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,13 @@ this.$q.cookies.get('cookie_name')
4949
// outside of a Vue file
5050
import { Cookies } from 'quasar'
5151

52-
var cookies = Cookies.all()
52+
var cookies = Cookies.getAll()
5353
```
5454
`cookies` variable will be an object with key-value pairs (cookie_name : cookie_value).
5555

5656
```js
5757
// inside of a Vue file
58-
this.$q.cookies.all()
58+
this.$q.cookies.getAll()
5959
```
6060

6161
## Verify if Cookie is Set
@@ -131,3 +131,6 @@ Cookies.remove('cookie_name')
131131
// inside of a Vue file
132132
this.$q.cookies.remove('cookie_name')
133133
```
134+
135+
## API
136+
<doc-api file="Cookies" />

quasar/dev/components/other/cookies.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@
3030
export default {
3131
data () {
3232
return {
33-
cookies: this.$q.cookies.all()
33+
cookies: this.$q.cookies.getAll()
3434
}
3535
},
3636
methods: {
3737
refresh () {
38-
this.cookies = this.$q.cookies.all()
38+
this.cookies = this.$q.cookies.getAll()
3939
},
4040
add (name) {
4141
this.$q.cookies.set(name, 'val')

quasar/src/plugins/Cookies.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ export function getObject (ctx = {}) {
148148
set: (key, val, opts) => set(key, val, opts, ssr),
149149
has: key => has(key, ssr),
150150
remove: (key, options) => remove(key, options, ssr),
151-
all: () => get(null, ssr)
151+
getAll: () => get(null, ssr)
152152
}
153153
}
154154

quasar/src/plugins/Cookies.json

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,17 @@
1919
}
2020
},
2121

22+
"getAll": {
23+
"desc": "Get all cookies",
24+
"returns": {
25+
"type": "Object",
26+
"desc": "Object with cookie names (as keys) and their values",
27+
"examples": [
28+
"{ userId: 'john12', XFrame: 'x534' }"
29+
]
30+
}
31+
},
32+
2233
"set": {
2334
"desc": "Set cookie",
2435
"params": {
@@ -121,17 +132,6 @@
121132
}
122133
},
123134

124-
"all": {
125-
"desc": "Get all cookies",
126-
"returns": {
127-
"type": "Object",
128-
"desc": "Object with cookie names (as keys) and their values",
129-
"examples": [
130-
"{ userId: 'john12', XFrame: 'x534' }"
131-
]
132-
}
133-
},
134-
135135
"parseSSR": {
136136
"desc": "For SSR usage only, and only on the global import (not on $q.cookies)",
137137
"params": {

0 commit comments

Comments
 (0)