@wix/site-service-site-theme 1.0.4 → 1.0.6
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 +1 -1
- package/cjs/build/definition/index.d.ts +40 -0
- package/cjs/build/definition/index.js +1 -0
- package/cjs/build/definition/index.js.map +1 -1
- package/cjs/build/types/index.d.ts +12 -1
- package/dist/definition/index.d.ts +40 -0
- package/dist/definition/index.js +1 -0
- package/dist/definition/index.js.map +1 -1
- package/dist/types/index.d.ts +12 -1
- package/package.json +4 -4
- package/src/definition/index.ts +40 -0
- package/src/types/index.ts +18 -3
package/README.md
CHANGED
|
@@ -1,17 +1,57 @@
|
|
|
1
1
|
import type { ServiceDefinition } from '@wix/services-definitions';
|
|
2
2
|
import type { SiteColors, SiteFonts, ColorsMap } from '../types';
|
|
3
|
+
/** Values the host supplies when it creates the service. */
|
|
3
4
|
export type ISiteThemeServiceConfig = {
|
|
4
5
|
siteColors: SiteColors;
|
|
5
6
|
siteFonts: SiteFonts;
|
|
6
7
|
colorsMap: ColorsMap;
|
|
7
8
|
};
|
|
9
|
+
/**
|
|
10
|
+
* Reads the site's theme colors and fonts, so code running on the site can match the design a Wix user
|
|
11
|
+
* chose.
|
|
12
|
+
*/
|
|
8
13
|
export interface ISiteThemeService {
|
|
14
|
+
/**
|
|
15
|
+
* Site's theme colors, keyed by theme color ID.
|
|
16
|
+
*
|
|
17
|
+
* Use it to resolve a theme color ID, such as `color_4`, to its color value.
|
|
18
|
+
*
|
|
19
|
+
* The host fills `colors` and `colorsMap` from the same list of theme colors, so `colors['color_<n>']`
|
|
20
|
+
* is the same value as `colorsMap[n]`, counting from `color_0`.
|
|
21
|
+
*
|
|
22
|
+
* Don't change the object's entries. The property is read-only, but the object it returns isn't, and
|
|
23
|
+
* changing it affects other code on the page.
|
|
24
|
+
*
|
|
25
|
+
* @exampleValue `{ "color_0": "#FFFFFF", "color_1": "#E8E6E6", "color_2": "#9C9C9C", "color_3": "#1F1F1F", "color_4": "#0088CB", "color_5": "#ED1C24" }`
|
|
26
|
+
*/
|
|
9
27
|
readonly colors: SiteColors;
|
|
28
|
+
/**
|
|
29
|
+
* Site's theme fonts, keyed by theme font ID.
|
|
30
|
+
*
|
|
31
|
+
* Don't change the object's entries. The property is read-only, but the object it returns isn't, and
|
|
32
|
+
* changing it affects other code on the page.
|
|
33
|
+
*
|
|
34
|
+
* @exampleValue `{ "font_0": "normal normal normal 40px/1.4em helvetica-w01-bold,sans-serif", "font_1": "normal normal normal 16px/1.4em proxima-n-w01-reg,sans-serif" }`
|
|
35
|
+
*/
|
|
10
36
|
readonly fonts: SiteFonts;
|
|
37
|
+
/**
|
|
38
|
+
* Site's theme colors, in order.
|
|
39
|
+
*
|
|
40
|
+
* The host fills `colorsMap` and `colors` from the same list of theme colors, so entry `n` is the theme
|
|
41
|
+
* color with ID `color_<n>`.
|
|
42
|
+
*
|
|
43
|
+
* Don't change the array, for example by sorting it in place. The property is read-only, but the array
|
|
44
|
+
* it returns isn't, and changing it affects other code on the page.
|
|
45
|
+
*
|
|
46
|
+
* @exampleValue `["#FFFFFF", "#E8E6E6", "#9C9C9C", "#1F1F1F", "#0088CB", "#ED1C24"]`
|
|
47
|
+
*/
|
|
11
48
|
readonly colorsMap: ColorsMap;
|
|
49
|
+
/** @internal Host-only. Replaces config values when the host's state changes. */
|
|
12
50
|
_updateConfig: (config: Partial<ISiteThemeServiceConfig>) => void;
|
|
13
51
|
}
|
|
52
|
+
/** Definition of the Site Theme service, used to resolve it from the services manager. */
|
|
14
53
|
export type ISiteThemeDefinition = ServiceDefinition<ISiteThemeService, ISiteThemeServiceConfig>;
|
|
54
|
+
/** Definition of the Site Theme service. Specify it in `useService()` or `servicesManager.getService()`. */
|
|
15
55
|
export declare const SiteThemeDefinition: string & {
|
|
16
56
|
__api: ISiteThemeService;
|
|
17
57
|
__config: ISiteThemeServiceConfig;
|
|
@@ -2,5 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SiteThemeDefinition = void 0;
|
|
4
4
|
const services_definitions_1 = require("@wix/services-definitions");
|
|
5
|
+
/** Definition of the Site Theme service. Specify it in `useService()` or `servicesManager.getService()`. */
|
|
5
6
|
exports.SiteThemeDefinition = (0, services_definitions_1.defineService)('@wix/site-service-site-theme');
|
|
6
7
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/definition/index.ts"],"names":[],"mappings":";;;AAAA,oEAAyD;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/definition/index.ts"],"names":[],"mappings":";;;AAAA,oEAAyD;AA0DzD,4GAA4G;AAC/F,QAAA,mBAAmB,GAAG,IAAA,oCAAa,EAC/C,8BAA8B,CAC9B,CAAA"}
|
|
@@ -1,10 +1,21 @@
|
|
|
1
|
-
/** CSS
|
|
1
|
+
/** CSS color value, such as `#0088CB`. */
|
|
2
2
|
export type Color = string;
|
|
3
|
+
/** Site's theme colors, keyed by theme color ID. */
|
|
3
4
|
export type SiteColors = {
|
|
5
|
+
/**
|
|
6
|
+
* CSS color value of the theme color with this ID. IDs have the form `color_<n>`, starting at
|
|
7
|
+
* `color_0`.
|
|
8
|
+
*/
|
|
4
9
|
[colorIndex: string]: Color;
|
|
5
10
|
};
|
|
11
|
+
/** Site's theme fonts, keyed by theme font ID. */
|
|
6
12
|
export type SiteFonts = {
|
|
13
|
+
/**
|
|
14
|
+
* Definition of the theme font with this ID, such as its size and font family. IDs have the form
|
|
15
|
+
* `font_<n>`, starting at `font_0`.
|
|
16
|
+
*/
|
|
7
17
|
[fontIndex: string]: string;
|
|
8
18
|
};
|
|
19
|
+
/** Site's theme colors, in order. */
|
|
9
20
|
export type ColorsMap = Array<Color>;
|
|
10
21
|
export type { ISiteThemeService, ISiteThemeServiceConfig, ISiteThemeDefinition } from '../definition';
|
|
@@ -1,17 +1,57 @@
|
|
|
1
1
|
import type { ServiceDefinition } from '@wix/services-definitions';
|
|
2
2
|
import type { SiteColors, SiteFonts, ColorsMap } from '../types';
|
|
3
|
+
/** Values the host supplies when it creates the service. */
|
|
3
4
|
export type ISiteThemeServiceConfig = {
|
|
4
5
|
siteColors: SiteColors;
|
|
5
6
|
siteFonts: SiteFonts;
|
|
6
7
|
colorsMap: ColorsMap;
|
|
7
8
|
};
|
|
9
|
+
/**
|
|
10
|
+
* Reads the site's theme colors and fonts, so code running on the site can match the design a Wix user
|
|
11
|
+
* chose.
|
|
12
|
+
*/
|
|
8
13
|
export interface ISiteThemeService {
|
|
14
|
+
/**
|
|
15
|
+
* Site's theme colors, keyed by theme color ID.
|
|
16
|
+
*
|
|
17
|
+
* Use it to resolve a theme color ID, such as `color_4`, to its color value.
|
|
18
|
+
*
|
|
19
|
+
* The host fills `colors` and `colorsMap` from the same list of theme colors, so `colors['color_<n>']`
|
|
20
|
+
* is the same value as `colorsMap[n]`, counting from `color_0`.
|
|
21
|
+
*
|
|
22
|
+
* Don't change the object's entries. The property is read-only, but the object it returns isn't, and
|
|
23
|
+
* changing it affects other code on the page.
|
|
24
|
+
*
|
|
25
|
+
* @exampleValue `{ "color_0": "#FFFFFF", "color_1": "#E8E6E6", "color_2": "#9C9C9C", "color_3": "#1F1F1F", "color_4": "#0088CB", "color_5": "#ED1C24" }`
|
|
26
|
+
*/
|
|
9
27
|
readonly colors: SiteColors;
|
|
28
|
+
/**
|
|
29
|
+
* Site's theme fonts, keyed by theme font ID.
|
|
30
|
+
*
|
|
31
|
+
* Don't change the object's entries. The property is read-only, but the object it returns isn't, and
|
|
32
|
+
* changing it affects other code on the page.
|
|
33
|
+
*
|
|
34
|
+
* @exampleValue `{ "font_0": "normal normal normal 40px/1.4em helvetica-w01-bold,sans-serif", "font_1": "normal normal normal 16px/1.4em proxima-n-w01-reg,sans-serif" }`
|
|
35
|
+
*/
|
|
10
36
|
readonly fonts: SiteFonts;
|
|
37
|
+
/**
|
|
38
|
+
* Site's theme colors, in order.
|
|
39
|
+
*
|
|
40
|
+
* The host fills `colorsMap` and `colors` from the same list of theme colors, so entry `n` is the theme
|
|
41
|
+
* color with ID `color_<n>`.
|
|
42
|
+
*
|
|
43
|
+
* Don't change the array, for example by sorting it in place. The property is read-only, but the array
|
|
44
|
+
* it returns isn't, and changing it affects other code on the page.
|
|
45
|
+
*
|
|
46
|
+
* @exampleValue `["#FFFFFF", "#E8E6E6", "#9C9C9C", "#1F1F1F", "#0088CB", "#ED1C24"]`
|
|
47
|
+
*/
|
|
11
48
|
readonly colorsMap: ColorsMap;
|
|
49
|
+
/** @internal Host-only. Replaces config values when the host's state changes. */
|
|
12
50
|
_updateConfig: (config: Partial<ISiteThemeServiceConfig>) => void;
|
|
13
51
|
}
|
|
52
|
+
/** Definition of the Site Theme service, used to resolve it from the services manager. */
|
|
14
53
|
export type ISiteThemeDefinition = ServiceDefinition<ISiteThemeService, ISiteThemeServiceConfig>;
|
|
54
|
+
/** Definition of the Site Theme service. Specify it in `useService()` or `servicesManager.getService()`. */
|
|
15
55
|
export declare const SiteThemeDefinition: string & {
|
|
16
56
|
__api: ISiteThemeService;
|
|
17
57
|
__config: ISiteThemeServiceConfig;
|
package/dist/definition/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { defineService } from '@wix/services-definitions';
|
|
2
|
+
/** Definition of the Site Theme service. Specify it in `useService()` or `servicesManager.getService()`. */
|
|
2
3
|
export const SiteThemeDefinition = defineService('@wix/site-service-site-theme');
|
|
3
4
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/definition/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/definition/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AA0DzD,4GAA4G;AAC5G,MAAM,CAAC,MAAM,mBAAmB,GAAG,aAAa,CAC/C,8BAA8B,CAC9B,CAAA"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,10 +1,21 @@
|
|
|
1
|
-
/** CSS
|
|
1
|
+
/** CSS color value, such as `#0088CB`. */
|
|
2
2
|
export type Color = string;
|
|
3
|
+
/** Site's theme colors, keyed by theme color ID. */
|
|
3
4
|
export type SiteColors = {
|
|
5
|
+
/**
|
|
6
|
+
* CSS color value of the theme color with this ID. IDs have the form `color_<n>`, starting at
|
|
7
|
+
* `color_0`.
|
|
8
|
+
*/
|
|
4
9
|
[colorIndex: string]: Color;
|
|
5
10
|
};
|
|
11
|
+
/** Site's theme fonts, keyed by theme font ID. */
|
|
6
12
|
export type SiteFonts = {
|
|
13
|
+
/**
|
|
14
|
+
* Definition of the theme font with this ID, such as its size and font family. IDs have the form
|
|
15
|
+
* `font_<n>`, starting at `font_0`.
|
|
16
|
+
*/
|
|
7
17
|
[fontIndex: string]: string;
|
|
8
18
|
};
|
|
19
|
+
/** Site's theme colors, in order. */
|
|
9
20
|
export type ColorsMap = Array<Color>;
|
|
10
21
|
export type { ISiteThemeService, ISiteThemeServiceConfig, ISiteThemeDefinition } from '../definition';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wix/site-service-site-theme",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -48,8 +48,8 @@
|
|
|
48
48
|
},
|
|
49
49
|
"scripts": {
|
|
50
50
|
"build": "tsc -b . && tsc --project tsconfig.cjs.json",
|
|
51
|
-
"lint": "
|
|
52
|
-
"test": "vitest --run &&
|
|
51
|
+
"lint": "pnpm --workspace-root run lint:package --package $npm_package_name",
|
|
52
|
+
"test": "vitest --run && pnpm run test-type-check",
|
|
53
53
|
"test-type-check": "echo 'validating typescript in test files' && tsc --project tsconfig.test.json && echo 'Finished validating typescript in test files successfully'"
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
@@ -77,5 +77,5 @@
|
|
|
77
77
|
]
|
|
78
78
|
}
|
|
79
79
|
},
|
|
80
|
-
"falconPackageHash": "
|
|
80
|
+
"falconPackageHash": "fd9bc41bb4cf871ebd000b453100cdc1d2953d1260617f8901d4833e"
|
|
81
81
|
}
|
package/src/definition/index.ts
CHANGED
|
@@ -2,21 +2,61 @@ import { defineService } from '@wix/services-definitions'
|
|
|
2
2
|
import type { ServiceDefinition } from '@wix/services-definitions'
|
|
3
3
|
import type { SiteColors, SiteFonts, ColorsMap } from '../types'
|
|
4
4
|
|
|
5
|
+
/** Values the host supplies when it creates the service. */
|
|
5
6
|
export type ISiteThemeServiceConfig = {
|
|
6
7
|
siteColors: SiteColors
|
|
7
8
|
siteFonts: SiteFonts
|
|
8
9
|
colorsMap: ColorsMap
|
|
9
10
|
}
|
|
10
11
|
|
|
12
|
+
/**
|
|
13
|
+
* Reads the site's theme colors and fonts, so code running on the site can match the design a Wix user
|
|
14
|
+
* chose.
|
|
15
|
+
*/
|
|
11
16
|
export interface ISiteThemeService {
|
|
17
|
+
/**
|
|
18
|
+
* Site's theme colors, keyed by theme color ID.
|
|
19
|
+
*
|
|
20
|
+
* Use it to resolve a theme color ID, such as `color_4`, to its color value.
|
|
21
|
+
*
|
|
22
|
+
* The host fills `colors` and `colorsMap` from the same list of theme colors, so `colors['color_<n>']`
|
|
23
|
+
* is the same value as `colorsMap[n]`, counting from `color_0`.
|
|
24
|
+
*
|
|
25
|
+
* Don't change the object's entries. The property is read-only, but the object it returns isn't, and
|
|
26
|
+
* changing it affects other code on the page.
|
|
27
|
+
*
|
|
28
|
+
* @exampleValue `{ "color_0": "#FFFFFF", "color_1": "#E8E6E6", "color_2": "#9C9C9C", "color_3": "#1F1F1F", "color_4": "#0088CB", "color_5": "#ED1C24" }`
|
|
29
|
+
*/
|
|
12
30
|
readonly colors: SiteColors
|
|
31
|
+
/**
|
|
32
|
+
* Site's theme fonts, keyed by theme font ID.
|
|
33
|
+
*
|
|
34
|
+
* Don't change the object's entries. The property is read-only, but the object it returns isn't, and
|
|
35
|
+
* changing it affects other code on the page.
|
|
36
|
+
*
|
|
37
|
+
* @exampleValue `{ "font_0": "normal normal normal 40px/1.4em helvetica-w01-bold,sans-serif", "font_1": "normal normal normal 16px/1.4em proxima-n-w01-reg,sans-serif" }`
|
|
38
|
+
*/
|
|
13
39
|
readonly fonts: SiteFonts
|
|
40
|
+
/**
|
|
41
|
+
* Site's theme colors, in order.
|
|
42
|
+
*
|
|
43
|
+
* The host fills `colorsMap` and `colors` from the same list of theme colors, so entry `n` is the theme
|
|
44
|
+
* color with ID `color_<n>`.
|
|
45
|
+
*
|
|
46
|
+
* Don't change the array, for example by sorting it in place. The property is read-only, but the array
|
|
47
|
+
* it returns isn't, and changing it affects other code on the page.
|
|
48
|
+
*
|
|
49
|
+
* @exampleValue `["#FFFFFF", "#E8E6E6", "#9C9C9C", "#1F1F1F", "#0088CB", "#ED1C24"]`
|
|
50
|
+
*/
|
|
14
51
|
readonly colorsMap: ColorsMap
|
|
52
|
+
/** @internal Host-only. Replaces config values when the host's state changes. */
|
|
15
53
|
_updateConfig: (config: Partial<ISiteThemeServiceConfig>) => void
|
|
16
54
|
}
|
|
17
55
|
|
|
56
|
+
/** Definition of the Site Theme service, used to resolve it from the services manager. */
|
|
18
57
|
export type ISiteThemeDefinition = ServiceDefinition<ISiteThemeService, ISiteThemeServiceConfig>
|
|
19
58
|
|
|
59
|
+
/** Definition of the Site Theme service. Specify it in `useService()` or `servicesManager.getService()`. */
|
|
20
60
|
export const SiteThemeDefinition = defineService<ISiteThemeService, ISiteThemeServiceConfig>(
|
|
21
61
|
'@wix/site-service-site-theme'
|
|
22
62
|
)
|
package/src/types/index.ts
CHANGED
|
@@ -1,7 +1,22 @@
|
|
|
1
|
-
/** CSS
|
|
1
|
+
/** CSS color value, such as `#0088CB`. */
|
|
2
2
|
export type Color = string
|
|
3
|
-
|
|
4
|
-
export type
|
|
3
|
+
/** Site's theme colors, keyed by theme color ID. */
|
|
4
|
+
export type SiteColors = {
|
|
5
|
+
/**
|
|
6
|
+
* CSS color value of the theme color with this ID. IDs have the form `color_<n>`, starting at
|
|
7
|
+
* `color_0`.
|
|
8
|
+
*/
|
|
9
|
+
[colorIndex: string]: Color
|
|
10
|
+
}
|
|
11
|
+
/** Site's theme fonts, keyed by theme font ID. */
|
|
12
|
+
export type SiteFonts = {
|
|
13
|
+
/**
|
|
14
|
+
* Definition of the theme font with this ID, such as its size and font family. IDs have the form
|
|
15
|
+
* `font_<n>`, starting at `font_0`.
|
|
16
|
+
*/
|
|
17
|
+
[fontIndex: string]: string
|
|
18
|
+
}
|
|
19
|
+
/** Site's theme colors, in order. */
|
|
5
20
|
export type ColorsMap = Array<Color>
|
|
6
21
|
|
|
7
22
|
export type { ISiteThemeService, ISiteThemeServiceConfig, ISiteThemeDefinition } from '../definition'
|