-
-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* π feat(docs): add Cards Translation guide to topic data * πβ¨ feat(docs): add cards translation guide example * π feat(test): add translation test for cards * π¦ feat: add translated card SVG for testing purposes * π§ͺ feat: add translation test script to package.json
- Loading branch information
1 parent
70ce3c2
commit e4037bc
Showing
5 changed files
with
67 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
apps/docs/src/pages/guide/_guides/Examples/cards-translation.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
## Cards Translation | ||
|
||
The `setTextStyles` method is used to customize the text styles for different elements in a rank card or leaderboard. This method allows for the modification of default labels for level, experience points (XP), and rank display. | ||
|
||
## Usage | ||
|
||
For Rank Card or Leaderboard : | ||
```ts | ||
const rankCard = new RankCardBuilder() | ||
.setTextStyles({ | ||
level: 'NIVEAU :', // Custom text for the level | ||
xp: 'EXP :', // Custom text for the experience points | ||
rank: 'CLASSEMENT :' // Custom text for the rank | ||
}) | ||
``` | ||
|
||
# Output | ||
![xp-card](https://raw.githubusercontent.com/neplextech/canvacord/main/packages/canvacord/test/normal/cardTranslated.svg) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { RankCardBuilder, Font, BuiltInGraphemeProvider } from "../src"; | ||
import { writeFileSync } from "fs"; | ||
import { RankCardUserStatus } from "../src/components/rank-card/NeoClassicalCard"; | ||
|
||
Font.loadDefault(); | ||
|
||
async function main() { | ||
const card = new RankCardBuilder() | ||
.setDisplayName("Wumpus π") | ||
.setUsername("@wumpus") | ||
.setAvatar("https://cdn.discordapp.com/embed/avatars/0.png?size=256") | ||
.setCurrentXP(300) | ||
.setRequiredXP(600) | ||
.setProgressCalculator(() => { | ||
return Math.floor(Math.random() * 100); | ||
}) | ||
.setLevel(2) | ||
.setRank(5) | ||
.setOverlay(90) | ||
.setBackground("#23272a") | ||
.setTextStyles({level: 'NIVEAU :', xp: 'EXP :', rank: 'CLASSEMENT :'}) | ||
.setStatus(RankCardUserStatus.Online) | ||
.setGraphemeProvider(BuiltInGraphemeProvider.FluentEmojiFlat); | ||
|
||
card | ||
.build({ | ||
format: "png", | ||
}) | ||
.then((data) => { | ||
writeFileSync(`${__dirname}/normal/cardTranslated.png`, data); | ||
}); | ||
|
||
card | ||
.build({ | ||
format: "svg", | ||
}) | ||
.then((data) => { | ||
writeFileSync(`${__dirname}/normal/cardTranslated.svg`, data); | ||
}); | ||
} | ||
|
||
main(); |
Oops, something went wrong.