Skip to content

Commit

Permalink
More refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
MohamedHamouGisaia committed Dec 20, 2024
1 parent 6d1d3dd commit af45601
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 223 deletions.
131 changes: 54 additions & 77 deletions projects/arlas-map/src/lib/draw/themes/default-theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,43 @@ const roundLineLayout = {
'line-join': 'round'
};

const staticModeVertex = ['all',
['==', 'meta', 'vertex'],
['==', '$type', 'Point'],
['!=', 'mode', 'static']
];

const deactivatedStaticModeFeature = ['all',
['==', 'active', 'false'],
['==', '$type', 'Point'],
['==', 'meta', 'feature'],
['!=', 'mode', 'static']
];
const deactivatedStaticPolygon = ['all',
['==', 'active', 'false'],
['==', '$type', 'Polygon'],
['!=', 'mode', 'static']
];

const activatedMidPoint = ['all',
['==', '$type', 'Point'],
['==', 'active', 'true'],
['!=', 'meta', 'midpoint']
];
const staticLineMidPoint = ['all', ['==', 'meta', 'midpoint'],
['==', 'actionType', 'rotation'],
['==', '$type', 'LineString'],
['!=', 'mode', 'static']
];

const staticPolygon = ['all', ['==', 'mode', 'static'], ['==', '$type', 'Polygon']];
const activePolygon = ['all', ['==', 'active', 'true'], ['==', '$type', 'Polygon']];
const staticMidpoint = ['all',
['==', 'meta', 'midpoint'],
['==', 'actionType', 'resize'],
['==', '$type', 'Point'],
['!=', 'mode', 'static']
];
const dashedLinePaint = {
'line-color': '#fbb03b',
'line-dasharray': [0.2, 2],
Expand All @@ -43,11 +80,7 @@ export default [
{
'id': 'gl-draw-polygon-fill-inactive',
'type': 'fill',
'filter': ['all',
['==', 'active', 'false'],
['==', '$type', 'Polygon'],
['!=', 'mode', 'static']
],
'filter': deactivatedStaticPolygon,
'paint': {
'fill-color': '#3bb2d0',
'fill-outline-color': '#3bb2d0',
Expand All @@ -57,7 +90,7 @@ export default [
{
'id': 'gl-draw-polygon-fill-active',
'type': 'fill',
'filter': ['all', ['==', 'active', 'true'], ['==', '$type', 'Polygon']],
'filter': activePolygon,
'paint': {
'fill-color': '#fbb03b',
'fill-outline-color': '#fbb03b',
Expand All @@ -78,18 +111,14 @@ export default [
{
'id': 'gl-draw-polygon-stroke-inactive',
'type': 'line',
'filter': ['all',
['==', 'active', 'false'],
['==', '$type', 'Polygon'],
['!=', 'mode', 'static']
],
'filter': deactivatedStaticPolygon,
'layout': roundLineLayout,
'paint': linePaint
},
{
'id': 'gl-draw-polygon-stroke-active',
'type': 'line',
'filter': ['all', ['==', 'active', 'true'], ['==', '$type', 'Polygon']],
'filter': activePolygon,
'layout': roundLineLayout,
'paint': dashedLinePaint
},
Expand Down Expand Up @@ -118,11 +147,7 @@ export default [
{
'id': 'gl-draw-polygon-and-line-vertex-stroke-inactive',
'type': 'circle',
'filter': ['all',
['==', 'meta', 'vertex'],
['==', '$type', 'Point'],
['!=', 'mode', 'static']
],
'filter': staticModeVertex,
'paint': {
'circle-radius': 5,
'circle-color': '#fff'
Expand All @@ -131,11 +156,7 @@ export default [
{
'id': 'gl-draw-polygon-and-line-vertex-inactive',
'type': 'circle',
'filter': ['all',
['==', 'meta', 'vertex'],
['==', '$type', 'Point'],
['!=', 'mode', 'static']
],
'filter': staticModeVertex,
'paint': {
'circle-radius': 3,
'circle-color': '#fbb03b'
Expand All @@ -144,12 +165,7 @@ export default [
{
'id': 'gl-draw-point-point-stroke-inactive',
'type': 'circle',
'filter': ['all',
['==', 'active', 'false'],
['==', '$type', 'Point'],
['==', 'meta', 'feature'],
['!=', 'mode', 'static']
],
'filter': deactivatedStaticModeFeature,
'paint': {
'circle-radius': 5,
'circle-opacity': 1,
Expand All @@ -159,12 +175,7 @@ export default [
{
'id': 'gl-draw-point-inactive',
'type': 'circle',
'filter': ['all',
['==', 'active', 'false'],
['==', '$type', 'Point'],
['==', 'meta', 'feature'],
['!=', 'mode', 'static']
],
'filter': deactivatedStaticModeFeature,
'paint': {
'circle-radius': 3,
'circle-color': '#3bb2d0'
Expand All @@ -173,11 +184,7 @@ export default [
{
'id': 'gl-draw-point-stroke-active',
'type': 'circle',
'filter': ['all',
['==', '$type', 'Point'],
['==', 'active', 'true'],
['!=', 'meta', 'midpoint']
],
'filter': activatedMidPoint,
'paint': {
'circle-radius': 7,
'circle-color': '#fff'
Expand All @@ -186,10 +193,7 @@ export default [
{
'id': 'gl-draw-point-active',
'type': 'circle',
'filter': ['all',
['==', '$type', 'Point'],
['!=', 'meta', 'midpoint'],
['==', 'active', 'true']],
'filter': activatedMidPoint,
'paint': {
'circle-radius': 5,
'circle-color': '#fbb03b'
Expand All @@ -198,7 +202,7 @@ export default [
{
'id': 'gl-draw-polygon-fill-static',
'type': 'fill',
'filter': ['all', ['==', 'mode', 'static'], ['==', '$type', 'Polygon']],
'filter': staticPolygon,
'paint': {
'fill-color': '#3bb2d0',
'fill-outline-color': '#3bb2d0',
Expand All @@ -208,7 +212,7 @@ export default [
{
'id': 'gl-draw-polygon-stroke-static',
'type': 'line',
'filter': ['all', ['==', 'mode', 'static'], ['==', '$type', 'Polygon']],
'filter': staticPolygon,
'layout': roundLineLayout,

'paint': linePaint
Expand Down Expand Up @@ -236,13 +240,7 @@ export default [
{
'id': 'gl-draw-line-rotate-point',
'type': 'line',
'filter': ['all',
['==', 'meta', 'midpoint'],
['==', 'actionType', 'rotation'],
['==', '$type', 'LineString'],
['!=', 'mode', 'static']
// ['==', 'active', 'true']
],
'filter': staticLineMidPoint,
'layout': roundLineLayout,

'paint': dashedLinePaint
Expand Down Expand Up @@ -287,26 +285,15 @@ export default [
{
'id': 'gl-draw-line-resize-point',
'type': 'line',
'filter': ['all',
['==', 'meta', 'midpoint'],
['==', 'actionType', 'rotation'],
['==', '$type', 'LineString'],
['!=', 'mode', 'static']
// ['==', 'active', 'true']
],
'filter': staticLineMidPoint,
'layout': roundLineLayout,

'paint': dashedLinePaint
},
{
'id': 'gl-draw-polygon-resize-point-stroke',
'type': 'circle',
'filter': ['all',
['==', 'meta', 'midpoint'],
['==', 'actionType', 'resize'],
['==', '$type', 'Point'],
['!=', 'mode', 'static']
],
'filter': staticMidpoint,
'paint': {
'circle-radius': 5,
'circle-color': '#fff'
Expand All @@ -315,12 +302,7 @@ export default [
{
'id': 'gl-draw-polygon-resize-point',
'type': 'circle',
'filter': ['all',
['==', 'meta', 'midpoint'],
['==', 'actionType', 'resize'],
['==', '$type', 'Point'],
['!=', 'mode', 'static']
],
'filter': staticMidpoint,
'paint': {
'circle-radius': 6,
'circle-color': '#fbb03b'
Expand All @@ -329,12 +311,7 @@ export default [
{
'id': 'gl-draw-polygon-resize-point-icon',
'type': 'symbol',
'filter': ['all',
['==', 'meta', 'midpoint'],
['==', 'actionType', 'resize'],
['==', '$type', 'Point'],
['!=', 'mode', 'static']
],
'filter': staticMidpoint,
'layout': {
'icon-image': 'resize',
'icon-allow-overlap': true,
Expand Down
Loading

0 comments on commit af45601

Please sign in to comment.