Skip to content

Commit d8b1ffc

Browse files
authored
Merge pull request #267 from IFRCGo/feature/improve-dref-export
Improve dref application export
2 parents b7d0f9e + fc02f19 commit d8b1ffc

File tree

24 files changed

+1483
-1792
lines changed

24 files changed

+1483
-1792
lines changed

src/components/Button/styles.module.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@
140140
&.dropdown-item {
141141
display: flex;
142142
width: 100%;
143+
text-align: left;
143144
--border-radius: unset;
144145
--padding: var(--go-ui-spacing-sm) var(--go-ui-spacing-lg);
145146

src/components/domain/BlockTextOutput/index.tsx

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

src/components/domain/BlockTextOutput/styles.module.css

Lines changed: 0 additions & 11 deletions
This file was deleted.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { _cs } from '@togglecorp/fujs';
2+
3+
import Heading, { type HeadingLevel } from '#components/printable/Heading';
4+
import styles from './styles.module.css';
5+
6+
interface Props {
7+
heading?: React.ReactNode;
8+
headingLevel?: HeadingLevel;
9+
children?: React.ReactNode;
10+
childrenContainerClassName?: string;
11+
}
12+
13+
function Container(props: Props) {
14+
const {
15+
heading,
16+
headingLevel = 3,
17+
children,
18+
childrenContainerClassName,
19+
} = props;
20+
21+
return (
22+
<>
23+
{heading && (
24+
<Heading level={headingLevel}>
25+
{heading}
26+
</Heading>
27+
)}
28+
<div className={_cs(styles.content, childrenContainerClassName)}>
29+
{children}
30+
</div>
31+
</>
32+
);
33+
}
34+
35+
export default Container;
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.content {
2+
margin-bottom: var(--go-ui-spacing-lg);
3+
4+
.content {
5+
&:last-child {
6+
margin-bottom: unset;
7+
}
8+
}
9+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import { _cs } from '@togglecorp/fujs';
2+
3+
import styles from './styles.module.css';
4+
5+
export type HeadingLevel = 1 | 2 | 3 | 4 | 5 | 6;
6+
7+
const levelToClassName: Record<HeadingLevel, string> = {
8+
1: styles.levelOne,
9+
2: styles.levelTwo,
10+
3: styles.levelThree,
11+
4: styles.levelFour,
12+
5: styles.levelFive,
13+
6: styles.levelSix,
14+
};
15+
16+
interface Props {
17+
className?: string;
18+
children?: React.ReactNode;
19+
level?: HeadingLevel;
20+
}
21+
22+
function Heading(props: Props) {
23+
const {
24+
className,
25+
level = 3,
26+
children,
27+
} = props;
28+
29+
const HeadingEl = `h${level}` as React.ElementType;
30+
31+
return (
32+
<HeadingEl className={_cs(styles.heading, levelToClassName[level], className)}>
33+
{children}
34+
</HeadingEl>
35+
);
36+
}
37+
38+
export default Heading;
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
.heading {
2+
--font-size: var(--go-ui-font-size-xl);
3+
4+
margin: 0 0 var(--go-ui-spacing-sm) 0;
5+
font-family: Montserrat, sans-serif;
6+
font-size: var(--font-size);
7+
font-weight: var(--go-ui-font-weight-bold);
8+
page-break-after: avoid;
9+
10+
&.level-one {
11+
--font-size: var(--go-ui-font-size-4xl);
12+
color: var(--go-ui-color-primary-red);
13+
}
14+
15+
&.level-two {
16+
--font-size: var(--go-ui-font-size-3xl);
17+
color: var(--go-ui-color-primary-blue);
18+
}
19+
20+
&.level-three {
21+
--font-size: var(--go-ui-font-size-xl);
22+
color: var(--go-ui-color-primary-red);
23+
}
24+
25+
&.level-four {
26+
--font-size: var(--go-ui-font-size-lg);
27+
}
28+
29+
&.level-five {
30+
--font-size: var(--go-ui-font-size-md);
31+
}
32+
33+
&.level-six {
34+
--font-size: var(--go-ui-font-size-sm);
35+
}
36+
}
37+
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
import { useCallback, useState } from 'react';
2+
import {
3+
_cs,
4+
isDefined,
5+
isFalsyString,
6+
isTruthyString,
7+
} from '@togglecorp/fujs';
8+
9+
import styles from './styles.module.css';
10+
11+
interface Props {
12+
src?: string;
13+
alt?: string;
14+
caption?: React.ReactNode;
15+
imgElementClassName?: string;
16+
}
17+
18+
function Image(props: Props) {
19+
const {
20+
src,
21+
alt,
22+
caption,
23+
imgElementClassName,
24+
} = props;
25+
26+
const [errored, setErrored] = useState(false);
27+
28+
const handleImageError = useCallback(
29+
() => {
30+
setErrored(true);
31+
},
32+
[],
33+
);
34+
35+
const handleImageLoad = useCallback(
36+
() => {
37+
setErrored(false);
38+
},
39+
[],
40+
);
41+
42+
if (isFalsyString(src)) {
43+
return null;
44+
}
45+
46+
const hasCaption = typeof caption === 'string' ? isTruthyString(caption) : isDefined(caption);
47+
48+
return (
49+
<figure className={_cs(styles.image, errored && styles.errored)}>
50+
{errored && (
51+
<div className={_cs(styles.imgError, imgElementClassName)}>
52+
Image not available!
53+
</div>
54+
)}
55+
<img
56+
onError={handleImageError}
57+
onLoad={handleImageLoad}
58+
className={_cs(styles.imgElement, imgElementClassName)}
59+
src={src}
60+
alt={alt}
61+
/>
62+
{hasCaption && (
63+
<figcaption className={styles.caption}>
64+
{caption}
65+
</figcaption>
66+
)}
67+
</figure>
68+
);
69+
}
70+
71+
export default Image;

0 commit comments

Comments
 (0)