diff --git a/.eslintrc.yml b/.eslintrc.yml deleted file mode 100644 index 994a328..0000000 --- a/.eslintrc.yml +++ /dev/null @@ -1,25 +0,0 @@ -env: - browser: true - node: true -extends: - - plugin:svelte/recommended - - eslint:recommended - - plugin:@typescript-eslint/recommended -overrides: - - files: ['*.svelte'] - parser: svelte-eslint-parser - parserOptions: - parser: '@typescript-eslint/parser' -rules: - indent: [error, 2, SwitchCase: 1] - '@typescript-eslint/quotes': [error, backtick, avoidEscape: true] - semi: [error, never] - linebreak-style: [error, unix] - no-console: [error, allow: [warn, error]] - no-var: error - '@typescript-eslint/no-inferrable-types': off - '@typescript-eslint/no-unused-vars': - [error, { argsIgnorePattern: ^_, varsIgnorePattern: ^_ }] - svelte/no-at-html-tags: off - no-inner-declarations: off -ignorePatterns: [build/, dist/] diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml index 5b6fb7a..71c41a3 100644 --- a/.github/workflows/gh-pages.yml +++ b/.github/workflows/gh-pages.yml @@ -10,3 +10,5 @@ on: jobs: build: uses: janosh/workflows/.github/workflows/nodejs-gh-pages.yml@main + with: + install-cmd: npm install --force diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d54ad54..4aba752 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -12,3 +12,5 @@ on: jobs: tests: uses: janosh/workflows/.github/workflows/npm-test-release.yml@main + with: + install-cmd: npm install --force diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2c9f298..d833663 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,11 +1,15 @@ ci: autoupdate_schedule: quarterly + skip: [eslint] default_install_hook_types: [pre-commit, commit-msg] +default_language_version: + node: '22.0.0' + repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 + rev: v4.6.0 hooks: - id: check-case-conflict - id: check-symlinks @@ -17,7 +21,7 @@ repos: - id: trailing-whitespace - repo: https://github.com/pre-commit/mirrors-prettier - rev: v3.0.1 + rev: v4.0.0-alpha.8 hooks: - id: prettier args: [--write] # edit files in-place @@ -29,7 +33,7 @@ repos: exclude: ^changelog.md|.*/(structures|molecules)/.*\.json|.py$ - repo: https://github.com/pre-commit/mirrors-eslint - rev: v8.46.0 + rev: v9.5.0 hooks: - id: eslint types: [file] @@ -37,16 +41,16 @@ repos: files: \.(js|ts|svelte)$ additional_dependencies: - eslint - - svelte - - typescript - eslint-plugin-svelte - - '@typescript-eslint/eslint-plugin' - - '@typescript-eslint/parser' + - svelte - svelte-eslint-parser + - typescript + - typescript-eslint - repo: https://github.com/codespell-project/codespell - rev: v2.2.5 + rev: v2.3.0 hooks: - id: codespell stages: [commit, commit-msg] - args: [--ignore-words-list, 'te,ba,nd,ore,claus', --check-filenames] + args: + [--ignore-words-list, 'te,ba,nd,ore,claus,manuel', --check-filenames] diff --git a/eslint.config.js b/eslint.config.js new file mode 100644 index 0000000..65ec3fb --- /dev/null +++ b/eslint.config.js @@ -0,0 +1,32 @@ +import svelte from 'eslint-plugin-svelte' +import tslint from 'typescript-eslint' + +/** @type { import("eslint").Linter.FlatConfig[] } */ +export default [ + ...tslint.configs.recommended, + ...svelte.configs[`flat/recommended`], + { + rules: { + '@typescript-eslint/no-unused-vars': [ + `error`, + { argsIgnorePattern: `^_`, varsIgnorePattern: `^_` }, + ], + '@typescript-eslint/quotes': [`error`, `backtick`, { avoidEscape: true }], + 'svelte/no-at-html-tags': `off`, + }, + }, + { + languageOptions: { ecmaVersion: 2020 }, + }, + { + files: [`**/*.svelte`], + languageOptions: { + parserOptions: { + parser: tslint.parser, + }, + }, + }, + { + ignores: [`build/`], + }, +] diff --git a/package.json b/package.json index 40ad6b9..0aa7a00 100644 --- a/package.json +++ b/package.json @@ -23,59 +23,58 @@ "update-coverage": "vitest tests/unit --run --coverage && npx istanbul-badges-readme" }, "dependencies": { - "@iconify/svelte": "^3.1.6", - "@sveltejs/kit": "^2.5.0", - "@threlte/core": "7.0.12", - "@threlte/extras": "8.3.0", - "d3": "^7.8.5", + "@iconify/svelte": "^4.0.2", + "@sveltejs/kit": "^2.5.17", + "@threlte/core": "7.3.1", + "d3": "^7.9.0", "d3-array": "^3.2.4", "d3-color": "^3.1.0", "d3-format": "^3.1.0", "d3-interpolate-path": "^2.3.0", "d3-scale": "^4.0.2", - "d3-scale-chromatic": "^3.0.0", + "d3-scale-chromatic": "^3.1.0", "d3-shape": "^3.2.0", "highlight.js": "^11.9.0", - "svelte": "4.2.9", - "svelte-multiselect": "^10.2.0", - "svelte-zoo": "^0.4.9", - "three": "^0.160.1" + "svelte": "4.2.18", + "svelte-multiselect": "^10.3.0", + "svelte-zoo": "^0.4.10", + "three": "^0.165.0" }, "devDependencies": { - "@playwright/test": "^1.41.1", - "@sveltejs/adapter-static": "3.0.1", - "@sveltejs/package": "^2.2.6", - "@sveltejs/vite-plugin-svelte": "^3.0.1", + "@playwright/test": "^1.45.0", + "@sveltejs/adapter-static": "3.0.2", + "@sveltejs/package": "^2.3.2", + "@sveltejs/vite-plugin-svelte": "^3.1.1", + "@threlte/extras": "8.11.4", "@types/d3-array": "^3.2.1", "@types/d3-color": "^3.1.3", "@types/d3-interpolate-path": "^2.0.3", "@types/d3-scale": "^4.0.8", "@types/d3-scale-chromatic": "^3.0.3", "@types/d3-shape": "^3.1.6", - "@types/three": "^0.160.0", - "@typescript-eslint/eslint-plugin": "^6.19.1", - "@typescript-eslint/parser": "^6.19.1", - "@vitest/coverage-v8": "^1.2.1", - "eslint": "^8.56.0", - "eslint-plugin-svelte": "^2.35.1", + "@types/three": "^0.165.0", + "@vitest/coverage-v8": "^1.6.0", + "eslint": "^9.5.0", + "eslint-plugin-svelte": "^2.41.0", "hastscript": "^9.0.0", - "jsdom": "^24.0.0", - "mdsvex": "^0.11.0", + "jsdom": "^24.1.0", + "mdsvex": "^0.11.2", "mdsvexamples": "^0.4.1", - "prettier": "^3.2.4", - "prettier-plugin-svelte": "^3.1.2", + "prettier": "^3.3.2", + "prettier-plugin-svelte": "^3.2.5", "rehype-autolink-headings": "^7.1.0", "rehype-katex-svelte": "^1.2.0", "rehype-slug": "^6.0.0", "remark-math": "3.0.0", - "sharp": "^0.33.2", - "svelte-check": "^3.6.3", - "svelte-preprocess": "^5.1.3", - "svelte-toc": "^0.5.7", - "svelte2tsx": "^0.7.0", - "typescript": "5.3.3", - "vite": "^5.0.12", - "vitest": "^1.2.1" + "sharp": "^0.33.4", + "svelte-check": "^3.8.4", + "svelte-preprocess": "^6.0.1", + "svelte-toc": "^0.5.9", + "svelte2tsx": "^0.7.13", + "typescript": "5.5.2", + "typescript-eslint": "^7.14.1", + "vite": "^5.3.2", + "vitest": "^1.6.0" }, "keywords": [ "svelte", diff --git a/src/lib/element/data.ts b/src/lib/element/data.ts index 8cbd334..e352426 100644 --- a/src/lib/element/data.ts +++ b/src/lib/element/data.ts @@ -3327,7 +3327,7 @@ export default [ atomic_mass: 190.233, category: `transition metal`, density: 22.59, - discoverer: `Smithson Tennant`, + discoverer: `Smithson Tennant`, // codespell:ignore molar_heat: 24.7, number: 76, period: 6, @@ -3370,7 +3370,7 @@ export default [ atomic_mass: 192.2173, category: `transition metal`, density: 22.56, - discoverer: `Smithson Tennant`, + discoverer: `Smithson Tennant`, // codespell:ignore molar_heat: 25.1, number: 77, period: 6, diff --git a/src/lib/structure/Lattice.svelte b/src/lib/structure/Lattice.svelte index 2f622c7..9c94ecd 100644 --- a/src/lib/structure/Lattice.svelte +++ b/src/lib/structure/Lattice.svelte @@ -5,7 +5,7 @@ import { BoxGeometry, Matrix4, Vector3 } from 'three' import Bond from './Bond.svelte' - export let matrix: [Vector, Vector, Vector] + export let matrix: [Vector, Vector, Vector] | undefined = undefined export let show_cell: 'surface' | 'wireframe' | null = `wireframe` // thickness of the wireframe lines that indicate the lattice's unit cell // due to limitations of OpenGL with WebGL renderer, on most platforms linewidth will be 1 regardless of set value @@ -13,7 +13,7 @@ export let cell_color: string = `white` export let cell_line_width: number = 1 // cell opacity - export let cell_opacity: number = 1 + export let cell_opacity: number | undefined = show_cell == `surface` ? 0.2 : 0.4 // whether to show the lattice vectors export let show_vectors: boolean = true // lattice vector colors @@ -21,46 +21,48 @@ // lattice vector origin (all arrows start from this point) export let vector_origin: Vector = [-1, -1, -1] - $: lattice_center = scale(add(...matrix), 0.5) + $: lattice_center = scale(add(...(matrix ?? [])), 0.5) -{#key matrix} - {#if show_cell} - {@const shear_matrix = new Matrix4().makeBasis( - ...matrix.map((vec) => new Vector3(...vec, 0)) - )} - {@const geometry = new BoxGeometry(1, 1, 1).applyMatrix4(shear_matrix)} - - - - {/if} +{#if matrix} + {#key matrix} + {#if show_cell} + {@const shear_matrix = new Matrix4().makeBasis( + ...matrix.map((vec) => new Vector3(...vec, 0)), + )} + {@const geometry = new BoxGeometry(1, 1, 1).applyMatrix4(shear_matrix)} + + + + {/if} - {#if show_vectors} - - - - - - {#each matrix as vec, idx} - - {/each} - + {#if show_vectors} + + + + + + {#each matrix as vec, idx} + + {/each} + - - - - - - {#each matrix as vec, idx} - - {/each} - - - {/if} -{/key} + + + + + + {#each matrix as vec, idx} + + {/each} + + + {/if} + {/key} +{/if} diff --git a/src/lib/structure/Structure.svelte b/src/lib/structure/Structure.svelte index e45f808..87d25b6 100644 --- a/src/lib/structure/Structure.svelte +++ b/src/lib/structure/Structure.svelte @@ -1,32 +1,23 @@ @@ -98,40 +113,59 @@ /> +{#if gizmo} + +{/if} + {#if show_atoms && structure?.sites} - - - - {#each structure.sites as site, idx} - {@const { species, xyz } = site} - {@const elem = species[0].element} + {#each structure.sites as site, site_idx} + {@const { species, xyz } = site} + {#each species as { element: elem, occu }, spec_idx} {@const radius = (same_size_atoms ? 1 : atomic_radii[elem]) * atom_radius} - { - hovered_idx = idx - }} - on:pointerleave={() => { - hovered_idx = null - }} - on:click={() => { - if (active_idx == idx) active_idx = null - else active_idx = idx - }} - scale={radius} - /> - + {@const start_angle = species + .slice(0, spec_idx) + .reduce((total, spec) => total + spec.occu, 0)} + + + { + hovered_idx = site_idx + }} + on:pointerleave={() => { + hovered_idx = null + }} + on:click={() => { + if (active_idx == site_idx) active_idx = null + else active_idx = site_idx + }} + scale={radius} + /> + {#if $$slots[`atom-label`]} - - + + {@const phi = 2 * Math.PI * (start_angle + occu / 2)} + {@const pos = add( + xyz, + scale([Math.cos(phi), 0, Math.sin(phi)], label_radius * radius), + )} + + {/if} {/each} - + {/each} {/if} {#if show_bonds} @@ -193,7 +227,7 @@ {/if} {#if structure?.lattice} - + {/if} diff --git a/src/routes/(demos)/structure/+page.md b/src/routes/(demos)/structure/+page.md index 91b4157..8f9cc16 100644 --- a/src/routes/(demos)/structure/+page.md +++ b/src/routes/(demos)/structure/+page.md @@ -1,7 +1,12 @@ @@ -14,7 +19,7 @@ import { structures } from '$site' import Select from 'svelte-multiselect' - let mp_id = `mp-756175` + let mp_id = `Bi2Zr2O7-Fm3m` let width let height $: href = `https://materialsproject.org/materials/${mp_id}` diff --git a/src/routes/acknowledgements/+page.md b/src/routes/acknowledgements/+page.md index 24243f3..9e2f5b8 100644 --- a/src/routes/acknowledgements/+page.md +++ b/src/routes/acknowledgements/+page.md @@ -30,9 +30,10 @@ Big thanks to the element image providers listed below. Each image caption links {#each Object.entries(img_sources) as [key, href]} {@const [number, name] = key.split(`-`)}
  • - - {name} {number} {name} + + {name} +
  • {/each} diff --git a/src/site/structures/Bi2Zr2O7-Fm3m.json b/src/site/structures/Bi2Zr2O7-Fm3m.json new file mode 100644 index 0000000..b1aa2e6 --- /dev/null +++ b/src/site/structures/Bi2Zr2O7-Fm3m.json @@ -0,0 +1 @@ +{ "@module": "pymatgen.core.structure", "@class": "Structure", "charge": 0.0, "lattice": { "matrix": [ [5.3485, 0.0, 3.275011702619809e-16], [-3.275011702619809e-16, 5.3485, 3.275011702619809e-16], [0.0, 0.0, 5.3485] ], "pbc": [true, true, true], "a": 5.3485, "b": 5.3485, "c": 5.3485, "alpha": 90.0, "beta": 90.0, "gamma": 90.0, "volume": 153.00160985912498 }, "properties": {}, "sites": [ { "species": [ { "element": "Bi", "oxidation_state": 3.0, "spin": null, "occu": 0.5 }, { "element": "Zr", "oxidation_state": 4.0, "spin": null, "occu": 0.5 } ], "abc": [0.0, 0.0, 0.0], "xyz": [0.0, 0.0, 0.0], "properties": {}, "label": "Zr" }, { "species": [ { "element": "Bi", "oxidation_state": 3.0, "spin": null, "occu": 0.5 }, { "element": "Zr", "oxidation_state": 4.0, "spin": null, "occu": 0.5 } ], "abc": [0.5, 0.5, 0.0], "xyz": [2.67425, 2.67425, 3.275011702619809e-16], "properties": {}, "label": "Zr" }, { "species": [ { "element": "Bi", "oxidation_state": 3.0, "spin": null, "occu": 0.5 }, { "element": "Zr", "oxidation_state": 4.0, "spin": null, "occu": 0.5 } ], "abc": [0.5, 0.0, 0.5], "xyz": [2.67425, 0.0, 2.67425], "properties": {}, "label": "Zr" }, { "species": [ { "element": "Bi", "oxidation_state": 3.0, "spin": null, "occu": 0.5 }, { "element": "Zr", "oxidation_state": 4.0, "spin": null, "occu": 0.5 } ], "abc": [0.0, 0.5, 0.5], "xyz": [-1.6375058513099044e-16, 2.67425, 2.67425], "properties": {}, "label": "Zr" }, { "species": [ { "element": "O", "oxidation_state": -2.0, "spin": null, "occu": 1 } ], "abc": [0.25, 0.25, 0.25], "xyz": [1.337125, 1.337125, 1.3371250000000001], "properties": {}, "label": "O" }, { "species": [ { "element": "O", "oxidation_state": -2.0, "spin": null, "occu": 1 } ], "abc": [0.75, 0.75, 0.25], "xyz": [4.011374999999999, 4.011374999999999, 1.3371250000000003], "properties": {}, "label": "O" }, { "species": [ { "element": "O", "oxidation_state": -2.0, "spin": null, "occu": 1 } ], "abc": [0.75, 0.75, 0.75], "xyz": [4.011374999999999, 4.011374999999999, 4.011375], "properties": {}, "label": "O" }, { "species": [ { "element": "O", "oxidation_state": -2.0, "spin": null, "occu": 1 } ], "abc": [0.75, 0.25, 0.75], "xyz": [4.011374999999999, 1.337125, 4.011375], "properties": {}, "label": "O" }, { "species": [ { "element": "O", "oxidation_state": -2.0, "spin": null, "occu": 1 } ], "abc": [0.75, 0.25, 0.25], "xyz": [4.011374999999999, 1.337125, 1.3371250000000001], "properties": {}, "label": "O" }, { "species": [ { "element": "O", "oxidation_state": -2.0, "spin": null, "occu": 1 } ], "abc": [0.25, 0.75, 0.75], "xyz": [1.3371249999999997, 4.011374999999999, 4.011375], "properties": {}, "label": "O" }, { "species": [ { "element": "O", "oxidation_state": -2.0, "spin": null, "occu": 1 } ], "abc": [0.25, 0.75, 0.25], "xyz": [1.3371249999999997, 4.011374999999999, 1.3371250000000001], "properties": {}, "label": "O" }, { "species": [ { "element": "O", "oxidation_state": -2.0, "spin": null, "occu": 1 } ], "abc": [0.25, 0.25, 0.75], "xyz": [1.337125, 1.337125, 4.011375], "properties": {}, "label": "O" } ] } diff --git a/svelte.config.js b/svelte.config.js index 771f0c3..76c9ef9 100644 --- a/svelte.config.js +++ b/svelte.config.js @@ -6,7 +6,7 @@ import math from 'remark-math' import preprocess from 'svelte-preprocess' const { default: pkg } = await import(`./package.json`, { - assert: { type: `json` }, + with: { type: `json` }, }) const defaults = { Wrapper: `svelte-zoo/CodeExample.svelte`,