Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump @canva/app-ui-kit to version 4.4.0 #44

Merged
merged 1 commit into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## 2024-11-28

### 🔧 Changed

- Upgraded `@canva/app-ui-kit` to version `4.4.0` Please see the [changelog](https://www.canva.dev/docs/apps/app-ui-kit/changelog/) for the list of changes.
- Upgraded `@canva/app-i18n-kit` to version `1.0.1`
- Upgraded `react-intl` to version `6.8.7`

## 2024-11-13

### 🧰 Added
Expand Down
30 changes: 15 additions & 15 deletions examples/i18n/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ export const App = ({
/>
</Text>
{/* ==================== Plurals ==================== */}
<TokenCount used={0} total={25} />
<TokenCount used={1} total={25} />
<TokenCount used={25} total={25} />
<CreditUsage creditsCost={5} remainingCredits={50} />
<CreditUsage creditsCost={1} remainingCredits={1} />
<CreditUsage creditsCost={1} remainingCredits={0} />
{/* ==================== Rich Text ==================== */}
<FormattedMessage
defaultMessage="Discover stunning AI-generated example images in our <link>gallery</link> and <callToAction>start exploring now!</callToAction>"
Expand Down Expand Up @@ -153,23 +153,23 @@ export const App = ({
);
};

export const TokenCount = ({
used,
total,
export const CreditUsage = ({
creditsCost,
remainingCredits,
}: {
used: number;
total: number;
creditsCost: number;
remainingCredits: number;
}) => (
<Text>
<FormattedMessage
defaultMessage={`You've used {usedTokens, number} {usedTokens, plural,
one {token}
other {tokens}
} out of {totalTokens, number}.`}
description="Message that tells the user how many tokens they have used out of the total available"
defaultMessage={`Use {creditsCost, number} of {remainingCredits, plural,
one {# credit}
other {# credits}
}`}
description="Informs the user about the number of credits they will use for the image generation task. Appears below the image generation button."
values={{
usedTokens: used,
totalTokens: total,
creditsCost,
remainingCredits,
}}
/>
</Text>
Expand Down
6 changes: 3 additions & 3 deletions examples/i18n/tests/__snapshots__/app.tests.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ exports[`app Renders token counts consistently 🎉 1`] = `
<p
class="fFOiLQ _5Ob_nQ fM_HdA"
>
You've used 0 tokens out of 25.
Use 5 of 50 credits
</p>
</div>
`;
Expand All @@ -15,7 +15,7 @@ exports[`app Renders token counts consistently 🎉 2`] = `
<p
class="fFOiLQ _5Ob_nQ fM_HdA"
>
You've used 1 token out of 25.
Use 1 of 1 credit
</p>
</div>
`;
Expand All @@ -25,7 +25,7 @@ exports[`app Renders token counts consistently 🎉 3`] = `
<p
class="fFOiLQ _5Ob_nQ fM_HdA"
>
You've used 10 tokens out of 25.
Use 1 of 0 credits
</p>
</div>
`;
8 changes: 4 additions & 4 deletions examples/i18n/tests/app.tests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { RenderResult } from "@testing-library/react";
import { fireEvent, render } from "@testing-library/react";
import { TestAppUiProvider } from "@canva/app-ui-kit";
import { TestAppI18nProvider } from "@canva/app-i18n-kit";
import { App, TokenCount } from "../app";
import { App, CreditUsage } from "../app";

function renderInTestProvider(node: React.ReactNode): RenderResult {
return render(
Expand Down Expand Up @@ -49,18 +49,18 @@ describe("app", () => {

it("Renders token counts consistently 🎉", () => {
const resultToken0 = renderInTestProvider(
<TokenCount used={0} total={25} />,
<CreditUsage creditsCost={5} remainingCredits={50} />,
);
// The snapshot test can be used to detect unexpected changes in the rendered output.
expect(resultToken0.container).toMatchSnapshot();

const resultToken1 = renderInTestProvider(
<TokenCount used={1} total={25} />,
<CreditUsage creditsCost={1} remainingCredits={1} />,
);
expect(resultToken1.container).toMatchSnapshot();

const resultToken10 = renderInTestProvider(
<TokenCount used={10} total={25} />,
<CreditUsage creditsCost={1} remainingCredits={0} />,
);
expect(resultToken10.container).toMatchSnapshot();
});
Expand Down
Loading