Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor code #21

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": ["@babel/preset-env"]
}
137 changes: 135 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Currently detects
- changes to all parameters within each style layer
- changes to the layer stack (new, removed, moved layers)
- changes to sources (new, removed, updated sources)
- changes to root properties of `glyphs`, `sprite`, `fog`, `terrain`, `id`, `name`, `light`

To be implemented

Expand All @@ -17,6 +18,138 @@ To be implemented

`bin/mapbox-gl-style-diff ./path/to/style/a.json ./path/to/style/b.json`

## Standalone tool
## Output

Currently you can also use this as a standalone tool via `stamen-diff.html`
The output is a JSON in the format of:

```js
{
root: {},
layerProps: {},
layers: {},
sources: {}
}
```

Within this, the expected output for each section is:

### Layer props

```js
{
[layer id]: {
[property type (layout or paint)]: {
[property id]: {
type: 'add' | 'remove' | 'move' | 'update',
before: <previous value>,
after: <next value>
}
}
}
}
```

### Layers

#### Add

```js
{
[layer id]: {
type: 'add',
layer: <layer object>,
layerAbove: <id of layer above where added layer is slotted>
}
}
```

#### Remove

```js
{
[layer id]: {
type: 'remove',
}
}
```

#### Move

```js
{
[layer id]: {
type: 'move',
layerAbove: <id of layer above where moved layer is slotted>
}
}
```

### Sources

#### Add

```js
{
[source id]: {
type: 'add',
source: <layer object>
}
}
```

#### Remove

```js
{
[source id]: {
type: 'remove',
}
}
```

#### Update

```js
{
[source id]: {
type: 'update',
before: <previous value>,
after: <next value>
}
}
```

### Root

#### Add

```js
{
[root property]: {
type: 'add',
value: <root property value>
}
}
```

#### Remove

```js
{
[root property]: {
type: 'remove',
}
}
```

#### Update

```js
{
[root property]: {
type: 'update',
before: <previous value>,
after: <next value>
}
}
```
Loading