|
1 | 1 | --- |
2 | | -title: Docs |
| 2 | +title: Mobile Addressbar Coloring |
3 | 3 | --- |
| 4 | +Newer mobile browsers have the ability to specify a color for the addressbar, like in the example below. |
4 | 5 |
|
5 | | -[Internal Link](/docs), [External Link](https://vuejs.org) |
6 | | - |
7 | | -Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer non laoreet eros. `token` Morbi non ipsum ac purus dignissim rutrum. Nulla nec ante congue, rutrum tortor facilisis, aliquet ligula. Fusce vitae odio elit. `/quasar.conf.js` |
| 6 | +::: warning |
| 7 | +**Note 1.** There isn't yet a Web standard for this so it won't work for all mobile browsers. |
| 8 | +**Note 2.** This applies when building a website only. For coloring top bar on a mobile app (built with Cordova wrapper), please refer to [Cordova plugins](https://cordova.apache.org/plugins/). |
| 9 | +::: |
8 | 10 |
|
9 | | -## Heading 2 |
10 | | -### Heading 3 |
11 | | -#### Heading 4 |
12 | | -##### Heading 5 |
13 | | -###### Heading 6 |
| 11 | + |
14 | 12 |
|
15 | | -``` |
16 | | -const m = 'lala' |
17 | | -``` |
| 13 | +## Installation |
| 14 | +<doc-installation plugins="AddressbarColor" /> |
18 | 15 |
|
19 | | -```html |
20 | | -<div> |
21 | | - <q-btn @click="doSomething">Do something</q-btn> |
22 | | - <q-icon name="alarm" /> |
23 | | -</div> |
24 | | -``` |
| 16 | +## Usage |
25 | 17 |
|
26 | | -```vue |
27 | | -<template> |
28 | | - <!-- you define your Vue template here --> |
29 | | -</template> |
| 18 | +We create boot file to initialize its usage: `$ quasar new boot addressbar-color`. A file is created (`/src/boot/addressbar-color.js`). We edit it: |
30 | 19 |
|
31 | | -<script> |
32 | | -// This is where your Javascript goes |
33 | | -// to define your Vue component, which |
34 | | -// can be a Layout, a Page or your own |
35 | | -// component used throughout the app. |
| 20 | +```js |
| 21 | +// file: /src/boot/addressbar-color.js |
| 22 | +import { AddressbarColor } from 'quasar' |
36 | 23 |
|
37 | | -export default { |
38 | | - // |
| 24 | +export default () => { |
| 25 | + AddressbarColor.set('#a2e3fa') |
39 | 26 | } |
40 | | -</script> |
41 | | -
|
42 | | -<style> |
43 | | -/* This is where your CSS goes */ |
44 | | -</style> |
45 | 27 | ``` |
46 | 28 |
|
47 | | -| Table Example | Type | Description | |
48 | | -| --- | --- | --- | |
49 | | -| infinite | Boolean | Infinite slides scrolling | |
50 | | -| size | String | Thickness of loading bar. | |
51 | | - |
52 | | -> Something... |
| 29 | +We then have to tell quasar to use this boot file we just created. To do this we edit the boot section of the quasar config: |
| 30 | +```js |
| 31 | +// file: /quasar.conf.js |
| 32 | +return { |
| 33 | + boot: [ |
| 34 | + 'addressbar-color' |
| 35 | + ] |
| 36 | +} |
| 37 | +``` |
53 | 38 |
|
54 | | -::: tip |
55 | | -Some tip |
56 | | -::: |
| 39 | +What this does is that it injects some `<meta>` tags into your `index.html` at runtime. |
57 | 40 |
|
58 | | -::: warning |
59 | | -Some tip |
60 | | -::: |
| 41 | +Because the meta tag doesn't get injected until run time you can dynamically change this color multiple times, based on the page the user is on (by calling the `set` method in the `created()` lifecycle hook on the respective pages): |
61 | 42 |
|
62 | | -::: danger |
63 | | -Some tip |
64 | | -::: |
65 | 43 |
|
66 | | -::: warning CUSTOM TITLE |
67 | | -Some tip |
| 44 | +```js |
| 45 | +// a .vue file representing a page |
| 46 | +export default { |
| 47 | + // ..., |
| 48 | + created () { |
| 49 | + this.$q.addressbarColor.set('#a2e3fa') |
| 50 | + } |
| 51 | +} |
| 52 | +``` |
| 53 | +::: tip |
| 54 | +Calling `set()` with no parameters will use the primary color. |
68 | 55 | ::: |
69 | | - |
70 | | -* Something |
71 | | - * something |
72 | | - * else |
73 | | -* Back |
74 | | - * wee |
75 | | - |
76 | | -## Installation |
77 | | -<doc-installation components="QBtn" :plugins="['Meta', 'Cookies']" directives="Ripple" :config="{ notify: 'Notify' }" /> |
78 | | - |
79 | | -## Usage |
80 | | -<doc-example title="Standard" file="QBtn/Standard" /> |
81 | | - |
82 | | -## API |
83 | | -<doc-api file="QTh" /> |
0 commit comments