@macrostrat/map-interface 1.0.6 → 1.0.8
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/CHANGELOG.md +5 -0
- package/package.json +2 -2
- package/src/dev/map-page.ts +2 -0
- package/src/dev/xray.ts +13 -10
- package/dist/main.css +0 -951
- package/dist/main.css.map +0 -1
- package/dist/main.js +0 -1915
- package/dist/main.js.map +0 -1
- package/dist/module.css +0 -951
- package/dist/module.css.map +0 -1
- package/dist/module.js +0 -1906
- package/dist/module.js.map +0 -1
- package/dist/types.d.ts +0 -260
- package/dist/types.d.ts.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file. The format
|
|
|
4
4
|
is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this
|
|
5
5
|
project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
6
|
|
|
7
|
+
## [1.0.8] - 2024-10-26
|
|
8
|
+
|
|
9
|
+
- Fix inspector colors with new version of `chroma-js`
|
|
10
|
+
- Introduce dependency on `@macrostrat/color-utils`
|
|
11
|
+
|
|
7
12
|
## [1.0.5] - 2024-10-24
|
|
8
13
|
|
|
9
14
|
- Fix bundling
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@macrostrat/map-interface",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.8",
|
|
4
4
|
"description": "Map interface for Macrostrat",
|
|
5
5
|
"main": "dist/main.cjs",
|
|
6
6
|
"module": "dist/module.mjs",
|
|
@@ -8,12 +8,12 @@
|
|
|
8
8
|
"source": "src/index.ts",
|
|
9
9
|
"style": "dist/main.css",
|
|
10
10
|
"dependencies": {
|
|
11
|
+
"@macrostrat/color-utils": "^1.0.0",
|
|
11
12
|
"@macrostrat/hyper": "^3.0.0",
|
|
12
13
|
"@macrostrat/mapbox-react": "^2.2.3",
|
|
13
14
|
"@macrostrat/mapbox-utils": "^1.3.2",
|
|
14
15
|
"@macrostrat/ui-components": "^4.0.4",
|
|
15
16
|
"@mapbox/tilebelt": "^2.0.0",
|
|
16
|
-
"chroma-js": "^3.0.0",
|
|
17
17
|
"classnames": "^2.5.1",
|
|
18
18
|
"d3-array": "^3.2.4",
|
|
19
19
|
"d3-format": "^3.1.0",
|
package/src/dev/map-page.ts
CHANGED
package/src/dev/xray.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getMapboxStyle, mergeStyles } from "@macrostrat/mapbox-utils";
|
|
2
|
-
import
|
|
2
|
+
import { asChromaColor, toRGBAString } from "@macrostrat/color-utils";
|
|
3
3
|
import mapboxgl from "mapbox-gl";
|
|
4
4
|
|
|
5
5
|
interface XRayOptions {
|
|
@@ -17,7 +17,7 @@ export async function buildXRayStyle(
|
|
|
17
17
|
inDarkMode = false,
|
|
18
18
|
color = "rgb(74, 242, 161)",
|
|
19
19
|
mapboxToken,
|
|
20
|
-
xRaySources
|
|
20
|
+
xRaySources,
|
|
21
21
|
} = params;
|
|
22
22
|
const style = await getMapboxStyle(baseStyle, { access_token: mapboxToken });
|
|
23
23
|
const sources = xRaySources ?? Object.keys(style.sources);
|
|
@@ -41,15 +41,12 @@ export async function buildXRayStyle(
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
function transformMapboxLayer(layer, color, inDarkMode) {
|
|
44
|
-
const c =
|
|
44
|
+
const c = asChromaColor(color);
|
|
45
45
|
const xRayColor = (opacity = 1, darken = 0) => {
|
|
46
46
|
if (!inDarkMode) {
|
|
47
|
-
return
|
|
48
|
-
.darken(2 - darken)
|
|
49
|
-
.alpha(opacity)
|
|
50
|
-
.css();
|
|
47
|
+
return toRGBAString(c.darken(2 - darken).alpha(opacity));
|
|
51
48
|
}
|
|
52
|
-
return c.alpha(opacity).darken(darken)
|
|
49
|
+
return toRGBAString(c.alpha(opacity).darken(darken));
|
|
53
50
|
};
|
|
54
51
|
|
|
55
52
|
if (layer.type == "background") {
|
|
@@ -58,6 +55,8 @@ function transformMapboxLayer(layer, color, inDarkMode) {
|
|
|
58
55
|
|
|
59
56
|
let newLayer = { ...layer };
|
|
60
57
|
|
|
58
|
+
console.log(xRayColor(0.5));
|
|
59
|
+
|
|
61
60
|
if (layer.type == "fill") {
|
|
62
61
|
newLayer.paint = {
|
|
63
62
|
"fill-color": xRayColor(0.1),
|
|
@@ -93,7 +92,12 @@ export async function buildInspectorStyle(
|
|
|
93
92
|
overlayStyle: mapboxgl.Style | string | null = null,
|
|
94
93
|
params: InspectorStyleOptions = {}
|
|
95
94
|
) {
|
|
96
|
-
const {
|
|
95
|
+
const {
|
|
96
|
+
mapboxToken,
|
|
97
|
+
xRay = false,
|
|
98
|
+
xRaySources: _xRaySources,
|
|
99
|
+
...rest
|
|
100
|
+
} = params;
|
|
97
101
|
let xRaySources = _xRaySources;
|
|
98
102
|
let style = await getMapboxStyle(baseStyle, {
|
|
99
103
|
access_token: mapboxToken,
|
|
@@ -107,7 +111,6 @@ export async function buildInspectorStyle(
|
|
|
107
111
|
xRaySources ??= Object.keys(overlay.sources);
|
|
108
112
|
}
|
|
109
113
|
|
|
110
|
-
|
|
111
114
|
if (xRay) {
|
|
112
115
|
// If we haven't specified sources, then we'll use all of them
|
|
113
116
|
xRaySources ??= Object.keys(style.sources);
|