Skip to content

Commit c44b9fd

Browse files
committed
Add preferred width to Popup
- Use preferred with for the navbar popups - Use condensed spacing on risk event list
1 parent d84eb21 commit c44b9fd

File tree

11 files changed

+33
-17
lines changed

11 files changed

+33
-17
lines changed

src/components/DropdownMenu/index.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import styles from './styles.module.css';
2121
export interface Props {
2222
className?: string;
2323
popupClassName?: string;
24+
preferredPopupWidth?: number;
2425
children?: React.ReactNode;
2526
label?: React.ReactNode;
2627
activeClassName?: string;
@@ -50,6 +51,7 @@ function DropdownMenu(props: Props) {
5051
componentRef,
5152
elementRef: buttonRef = newButtonRef,
5253
persistent,
54+
preferredPopupWidth,
5355
} = props;
5456

5557
const dropdownRef = useRef<HTMLDivElement>(null);
@@ -135,6 +137,7 @@ function DropdownMenu(props: Props) {
135137
elementRef={dropdownRef}
136138
className={_cs(styles.dropdownContent, popupClassName)}
137139
parentRef={buttonRef}
140+
preferredWidth={preferredPopupWidth}
138141
>
139142
{children}
140143
</Popup>

src/components/Navbar/CountryDropdown/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ function CountryDropdown() {
102102
variant="tertiary"
103103
popupClassName={styles.dropdown}
104104
persistent
105+
preferredPopupWidth={56}
105106
>
106107
{isEmpty && (
107108
<Message
@@ -176,6 +177,7 @@ function CountryDropdown() {
176177
urlParams={{ countryId: id }}
177178
variant="tertiary"
178179
withLinkIcon
180+
className={styles.countryLink}
179181
>
180182
{name}
181183
</DropdownMenuItem>

src/components/Navbar/CountryDropdown/styles.module.css

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
display: flex;
33
flex-direction: row;
44
padding: var(--go-ui-spacing-md);
5-
width: calc(100% - var(--go-ui-spacing-md) * 2)!important;
65
max-width: 64rem;
76
min-height: 16rem;
87
gap: var(--go-ui-spacing-md);
@@ -37,6 +36,10 @@
3736
grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
3837
grid-gap: var(--go-ui-spacing-sm);
3938
overflow: auto;
39+
40+
.country-link {
41+
font-size: var(--go-ui-font-size-sm);
42+
}
4043
}
4144
}
4245
}

src/components/Navbar/index.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ import TabPanel from '#components/Tabs/TabPanel';
1919

2020
import AuthenticatedUserDropdown from './AuthenticatedUserDropdown';
2121
import LangaugeDropdown from './LanguageDropdown';
22+
import CountryDropdown from './CountryDropdown';
2223
import i18n from './i18n.json';
2324
import styles from './styles.module.css';
24-
import CountryDropdown from './CountryDropdown';
2525

2626
interface Props {
2727
className?: string;
@@ -135,6 +135,7 @@ function Navbar(props: Props) {
135135
label={strings.userMenuPrepare}
136136
variant="tertiary"
137137
persistent
138+
preferredPopupWidth={56}
138139
>
139140
<Tabs
140141
value={activePrepareOption}
@@ -252,6 +253,7 @@ function Navbar(props: Props) {
252253
label={strings.userMenuRespondLabel}
253254
variant="tertiary"
254255
persistent
256+
preferredPopupWidth={56}
255257
>
256258
<Tabs
257259
value={activeRespondOption}
@@ -398,6 +400,7 @@ function Navbar(props: Props) {
398400
label={strings.userMenuLearnLabel}
399401
variant="tertiary"
400402
persistent
403+
preferredPopupWidth={56}
401404
>
402405
<Tabs
403406
value={activeLearnOption}

src/components/Navbar/styles.module.css

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
display: flex;
33
flex-direction: row;
44
padding: var(--go-ui-spacing-md);
5-
width: calc(100% - var(--go-ui-spacing-md) * 2)!important;
65
max-width: 32rem;
76
min-height: 16rem;
87
gap: var(--go-ui-spacing-md);

src/components/Popup/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ interface Props {
1111
elementRef?: React.RefObject<HTMLDivElement>;
1212
parentRef: React.RefObject<HTMLElement | undefined>;
1313
children?: React.ReactNode;
14+
preferredWidth?: number;
1415
}
1516

1617
function Popup(props: Props) {
@@ -20,14 +21,15 @@ function Popup(props: Props) {
2021
children,
2122
className,
2223
pointerClassName,
24+
preferredWidth,
2325
} = props;
2426

2527
const {
2628
content,
2729
pointer,
2830
width,
2931
orientation,
30-
} = useFloatPlacement(parentRef);
32+
} = useFloatPlacement(parentRef, preferredWidth);
3133

3234
return (
3335
<Portal>

src/components/domain/RiskImminentEvents/Gdacs/EventListItem/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ function EventListItem(props: Props) {
3232
return (
3333
<Header
3434
className={styles.eventListItem}
35-
heading={hazard_name}
35+
heading={hazard_name ?? '--'}
3636
headingLevel={5}
3737
actions={(
3838
<Button
@@ -44,7 +44,7 @@ function EventListItem(props: Props) {
4444
<ChevronRightLineIcon className={styles.icon} />
4545
</Button>
4646
)}
47-
spacing="compact"
47+
spacing="condensed"
4848
>
4949
<TextOutput
5050
label={strings.gdacsEventStartedOn}

src/components/domain/RiskImminentEvents/MeteoSwiss/EventListItem/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ function EventListItem(props: Props) {
3636
return (
3737
<Header
3838
className={styles.eventListItem}
39-
heading={hazardName}
39+
heading={hazardName ?? '--'}
4040
headingLevel={5}
4141
actions={(
4242
<Button
@@ -48,7 +48,7 @@ function EventListItem(props: Props) {
4848
<ChevronRightLineIcon className={styles.icon} />
4949
</Button>
5050
)}
51-
spacing="compact"
51+
spacing="condensed"
5252
>
5353
<TextOutput
5454
label={strings.meteoSwissEventListStartedOn}

src/components/domain/RiskImminentEvents/Pdc/EventListItem/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ function EventListItem(props: Props) {
3232
return (
3333
<Header
3434
className={styles.eventListItem}
35-
heading={hazard_name}
35+
heading={hazard_name ?? '--'}
3636
headingLevel={5}
3737
actions={(
3838
<Button
@@ -44,6 +44,7 @@ function EventListItem(props: Props) {
4444
<ChevronRightLineIcon className={styles.icon} />
4545
</Button>
4646
)}
47+
spacing="condensed"
4748
>
4849
<TextOutput
4950
label={strings.eventListStartedOn}

src/components/domain/RiskImminentEvents/WfpAdam/EventListItem/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ function EventListItem(props: Props) {
3232
return (
3333
<Header
3434
className={styles.eventListItem}
35-
heading={title}
35+
heading={title ?? '--'}
3636
headingLevel={5}
3737
actions={(
3838
<Button
@@ -44,7 +44,7 @@ function EventListItem(props: Props) {
4444
<ChevronRightLineIcon className={styles.icon} />
4545
</Button>
4646
)}
47-
spacing="compact"
47+
spacing="condensed"
4848
>
4949
<TextOutput
5050
label={strings.wfpEventListPublishedOn}

0 commit comments

Comments
 (0)