Skip to content

Commit 7ccfc39

Browse files
committed
structurevisualiser improvements
1 parent 6dac1c1 commit 7ccfc39

6 files changed

Lines changed: 281 additions & 245 deletions

File tree

src/AiidaExplorer/VisualiserPane/Rich/KpointsDataVisualiser/index.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ export default function KpointsDataVisualiser({ nodeData = {} }) {
174174

175175
{/* Tables in cards */}
176176
<div className="ae:@container">
177-
{/* Small 1 col >xl 2 col */}
177+
{/* <xl=1col, >xl=2col */}
178178
<div className="ae:grid ae:grid-cols-1 ae:@xl:grid-cols-2">
179179
{tables.map(({ title, columns, data }) => (
180180
<DataTable

src/AiidaExplorer/VisualiserPane/Rich/StructureDataVisualiser.jsx

Lines changed: 0 additions & 180 deletions
This file was deleted.

src/AiidaExplorer/components/StructDownloadButton/index.jsx renamed to src/AiidaExplorer/VisualiserPane/Rich/StructureDataVisualiser/StructDownloadButton.jsx

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
11
import React, { useState, useRef, useEffect } from "react";
2-
import "./StructDownloadButton.css";
32

43
const defaultFormats = [
54
{ format: "cif", label: "CIF" },
65
{ format: "xsf", label: "XSF" },
76
{ format: "xyz", label: "XYZ" },
87
];
98

10-
// one to one copy of the MCXD StructDownloadButton (w/css in .css file)
119
export function StructDownloadButton(props) {
1210
const dl_url = `${props.aiida_rest_url}/nodes/${props.uuid}/download`;
1311
const downloadFormats = props.download_formats || defaultFormats;
1412

1513
const [open, setOpen] = useState(false);
1614
const ref = useRef(null);
1715

16+
// Close menu when clicking outside
1817
useEffect(() => {
1918
function handleClick(e) {
2019
if (ref.current && !ref.current.contains(e.target)) {
@@ -26,12 +25,14 @@ export function StructDownloadButton(props) {
2625
}, []);
2726

2827
return (
29-
<div ref={ref} className="download-wrapper">
28+
<div ref={ref} className="ae:relative ae:inline-block">
29+
{/* Download button */}
3030
<button
3131
type="button"
32-
className="download-button"
3332
title="Download"
3433
onClick={() => setOpen(!open)}
34+
className="ae:bg-blue-600 ae:text-white ae:text-xs ae:px-1 ae:py-1 ae:rounded-md ae:cursor-pointer
35+
ae:hover:bg-blue-800 ae:focus:bg-blue-700 ae:focus:ring-3 ae:focus:ring-[#2563eb4d]"
3536
>
3637
<svg
3738
xmlns="http://www.w3.org/2000/svg"
@@ -40,7 +41,7 @@ export function StructDownloadButton(props) {
4041
viewBox="0 0 24 24"
4142
fill="none"
4243
stroke="currentColor"
43-
strokeWidth="1"
44+
strokeWidth="1.25"
4445
strokeLinecap="round"
4546
strokeLinejoin="round"
4647
>
@@ -50,16 +51,23 @@ export function StructDownloadButton(props) {
5051
</svg>
5152
</button>
5253

54+
{/* Dropdown menu */}
5355
{open && (
54-
<div className="download-menu-container">
55-
<ul className="download-menu">
56-
{downloadFormats.map(({ format, label }) => (
57-
<li key={format}>
58-
<a href={`${dl_url}?download_format=${format}`}>{label}</a>
59-
</li>
60-
))}
61-
</ul>
62-
</div>
56+
<ul
57+
className="ae:absolute ae:top-full ae:left-1/2 ae:-translate-x-1/2 ae:mt-1 ae:min-w-max
58+
ae:border ae:border-gray-200 ae:rounded-md ae:shadow-md text-sm z-50"
59+
>
60+
{downloadFormats.map(({ format, label }) => (
61+
<li key={format}>
62+
<a
63+
href={`${dl_url}?download_format=${format}`}
64+
className="ae:block ae:px-3 ae:py-1 ae:text-gray-900 ae:hover:bg-gray-100 ae:whitespace-nowrap"
65+
>
66+
{label}
67+
</a>
68+
</li>
69+
))}
70+
</ul>
6371
)}
6472
</div>
6573
);

0 commit comments

Comments
 (0)