Skip to content

Commit 2ff1f3d

Browse files
committed
Merge remote-tracking branch 'origin/main' into tiling
2 parents cbcf49a + 3ef2584 commit 2ff1f3d

File tree

144 files changed

+24250
-92011
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

144 files changed

+24250
-92011
lines changed

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,12 @@ index.css.map
3030
**/wip-components/**
3131

3232
# Unused files used only for reference
33-
src/archive/
33+
archive/
3434

3535
# VSCode configs
3636
.vscode/
3737

3838
# Assets used for local development only
3939
src/assets/fonts
40-
src/assets/styles.css
40+
src/assets/styles.css
41+
src/assets/fonts.css

.storybook/main.js

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,28 @@
1-
2-
31
module.exports = {
4-
stories: ["../src/stories/**/*.stories.(ts|tsx|js|jsx)"],
5-
addons: ['@storybook/addon-actions',
6-
'@storybook/addon-links',
7-
'@storybook/addon-docs',
8-
'@storybook/addon-knobs/register',
9-
'@storybook/addon-storysource'],
10-
webpackFinal: async config => {
2+
stories: ['../src/stories/**/**/*.stories.@(ts|tsx|js|jsx|mdx)'],
3+
addons: [
4+
'@storybook/addon-essentials',
5+
'@storybook/addon-actions'
6+
// '@storybook/addon-knobs/register',
7+
// '@storybook/addon-storysource'
8+
],
9+
core: {
10+
builder: 'webpack5'
11+
},
12+
webpackFinal: async (config) => {
1113
config.module.rules.push({
1214
test: /\.(ts|tsx)$/,
1315
use: [
1416
{
15-
loader: require.resolve('awesome-typescript-loader'),
16-
},
17-
{
18-
loader: require.resolve('react-docgen-typescript-loader'),
19-
},
20-
],
17+
loader: require.resolve('ts-loader')
18+
}
19+
]
2120
});
2221
config.resolve.extensions.push('.ts', '.tsx');
2322
config.module.rules.push({
2423
test: /\.less$/,
2524
use: ['style-loader', 'css-loader', 'less-loader']
2625
});
2726
return config;
28-
},
27+
}
2928
};

.storybook/preview.js

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,31 @@
1-
import '../node_modules/bulma/css/bulma.min.css';
1+
import '../node_modules/bulma/css/bulma.min.css';
2+
import '../src/styles.less';
3+
import '../src/assets/fonts.css';
4+
import '../src//stories/stories.css';
5+
6+
export const parameters = {
7+
controls: { expanded: true, sort: 'alpha' },
8+
options: {
9+
storySort: {
10+
order: [
11+
'Introduction',
12+
['MP React Components', 'Usage with Dash'],
13+
'Search UI',
14+
[
15+
'SearchUI Component',
16+
'Columns',
17+
'Filters',
18+
'Conditional Row Styles',
19+
'Allowed Input Types Map'
20+
],
21+
'Data-Entry',
22+
'Data-Display',
23+
'Publications',
24+
['BibCard', 'CrossrefCard', 'BibjsonCard', 'PublicationCard', 'BibtexCard', 'BibFilter'],
25+
'Crystal Toolkit',
26+
['CrystalToolkitScene', 'ReactGraphComponent'],
27+
'Navigation'
28+
]
29+
}
30+
}
31+
};

package-lock.json

Lines changed: 18704 additions & 12409 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
},
3030
"dependencies": {
3131
"@s-ui/react-molecule-button-group": "^2.3.0",
32+
"@storybook/addon-actions": "^6.3.12",
3233
"@trendmicro/react-dropdown": "^1.4.0",
3334
"@types/classnames": "^2.2.11",
3435
"@welldone-software/why-did-you-render": "^4.3.2",
@@ -105,14 +106,16 @@
105106
"@rollup/plugin-image": "^2.0.6",
106107
"@rollup/plugin-node-resolve": "^11.0.1",
107108
"@rollup/plugin-url": "^6.0.0",
108-
"@storybook/addon-actions": "5.3.18",
109-
"@storybook/addon-docs": "5.3.18",
109+
"@storybook/addon-docs": "^6.3.12",
110+
"@storybook/addon-essentials": "^6.3.12",
110111
"@storybook/addon-knobs": "6.2.9",
111112
"@storybook/addon-links": "^6.3.8",
112113
"@storybook/addon-storysource": "6.3.8",
113114
"@storybook/addons": "5.3.18",
115+
"@storybook/builder-webpack5": "^6.3.12",
114116
"@storybook/client-api": "^6.3.8",
115117
"@storybook/core": "5.3.18",
118+
"@storybook/manager-webpack5": "^6.3.12",
116119
"@storybook/react": "6.3.8",
117120
"@storybook/storybook-deployer": "^2.8.7",
118121
"@testing-library/jest-dom": "^5.11.6",
@@ -156,7 +159,7 @@
156159
"style-loader": "^1.3.0",
157160
"ts-jest": "^25.2.0",
158161
"ts-loader": "^9.2.3",
159-
"typescript": "^3.9.7",
162+
"typescript": "^4.4.4",
160163
"webpack": "^5.41.1",
161164
"webpack-cli": "^4.7.2",
162165
"yaml-lint": "^1.2.4"

src/app.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import * as React from 'react';
99
import * as ReactDOM from 'react-dom';
1010
import './styles.less';
11+
import './assets/fonts.css';
1112
import '../node_modules/bulma/css/bulma.min.css';
1213
import '../node_modules/bulma-tooltip/dist/css/bulma-tooltip.min.css';
1314
import { MaterialsExplorer } from './pages/MaterialsExplorer';
@@ -24,6 +25,7 @@ import { CatalystExplorer } from './pages/CatalystExplorer';
2425
import { PhononVisualization } from './pages/PhononVisualization';
2526
import { Navbar } from './components/navigation/Navbar';
2627
import periodicTableImage from './assets/images/periodictable.png';
28+
import { MofExplorer } from './pages/MofExplorer';
2729

2830
const mountNodeSelector = 'app';
2931
const mountNode = document.getElementById(mountNodeSelector);
@@ -57,6 +59,10 @@ ReactDOM.render(
5759
label: 'Catalysts',
5860
href: '/catalysts'
5961
},
62+
{
63+
label: 'MOF',
64+
href: '/mof'
65+
},
6066
{
6167
label: 'X-Ray Absorption Spectra',
6268
href: '/xas'
@@ -126,6 +132,9 @@ ReactDOM.render(
126132
<Route path="/catalysts">
127133
<CatalystExplorer />
128134
</Route>
135+
<Route path="/mof">
136+
<MofExplorer />
137+
</Route>
129138
<Route path="/sandbox">
130139
<Sandbox />
131140
</Route>

src/components/crystal-toolkit/CrystalToolkitScene/CrystalToolkitScene.tsx

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,11 @@ import { ColladaExporter } from 'three/examples/jsm/exporters/ColladaExporter';
3636
import { Action } from '../utils';
3737
import useResizeObserver from 'use-resize-observer';
3838

39-
/**
40-
* CrystalToolkitScene is intended to draw simple 3D scenes using the popular
41-
* Three.js scene graph library. In particular, the JSON representing the 3D scene
42-
* is intended to be human-readable, and easily generated via Python. This is not
43-
* intended to be a replacement for a full scene graph library, but for rapid
44-
* prototyping by non-experts.
45-
*/
46-
4739
const getSceneSize = (sceneSize) => (sceneSize ? sceneSize : DEFAULT_SCENE_SIZE);
4840

4941
let ID_GENERATOR = 0;
5042

51-
interface Props {
43+
export interface CrystalToolkitSceneProps {
5244
/**
5345
* The ID used to identify this component in Dash callbacks
5446
*/
@@ -176,7 +168,14 @@ interface Props {
176168
setProps?: (value: any) => any;
177169
}
178170

179-
export const CrystalToolkitScene: React.FC<Props> = ({
171+
/**
172+
* This component is intended to draw simple 3D scenes using the popular
173+
* Three.js scene graph library. In particular, the JSON representing the 3D scene
174+
* is intended to be human-readable, and easily generated via Python. This is not
175+
* intended to be a replacement for a full scene graph library, but for rapid
176+
* prototyping by non-experts.
177+
*/
178+
export const CrystalToolkitScene: React.FC<CrystalToolkitSceneProps> = ({
180179
imageRequest = {},
181180
setProps = () => null,
182181
...otherProps

src/components/crystal-toolkit/Download/Download.tsx

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -63,21 +63,16 @@ export const Download: React.FC<Props> = ({
6363
// Construct the blob.
6464
const blob = new Blob([content], { type: mimeType });
6565
const filename = props.data.filename;
66-
// Save file function, from https://stackoverflow.com/questions/19327749/javascript-blob-filename-without-link
67-
if (window.navigator.msSaveOrOpenBlob) {
68-
window.navigator.msSaveOrOpenBlob(blob, filename);
69-
} else {
70-
const a = document.createElement('a');
71-
document.body.appendChild(a);
72-
const url = window.URL.createObjectURL(blob);
73-
a.href = url;
74-
a.download = filename;
75-
a.click();
76-
setTimeout(() => {
77-
window.URL.revokeObjectURL(url);
78-
document.body.removeChild(a);
79-
}, 0);
80-
}
66+
const a = document.createElement('a');
67+
document.body.appendChild(a);
68+
const url = window.URL.createObjectURL(blob);
69+
a.href = url;
70+
a.download = filename;
71+
a.click();
72+
setTimeout(() => {
73+
window.URL.revokeObjectURL(url);
74+
document.body.removeChild(a);
75+
}, 0);
8176
}
8277
}, [props.data]);
8378

src/components/data-display/DataBlock/DataBlock.test.tsx

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React from 'react';
22
import { render, fireEvent, waitFor, screen, cleanup } from '@testing-library/react';
33
import { DataBlock } from '.';
4+
import { Column } from '../SearchUI/types';
45

56
describe('<DataBlock/>', () => {
67
it('should render data items', () => {
@@ -48,9 +49,9 @@ const defaultProps = {
4849
},
4950
columns: [
5051
{
51-
name: 'Material ID',
52+
title: 'Material ID',
5253
selector: 'material_id',
53-
format: 'LINK',
54+
formatType: 'LINK',
5455
formatOptions: {
5556
baseUrl: 'https://lbl.gov',
5657
target: '_blank'
@@ -60,25 +61,25 @@ const defaultProps = {
6061
isTop: true
6162
},
6263
{
63-
name: 'Formula',
64+
title: 'Formula',
6465
selector: 'formula_pretty',
65-
format: 'FORMULA',
66+
formatType: 'FORMULA',
6667
minWidth: '300px',
6768
maxWidth: '300px',
6869
isTop: true
6970
},
7071
{
71-
name: 'Data Items',
72+
title: 'Data Items',
7273
selector: 'data',
73-
format: 'ARRAY',
74+
formatType: 'ARRAY',
7475
formatOptions: {
7576
arrayTooltipsKey: 'dataTooltips'
7677
}
7778
},
7879
{
79-
name: 'Tables',
80+
title: 'Tables',
8081
selector: 'tables',
81-
format: 'ARRAY',
82+
formatType: 'ARRAY',
8283
formatOptions: {
8384
arrayTooltipsKey: 'tablesTooltips',
8485
arrayLinksKey: 'tablesLinks',
@@ -88,11 +89,11 @@ const defaultProps = {
8889
isBottom: true
8990
},
9091
{
91-
name: 'Description',
92+
title: 'Description',
9293
selector: 'description',
9394
isBottom: true
9495
}
95-
],
96+
] as Column[],
9697
footer: <div>Footer</div>,
9798
iconClassName: 'fas fa-pizza-slice',
9899
iconTooltip: 'Pizza'

src/components/data-display/DataBlock/DataBlock.tsx

Lines changed: 52 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,78 @@ import { initColumns } from '../SearchUI/utils';
88
import { Tooltip } from '../../data-display/Tooltip';
99
import './DataBlock.css';
1010

11-
interface Props {
11+
export interface DataBlockProps {
12+
/**
13+
* The ID used to identify this component in Dash callbacks
14+
*/
1215
id?: string;
16+
/**
17+
* Dash-assigned callback that should be called whenever any of the
18+
* properties change
19+
*/
1320
setProps?: (value: any) => any;
21+
/**
22+
* Class name(s) to append to the component's default class (`mpc-data-block`)
23+
*/
1424
className?: string;
25+
/**
26+
* Object to render inside the data block.
27+
* A key value must be a string, number, or array of strings/numbers.
28+
* Key values cannot be objects.
29+
*/
1530
data: object;
31+
/**
32+
* An array of column definition objects to control how keys/values are rendered in the data block.
33+
* See `Column` documentation for specifics on how to construct `Column` objects.
34+
* If no column definitions are supplied, the key names are used as labels and the values are rendered
35+
* without any formatting.
36+
*/
1637
columns?: Column[];
38+
/**
39+
* Set to true to have bottom columns section expanded on load.
40+
*/
1741
expanded?: boolean;
42+
/**
43+
* Content to display at the bottom-most section of the block.
44+
*/
1845
footer?: ReactNode;
46+
/**
47+
* Class name of an icon to display in the top right of the block.
48+
*/
1949
iconClassName?: string;
50+
/**
51+
* Tooltip text to display when hovering over the icon.
52+
*/
2053
iconTooltip?: string;
54+
/**
55+
* This is a temporary solution to allow SearchUI's to render in Storybook.
56+
* There is an issue with the dynamic column header components that causes
57+
* Storybook to crash. Rendering column headers as plain strings fixes the problem.
58+
* Note that this will disable column tooltips and unit labels.
59+
*/
60+
disableRichColumnHeaders?: boolean;
2161
}
2262

2363
const getColumnsFromKeys = (data: object): Column[] => {
2464
const keys = Object.keys(data);
2565
return keys.map((key) => {
2666
return {
27-
name: key,
67+
title: key,
2868
selector: key
2969
};
3070
});
3171
};
3272

33-
export const DataBlock: React.FC<Props> = (props) => {
73+
/**
74+
* Component for displaying a single row (object) of data in a card-like block.
75+
* Blocks have a top section that displays data horizontally and an optional collapsible bottom
76+
* section that displays data vertically.
77+
*/
78+
export const DataBlock: React.FC<DataBlockProps> = (props) => {
3479
const [columns, setColumns] = useState(() => {
35-
return props.columns ? initColumns(props.columns) : getColumnsFromKeys(props.data);
80+
return props.columns
81+
? initColumns(props.columns, props.disableRichColumnHeaders)
82+
: getColumnsFromKeys(props.data);
3683
});
3784
const [topColumns, setTopColumns] = useState(() =>
3885
columns.filter((c) => !c.hidden && (c.isTop || (!c.isTop && !c.isBottom)))
@@ -82,7 +129,7 @@ export const DataBlock: React.FC<Props> = (props) => {
82129
)}
83130
{props.iconTooltip && <Tooltip id={tooltipId}>{props.iconTooltip}</Tooltip>}
84131
</div>
85-
{bottomColumns && (
132+
{bottomColumns && bottomColumns.length > 0 && (
86133
<div className="mpc-data-block-expandable">
87134
<Collapsible trigger={<span></span>} open={expanded} transitionTime={250}>
88135
{!expanded && <div className="mpc-data-block-fade"></div>}

0 commit comments

Comments
 (0)