Skip to content

Commit be0edcf

Browse files
committed
Initial commit
0 parents  commit be0edcf

28 files changed

+63361
-0
lines changed

.babelrc

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"presets": ["@babel/preset-env", "@babel/preset-react"]
3+
}

.env.example

Whitespace-only changes.

.eslintrc

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"env": {
3+
"browser": true,
4+
"node": true,
5+
"es2021": true,
6+
"mocha": true
7+
},
8+
"extends": [
9+
"eslint:recommended",
10+
"plugin:react/recommended"
11+
],
12+
"parserOptions": {
13+
"ecmaFeatures": {
14+
"jsx": true
15+
},
16+
"ecmaVersion": 2020,
17+
"sourceType": "module"
18+
},
19+
"plugins": [
20+
"react"
21+
],
22+
"rules": {
23+
"semi": ["error", "always"],
24+
"quotes": ["error", "single"],
25+
"indent": ["error", 2]
26+
},
27+
"settings": {
28+
"react": {
29+
"version": "detect"
30+
}
31+
}
32+
}

.gitignore

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
node_modules/
2+
dist/
3+
storybook-static/
4+
.env
5+
6+
# IDEA
7+
*.iml
8+
.project
9+
.idea/

.storybook/main.js

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
const path = require('path');
2+
const toPath = (filePath) => path.join(process.cwd(), filePath);
3+
4+
module.exports = {
5+
"stories": [
6+
"../src/**/*.stories.mdx",
7+
"../src/**/*.stories.@(js|jsx|ts|tsx)"
8+
],
9+
"addons": [
10+
"@storybook/addon-links",
11+
"@storybook/addon-essentials",
12+
],
13+
webpackFinal: async (config) => {
14+
return {
15+
...config,
16+
resolve: {
17+
...config.resolve,
18+
alias: {
19+
...config.resolve.alias,
20+
'@emotion/core': toPath('node_modules/@emotion/react'),
21+
'emotion-theming': toPath('node_modules/@emotion/react'),
22+
}
23+
}
24+
};
25+
}
26+
}

.storybook/preview.js

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import React from 'react';
2+
import CssBaseline from '@mui/material/CssBaseline';
3+
4+
import ThemeProvider from '@mui/material/styles/ThemeProvider';
5+
import {ThemeProvider as Emotion10ThemeProvider} from 'emotion-theming';
6+
7+
import '../src/i18n';
8+
9+
import theme from '../src/theme';
10+
11+
export const parameters = {
12+
actions: {argTypesRegex: "^on[A-Z].*"},
13+
backgrounds: {disable: true},
14+
layout: 'fullscreen'
15+
}
16+
17+
export const globalTypes = {
18+
theme: {
19+
name: 'Theme',
20+
description: 'Material-ui theme',
21+
defaultValue: 'light',
22+
toolbar: {
23+
icon: 'circle', // Available icons: https://www.chromatic.com/component?appId=5a375b97f4b14f0020b0cda3&name=Basics%7CIcon&buildNumber=13899
24+
items: [
25+
{value: 'light', left: '⚪', title: 'Light'},
26+
{value: 'dark', left: '⚫', title: 'Dark'}
27+
],
28+
},
29+
},
30+
};
31+
32+
const withThemeProvider = (Story, context) =>
33+
<Emotion10ThemeProvider theme={theme(context.globals.theme)}>
34+
<ThemeProvider theme={theme(context.globals.theme)}>
35+
<CssBaseline/>
36+
<Story {...context} />
37+
</ThemeProvider>
38+
</Emotion10ThemeProvider>;
39+
40+
export const decorators = [
41+
withThemeProvider,
42+
];

README.md

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# plantilla-visor-react
2+
3+
Template for a simple viewer, to use it, go to https://github.com/geomatico/plantilla-visor-react and click on 'Use this template', a new repository will be created based on this template.
4+
If you want to add functionalities, you can see more components here: https://labs.geomatico.es/geocomponents/
5+
6+
## First steps
7+
8+
Rename project in the following files:
9+
10+
- package.json:
11+
- name
12+
- repository.url
13+
- bugs.url
14+
- homepage
15+
- package-lock.json:
16+
- name
17+
- template.html:
18+
- Etiqueta `<title>`
19+
20+
## Mapbox version
21+
22+
Not needed with the included versions: react-map-gl v5 (which implies mapbox v1).
23+
24+
If mapbox v2 is needed, do:
25+
* `npm install react-map-gl@6`
26+
* Add the `MAPBOX_ACCESS_TOKEN=` empty key (without the token value!) to `.env.example`.
27+
* Add the `MAPBOX_ACCESS_TOKEN=XXXXXXX` entry with a valid token to `.env`.
28+
* Pass the `mapboxAccessToken={process.env.MAPBOX_ACCESS_TOKEN}` prop to the `<Map>` instance.
29+
30+
## i18n
31+
32+
We use **i18next** framework to localize our components:
33+
34+
- Web: [https://www.i18next.com/](https://www.i18next.com/)
35+
- React integration: [https://react.i18next.com/](https://react.i18next.com/)
36+
37+
Usage example on functional component:
38+
39+
```js
40+
import { useTranslation } from 'react-i18next';
41+
42+
const FunctionalComponent = () => {
43+
const { t } = useTranslation();
44+
return <h1>{t('welcome')}</h1>
45+
}
46+
```
47+
48+
The applied language will be determined by:
49+
50+
1. The `lang` query string. For instance, use [http://localhost:8080/?lang=es](http://localhost:8080/?lang=es).
51+
2. The browser language preferences.
52+
3. If detection fails, will default to `es`.
53+
54+
There are other detection strategies available, see
55+
[https://github.com/i18next/i18next-browser-languageDetector](https://github.com/i18next/i18next-browser-languageDetector).

karma.config.js

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
// eslint-disable-next-line no-undef
2+
const webpackConfig = require('./webpack.config')({
3+
test: true,
4+
});
5+
6+
// eslint-disable-next-line no-undef
7+
module.exports = (config) => {
8+
config.set({
9+
10+
// base path that will be used to resolve all patterns (eg. files, exclude)
11+
basePath: 'src',
12+
13+
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
14+
frameworks: ['mocha', 'webpack'],
15+
16+
plugins: [
17+
'karma-webpack',
18+
'karma-mocha',
19+
'karma-sourcemap-loader',
20+
'karma-chrome-launcher',
21+
'karma-mocha-reporter'
22+
],
23+
24+
files: [
25+
{ pattern: 'test.js', watched: false }
26+
],
27+
28+
exclude: [],
29+
30+
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
31+
preprocessors: {
32+
'test.js': ['webpack', 'sourcemap'],
33+
},
34+
webpack: webpackConfig,
35+
webpackServer: {
36+
noInfo: true,
37+
},
38+
// possible values: 'dots', 'progress'
39+
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
40+
reporters: ['mocha'],
41+
42+
mochaReporter: {
43+
showDiff: true,
44+
},
45+
46+
// web server port
47+
port: 9876,
48+
49+
// enable / disable colors in the output (reporters and logs)
50+
colors: true,
51+
52+
// config.LOG_DISABLE config.LOG_ERROR config.LOG_WARN config.LOG_INFO config.LOG_DEBUG
53+
logLevel: config.LOG_INFO,
54+
55+
// enable / disable watching file and executing tests whenever any file changes
56+
autoWatch: true,
57+
58+
// start these browsers
59+
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
60+
browsers: ['Chrome'],
61+
62+
// Continuous Integration mode
63+
// if true, Karma captures browsers, runs the tests and exits
64+
singleRun: true,
65+
66+
// Concurrency level
67+
// how many browser should be started simultaneous
68+
concurrency: Infinity,
69+
});
70+
};

0 commit comments

Comments
 (0)