Skip to content

Commit fe74788

Browse files
committed
List components
1 parent ec6d703 commit fe74788

File tree

2 files changed

+113
-50
lines changed

2 files changed

+113
-50
lines changed

components.md

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
# Periodic table
2+
3+
## MatPeriodicTable
4+
5+
A single periodic table; you can pass an array of enable/disabled elements
6+
7+
```
8+
html.Div([
9+
PeriodicContextTable(
10+
id=self.id("periodic-table-absorbing"),
11+
maxElementSelectable=1,
12+
forwardOuterChange=False,
13+
disabledElements=NON_SUPPORTED_ELEMENTS,
14+
forceTableLayout="small")],
15+
className="mp-absorbing-table")
16+
]
17+
```
18+
19+
You can use the prop `state` in your callbacks. The callback will be fired when the state of the
20+
table change.
21+
22+
## PeriodicContext, SelectableTable, PeriodicFilter
23+
24+
You can use this component to wire multiple table together.
25+
PeriodicContext is a top-level that provides a model for the periodic table that it wraps.
26+
PeriodicFilter allows you to use filter some elements on table, by groups/periods/properties.
27+
It updates the PeriodicContext, which in turn is mirrored on the table.
28+
```
29+
//TODO
30+
```
31+
32+
#3D Scene
33+
34+
## Simple3DScene
35+
36+
Simple3DScene displays a simple scene
37+
38+
```
39+
dash_mp_components.Simple3DScene(
40+
id='3d-3',
41+
sceneSize=800,
42+
debug=True,
43+
inletSize=150,
44+
settings={'extractAxis': True},
45+
inletPadding=0,
46+
axisView='SW',
47+
data={ /* scene definition */ }
48+
```
49+
50+
`selectedObject` can be used in your callback. The callback will fire when an object is selected.
51+
The JSON of the object will be passed as an argument
52+
53+
## CameraContext
54+
55+
Camera context allows you to wire the camera of multiple SimpleScenes together.
56+
57+
```
58+
dash_mp_components.CameraContext(children=[
59+
html.Div([
60+
dash_mp_components.Simple3DScene(
61+
id='3d-2',
62+
axisView='NW',
63+
animation='play',
64+
settings={
65+
'secondaryObjectView': True,
66+
'staticScene': False
67+
},
68+
sceneSize=550,
69+
data={ /* scene definition */ }
70+
),
71+
dash_mp_components.Simple3DScene(
72+
id='3d-3',
73+
sceneSize=800,
74+
debug=True,
75+
inletSize=150,
76+
settings={'extractAxis': True},
77+
inletPadding=0,
78+
axisView='SW',
79+
data={ /* scene definition */ }
80+
)
81+
])
82+
])
83+
```
84+
85+
86+
# Search
87+
88+
## SearchGrid
89+
90+
This is the whole search interface, wrapped in a React component. Everything happens in the frontend.
91+
92+
## MatSearchGrid / MatPrintViewContext / MAtMaterialsTable
93+
94+
This is the same interface. The search funnel and the result table are decoupled. The REST call
95+
happens in dash. See usage.py for more details
96+
97+
```
98+
dash_mp_components.MatPrintViewContext(children=[
99+
dash_mp_components.MatSearchGrid(id='search-table'),
100+
dcc.Loading(
101+
[dash_mp_components.MatMaterialsTable(id='mat-result-table')]),
102+
])
103+
```
104+
105+
##
106+
107+

usage.py

Lines changed: 6 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,22 @@
88
from dash.exceptions import PreventUpdate
99
from pymatgen import MPRester
1010

11-
#
12-
1311
app = dash.Dash(__name__)
1412

1513
app.layout = html.Div(children=[
16-
# dash_mp_components.Search(
17-
# id='test3', allDefinitions=grid, initCards=['has_properties']),
18-
# dash_mp_components.SearchGrid(id='test'),
19-
# dash_mp_components.MatSidebar(id='bar', layout='horizontal'),
2014
dash_mp_components.MatPrintViewContext(children=[
2115
dash_mp_components.MatSearchGrid(id='search-table'),
2216
dcc.Loading(
2317
[dash_mp_components.MatMaterialsTable(id='mat-result-table')]),
2418
])
2519
])
2620

21+
# make a dedicated example
22+
# dash_mp_components.Search(
23+
# id='test3', allDefinitions=grid, initCards=['has_properties']),
24+
# dash_mp_components.SearchGrid(id='test'),
25+
# dash_mp_components.MatSidebar(id='bar', layout='horizontal'),
26+
2727

2828
@app.callback(
2929
Output(component_id='mat-result-table', component_property='data'),
@@ -112,50 +112,6 @@ def display_output2(c):
112112
return q
113113

114114

115-
# @app.callback([Output(component_id='p2', component_property='children')],
116-
# [Input(component_id='bar', component_property='appId')])
117-
# def display_output2(value):
118-
# print(value)
119-
# if value is None:
120-
# return ['']
121-
# return [value]
122-
123-
#
124-
# @app.callback([Output(component_id='p', component_property='children')],
125-
# [Input(component_id='context', component_property='state')])
126-
# def display_output2(value):
127-
# print(value)
128-
# if value is None:
129-
# return ['']
130-
# return [value['enabledElements']]
131-
#
132-
#
133-
# @app.callback([
134-
# Output(component_id='context', component_property='disabledElements'),
135-
# Output(component_id='context', component_property='enabledElements')
136-
# ], [Input('RR', 'value')])
137-
# def display_output(value):
138-
# return [], [value]
139-
#
140-
#
141-
# @app.callback(
142-
# Output(component_id='context', component_property='forceTableLayout'),
143-
# [Input('RR', 'value')])
144-
# def display_output(value):
145-
# if value == 'K':
146-
# return 'small'
147-
# if value == 'Cl':
148-
# return 'compact'
149-
# if value == 'Na':
150-
# return 'spaced'
151-
152-
#
153-
# @app.callback(
154-
# Output(component_id='selected-object', component_property='children'),
155-
# [Input('3d-2', 'selectedObject')])
156-
# def display_selectedObject(value):
157-
# return f'Type {value} color {value}'
158-
159115
# use True to load a dev build of react
160116
if __name__ == '__main__':
161117
app.run_server(debug=True)

0 commit comments

Comments
 (0)