Skip to content

Commit

Permalink
Refactored file structure and added url-loader to webpack. (equinor#82)
Browse files Browse the repository at this point in the history
In order to have it similar to webviz-subsurface-components.

Added MIT copyright notices.
  • Loading branch information
rubenthoms authored Feb 18, 2021
1 parent 380d48d commit 20ef34e
Show file tree
Hide file tree
Showing 23 changed files with 216 additions and 17 deletions.
53 changes: 53 additions & 0 deletions package-lock.json

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

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"name": "webviz_core_components",
"version": "0.0.1",
"description": "Core components for webviz config",
"repository": {
"type": "git",
Expand All @@ -15,7 +16,7 @@
"postinstall": "cp ./package.json webviz_core_components/package-info.json",
"build:js": "webpack --mode production",
"build:js-dev": "webpack --mode development",
"build:py_and_r": "dash-generate-components ./src/lib/components webviz_core_components -p package-info.json --r-prefix ''",
"build:py_and_r": "dash-generate-components ./src/lib/components webviz_core_components -p package-info.json --r-prefix '' --ignore .*.js$",
"build": "npm run build:js && npm run build:js-dev && npm run build:py_and_r",
"format": "prettier --write *.js *.json 'src/**/*.+(js|jsx|json|css)'",
"linting": "prettier --check *.js *.json 'src/**/*.+(js|jsx|json|css)' && eslint src/"
Expand All @@ -42,6 +43,7 @@
"babel-loader": "^8.0.6",
"copyfiles": "^2.1.1",
"css-loader": "^3.0.0",
"url-loader": "^4.1.1",
"eslint": "^6.0.1",
"eslint-config-prettier": "^6.0.0",
"eslint-plugin-import": "^2.18.0",
Expand Down
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# dash is required to call `build:py`
dash[dev]>=1.15.0
8 changes: 8 additions & 0 deletions src/demo/App.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
/**
* Copyright (c) 2021- Equinor ASA
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/


/* eslint no-magic-numbers: 0 */
import React, { Component } from "react";

Expand Down
8 changes: 8 additions & 0 deletions src/demo/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
/**
* Copyright (c) 2021- Equinor ASA
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/


import React from "react";
import ReactDOM from "react-dom";
import App from "./App";
Expand Down
File renamed without changes.
8 changes: 8 additions & 0 deletions src/lib/components/ColorScales/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* Copyright (c) 2021- Equinor ASA
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

export { default } from "./ColorScales";
6 changes: 0 additions & 6 deletions src/lib/components/Select.css

This file was deleted.

13 changes: 13 additions & 0 deletions src/lib/components/Select/Select.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/**
* Copyright (c) 2021- Equinor ASA
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

.webviz-config-select {
width: 100%;
overflow-y: auto;
font-family: inherit;
font-size: inherit;
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
/**
* Copyright (c) 2021- Equinor ASA
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

import React, { Component } from "react";
import PropTypes from "prop-types";
import "./Select.css";
Expand Down
8 changes: 8 additions & 0 deletions src/lib/components/Select/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* Copyright (c) 2021- Equinor ASA
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

export { default } from "./Select";
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
/**
* Copyright (c) 2021- Equinor ASA
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/


import React, { Component } from "react";
import PropTypes from "prop-types";
import html2canvas from "html2canvas";
Expand All @@ -11,9 +19,9 @@ import {
faDownload,
} from "@fortawesome/free-solid-svg-icons";

import WebvizToolbarButton from "../private-components/webviz-plugin-placeholder-resources/WebvizToolbarButton";
import WebvizContentOverlay from "../private-components/webviz-plugin-placeholder-resources/WebvizContentOverlay";
import download_file from "../private-components/webviz-plugin-placeholder-resources/download_file";
import WebvizToolbarButton from "./utils/WebvizToolbarButton";
import WebvizContentOverlay from "./utils/WebvizContentOverlay";
import download_file from "./utils/download_file";

import "./webviz_plugin_component.css";

Expand Down Expand Up @@ -87,7 +95,7 @@ export default class WebvizPluginPlaceholder extends Component {
{
scrollX: -window.scrollX,
scrollY: -window.scrollY,
}
}
).then(canvas =>
canvas.toBlob(blob =>
download_file({
Expand Down Expand Up @@ -139,7 +147,7 @@ export default class WebvizPluginPlaceholder extends Component {
)}
{this.props.buttons.includes("contact_person") &&
Object.keys(this.props.contact_person).length >
0 && (
0 && (
<WebvizToolbarButton
icon={faAddressCard}
tooltip="Contact person"
Expand Down
8 changes: 8 additions & 0 deletions src/lib/components/WebvizPluginPlaceholder/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* Copyright (c) 2021- Equinor ASA
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

export { default } from "./WebvizPluginPlaceholder";
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
/**
* Copyright (c) 2021- Equinor ASA
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

import React, { Component } from "react";
import PropTypes from "prop-types";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
/**
* Copyright (c) 2021- Equinor ASA
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

import React, { Component } from "react";
import PropTypes from "prop-types";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
export default function download_file({filename, data, mimeType}) {
/**
* Copyright (c) 2021- Equinor ASA
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

export default function download_file({ filename, data, mimeType }) {
const link = document.createElement("a");

if (data instanceof Blob) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
/**
* Copyright (c) 2021- Equinor ASA
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/


.webviz-config-plugin-wrapper {
width: 100%;
box-sizing: border-box;
Expand Down
8 changes: 8 additions & 0 deletions src/lib/flexbox.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
/**
* Copyright (c) 2021- Equinor ASA
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/


div.webviz-core-components-flexbox {
display: flex;
flex-wrap: wrap;
Expand Down
13 changes: 10 additions & 3 deletions src/lib/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
/**
* Copyright (c) 2021- Equinor ASA
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

/* eslint-disable import/prefer-default-export */
import WebvizPluginPlaceholder from "./components/WebvizPluginPlaceholder.react";
import ColorScales from "./components/ColorScales.react";
import Select from "./components/Select.react";
import WebvizPluginPlaceholder from "./components/WebvizPluginPlaceholder";
import ColorScales from "./components/ColorScales";
import Select from "./components/Select";

import "./flexbox.css"

Expand Down
9 changes: 9 additions & 0 deletions tests/test_color_scales.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
##################################################################
#
# Copyright (c) 2021- Equinor ASA
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
#
##################################################################

import dash
import dash_html_components as html
import webviz_core_components
Expand Down
9 changes: 9 additions & 0 deletions tests/test_graph.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
##################################################################
#
# Copyright (c) 2021- Equinor ASA
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
#
##################################################################

import dash
import dash_html_components as html
import webviz_core_components
Expand Down
9 changes: 9 additions & 0 deletions tests/test_plugin_placeholder.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
##################################################################
#
# Copyright (c) 2021- Equinor ASA
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
#
##################################################################

import dash
import dash_html_components as html
import webviz_core_components
Expand Down
11 changes: 10 additions & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ module.exports = (env, argv) => {
return {
mode,
entry,
resolve: {
extensions: [".ts", ".tsx", ".js", ".jsx"],
},
output: {
path: path.resolve(__dirname, dashLibraryName),
filename,
Expand All @@ -74,7 +77,7 @@ module.exports = (env, argv) => {
module: {
rules: [
{
test: /\.js$/,
test: /\.(ts|js)x?$/,
exclude: /node_modules/,
use: {
loader: "babel-loader",
Expand All @@ -92,6 +95,12 @@ module.exports = (env, argv) => {
"css-loader",
],
},
{
test: /\.(png|svg|jpg|jpeg|gif)$/i,
use: {
loader: 'url-loader',
},
},
],
},
devtool,
Expand Down

0 comments on commit 20ef34e

Please sign in to comment.