-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
handle structure=undefined in Structure and StructureCard component
add select to switch between multiple structures on demo page
- Loading branch information
Showing
7 changed files
with
166 additions
and
630 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,56 @@ | ||
<script> | ||
import struct_json from './mp-1234.json?raw' | ||
</script> | ||
|
||
## `Structure.svelte` | ||
|
||
```svelte example stackblitz code_above | ||
```svelte example stackblitz code_above hideStyle | ||
<script> | ||
import { Structure, StructureCard } from '$lib' | ||
import structure from './mp-1234.json' | ||
import Select from 'svelte-multiselect' | ||
const structs = import.meta.glob('./mp-*.json', { eager: true, as: 'raw' }) | ||
const mp_id = 'mp-1234' | ||
const href = `https://materialsproject.org/materials/${mp_id}` | ||
let mp_id = ['mp-1'] | ||
$: href = `https://materialsproject.org/materials/${mp_id[0]}` | ||
$: structure = JSON.parse(structs[`./${mp_id[0]}.json`] ?? '{}') | ||
</script> | ||
<form> | ||
<label for="select">Select a structure:</label> | ||
<Select | ||
id="select" | ||
options={Object.keys(structs).map((k) => k.slice(2, -5))} | ||
bind:selected={mp_id} | ||
maxSelect={1} | ||
minSelect={1} | ||
/> | ||
<details> | ||
<summary>JSON for structure {mp_id[0]}</summary> | ||
<pre> | ||
<code> | ||
{JSON.stringify(structure, null, 2)} | ||
</code> | ||
</pre> | ||
</details> | ||
</form> | ||
<StructureCard {structure}> | ||
<a slot="title" {href}>{mp_id}</a> | ||
</StructureCard> | ||
<Structure {structure} /> | ||
``` | ||
<details> | ||
<summary>JSON Structure for mp-1234</summary> | ||
<pre> | ||
<code> | ||
{struct_json} | ||
</code> | ||
</pre> | ||
</details> | ||
<style> | ||
form { | ||
display: flex; | ||
gap: 1em; | ||
position: relative; | ||
align-items: center; | ||
} | ||
details > pre { | ||
position: absolute; | ||
top: 2em; | ||
left: 0; | ||
background: black; | ||
width: calc(100cqw - 2em); | ||
z-index: 2; | ||
} | ||
</style> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"@module": "pymatgen.core.structure", "@class": "Structure", "charge": 0, "lattice": {"matrix": [[6.256930122878799, 0.0, 3.831264723736088e-16], [1.0061911048045417e-15, 6.256930122878799, 3.831264723736088e-16], [0.0, 0.0, 6.256930122878799]], "pbc": [true, true, true], "a": 6.256930122878799, "b": 6.256930122878799, "c": 6.256930122878799, "alpha": 90.0, "beta": 90.0, "gamma": 90.0, "volume": 244.95364960649798}, "sites": [{"species": [{"element": "Cs", "occu": 1}], "abc": [0.0, 0.0, 0.0], "xyz": [0.0, 0.0, 0.0], "label": "Cs", "properties": {}}, {"species": [{"element": "Cs", "occu": 1}], "abc": [0.5, 0.5, 0.5], "xyz": [3.1284650614394, 3.1284650614393996, 3.1284650614394], "label": "Cs", "properties": {}}]} |
Oops, something went wrong.