-
Notifications
You must be signed in to change notification settings - Fork 0
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
GSLUX-601: Style selector #85
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
bab2756
feat(style-selector): style selectors as expandable panels
tkohr 2b6dc73
feat(style-selector): make selectors exclusive
tkohr 91dcbbd
chore(lib): export style selector
tkohr b04ab25
refactor(expandable-panel): add new component
tkohr ac0b35b
refactor(layer-tree) use expandable panel
tkohr 034bb43
i18n(style-selector): fix translation keys
tkohr 2dbcf78
feat(style-selector): make reset button optional
tkohr f7e1909
test(style-selector): add e2e tests
tkohr a914ba1
fix some minor css style issues where v4 formatting was overthrown by v3
mki-c2c 34304b8
fix(ol.composable): only call restoreStyle if oldBgLayerId is defined
tkohr 5d398db
chore(lib): npm run build:lib:prod
tkohr 94bc09f
fix(e2e): fix lint error in tests for ci
tkohr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
describe('Style selector', () => { | ||
beforeEach(() => { | ||
cy.visit('/') | ||
cy.get('[data-cy="myLayersButton"]').click() | ||
cy.get('.fa-pencil').click() | ||
}) | ||
|
||
it('renders the style selector properly', () => { | ||
cy.get('[data-cy="styleSelector"').should('not.be.hidden') | ||
cy.get('[data-cy="styleSelector"') | ||
.find('button') | ||
.filter(':visible') | ||
.should('have.length', 3) | ||
}) | ||
|
||
it('has no style value in localStorage', () => { | ||
expect(localStorage.getItem('basemap_2015_global')).to.eq('') | ||
}) | ||
|
||
describe('Simple style selector', () => { | ||
beforeEach(() => { | ||
cy.get('[data-cy="styleSelector"') | ||
.find('button') | ||
.filter(':visible') | ||
.first() | ||
.as('simple') | ||
cy.get('@simple').click() | ||
}) | ||
it('renders the simple style selector properly', () => { | ||
cy.get('@simple') | ||
.siblings() | ||
.find('button') | ||
.filter(':visible') | ||
.should('have.length', 6) | ||
}) | ||
it('sets style to 4th style of list', () => { | ||
const newStyle = `{"medium":[{"label":"Roads primary","color":"#f9c50d","lines":["lu_road_trunk_primary","lu_bridge_major","lu_tunnel_major","lu_road_major_motorway"],"visible":true},{"label":"Roads secondary","color":"#ffffff","lines":["lu_road_minor","lu_road_secondary_tertiary","lu_bridge_minor","lu_road_path","lu_bridge_path","lu_bridge_railway case","lu_bridge_path case"],"visible":true},{"label":"Vegetation","color":"#839836","opacity":"1","fills":["lu_landcover_wood","lu_landcover_grass","lu_landuse_stadium","lu_landuse_cemetery"],"visible":true},{"label":"Buildings","color":"#d6d3ce","opacity":"1","fillExtrusions":["lu_building-3d_public","lu_building-3d"],"fills":["lu_building","lu_building_public"],"lines":["lu_bridge_railway","lu_railway","lu_tunnel_railway"],"visible":true},{"label":"Water","color":"#2a5ba8","lines":["lu_waterway","lu_waterway_tunnel","lu_waterway_intermittent"],"fills":["lu_water"],"visible":true},{"label":"Background","color":"#eeeeee","backgrounds":["background"],"visible":true},{"label":"Hillshade","hillshades":["hillshade"],"visible":false}]}` | ||
cy.get('@simple') | ||
.siblings() | ||
.find('button') | ||
.filter(':visible') | ||
.eq(3) | ||
.click() | ||
cy.window().then(win => { | ||
expect(win.localStorage.getItem('basemap_2015_global')).to.eq(newStyle) | ||
}) | ||
}) | ||
}) | ||
|
||
describe('Medium style selector', () => { | ||
beforeEach(() => { | ||
cy.get('[data-cy="styleSelector"') | ||
.find('button') | ||
.filter(':visible') | ||
.eq(1) | ||
.as('medium') | ||
cy.get('@medium').click() | ||
}) | ||
it('renders the medium style selector properly', () => { | ||
cy.get('@medium') | ||
.siblings() | ||
.find('input[type="checkbox"]') | ||
.filter(':visible') | ||
.should('have.length', 7) | ||
cy.get('@medium') | ||
.siblings() | ||
.find('input[type="color"]') | ||
.filter(':visible') | ||
.should('have.length', 6) | ||
}) | ||
it('sets "Roads primary" to "visible":false', () => { | ||
const newStyle = `{"medium":[{"label":"Roads primary","color":"#f7f7f7","lines":["lu_road_trunk_primary","lu_bridge_major","lu_tunnel_major","lu_road_major_motorway"],"visible":false},{"label":"Roads secondary","color":"#f7f7f7","lines":["lu_road_minor","lu_road_secondary_tertiary","lu_bridge_minor","lu_road_path","lu_bridge_path","lu_bridge_railway case","lu_bridge_path case"],"visible":true},{"label":"Vegetation","color":"#B8D293","opacity":"1","fills":["lu_landcover_wood","lu_landcover_grass","lu_landuse_stadium","lu_landuse_cemetery"],"visible":true},{"label":"Buildings","color":"#D6AA85","opacity":"1","fillExtrusions":["lu_building-3d_public","lu_building-3d"],"fills":["lu_building","lu_building_public"],"lines":["lu_bridge_railway","lu_railway","lu_tunnel_railway"],"visible":true},{"label":"Water","color":"#94c1e1","lines":["lu_waterway","lu_waterway_tunnel","lu_waterway_intermittent"],"fills":["lu_water"],"visible":true},{"label":"Background","color":"#e7e7e7","backgrounds":["background"],"visible":true},{"label":"Hillshade","hillshades":["hillshade"],"visible":true}]}` | ||
cy.get('@medium') | ||
.siblings() | ||
.find('input[type="checkbox"]') | ||
.filter(':visible') | ||
.first() | ||
.click() | ||
cy.window().then(win => { | ||
expect(win.localStorage.getItem('basemap_2015_global')).to.eq(newStyle) | ||
}) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<script lang="ts" setup> | ||
defineProps<{ | ||
expanded: boolean | ||
title: string | ||
}>() | ||
defineEmits<{ | ||
(e: 'togglePanel'): void | ||
}>() | ||
</script> | ||
|
||
<template> | ||
<button | ||
@click="$emit('togglePanel')" | ||
class="group w-full text-left flex px-2 py-1.5 uppercase bg-tertiary" | ||
:aria-expanded="expanded" | ||
> | ||
<div class="grow" :class="expanded ? 'text-white' : 'text-secondary'"> | ||
{{ title }} | ||
</div> | ||
<div class="leading-6"> | ||
<div | ||
class="fa fa-sharp fa-solid group-hover:text-white text-primary" | ||
:class="expanded ? 'fa-caret-up' : 'fa-caret-down'" | ||
></div> | ||
</div> | ||
</button> | ||
<div :class="expanded ? '' : 'hidden'"> | ||
<slot></slot> | ||
</div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice refactoring, thanks