ochre-sdk 1.3.31 → 1.3.32
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.
|
@@ -18,6 +18,18 @@ const WEBPAGE_PROPERTY_LABELS = {
|
|
|
18
18
|
isNavbarSearchBarDisplayed: "navbar-search-bar-displayed"
|
|
19
19
|
};
|
|
20
20
|
/**
|
|
21
|
+
A hex color as lowercase `#rrggbb`, from `#rgb` or `#rrggbb` with or without
|
|
22
|
+
the `#`
|
|
23
|
+
|
|
24
|
+
@param value - The raw OCHRE value
|
|
25
|
+
@returns The normalized hex color, or null when the value is not one
|
|
26
|
+
*/
|
|
27
|
+
function parseHexColor(value) {
|
|
28
|
+
const hex = /^#?([\da-f]{3}|[\da-f]{6})$/i.exec(value?.trim() ?? "")?.[1]?.toLowerCase();
|
|
29
|
+
if (hex == null) return null;
|
|
30
|
+
return `#${hex.length === 3 ? [...hex].map((digit) => digit.repeat(2)).join("") : hex}`;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
21
33
|
Parses raw website properties into a standardized Website properties structure
|
|
22
34
|
|
|
23
35
|
@param websiteReader - Reader over the website's "presentation" properties
|
|
@@ -35,6 +47,7 @@ function parseWebsiteProperties(websiteReader, websiteTree, sidebar, options, pa
|
|
|
35
47
|
isThemeToggleDisplayed: true,
|
|
36
48
|
defaultTheme: "system"
|
|
37
49
|
},
|
|
50
|
+
colors: { primary: parent?.colors.primary ?? null },
|
|
38
51
|
icon: {
|
|
39
52
|
logoUuid: null,
|
|
40
53
|
faviconUuid: null,
|
|
@@ -114,6 +127,7 @@ function parseWebsiteProperties(websiteReader, websiteTree, sidebar, options, pa
|
|
|
114
127
|
};
|
|
115
128
|
else throw new Error(`Contact property must use “name;email”, got “${contactProperty.values[0]?.content}” (website uuid “${websiteTree.uuid}”)`, { cause: websiteTree });
|
|
116
129
|
}
|
|
130
|
+
returnProperties.colors.primary = parseHexColor(websiteReader.stringValue("primary-color")) ?? returnProperties.colors.primary;
|
|
117
131
|
websiteReader.readAll(returnProperties, {
|
|
118
132
|
type: "webUI",
|
|
119
133
|
status: "status",
|
package/dist/types/website.d.mts
CHANGED
|
@@ -173,6 +173,14 @@ export type Website<T extends LanguageCodes = LanguageCodes> = {
|
|
|
173
173
|
isThemeToggleDisplayed: boolean;
|
|
174
174
|
defaultTheme: "light" | "dark" | "system";
|
|
175
175
|
};
|
|
176
|
+
/**
|
|
177
|
+
The website's brand colors as lowercase `#rrggbb` hex, read from a hex
|
|
178
|
+
value with or without its `#`, each null when the website leaves it unset
|
|
179
|
+
or sets a value that is not a hex color
|
|
180
|
+
*/
|
|
181
|
+
colors: {
|
|
182
|
+
primary: string | null;
|
|
183
|
+
};
|
|
176
184
|
icon: {
|
|
177
185
|
logoUuid: string | null;
|
|
178
186
|
faviconUuid: string | null;
|