Skip to content

Commit 25ab74e

Browse files
committed
0.4.2 - add scss styles
Add SCSS styles when the property `highighlight_selected == False`. This change make the cursor become normal if the grid elements are not selectable.
1 parent f75fa19 commit 25ab74e

File tree

6 files changed

+402
-98
lines changed

6 files changed

+402
-98
lines changed

Changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#### :mega: New
1010

1111
1. Add tests for passing an empty value to the `data` property.
12+
2. Add SCSS styles when the property `highighlight_selected == False`. This change make the cursor become normal if the grid elements are not selectable.
1213

1314
#### :wrench: Fix
1415

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
"@plotly/webpack-dash-dynamic-import": "^1.2.0",
5050
"babel-eslint": "^10.1.0",
5151
"babel-loader": "^9.1.2",
52+
"clsx": "^2.1.1",
5253
"copyfiles": "^2.1.1",
5354
"css-loader": "^6.8.1",
5455
"eslint": "^6.0.1",
@@ -59,6 +60,8 @@
5960
"react": "^17.0.2",
6061
"react-docgen": "^5.4.0",
6162
"react-dom": "^17.0.2",
63+
"sass": "^1.80.7",
64+
"sass-loader": "^16.0.3",
6265
"style-loader": "^3.3.3",
6366
"styled-jsx": "^4.0.1",
6467
"webpack": "^5.84.1",
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
.js-grid-container {
2+
overflow-x: auto;
3+
width: 100%;
4+
5+
& > div > table {
6+
margin-bottom: 0;
7+
8+
:global {
9+
tr:not(.highlight) {
10+
background-color: transparent;
11+
12+
&:nth-child(2n) {
13+
background-color: transparent;
14+
}
15+
}
16+
}
17+
}
18+
19+
&.no-select {
20+
& > div:global(.json-grid-container) {
21+
:global(.obj) {
22+
cursor: initial;
23+
}
24+
}
25+
}
26+
}

src/lib/fragments/DashJsonGrid.react.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,15 @@
1313

1414
import React, {Component} from "react";
1515
import {type} from "ramda";
16+
import clsx from "clsx/lite";
1617

1718
import JSONGrid from "@redheadphone/react-json-grid";
1819

1920
import {propTypes, defaultProps} from "../components/DashJsonGrid.react";
2021
import {isArray, sanitizeData} from "../utils";
2122

23+
import styles from "./DashJsonGrid.module.scss";
24+
2225
/**
2326
* DashJsonGrid is a Dash porting version for the React component:
2427
* `react-json-grid/JSONGrid`
@@ -144,7 +147,11 @@ export default class DashJsonGrid extends Component {
144147
return (
145148
<div
146149
id={id}
147-
className={class_name}
150+
className={clsx(
151+
styles["js-grid-container"],
152+
!highlight_selected && styles["no-select"],
153+
class_name
154+
)}
148155
style={style}
149156
data-dash-is-loading={
150157
(loading_state && loading_state.is_loading) || undefined

webpack.config.js

Lines changed: 124 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -1,113 +1,142 @@
1-
const path = require('path');
2-
const webpack = require('webpack');
3-
const WebpackDashDynamicImport = require('@plotly/webpack-dash-dynamic-import');
4-
const packagejson = require('./package.json');
1+
const path = require("path");
2+
const webpack = require("webpack");
3+
const WebpackDashDynamicImport = require("@plotly/webpack-dash-dynamic-import");
4+
const packagejson = require("./package.json");
55

6-
const dashLibraryName = packagejson.name.replace(/-/g, '_');
6+
const dashLibraryName = packagejson.name.replace(/-/g, "_");
77

88
module.exports = (env, argv) => {
9+
let mode;
910

10-
let mode;
11+
const overrides = module.exports || {};
1112

12-
const overrides = module.exports || {};
13+
// if user specified mode flag take that value
14+
if (argv && argv.mode) {
15+
mode = argv.mode;
16+
}
1317

14-
// if user specified mode flag take that value
15-
if (argv && argv.mode) {
16-
mode = argv.mode;
17-
}
18+
// else if configuration object is already set (module.exports) use that value
19+
else if (overrides.mode) {
20+
mode = overrides.mode;
21+
}
1822

19-
// else if configuration object is already set (module.exports) use that value
20-
else if (overrides.mode) {
21-
mode = overrides.mode;
22-
}
23+
// else take webpack default (production)
24+
else {
25+
mode = "production";
26+
}
2327

24-
// else take webpack default (production)
25-
else {
26-
mode = 'production';
27-
}
28+
let filename = (overrides.output || {}).filename;
29+
if (!filename) {
30+
const modeSuffix = mode === "development" ? "dev" : "min";
31+
filename = `${dashLibraryName}.${modeSuffix}.js`;
32+
}
2833

29-
let filename = (overrides.output || {}).filename;
30-
if(!filename) {
31-
const modeSuffix = mode === 'development' ? 'dev' : 'min';
32-
filename = `${dashLibraryName}.${modeSuffix}.js`;
33-
}
34+
const entry = overrides.entry || {main: "./src/lib/index.js"};
3435

35-
const entry = overrides.entry || {main: './src/lib/index.js'};
36+
const devtool = overrides.devtool || "source-map";
3637

37-
const devtool = overrides.devtool || 'source-map';
38+
const externals =
39+
"externals" in overrides
40+
? overrides.externals
41+
: {
42+
react: "React",
43+
"react-dom": "ReactDOM",
44+
"plotly.js": "Plotly",
45+
"prop-types": "PropTypes",
46+
};
3847

39-
const externals = ('externals' in overrides) ? overrides.externals : ({
40-
react: 'React',
41-
'react-dom': 'ReactDOM',
42-
'plotly.js': 'Plotly',
43-
'prop-types': 'PropTypes',
44-
});
45-
46-
return {
47-
mode,
48-
entry,
49-
output: {
50-
path: path.resolve(__dirname, dashLibraryName),
51-
chunkFilename: '[name].js',
52-
filename,
53-
library: dashLibraryName,
54-
libraryTarget: 'window',
55-
},
56-
devtool,
57-
devServer: {
58-
static: {
59-
directory: path.join(__dirname, '/')
60-
}
48+
return {
49+
mode,
50+
entry,
51+
output: {
52+
path: path.resolve(__dirname, dashLibraryName),
53+
chunkFilename: "[name].js",
54+
filename,
55+
library: dashLibraryName,
56+
libraryTarget: "window",
57+
},
58+
devtool,
59+
devServer: {
60+
static: {
61+
directory: path.join(__dirname, "/"),
62+
},
63+
},
64+
externals,
65+
module: {
66+
rules: [
67+
{
68+
test: /\.jsx?$/,
69+
exclude: /node_modules/,
70+
use: {
71+
loader: "babel-loader",
72+
},
6173
},
62-
externals,
63-
module: {
64-
rules: [
65-
{
66-
test: /\.jsx?$/,
67-
exclude: /node_modules/,
68-
use: {
69-
loader: 'babel-loader',
70-
},
74+
{
75+
test: /\.css$/,
76+
use: [
77+
{
78+
loader: "style-loader",
79+
},
80+
{
81+
loader: "css-loader",
82+
options: {
83+
modules: {
84+
localIdentHashSalt: "dash-json-grid",
85+
localIdentName: "djg-[local]__[hash:base64:8]",
7186
},
72-
{
73-
test: /\.css$/,
74-
use: [
75-
{
76-
loader: 'style-loader',
77-
},
78-
{
79-
loader: 'css-loader',
80-
},
81-
],
87+
},
88+
},
89+
],
90+
},
91+
{
92+
test: /\.s[ac]ss$/i,
93+
use: [
94+
{
95+
loader: "style-loader",
96+
},
97+
{
98+
loader: "css-loader",
99+
options: {
100+
modules: {
101+
localIdentHashSalt: "dash-json-grid",
102+
localIdentName: "djg-[local]__[hash:base64:8]",
82103
},
83-
],
104+
},
105+
},
106+
// Compiles Sass to CSS
107+
{
108+
loader: "sass-loader",
109+
},
110+
],
84111
},
85-
optimization: {
86-
splitChunks: {
87-
name: '[name].js',
88-
cacheGroups: {
89-
async: {
90-
chunks: 'async',
91-
minSize: 0,
92-
name(module, chunks, cacheGroupKey) {
93-
return `${cacheGroupKey}-${chunks[0].name}`;
94-
}
95-
},
96-
shared: {
97-
chunks: 'all',
98-
minSize: 0,
99-
minChunks: 2,
100-
name: 'dash_json_grid-shared'
101-
}
102-
}
103-
}
112+
],
113+
},
114+
optimization: {
115+
splitChunks: {
116+
name: "[name].js",
117+
cacheGroups: {
118+
async: {
119+
chunks: "async",
120+
minSize: 0,
121+
name(module, chunks, cacheGroupKey) {
122+
return `${cacheGroupKey}-${chunks[0].name}`;
123+
},
124+
},
125+
shared: {
126+
chunks: "all",
127+
minSize: 0,
128+
minChunks: 2,
129+
name: "dash_json_grid-shared",
130+
},
104131
},
105-
plugins: [
106-
new WebpackDashDynamicImport(),
107-
new webpack.SourceMapDevToolPlugin({
108-
filename: '[file].map',
109-
exclude: ['async-plotlyjs']
110-
})
111-
]
112-
}
132+
},
133+
},
134+
plugins: [
135+
new WebpackDashDynamicImport(),
136+
new webpack.SourceMapDevToolPlugin({
137+
filename: "[file].map",
138+
exclude: ["async-plotlyjs"],
139+
}),
140+
],
141+
};
113142
};

0 commit comments

Comments
 (0)