Skip to content

Commit acf3381

Browse files
committed
feat(ui): Add support for global config for components & directives too quasarframework#6524
1 parent d547796 commit acf3381

File tree

6 files changed

+65
-22
lines changed

6 files changed

+65
-22
lines changed

ui/build/build.api.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ function getMixedInAPI (api, mainFile) {
3737

3838
const topSections = {
3939
plugin: [ 'meta', 'injection', 'quasarConfOptions', 'props', 'methods' ],
40-
component: [ 'meta', 'behavior', 'props', 'slots', 'scopedSlots', 'events', 'methods' ],
41-
directive: [ 'meta', 'value', 'arg', 'modifiers' ]
40+
component: [ 'meta', 'behavior', 'quasarConfOptions', 'props', 'slots', 'scopedSlots', 'events', 'methods' ],
41+
directive: [ 'meta', 'quasarConfOptions', 'value', 'arg', 'modifiers' ]
4242
}
4343

4444
const objectTypes = {
@@ -167,7 +167,6 @@ const objectTypes = {
167167
isObject: [ 'params', 'returns' ]
168168
},
169169

170-
// plugin only
171170
quasarConfOptions: {
172171
props: [ 'propName', 'definition', 'link', 'addedIn' ],
173172
required: [ 'propName', 'definition' ]

ui/dev/quasar.conf.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ module.exports = function (ctx) {
2424

2525
framework: {
2626
// iconSet: 'svg-mdi-v4',
27+
// config: { ripple: { early: true } },
2728
all: true
2829
},
2930

ui/dev/src/pages/css/material-ripples-2.vue

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@
22
<div class="q-layout-padding">
33
<div class="q-gutter-sm">
44
<q-btn label="Regular" @click="onClick" />
5+
<q-btn label="Regular early=false" :ripple="{ early: false }" @click="onClick" />
56
<q-btn label="Regular" loading @click="onClick" />
67
<q-btn label="Link" type="a" href="about:blank" target="_blank" @click="onClick" />
78
</div>
89

910
<div class="q-gutter-sm q-pt-md">
10-
<q-btn label="Regular early" :ripple="{ early: true }" @click="onClick" />
11-
<q-btn label="Regular early" loading :ripple="{ early: true }" @click="onClick" />
11+
<q-btn label="Regular early=true" :ripple="{ early: true }" @click="onClick" />
12+
<q-btn label="Regular early=false" :ripple="{ early: false }" @click="onClick" />
13+
<q-btn label="Regular early=true" loading :ripple="{ early: true }" @click="onClick" />
1214
<q-btn label="Link early" :ripple="{ early: true }" type="a" href="about:blank" target="_blank" @click="onClick" />
1315
</div>
1416
</div>

ui/src/directives/Ripple.js

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { addEvt, cleanEvt } from '../utils/touch.js'
44
import { isKeyCode } from '../utils/key-composition.js'
55
import { client } from '../plugins/Platform.js'
66
import throttle from '../utils/throttle.js'
7+
import { $q } from '../install.js'
78

89
function showRipple (evt, el, ctx, forceCenter) {
910
ctx.modifiers.stop === true && stop(evt)
@@ -64,21 +65,14 @@ function updateCtx (ctx, { value, modifiers, arg }) {
6465
ctx.enabled = value !== false
6566

6667
if (ctx.enabled === true) {
67-
ctx.modifiers = Object(value) === value
68-
? {
69-
early: value.early === true || modifiers.early === true,
70-
stop: value.stop === true || modifiers.stop === true,
71-
center: value.center === true || modifiers.center === true,
72-
color: value.color || arg,
73-
keyCodes: [].concat(value.keyCodes || 13)
74-
}
75-
: {
76-
early: modifiers.early,
77-
stop: modifiers.stop,
78-
center: modifiers.center,
79-
color: arg,
80-
keyCodes: [ 13 ]
81-
}
68+
const cfg = Object.assign({}, $q.config.ripple, modifiers, value)
69+
ctx.modifiers = {
70+
early: cfg.early === true,
71+
stop: cfg.stop === true,
72+
center: cfg.center === true,
73+
color: cfg.color || arg,
74+
keyCodes: [].concat(cfg.keyCodes || 13)
75+
}
8276
}
8377
}
8478

ui/src/directives/Ripple.json

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,49 @@
33
"docsUrl": "https://v1.quasar.dev/vue-directives/material-ripple"
44
},
55

6+
"quasarConfOptions": {
7+
"propName": "ripple",
8+
"definition": {
9+
"early": {
10+
"type": "Boolean",
11+
"desc": "Trigger early/immediately on user interaction"
12+
},
13+
14+
"stop": {
15+
"type": "Boolean",
16+
"desc": "Stop click/touch event propagation"
17+
},
18+
19+
"center": {
20+
"type": "Boolean",
21+
"desc": "Ripple starts from the absolute center"
22+
},
23+
24+
"color": {
25+
"type": "String",
26+
"desc": "Color name from Quasar Color Palette; Overrides default dynamic color",
27+
"examples": [ "orange-5" ]
28+
},
29+
30+
"keyCodes": {
31+
"type": [ "Array", "Number" ],
32+
"desc": "List of keyCode that should trigger the ripple",
33+
"examples": [ "[]", "[13, 32]" ]
34+
}
35+
},
36+
"addedIn": "v1.9.8"
37+
},
38+
639
"value": {
740
"type": [ "Boolean", "Object" ],
841
"desc": "Boolean (if just wanting to enable/disable) or Object for configuring more options",
942
"definition": {
43+
"early": {
44+
"type": "Boolean",
45+
"desc": "Trigger early/immediately on user interaction",
46+
"addedIn": "v1.9.8"
47+
},
48+
1049
"stop": {
1150
"type": "Boolean",
1251
"desc": "Stop click/touch event propagation"
@@ -44,6 +83,13 @@
4483
},
4584

4685
"modifiers": {
86+
"early": {
87+
"type": "Boolean",
88+
"desc": "Trigger early/immediately on user interaction",
89+
"reactive": true,
90+
"addedIn": "v1.9.8"
91+
},
92+
4793
"stop": {
4894
"type": "Boolean",
4995
"desc": "Stop click/touch event propagation",

ui/src/install.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,15 @@ export const queues = {
1717
}
1818

1919
export const $q = {
20-
version
20+
version,
21+
config: {}
2122
}
2223

2324
export default function (Vue, opts = {}) {
2425
if (this.__qInstalled === true) { return }
2526
this.__qInstalled = true
2627

27-
const cfg = opts.config || {}
28+
const cfg = $q.config = Object.freeze(opts.config || {})
2829

2930
// required plugins
3031
Platform.install($q, queues)

0 commit comments

Comments
 (0)