matterviz 0.1.4 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -174,10 +174,11 @@ $effect(() => {
174
174
  box-sizing: border-box;
175
175
  display: flex;
176
176
  place-items: center;
177
- padding: 4pt;
177
+ padding: var(--panel-toggle-padding, 2pt);
178
178
  border-radius: var(--panel-toggle-border-radius, 3pt);
179
179
  background-color: transparent;
180
180
  transition: background-color 0.2s;
181
+ font-size: clamp(1em, 2cqw, 1.6em);
181
182
  }
182
183
  button.panel-toggle:hover {
183
184
  background-color: color-mix(in srgb, currentColor 8%, transparent);
@@ -208,6 +209,10 @@ $effect(() => {
208
209
  left: auto !important;
209
210
  }
210
211
  /* Panel content styling */
212
+ .draggable-panel :global(h4) {
213
+ margin: 8pt 0 2pt;
214
+ font-size: 0.9em;
215
+ }
211
216
  .draggable-panel :global(hr) {
212
217
  border: none;
213
218
  background: var(--panel-hr-bg, rgba(255, 255, 255, 0.1));
@@ -219,13 +224,26 @@ $effect(() => {
219
224
  align-items: center;
220
225
  gap: 2pt;
221
226
  }
227
+ .draggable-panel :global(input[type='text']) {
228
+ flex: 1;
229
+ padding: 4px 6px;
230
+ }
231
+ .draggable-panel :global(input[type='text'].invalid) {
232
+ border-color: var(--error-color, #ff6b6b);
233
+ background: rgba(255, 107, 107, 0.1);
234
+ }
235
+ .draggable-panel :global(input[type='text'].invalid):focus {
236
+ outline-color: var(--error-color, #ff6b6b);
237
+ box-shadow: 0 0 0 2px rgba(255, 107, 107, 0.2);
238
+ }
222
239
  .draggable-panel :global(input[type='range']) {
223
240
  margin-left: auto;
224
241
  width: 100px;
225
242
  flex-shrink: 0;
226
243
  }
227
- .draggable-panel :global(.slider-control input[type='range']) {
228
- margin-left: 0;
244
+ .draggable-panel :global(input[type='range']) {
245
+ flex: 1;
246
+ min-width: 60px;
229
247
  }
230
248
  .draggable-panel :global(input[type='number']) {
231
249
  box-sizing: border-box;
@@ -247,6 +265,10 @@ $effect(() => {
247
265
  }
248
266
  .draggable-panel :global(select) {
249
267
  margin: 0 0 0 5pt;
268
+ flex: 1;
269
+ border-radius: 3px;
270
+ padding: 2px 4px;
271
+ font-size: 0.8em;
250
272
  }
251
273
  .draggable-panel :global(input[type='color']) {
252
274
  width: 40px;
@@ -257,15 +279,8 @@ $effect(() => {
257
279
  }
258
280
  .draggable-panel :global(.panel-row) {
259
281
  display: flex;
260
- gap: 4pt;
261
- align-items: flex-start;
262
- }
263
- .draggable-panel :global(.panel-row label) {
264
- min-width: 0;
265
- }
266
- .draggable-panel :global(.panel-row label.compact) {
267
- flex: 0 0 auto;
268
- margin-right: 8pt;
282
+ gap: 8pt;
283
+ align-items: center;
269
284
  }
270
285
  .draggable-panel :global(.panel-row label.slider-control) {
271
286
  flex: 1;
package/dist/app.css CHANGED
@@ -118,7 +118,7 @@ input {
118
118
  border-radius: 3pt;
119
119
  }
120
120
  input[type='number'] {
121
- min-width: 60px;
121
+ min-width: 40px;
122
122
  width: auto;
123
123
  }
124
124
  input[type='color'] {
@@ -21,18 +21,9 @@ export const default_category_colors = {
21
21
  lanthanide: `#58748e`,
22
22
  actinide: `#6495ed`, // cornflowerblue
23
23
  };
24
- function rgb_scheme_to_hex(obj) {
25
- const result = {};
26
- for (const key in obj) {
27
- if (Object.hasOwn(obj, key)) {
28
- const val = obj[key];
29
- if (val.length >= 3) {
30
- result[key] = rgb(val[0], val[1], val[2]).formatHex();
31
- }
32
- }
33
- }
34
- return result;
35
- }
24
+ const rgb_scheme_to_hex = (obj) => Object.fromEntries(Object.entries(obj)
25
+ .filter(([, val]) => val.length >= 3)
26
+ .map(([key, val]) => [key, rgb(val[0], val[1], val[2]).formatHex()]));
36
27
  export const vesta_hex = rgb_scheme_to_hex(vesta_colors);
37
28
  export const jmol_hex = rgb_scheme_to_hex(jmol_colors);
38
29
  export const alloy_hex = rgb_scheme_to_hex(alloy_colors);
package/dist/icons.d.ts CHANGED
@@ -125,7 +125,7 @@ export declare const icon_data: {
125
125
  };
126
126
  readonly Database: {
127
127
  readonly viewBox: "0 0 24 24";
128
- readonly path: "M12 5a9 3 0 0 1 9 3M21 12c0 1.66-4 3-9 3s-9-1.34-9-3M3 5v14c0 1.66 4 3 9 3s9-1.34 9-3V5";
128
+ readonly path: "M12 11q3.75 0 6.375-1.175T21 7t-2.625-2.825T12 3T5.625 4.175T3 7t2.625 2.825T12 11m0 2.5q1.025 0 2.563-.213t2.962-.687t2.45-1.237T21 9.5V12q0 1.1-1.025 1.863t-2.45 1.237t-2.962.688T12 16t-2.562-.213t-2.963-.687t-2.45-1.237T3 12V9.5q0 1.1 1.025 1.863t2.45 1.237t2.963.688T12 13.5m0 5q1.025 0 2.563-.213t2.962-.687t2.45-1.237T21 14.5V17q0 1.1-1.025 1.863t-2.45 1.237t-2.962.688T12 21t-2.562-.213t-2.963-.687t-2.45-1.237T3 17v-2.5q0 1.1 1.025 1.863t2.45 1.237t2.963.688T12 18.5";
129
129
  };
130
130
  readonly ORCID: {
131
131
  readonly viewBox: "0 0 24 24";
@@ -212,8 +212,8 @@ export declare const icon_data: {
212
212
  readonly path: "M8 1a1.993 1.993 0 0 0-1 3.72V6L5 8L3 6V4.72A1.993 1.993 0 0 0 2 1a1.993 1.993 0 0 0-1 3.72V6.5l3 3v1.78A1.993 1.993 0 0 0 5 15a1.993 1.993 0 0 0 1-3.72V9.5l3-3V4.72A1.993 1.993 0 0 0 8 1zM2 4.2C1.34 4.2.8 3.65.8 3c0-.65.55-1.2 1.2-1.2c.65 0 1.2.55 1.2 1.2c0 .65-.55 1.2-1.2 1.2zm3 10c-.66 0-1.2-.55-1.2-1.2c0-.65.55-1.2 1.2-1.2c.65 0 1.2.55 1.2 1.2c0 .65-.55 1.2-1.2 1.2zm3-10c-.66 0-1.2-.55-1.2-1.2c0-.65.55-1.2 1.2-1.2c.65 0 1.2.55 1.2 1.2c0 .65-.55 1.2-1.2 1.2z";
213
213
  };
214
214
  readonly Fullscreen: {
215
- readonly viewBox: "0 0 16 16";
216
- readonly path: "M1.5 1a.5.5 0 0 0-.5.5v4a.5.5 0 0 1-1 0v-4A1.5 1.5 0 0 1 1.5 0h4a.5.5 0 0 1 0 1zM10 .5a.5.5 0 0 1 .5-.5h4A1.5 1.5 0 0 1 16 1.5v4a.5.5 0 0 1-1 0v-4a.5.5 0 0 0-.5-.5h-4a.5.5 0 0 1-.5-.5M.5 10a.5.5 0 0 1 .5.5v4a.5.5 0 0 0 .5.5h4a.5.5 0 0 1 0 1h-4A1.5 1.5 0 0 1 0 14.5v-4a.5.5 0 0 1 .5-.5m15 0a.5.5 0 0 1 .5.5v4a1.5 1.5 0 0 1-1.5 1.5h-4a.5.5 0 0 1 0-1h4a.5.5 0 0 0 .5-.5v-4a.5.5 0 0 1 .5-.5";
215
+ readonly viewBox: "0 0 24 24";
216
+ readonly path: "M5 5h5V3H3v7h2zm5 14H5v-5H3v7h7zm11-5h-2v5h-5v2h7zm-2-4h2V3h-7v2h5z";
217
217
  };
218
218
  readonly ExitFullscreen: {
219
219
  readonly viewBox: "0 0 24 24";
package/dist/icons.js CHANGED
@@ -126,7 +126,7 @@ export const icon_data = {
126
126
  },
127
127
  Database: {
128
128
  viewBox: `0 0 24 24`,
129
- path: `M12 5a9 3 0 0 1 9 3M21 12c0 1.66-4 3-9 3s-9-1.34-9-3M3 5v14c0 1.66 4 3 9 3s9-1.34 9-3V5`,
129
+ path: `M12 11q3.75 0 6.375-1.175T21 7t-2.625-2.825T12 3T5.625 4.175T3 7t2.625 2.825T12 11m0 2.5q1.025 0 2.563-.213t2.962-.687t2.45-1.237T21 9.5V12q0 1.1-1.025 1.863t-2.45 1.237t-2.962.688T12 16t-2.562-.213t-2.963-.687t-2.45-1.237T3 12V9.5q0 1.1 1.025 1.863t2.45 1.237t2.963.688T12 13.5m0 5q1.025 0 2.563-.213t2.962-.687t2.45-1.237T21 14.5V17q0 1.1-1.025 1.863t-2.45 1.237t-2.962.688T12 21t-2.562-.213t-2.963-.687t-2.45-1.237T3 17v-2.5q0 1.1 1.025 1.863t2.45 1.237t2.963.688T12 18.5`,
130
130
  },
131
131
  ORCID: {
132
132
  viewBox: `0 0 24 24`,
@@ -213,8 +213,8 @@ export const icon_data = {
213
213
  path: `M8 1a1.993 1.993 0 0 0-1 3.72V6L5 8L3 6V4.72A1.993 1.993 0 0 0 2 1a1.993 1.993 0 0 0-1 3.72V6.5l3 3v1.78A1.993 1.993 0 0 0 5 15a1.993 1.993 0 0 0 1-3.72V9.5l3-3V4.72A1.993 1.993 0 0 0 8 1zM2 4.2C1.34 4.2.8 3.65.8 3c0-.65.55-1.2 1.2-1.2c.65 0 1.2.55 1.2 1.2c0 .65-.55 1.2-1.2 1.2zm3 10c-.66 0-1.2-.55-1.2-1.2c0-.65.55-1.2 1.2-1.2c.65 0 1.2.55 1.2 1.2c0 .65-.55 1.2-1.2 1.2zm3-10c-.66 0-1.2-.55-1.2-1.2c0-.65.55-1.2 1.2-1.2c.65 0 1.2.55 1.2 1.2c0 .65-.55 1.2-1.2 1.2z`,
214
214
  },
215
215
  Fullscreen: {
216
- viewBox: `0 0 16 16`,
217
- path: `M1.5 1a.5.5 0 0 0-.5.5v4a.5.5 0 0 1-1 0v-4A1.5 1.5 0 0 1 1.5 0h4a.5.5 0 0 1 0 1zM10 .5a.5.5 0 0 1 .5-.5h4A1.5 1.5 0 0 1 16 1.5v4a.5.5 0 0 1-1 0v-4a.5.5 0 0 0-.5-.5h-4a.5.5 0 0 1-.5-.5M.5 10a.5.5 0 0 1 .5.5v4a.5.5 0 0 0 .5.5h4a.5.5 0 0 1 0 1h-4A1.5 1.5 0 0 1 0 14.5v-4a.5.5 0 0 1 .5-.5m15 0a.5.5 0 0 1 .5.5v4a1.5 1.5 0 0 1-1.5 1.5h-4a.5.5 0 0 1 0-1h4a.5.5 0 0 0 .5-.5v-4a.5.5 0 0 1 .5-.5`,
216
+ viewBox: `0 0 24 24`,
217
+ path: `M5 5h5V3H3v7h2zm5 14H5v-5H3v7h7zm11-5h-2v5h-5v2h7zm-2-4h2V3h-7v2h5z`,
218
218
  },
219
219
  ExitFullscreen: {
220
220
  viewBox: `0 0 24 24`,
@@ -53,3 +53,4 @@ export type CellType = `primitive_cell` | `unit_cell` | `supercell` | `phonon_pr
53
53
  export declare function parse_phonopy_yaml(content: string, cell_type?: CellType): ParsedStructure | null;
54
54
  export declare function parse_structure_file(content: string, filename?: string): ParsedStructure | null;
55
55
  export declare function parse_any_structure(content: string, filename: string): AnyStructure | null;
56
+ export declare function is_structure_file(filename: string): boolean;
package/dist/io/parse.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { elem_symbols } from '..';
2
2
  import * as math from '../math';
3
+ import { is_trajectory_file } from '../trajectory/parse';
3
4
  import { load as yaml_load } from 'js-yaml';
4
5
  // Normalize scientific notation in coordinate strings
5
6
  // Handles eEdD and *^ notation variants
@@ -884,3 +885,16 @@ export function parse_any_structure(content, filename) {
884
885
  : null;
885
886
  }
886
887
  }
888
+ // Check if filename indicates a structure file
889
+ export function is_structure_file(filename) {
890
+ const name = filename.toLowerCase();
891
+ // First check if this is a trajectory file and so not a structure file
892
+ if (is_trajectory_file(filename))
893
+ return false;
894
+ const structure_extensions = /\.(cif|poscar|vasp|xyz|extxyz|json|yaml|yml|xml|lmp|data|dump|pdb|mol|mol2|sdf|mmcif)$/;
895
+ const structure_keywords = /(poscar|contcar|potcar|incar|kpoints|outcar)/;
896
+ return (structure_extensions.test(name) ||
897
+ structure_keywords.test(name) || // Files with structure-related keywords
898
+ (name.endsWith(`.gz`) && // Compressed structure files
899
+ (structure_extensions.test(name.slice(0, -3)) || structure_keywords.test(name))));
900
+ }
@@ -182,7 +182,7 @@ function toggle_series_visibility(series_idx) {
182
182
  x2={width - padding.r}
183
183
  y1={height - padding.b}
184
184
  y2={height - padding.b}
185
- stroke="var(--histogram-axis-color)"
185
+ stroke="var(--border-color, gray)"
186
186
  stroke-width="1"
187
187
  />
188
188
 
@@ -193,23 +193,23 @@ function toggle_series_visibility(series_idx) {
193
193
  <line
194
194
  y1={-(height - padding.b - padding.t)}
195
195
  y2="0"
196
- stroke="var(--histogram-grid-stroke, gray)"
197
- stroke-dasharray="var(--histogram-grid-dash, 4)"
198
- stroke-width="var(--histogram-grid-width, 0.4)"
196
+ stroke="var(--border-color, gray)"
197
+ stroke-dasharray="4"
198
+ stroke-width="0.4"
199
199
  {...typeof x_grid === `object` ? x_grid : {}}
200
200
  />
201
201
  {/if}
202
202
  <line
203
203
  y1="0"
204
204
  y2="5"
205
- stroke="var(--histogram-axis-color)"
205
+ stroke="var(--border-color, gray)"
206
206
  stroke-width="1"
207
207
  />
208
208
  <text
209
209
  y="18"
210
210
  text-anchor="middle"
211
- font-size="12"
212
- fill="var(--histogram-text-color)"
211
+ font-size="14"
212
+ fill="var(--text-color)"
213
213
  >
214
214
  {format_value(tick, x_format)}
215
215
  </text>
@@ -221,8 +221,8 @@ function toggle_series_visibility(series_idx) {
221
221
  x={padding.l + chart_width / 2}
222
222
  y={height - 10}
223
223
  text-anchor="middle"
224
- font-size="14"
225
- fill="var(--histogram-text-color)"
224
+ font-size="16"
225
+ fill="var(--text-color)"
226
226
  >
227
227
  {x_label}
228
228
  </text>
@@ -234,7 +234,7 @@ function toggle_series_visibility(series_idx) {
234
234
  x2={padding.l}
235
235
  y1={padding.t}
236
236
  y2={height - padding.b}
237
- stroke="var(--histogram-axis-color)"
237
+ stroke="var(--border-color, gray)"
238
238
  stroke-width="1"
239
239
  />
240
240
 
@@ -245,24 +245,24 @@ function toggle_series_visibility(series_idx) {
245
245
  <line
246
246
  x1="0"
247
247
  x2={width - padding.l - padding.r}
248
- stroke="var(--histogram-grid-stroke, gray)"
249
- stroke-dasharray="var(--histogram-grid-dash, 4)"
250
- stroke-width="var(--histogram-grid-width, 0.4)"
248
+ stroke="var(--border-color, gray)"
249
+ stroke-dasharray="4"
250
+ stroke-width="0.4"
251
251
  {...typeof y_grid === `object` ? y_grid : {}}
252
252
  />
253
253
  {/if}
254
254
  <line
255
255
  x1="-5"
256
256
  x2="0"
257
- stroke="var(--histogram-axis-color)"
257
+ stroke="var(--border-color, gray)"
258
258
  stroke-width="1"
259
259
  />
260
260
  <text
261
261
  x="-10"
262
262
  text-anchor="end"
263
263
  dominant-baseline="central"
264
- font-size="12"
265
- fill="var(--histogram-text-color)"
264
+ font-size="14"
265
+ fill="var(--text-color)"
266
266
  >
267
267
  {format_value(tick, y_format)}
268
268
  </text>
@@ -274,8 +274,8 @@ function toggle_series_visibility(series_idx) {
274
274
  x={15}
275
275
  y={padding.t + chart_height / 2}
276
276
  text-anchor="middle"
277
- font-size="14"
278
- fill="var(--histogram-text-color)"
277
+ font-size="16"
278
+ fill="var(--text-color)"
279
279
  transform="rotate(-90, 15, {padding.t + chart_height / 2})"
280
280
  >
281
281
  {y_label}
@@ -284,7 +284,6 @@ function toggle_series_visibility(series_idx) {
284
284
  </svg>
285
285
  {/if}
286
286
 
287
- <!-- Control Panel -->
288
287
  {#if show_controls}
289
288
  <HistogramControls
290
289
  toggle_props={controls_toggle_props}
@@ -309,7 +308,6 @@ function toggle_series_visibility(series_idx) {
309
308
  />
310
309
  {/if}
311
310
 
312
- <!-- Legend -->
313
311
  {#if show_legend && legend && series.length > 1}
314
312
  <PlotLegend
315
313
  {...legend}
@@ -332,14 +330,14 @@ function toggle_series_visibility(series_idx) {
332
330
  height: 100%;
333
331
  }
334
332
  .tooltip {
335
- background: var(--histogram-tooltip-bg);
336
- color: var(--histogram-tooltip-color);
333
+ background: var(--tooltip-bg);
334
+ color: var(--text-color);
337
335
  padding: 4px 8px;
338
336
  border-radius: 4px;
339
337
  font-size: 12px;
340
338
  pointer-events: none;
341
339
  white-space: nowrap;
342
- border: 1px solid var(--histogram-tooltip-border);
340
+ border: var(--tooltip-border);
343
341
  }
344
342
  .histogram-series rect {
345
343
  transition: opacity 0.2s ease;
@@ -41,6 +41,6 @@ interface Props {
41
41
  controls_toggle_props?: ComponentProps<typeof DraggablePanel>[`toggle_props`];
42
42
  [key: string]: unknown;
43
43
  }
44
- declare const Histogram: import("svelte").Component<Props, {}, "mode" | "controls_open" | "show_controls" | "y_format" | "x_format" | "bins" | "x_scale_type" | "y_scale_type" | "show_legend" | "bar_opacity" | "bar_stroke_width" | "selected_property" | "x_grid" | "y_grid" | "x_ticks" | "y_ticks">;
44
+ declare const Histogram: import("svelte").Component<Props, {}, "mode" | "controls_open" | "x_format" | "y_format" | "bins" | "x_scale_type" | "y_scale_type" | "show_legend" | "bar_opacity" | "bar_stroke_width" | "selected_property" | "x_grid" | "y_grid" | "x_ticks" | "y_ticks" | "show_controls">;
45
45
  type Histogram = ReturnType<typeof Histogram>;
46
46
  export default Histogram;