Skip to content

Commit bae136f

Browse files
Translate GuidePanel and HelpText, remove text from InternalHeader. (#3424)
Co-authored-by: Ken <[email protected]>
1 parent 53d1fe5 commit bae136f

File tree

9 files changed

+48
-20
lines changed

9 files changed

+48
-20
lines changed

.changeset/fair-countries-admire.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@navikt/ds-react": patch
3+
---
4+
5+
InternalHeader.UserButton: Remove `title`-attribute on icon and improved types.

@navikt/core/react/src/guide-panel/Illustration.tsx

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React, { SVGProps } from "react";
22
import { useId } from "../util/hooks";
3+
import { useI18n } from "../util/i18n/i18n.context";
34

45
interface SVGRProps {
56
title?: string;
@@ -15,6 +16,8 @@ export const DefaultIllustration: DefaultIllustrationType = ({
1516
titleId: _titleId,
1617
...props
1718
}) => {
19+
const translate = useI18n("GuidePanel");
20+
1821
let titleId: string | undefined = useId();
1922
titleId = title ? (_titleId ? _titleId : "title-" + titleId) : undefined;
2023

@@ -25,7 +28,7 @@ export const DefaultIllustration: DefaultIllustrationType = ({
2528
viewBox="0 0 56 85"
2629
fill="none"
2730
xmlns="http://www.w3.org/2000/svg"
28-
aria-label="NAV veileder illustrasjon"
31+
aria-label={translate("illustrationLabel")}
2932
focusable={false}
3033
role="img"
3134
aria-labelledby={titleId}

@navikt/core/react/src/help-text/HelpText.tsx

+8-6
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { Popover, PopoverProps } from "../popover";
44
import { UNSAFE_useAkselTheme } from "../provider";
55
import { composeEventHandlers } from "../util/composeEventHandlers";
66
import { useMergeRefs } from "../util/hooks/useMergeRefs";
7+
import { useI18n } from "../util/i18n/i18n.context";
78
import { HelpTextIcon } from "./HelpTextIcon";
89

910
export interface HelpTextProps
@@ -12,7 +13,7 @@ export interface HelpTextProps
1213
children: React.ReactNode;
1314
/**
1415
* Adds a title-tooltip with the given text
15-
* @default "hjelp"
16+
* @default "Mer informasjon"
1617
*/
1718
title?: string;
1819
/**
@@ -41,7 +42,7 @@ export const HelpText = forwardRef<HTMLButtonElement, HelpTextProps>(
4142
children,
4243
placement,
4344
strategy = "absolute",
44-
title = "hjelp",
45+
title,
4546
onClick,
4647
wrapperClassName,
4748
...rest
@@ -50,10 +51,11 @@ export const HelpText = forwardRef<HTMLButtonElement, HelpTextProps>(
5051
) => {
5152
const buttonRef = useRef<HTMLButtonElement | null>(null);
5253
const mergedRef = useMergeRefs(buttonRef, ref);
53-
5454
const [open, setOpen] = useState(false);
55-
5655
const themeContext = UNSAFE_useAkselTheme(false);
56+
const translate = useI18n("HelpText");
57+
58+
const titleWithFallback = title || translate("title");
5759

5860
return (
5961
<div className={cl("navds-help-text", wrapperClassName)}>
@@ -65,8 +67,8 @@ export const HelpText = forwardRef<HTMLButtonElement, HelpTextProps>(
6567
type="button"
6668
aria-expanded={open}
6769
>
68-
<HelpTextIcon title={title} />
69-
<HelpTextIcon filled title={title} />
70+
<HelpTextIcon title={titleWithFallback} />
71+
<HelpTextIcon filled title={titleWithFallback} />
7072
</button>
7173
<Popover
7274
onClose={() => setOpen(false)}

@navikt/core/react/src/internal-header/InternalHeaderButton.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import React, { forwardRef } from "react";
33
import { OverridableComponent } from "../util/types";
44

55
export interface InternalHeaderButtonProps
6-
extends React.AnchorHTMLAttributes<HTMLButtonElement> {
6+
extends React.ButtonHTMLAttributes<HTMLButtonElement> {
77
/**
88
* Application Button
99
*/

@navikt/core/react/src/internal-header/InternalHeaderUserButton.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { OverridableComponent } from "../util/types";
66
import InternalHeaderButton from "./InternalHeaderButton";
77

88
export interface InternalHeaderUserButtonProps
9-
extends React.AnchorHTMLAttributes<HTMLButtonElement> {
9+
extends React.ButtonHTMLAttributes<HTMLButtonElement> {
1010
/**
1111
* User name
1212
*/
@@ -33,7 +33,7 @@ export const InternalHeaderUserButton: OverridableComponent<
3333
</BodyShort>
3434
{description && <Detail as="div">{description}</Detail>}
3535
</div>
36-
<ChevronDownIcon title="vis meny" />
36+
<ChevronDownIcon aria-hidden />
3737
</InternalHeaderButton>
3838
));
3939

@navikt/core/react/src/internal-header/header.stories.tsx

+10-10
Original file line numberDiff line numberDiff line change
@@ -40,22 +40,22 @@ export const Default = {
4040
>
4141
<MenuGridIcon
4242
style={{ fontSize: "1.5rem" }}
43-
title="MenuGridIconer og oppslagsverk"
43+
title="Systemer og oppslagsverk"
4444
/>
4545
</InternalHeader.Button>
4646
<Dropdown.Menu strategy="fixed">
4747
<Dropdown.Menu.List>
4848
<Dropdown.Menu.List.Item>
4949
<span>A.Inntekt</span>
50-
<ExternalLinkIcon style={{ fontSize: "0.875rem" }} />
50+
<ExternalLinkIcon aria-hidden fontSize="0.875rem" />
5151
</Dropdown.Menu.List.Item>
5252
<Dropdown.Menu.List.Item>
5353
<span>Aa-registeret</span>
54-
<ExternalLinkIcon style={{ fontSize: "0.875rem" }} />
54+
<ExternalLinkIcon aria-hidden fontSize="0.875rem" />
5555
</Dropdown.Menu.List.Item>
5656
<Dropdown.Menu.List.Item>
5757
<span>Gosys</span>
58-
<ExternalLinkIcon style={{ fontSize: "0.875rem" }} />
58+
<ExternalLinkIcon aria-hidden fontSize="0.875rem" />
5959
</Dropdown.Menu.List.Item>
6060
</Dropdown.Menu.List>
6161
</Dropdown.Menu>
@@ -86,7 +86,7 @@ export const Default = {
8686
}}
8787
>
8888
<BodyShort title="Ola Normann">KH</BodyShort>
89-
<ChevronDownIcon />
89+
<ChevronDownIcon title="Brukermeny" />
9090
</InternalHeader.Button>
9191
<Dropdown.Menu strategy="fixed">
9292
<div>
@@ -172,7 +172,7 @@ export const UserWithMenu = () => (
172172
}}
173173
>
174174
<BodyShort title="Ola Normann">KH</BodyShort>
175-
<ChevronDownIcon />
175+
<ChevronDownIcon title="Brukermeny" />
176176
</InternalHeader.Button>
177177
<Dropdown.Menu strategy="fixed">
178178
<div>
@@ -208,22 +208,22 @@ export const UserWithMenuGridIconMenu = () => (
208208
>
209209
<MenuGridIcon
210210
style={{ fontSize: "1.5rem" }}
211-
title="MenuGridIconer og oppslagsverk"
211+
title="Systemer og oppslagsverk"
212212
/>
213213
</InternalHeader.Button>
214214
<Dropdown.Menu strategy="fixed">
215215
<Dropdown.Menu.List>
216216
<Dropdown.Menu.List.Item>
217217
<span>A.Inntekt</span>
218-
<ExternalLinkIcon style={{ fontSize: "0.875rem" }} />
218+
<ExternalLinkIcon aria-hidden fontSize="0.875rem" />
219219
</Dropdown.Menu.List.Item>
220220
<Dropdown.Menu.List.Item>
221221
<span>Aa-registeret</span>
222-
<ExternalLinkIcon style={{ fontSize: "0.875rem" }} />
222+
<ExternalLinkIcon aria-hidden fontSize="0.875rem" />
223223
</Dropdown.Menu.List.Item>
224224
<Dropdown.Menu.List.Item>
225225
<span>Gosys</span>
226-
<ExternalLinkIcon style={{ fontSize: "0.875rem" }} />
226+
<ExternalLinkIcon aria-hidden fontSize="0.875rem" />
227227
</Dropdown.Menu.List.Item>
228228
</Dropdown.Menu.List>
229229
</Dropdown.Menu>

@navikt/core/react/src/util/i18n/locales/en.ts

+6
Original file line numberDiff line numberDiff line change
@@ -123,4 +123,10 @@ export default {
123123
maxSelected: "{selected} of max {limit} are selected.",
124124
clear: "Clear",
125125
},
126+
GuidePanel: {
127+
illustrationLabel: "Illustration of advisor",
128+
},
129+
HelpText: {
130+
title: "More information",
131+
},
126132
} satisfies Translations;

@navikt/core/react/src/util/i18n/locales/nb.ts

+6
Original file line numberDiff line numberDiff line change
@@ -130,4 +130,10 @@ export default {
130130
maxSelected: "{selected} av maks {limit} er valgt.",
131131
clear: "Tøm",
132132
},
133+
GuidePanel: {
134+
illustrationLabel: "Illustrasjon av veileder",
135+
},
136+
HelpText: {
137+
title: "Mer informasjon",
138+
},
133139
} satisfies TranslationMap;

@navikt/core/react/src/util/i18n/locales/nn.ts

+6
Original file line numberDiff line numberDiff line change
@@ -123,4 +123,10 @@ export default {
123123
maxSelected: "{selected} av maks {limit} er valt.",
124124
clear: "Tøm",
125125
},
126+
GuidePanel: {
127+
illustrationLabel: "Illustrasjon av rettleiar",
128+
},
129+
HelpText: {
130+
title: "Meir informasjon",
131+
},
126132
} satisfies Translations;

0 commit comments

Comments
 (0)