Skip to content

Commit

Permalink
refactor: factor out some code to react-util and use it (#3498)
Browse files Browse the repository at this point in the history
  • Loading branch information
hwbllmnn authored and simonseyock committed May 6, 2024
1 parent 7dba4ad commit 7d2e6cf
Show file tree
Hide file tree
Showing 67 changed files with 300 additions and 2,050 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/on-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
${{ runner.OS }}-
- name: Install dependencies ⏬
run: npm ci
run: npm ci --force

- name: Build styleguide 🏗️
run: npm run build:styleguide
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/on-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
${{ runner.OS }}-
- name: Install dependencies ⏬
run: npm ci
run: npm ci --force

- name: Build artifacts 🏗️
run: npm run build
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/on-push-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
${{ runner.OS }}-
- name: Install dependencies ⏬
run: npm ci
run: npm ci --force

- name: Generate coverage 🧪
run: npm test
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
node-version: 18

- name: Install dependencies ⏬
run: npm ci
run: npm ci --force

- name: Build artifacts 🏗️
run: npm run build
Expand Down
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ module.exports = {
'<rootDir>/dist/'
],
transformIgnorePatterns: [
'node_modules/(?!(ol|antd|d3-selection|@camptocamp/inkmap|(rc-[a-z-]*)|@ant-design\/css-animation|(-[a-z]+)*|@babel\/runtime)/)'
'node_modules/(?!(@terrestris/.*|ol|antd|@camptocamp/inkmap|(rc-[a-z-]*)|@ant-design\/css-animation|(-[a-z]+)*|@babel\/runtime)/)'
],
setupFiles: [
'<rootDir>/jest/__mocks__/matchMediaMock.js'
Expand Down
17 changes: 17 additions & 0 deletions jest/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,20 @@ Object.assign(global, {
});

Enzyme.configure({ adapter: new Adapter() });

jest.mock('use-resize-observer', () => ({
__esModule: true,
default: jest.fn().mockImplementation(() => ({
observe: jest.fn(),
unobserve: jest.fn(),
disconnect: jest.fn(),
})),
}));

window.ResizeObserver =
window.ResizeObserver ||
jest.fn().mockImplementation(() => ({
disconnect: jest.fn(),
observe: jest.fn(),
unobserve: jest.fn(),
}));
48 changes: 36 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@
"@fortawesome/react-fontawesome": "^0.2.0",
"@terrestris/base-util": "^1.0.1",
"@terrestris/ol-util": "^14.0.0",
"@terrestris/react-util": "^2.2.0-beta.2",
"@types/geojson": "^7946.0.10",
"@types/lodash": "^4.14.197",
"@types/moment": "^2.13.0",
"ag-grid-community": "^28.2.1",
"ag-grid-react": "^28.2.1",
"jspdf": "^2.5.1",
Expand Down Expand Up @@ -151,13 +151,14 @@
"style-loader": "^3.3.3",
"tsconfig-paths-webpack-plugin": "^4.1.0",
"typescript": "^4.7.4",
"use-resize-observer": "^9.1.0",
"webpack": "^5.88.2",
"whatwg-fetch": "^3.6.18"
},
"peerDependencies": {
"@types/react": ">=18",
"antd": "^5",
"ol": "^7.1",
"ol": ">=^7",
"react": ">=18"
},
"engines": {
Expand Down
6 changes: 3 additions & 3 deletions src/BackgroundLayerChooser/BackgroundLayerChooser.example.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ The BackgroundLayerChooser

```jsx
import BackgroundLayerChooser from '@terrestris/react-geo/dist/BackgroundLayerChooser/BackgroundLayerChooser';
import MapContext from '@terrestris/react-geo/dist/Context/MapContext/MapContext';
import { useMap } from '@terrestris/react-geo/dist/Hook/useMap';
import MapComponent from '@terrestris/react-geo/dist/Map/MapComponent/MapComponent';
import MapContext from '@terrestris/react-util/dist/Context/MapContext/MapContext';
import { useMap } from '@terrestris/react-util/dist/hooks/useMap';
import MapComponent from '@terrestris/react-util/dist/Map/MapComponent/MapComponent';
import OlLayerTile from 'ol/layer/Tile';
import OlMap from 'ol/Map';
import OlSourceOsm from 'ol/source/OSM';
Expand Down
55 changes: 55 additions & 0 deletions src/BackgroundLayerChooser/BackgroundLayerChooser.less
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,58 @@
}

}

// styling for preview cards
.layer-cards {
display: flex;
gap: 10px;
padding: 5px;
background-color: var(--ant-primary-1);
border: solid 1px var(--ant-primary-color);
border-radius: 4px;
transition: 400ms;

.layer-preview {

cursor: pointer;
margin: auto 0;

&:hover {
outline: 2px solid var(--ant-primary-color-active);
}

&.selected {
.ant-spin-container {
img,
div.no-preview,
span.layer-title {
outline: 2px solid var(--ant-primary-color-active);
font-weight: bold;
}
}
}

.ant-spin-container {
display: flex;
flex-direction: column;

canvas {
outline: solid 1px var(--ant-primary-color );
}

span.layer-title {
position: absolute;
bottom: 0;
background: var(--ant-primary-color);
color: #fff;
text-align: center;
width: 100%;
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
padding: 0 4px;
}
}

}
}
Loading

0 comments on commit 7d2e6cf

Please sign in to comment.