Skip to content

Commit 77e2705

Browse files
frano-mFran McDade
andauthored
feat: update the guide to indicate study data export is currently disabled by default (#4103) (#4104)
Co-authored-by: Fran McDade <franmcdade@Frans-MacBook-Pro.local>
1 parent 8bfc55d commit 77e2705

34 files changed

Lines changed: 240 additions & 307 deletions

File tree

explorer/app/components/common/MDXContent/components/HelpIconButton/helpIconButton.tsx renamed to explorer/app/components/Layout/components/Content/components/HelpIconButton/helpIconButton.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,19 @@ import {
33
HelpIconButtonProps as DXHelpIconButtonProps,
44
} from "@databiosphere/findable-ui/lib/components/common/Button/components/HelpIconButton/helpIconButton";
55
import { useConfig } from "@databiosphere/findable-ui/lib/hooks/useConfig";
6-
import { getURL } from "../../../../../../mdx-components";
7-
import { SiteConfig } from "../../../../../../site-config/common/entities";
6+
import { SiteConfig } from "../../../../../../../site-config/common/entities";
7+
import { replaceParameters } from "../Link/common/utils";
88

99
export const HelpIconButton = ({
1010
url,
1111
...props
1212
}: DXHelpIconButtonProps): JSX.Element => {
1313
const { config } = useConfig();
14-
const { browserURL, portalURL } = config as SiteConfig;
14+
const { browserURL, portalURL = "{portalURL}" } = config as SiteConfig;
1515
return (
16-
<DXHelpIconButton url={getURL(url, browserURL, portalURL)} {...props} />
16+
<DXHelpIconButton
17+
url={replaceParameters(url, { browserURL, portalURL })}
18+
{...props}
19+
/>
1720
);
1821
};
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export interface Parameter {
2+
[key: string]: string;
3+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { Parameter } from "./entities";
2+
3+
/**
4+
* Replaces parameters in the given URL string e.g. {portalURL} with the corresponding value.
5+
* @param str - URL string, with parameters.
6+
* @param parameter - Parameter.
7+
* @returns string with parameters replaced.
8+
*/
9+
export function replaceParameters(str: string, parameter: Parameter): string {
10+
const decodedUrl = decodeURI(str);
11+
const result = Object.entries(parameter).reduce(
12+
(acc, [parameterKey, parameterValue]) => {
13+
const regex = new RegExp(`\\{${parameterKey}}`, "g");
14+
return acc.replace(regex, parameterValue);
15+
},
16+
decodedUrl
17+
);
18+
if (/{\w+}/.test(result)) {
19+
throw new Error(`URL still contains path parameters: ${result}`);
20+
}
21+
return result;
22+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { TypographyWordBreak } from "@databiosphere/findable-ui/lib/components/common/Typography/TypographyWordBreak/TypographyWordBreak";
2+
import { Link as DXLink } from "@databiosphere/findable-ui/lib/components/Links/components/Link/link";
3+
import { useConfig } from "@databiosphere/findable-ui/lib/hooks/useConfig";
4+
import { SiteConfig } from "../../../../../../../site-config/common/entities";
5+
import { replaceParameters } from "./common/utils";
6+
7+
/**
8+
* Basic anchor link component, used by MDX for all anchor links.
9+
* Takes in children and href as props, and passes them to the DXLink component.
10+
*/
11+
12+
export const Link = ({
13+
...props /* Spread props to allow for anchor link specific props e.g. "href". */
14+
}): JSX.Element => {
15+
const { children, href, ...linkProps } = props;
16+
const { config } = useConfig();
17+
const { browserURL, portalURL = "{portalURL}" } = config as SiteConfig;
18+
return (
19+
<DXLink
20+
label={<TypographyWordBreak>{children}</TypographyWordBreak>}
21+
url={replaceParameters(href, {
22+
browserURL,
23+
portalURL,
24+
})}
25+
{...linkProps}
26+
/>
27+
);
28+
};
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
import {
2+
textBodyLarge4002Lines,
3+
textBodyLarge500,
4+
textHeading,
5+
textHeadingLarge,
6+
textHeadingSmall,
7+
} from "@databiosphere/findable-ui/lib/styles/common/mixins/fonts";
8+
import { ThemeProps } from "@databiosphere/findable-ui/lib/theme/theme";
9+
import { css } from "@emotion/react";
10+
import styled from "@emotion/styled";
11+
12+
const muiAlert = (props: ThemeProps) => css`
13+
.MuiAlert-root {
14+
margin: 24px 0;
15+
16+
&.MuiAlert-standardWarning {
17+
margin: 16px 0;
18+
}
19+
20+
&:last-child {
21+
margin-bottom: 0;
22+
}
23+
24+
.MuiAlert-message {
25+
${textBodyLarge4002Lines(props)};
26+
}
27+
28+
.MuiAlert-message:first-of-type {
29+
gap: 16px;
30+
31+
.MuiAlertTitle-root {
32+
${textHeadingSmall(props)};
33+
}
34+
}
35+
}
36+
`;
37+
38+
const muiBreadcrumbs = () => css`
39+
.MuiBreadcrumbs-root {
40+
margin-bottom: 8px;
41+
42+
.MuiBreadcrumbs-li {
43+
margin: 0;
44+
45+
.MuiLink-root {
46+
text-decoration: none;
47+
48+
&:hover {
49+
text-decoration: underline;
50+
}
51+
}
52+
53+
.MuiTypography-root {
54+
margin: 0;
55+
}
56+
}
57+
}
58+
`;
59+
60+
export const Content = styled.div`
61+
a {
62+
color: inherit;
63+
text-decoration: underline;
64+
65+
&:hover {
66+
text-decoration: none;
67+
}
68+
}
69+
70+
h1 {
71+
${textHeadingLarge};
72+
margin: 0 0 16px;
73+
}
74+
75+
h2 {
76+
${textHeading};
77+
margin: 32px 0 16px;
78+
}
79+
80+
h3 {
81+
${textHeadingSmall};
82+
margin: 40px 0 16px;
83+
}
84+
85+
h4 {
86+
${textBodyLarge500};
87+
margin: 16px 0;
88+
}
89+
90+
h1,
91+
h2,
92+
h3,
93+
h4,
94+
h5,
95+
h6 {
96+
&:hover {
97+
a {
98+
opacity: 1;
99+
}
100+
}
101+
}
102+
103+
p {
104+
${textBodyLarge4002Lines};
105+
margin: 0 0 16px;
106+
107+
&:last-of-type {
108+
margin-bottom: 0;
109+
}
110+
}
111+
112+
ul {
113+
${textBodyLarge4002Lines};
114+
margin: 16px 0;
115+
padding: 0 0 0 24px;
116+
117+
li {
118+
margin: 8px 0;
119+
}
120+
}
121+
122+
${muiAlert};
123+
${muiBreadcrumbs};
124+
`;
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { ReactNode } from "react";
2+
import { Content as MDXContent } from "./content.styles";
3+
4+
export interface ContentProps {
5+
children: ReactNode | ReactNode[];
6+
}
7+
8+
export const Content = ({ children }: ContentProps): JSX.Element => {
9+
return <MDXContent>{children}</MDXContent>;
10+
};

explorer/app/components/common/Content/components/Breadcrumbs/breadcrumbs.styles.ts

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

explorer/app/components/common/Content/components/ContentTheme/contentTheme.tsx

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

explorer/app/components/common/Content/components/Link/link.styles.ts

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

explorer/app/components/common/Content/components/Link/link.tsx

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

0 commit comments

Comments
 (0)