@dpgradio/creative 5.0.5 → 5.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -4
- package/package.json +1 -1
- package/src/api/endpoints/Config.js +6 -4
- package/src/api/endpoints/Endpoint.js +4 -0
- package/src/config/config.js +29 -2
- package/styles/all.css +9 -0
package/README.md
CHANGED
|
@@ -14,8 +14,8 @@ The variables and fonts are no longer available as scss variables/imports.
|
|
|
14
14
|
Example:
|
|
15
15
|
|
|
16
16
|
```css
|
|
17
|
-
@import "
|
|
18
|
-
@import "
|
|
17
|
+
@import "@dpgradio/creative/styles/colors/qmusic";
|
|
18
|
+
@import "@dpgradio/creative/styles/fonts/qmusic";
|
|
19
19
|
|
|
20
20
|
body, html {
|
|
21
21
|
background-color: rgb(var(--q-teal));
|
|
@@ -24,6 +24,12 @@ body, html {
|
|
|
24
24
|
}
|
|
25
25
|
```
|
|
26
26
|
|
|
27
|
+
Use the following to import the colors and fonts of all brands:
|
|
28
|
+
|
|
29
|
+
```css
|
|
30
|
+
@import "@dpgradio/creative/styles/all";
|
|
31
|
+
```
|
|
32
|
+
|
|
27
33
|
## Config
|
|
28
34
|
|
|
29
35
|
### Usage
|
|
@@ -34,7 +40,12 @@ The configuration will also be used by other components of this package (e.g. pr
|
|
|
34
40
|
```js
|
|
35
41
|
import { configuration } from '@dpgradio/creative'
|
|
36
42
|
|
|
37
|
-
await configuration.
|
|
43
|
+
await configuration.retrieveConfigForDetectedStation(appId) // Default, by hostname or query parameter
|
|
44
|
+
|
|
45
|
+
// Or, if you want to retrieve the config by hostnames only.
|
|
46
|
+
await configuration.retrieveConfigByHostname(appId)
|
|
47
|
+
// Or, if you want to retrieve the config for a specific station:
|
|
48
|
+
await configuration.retrieveConfigByStation(appId, stationIdA, stationIdB, stationIdC)
|
|
38
49
|
|
|
39
50
|
// By default the first station ID (stationIdA) is used as the current station of the configuration.
|
|
40
51
|
// If you want to use a different station, you can do so by calling:
|
|
@@ -190,7 +201,7 @@ hybrid.decodeRadioToken(radioToken)
|
|
|
190
201
|
Example:
|
|
191
202
|
|
|
192
203
|
```js
|
|
193
|
-
import { Shareable, ImageGeneratorProperties } from '
|
|
204
|
+
import { Shareable, ImageGeneratorProperties } from '@dpgradio/creative/share'
|
|
194
205
|
|
|
195
206
|
const shareable = new Shareable()
|
|
196
207
|
.withTitle(`${this.name} is mijn seventies match!`)
|
package/package.json
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import Endpoint from './Endpoint.js'
|
|
2
2
|
|
|
3
3
|
export default class Config extends Endpoint {
|
|
4
|
-
async global() {
|
|
5
|
-
return await this.requestData((r) => r.get('/config'))
|
|
4
|
+
async global({ stationIds = null, domains = null }) {
|
|
5
|
+
return await this.requestData((r) => r.get('/config', this.withoutNullValues({ station_ids: stationIds, domains })))
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
async app(appId, stationIds) {
|
|
9
|
-
return await this.requestData((r) =>
|
|
8
|
+
async app(appId, { stationIds = null, domains = null }) {
|
|
9
|
+
return await this.requestData((r) =>
|
|
10
|
+
r.get(`/config/${appId}`, this.withoutNullValues({ station_ids: stationIds, domains }))
|
|
11
|
+
)
|
|
10
12
|
}
|
|
11
13
|
|
|
12
14
|
async updateSchema(appId, schema) {
|
package/src/config/config.js
CHANGED
|
@@ -15,11 +15,38 @@ class Configuration {
|
|
|
15
15
|
return this
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
async
|
|
18
|
+
async retrieveConfigForDetectedStation(appId) {
|
|
19
|
+
const parameters = new URLSearchParams(window.location.search)
|
|
20
|
+
if (parameters.has('stationId')) {
|
|
21
|
+
return this.retrieveConfigForStation(appId, parameters.get('stationId'))
|
|
22
|
+
}
|
|
23
|
+
return this.retrieveConfigByHostname(appId)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Retrieve the configuration for the given app and the current hostname.
|
|
28
|
+
*/
|
|
29
|
+
async retrieveConfigByHostname(appId) {
|
|
30
|
+
this.appId = appId
|
|
31
|
+
|
|
32
|
+
// This is not the most robust way to get the hostname without subdomains, e.g. .co.uk domains will break.
|
|
33
|
+
// However, for the TLDs we use, this should be fine.
|
|
34
|
+
const hostname = window.location.hostname.split('.').splice(-2).join('.')
|
|
35
|
+
this.rawConfig = await api.global().config.app(appId, { domains: [hostname] })
|
|
36
|
+
|
|
37
|
+
this.stationId = Object.keys(this.rawConfig)[0]
|
|
38
|
+
|
|
39
|
+
return this
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Retrieve the configuration for the given app and the given station(s).
|
|
44
|
+
*/
|
|
45
|
+
async retrieveConfigForStation(appId, ...stationIds) {
|
|
19
46
|
this.appId = appId
|
|
20
47
|
this.stationId = stationIds[0]
|
|
21
48
|
|
|
22
|
-
this.rawConfig = await api.global().config.app(appId, stationIds)
|
|
49
|
+
this.rawConfig = await api.global().config.app(appId, { stationIds })
|
|
23
50
|
|
|
24
51
|
return this
|
|
25
52
|
}
|