Skip to content

Commit 80562a3

Browse files
authored
feat(slot): support topbar.about_us.modal slot with fallback (#3676)
* update nmrium repository link in about us dialog
1 parent 60c6686 commit 80562a3

4 files changed

Lines changed: 96 additions & 68 deletions

File tree

package-lock.json

Lines changed: 22 additions & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@
6666
"@emotion/styled": "^11.14.1",
6767
"@hookform/resolvers": "^5.2.1",
6868
"@zakodium/nmr-types": "^0.1.1",
69-
"@zakodium/nmrium-core": "^0.1.6",
70-
"@zakodium/nmrium-core-plugins": "^0.1.9",
69+
"@zakodium/nmrium-core": "^0.1.7",
70+
"@zakodium/nmrium-core-plugins": "^0.1.10",
7171
"@zip.js/zip.js": "^2.7.72",
7272
"cheminfo-font": "^1.13.1",
7373
"cheminfo-types": "^1.8.1",
@@ -152,4 +152,4 @@
152152
"volta": {
153153
"node": "24.5.0"
154154
}
155-
}
155+
}

src/component/modal/aboutUs/AboutUsModal.tsx

Lines changed: 59 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ import { SvgLogoNmrium } from 'cheminfo-font';
44
import { Toolbar, useOnOff } from 'react-science/ui';
55

66
import versionInfo from '../../../versionInfo.js';
7+
import { useCore } from '../../context/CoreContext.js';
78
import Logo from '../../elements/Logo.js';
89
import { StyledDialogBody } from '../../elements/StyledDialogBody.js';
10+
import { renderCoreSlot } from '../../utility/renderCoreSlot.js';
911

1012
import AboutUsZakodium from './AboutUsZakodium.js';
1113

@@ -69,8 +71,60 @@ const Separator = styled.span`
6971
width: 15px;
7072
`;
7173

74+
const modalContentFallback = (
75+
<>
76+
<InfoBlock>
77+
<Logo width={160} height={50} />
78+
Version <VersionInfo />
79+
<Separator />
80+
<a
81+
href="https://github.com/cheminfo/nmrium"
82+
target="_blank"
83+
rel="noreferrer"
84+
>
85+
GitHub ( https://github.com/cheminfo/nmrium )
86+
</a>
87+
</InfoBlock>
88+
<InfoBlock>
89+
<Separator />
90+
</InfoBlock>
91+
<span className="content">
92+
This project is developed by Zakodium Sàrl (Switzerland), the University
93+
of Cologne (Germany), Johannes Gutenberg University Mainz (Germany) and
94+
Universidad del Valle (Colombia).
95+
</span>
96+
<InfoBlock>
97+
<Separator />
98+
<span className="title">Funding is provided by</span>
99+
<Separator />
100+
</InfoBlock>
101+
<div className="content">
102+
<ul>
103+
<li>
104+
IDNMR grant, which part of the Scientific Library Services and
105+
Information Systems (LIS) initiative of the DFG.
106+
</li>
107+
<li>
108+
<AboutUsZakodium />
109+
</li>
110+
<li>Universidad del Valle (Cali, Colombia).</li>
111+
<li>
112+
This project has received funding from the European Union’s Horizon
113+
2020 research and innovation programme under grant agreement No
114+
957189. The project is part of BATTERY 2030+, the large-scale European
115+
research initiative for inventing the sustainable batteries of the
116+
future.
117+
</li>
118+
</ul>
119+
</div>
120+
<Separator />
121+
</>
122+
);
123+
72124
function AboutUsModal() {
73125
const [isOpenDialog, openDialog, closeDialog] = useOnOff(false);
126+
const core = useCore();
127+
74128
return (
75129
<>
76130
<Toolbar.Item
@@ -91,47 +145,11 @@ function AboutUsModal() {
91145
>
92146
<CustomDialogBody>
93147
<Container>
94-
<InfoBlock>
95-
<Logo width={160} height={50} />
96-
Version <VersionInfo />
97-
<Separator />
98-
<a href="https://git.nmrium.org" target="_blank" rel="noreferrer">
99-
GitHub ( https://git.nmrium.org )
100-
</a>
101-
</InfoBlock>
102-
<InfoBlock>
103-
<Separator />
104-
</InfoBlock>
105-
<span className="content">
106-
This project is developed by Zakodium Sàrl (Switzerland), the
107-
University of Cologne (Germany), Johannes Gutenberg University
108-
Mainz (Germany) and Universidad del Valle (Colombia).
109-
</span>
110-
<InfoBlock>
111-
<Separator />
112-
<span className="title">Funding is provided by</span>
113-
<Separator />
114-
</InfoBlock>
115-
<div className="content">
116-
<ul>
117-
<li>
118-
IDNMR grant, which part of the Scientific Library Services and
119-
Information Systems (LIS) initiative of the DFG.
120-
</li>
121-
<li>
122-
<AboutUsZakodium />
123-
</li>
124-
<li>Universidad del Valle (Cali, Colombia).</li>
125-
<li>
126-
This project has received funding from the European Union’s
127-
Horizon 2020 research and innovation programme under grant
128-
agreement No 957189. The project is part of BATTERY 2030+, the
129-
large-scale European research initiative for inventing the
130-
sustainable batteries of the future.
131-
</li>
132-
</ul>
133-
</div>
134-
<Separator />
148+
{renderCoreSlot(
149+
core,
150+
'topbar.about_us.modal',
151+
modalContentFallback,
152+
)}
135153
</Container>
136154
</CustomDialogBody>
137155
</Dialog>
Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
11
import type { NMRiumCore, SupportedUISlot } from '@zakodium/nmrium-core';
22
import type { ReactNode } from 'react';
33

4+
/**
5+
* Render all components registered in the given slot.
6+
*
7+
* @param core
8+
* @param slot
9+
* @param fallback - return fallback if no component is registered in the slot
10+
*/
411
export function renderCoreSlot(
512
core: NMRiumCore,
613
slot: SupportedUISlot,
7-
): ReactNode[] {
8-
return Array.from(core.slot(slot), ([key, Component]) => (
14+
fallback?: ReactNode,
15+
): ReactNode {
16+
const jsx = Array.from(core.slot(slot), ([key, Component]) => (
917
<Component key={key} slot={slot} />
1018
));
19+
20+
return jsx.length > 0 ? jsx : fallback;
1121
}

0 commit comments

Comments
 (0)