Skip to content

Commit

Permalink
Use I18nContextType, update comment to make more sense
Browse files Browse the repository at this point in the history
  • Loading branch information
nishasy committed Dec 28, 2024
1 parent 415ce10 commit 84485df
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/perseus/src/components/i18n-context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {mockStrings} from "../strings";

import type {PerseusStrings} from "../strings";

type I18nContextType = {
export type I18nContextType = {
strings: PerseusStrings;
locale: string;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
useTransformVectorsToPixels,
} from "./use-transform";

import type {PerseusStrings} from "../../../strings";
import type {I18nContextType} from "../../../components/i18n-context";
import type {
AriaLive,
CircleGraphState,
Expand Down Expand Up @@ -209,8 +209,9 @@ function crossProduct<A, B>(as: A[], bs: B[]): [A, B][] {
}

function CircleGraphDescription({state}: {state: CircleGraphState}) {
// CircleGraphDescription needs to the `usePerseusI18n`, hook so it has]
// to be a component rather than a function that simply returns a string.
// The reason that CircleGraphDescription is a component (rather than a
// function that returns a string) is because it needs to use a
// hook: `usePerseusI18n`.
const i18n = usePerseusI18n();
const strings = describeCircleGraph(state, i18n);

Expand All @@ -220,7 +221,7 @@ function CircleGraphDescription({state}: {state: CircleGraphState}) {
// Exported for testing
export function describeCircleGraph(
state: CircleGraphState,
i18n: {strings: PerseusStrings; locale: string},
i18n: I18nContextType,
): Record<string, string> {
const {strings, locale} = i18n;
const {center, radiusPoint} = state;
Expand Down

0 comments on commit 84485df

Please sign in to comment.