Skip to content

Commit 4b986b1

Browse files
committed
fix: js library ui
1 parent 316e098 commit 4b986b1

File tree

2 files changed

+22
-13
lines changed

2 files changed

+22
-13
lines changed

client/packages/openblocks/src/components/JSLibraryModal.tsx

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import { LoadingOutlined } from "@ant-design/icons";
2222
import { RecommendedJSLibraryMeta } from "api/jsLibraryApi";
2323
import log from "loglevel";
2424
import { TacoMarkDown } from "components/markdown";
25-
import { HelpText } from "components/HelpText";
2625

2726
const ModalLabel = styled.div`
2827
display: flex;
@@ -209,6 +208,13 @@ const Error = (props: {
209208
</ErrorWrapper>
210209
);
211210

211+
const HelpText = styled(TacoMarkDown)`
212+
font-size: 13px;
213+
color: ${GreyTextColor};
214+
margin: 8px 0;
215+
line-height: 13px;
216+
`;
217+
212218
interface JSLibraryModalProps {
213219
trigger: ReactNode;
214220
runInHost: boolean;
@@ -268,9 +274,7 @@ export function JSLibraryModal(props: JSLibraryModalProps) {
268274
width="648px"
269275
>
270276
<div style={{ lineHeight: "10px" }}>URL</div>
271-
<HelpText style={{ lineHeight: "13px", margin: "8px 0 " }}>
272-
{trans("preLoad.urlTooltip")}
273-
</HelpText>
277+
<HelpText>{trans("preLoad.urlTooltip")}</HelpText>
274278
<InputWrapper>
275279
<Input
276280
status={urlError || installError ? "error" : undefined}
@@ -326,12 +330,16 @@ export function JSLibraryModal(props: JSLibraryModalProps) {
326330
/>
327331
)}
328332

329-
<div style={{ marginTop: "24px" }}>{trans("preLoad.recommended")}</div>
330-
<JSLibraryRecommends>
331-
{recommends.map((r, idx) => (
332-
<JSLibraryCard key={idx} meta={r} {...props} setError={setInstallError} />
333-
))}
334-
</JSLibraryRecommends>
333+
{recommends.length > 0 && (
334+
<>
335+
<div style={{ marginTop: "24px" }}>{trans("preLoad.recommended")}</div>
336+
<JSLibraryRecommends>
337+
{recommends.map((r, idx) => (
338+
<JSLibraryCard key={idx} meta={r} {...props} setError={setInstallError} />
339+
))}
340+
</JSLibraryRecommends>
341+
</>
342+
)}
335343
</CustomModal>
336344
</div>
337345
);

client/packages/openblocks/src/i18n/locales/en.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1921,7 +1921,8 @@ export const en = {
19211921
jsLibraryHelpText:
19221922
"Add JavaScript libraries to your current application via URL addresses. lodash, moment, uuid, numbro are built into the system for immediate use. JavaScript libraries are loaded before the application is initialized, which can have an impact on application performance.",
19231923
exportedAs: "Exported as",
1924-
urlTooltip: "URL address of the JavaScript library, unpkg.com or jsdelivr.net is recommended",
1924+
urlTooltip:
1925+
"URL address of the JavaScript library, [unpkg.com](https://unpkg.com/) or [jsdelivr.net](https://www.jsdelivr.com/) is recommended",
19251926
recommended: "Recommended",
19261927
viewJSLibraryDocument: "Document",
19271928
jsLibraryURLError: "Invalid URL",
@@ -1931,8 +1932,8 @@ export const en = {
19311932
jsLibraryInstallSuccess: "JavaScript library installed successfully",
19321933
jsLibraryInstallFailed: "JavaScript library installation failed",
19331934
jsLibraryInstallFailedCloud:
1934-
"JavaScript library installation failed. Perhaps the library is not available in the sandbox, [Documentation](https://docs.openblocks.dev/build-apps/write-javascript/use-third-party-libraries#manually-import-libraries)\n{message}",
1935-
jsLibraryInstallFailedHost: "JavaScript library installation failed\n{message}",
1935+
"Perhaps the library is not available in the sandbox, [Documentation](https://docs.openblocks.dev/build-apps/write-javascript/use-third-party-libraries#manually-import-libraries)\n{message}",
1936+
jsLibraryInstallFailedHost: "{message}",
19361937
add: "Add New",
19371938
jsHelpText: "Add a global method or variable to the current application.",
19381939
cssHelpText:

0 commit comments

Comments
 (0)