Skip to content

Commit 3f2fdd2

Browse files
committed
frontend: fix breaking settings words
A long settings description can break the short settings value to 2 lines. Example: Root fingerprint has very long description and breaks the actual value (the fingerprint on the right) onto 2 lines. Introduced a new SettingsValue component that by default does not break onto multiple lines.
1 parent 6dbd295 commit 3f2fdd2

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed

frontends/web/src/routes/settings/components/device-settings/root-fingerprint-setting.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616

1717
import { useTranslation } from 'react-i18next';
18-
import { SettingsItem } from '../settingsItem/settingsItem';
18+
import { SettingsItem, SettingsValue } from '../settingsItem/settingsItem';
1919

2020
type TProps = {
2121
rootFingerprint: string;
@@ -27,7 +27,9 @@ const RootFingerprintSetting = ({ rootFingerprint }: TProps) => {
2727
<SettingsItem
2828
settingName={'Root fingerprint'}
2929
secondaryText={t('deviceSettings.deviceInformation.rootFingerprint.description')}
30-
displayedValue={rootFingerprint}
30+
displayedValue={
31+
<SettingsValue>{rootFingerprint}</SettingsValue>
32+
}
3133
/>
3234
);
3335
};

frontends/web/src/routes/settings/components/settingsItem/settingsItem.module.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@
5656
text-overflow: ellipsis;
5757
}
5858

59+
.nowrap {
60+
white-space: nowrap;
61+
}
62+
5963
@media (max-width: 768px) {
6064
.container {
6165
height: auto;

frontends/web/src/routes/settings/components/settingsItem/settingsItem.tsx

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import styles from './settingsItem.module.css';
2020
type TProps = {
2121
className?: string
2222
collapseOnSmall?: boolean;
23-
displayedValue?: string;
23+
displayedValue?: string | ReactNode;
2424
extraComponent?: ReactNode;
2525
hideDisplayedValueOnSmall?: boolean;
2626
onClick?: () => void;
@@ -84,3 +84,18 @@ export const SettingsItem = ({
8484
</>
8585
);
8686
};
87+
88+
type TSettingsValueProps = {
89+
children: ReactNode;
90+
wrap?: boolean;
91+
}
92+
93+
export const SettingsValue = ({
94+
children,
95+
wrap,
96+
}: TSettingsValueProps) => {
97+
const classNames = wrap ? '' : styles.nowrap;
98+
return (
99+
<span className={classNames}>{children}</span>
100+
);
101+
};

0 commit comments

Comments
 (0)