-
Notifications
You must be signed in to change notification settings - Fork 237
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
241 additions
and
22 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,27 @@ | ||
import type { CharacterKey, LightConeKey } from '@genshin-optimizer/sr/consts' | ||
// import artifacts from './gen/artifacts' | ||
// import chars from './gen/chars' | ||
// import lightCones from './gen/lightCones' | ||
type characterAssetKey = 'icon' | 'cover' | ||
import type { | ||
LightConeKey, | ||
NonTrailblazerCharacterKey, | ||
RelicSetKey, | ||
RelicSlotKey, | ||
TrailblazerGenderedKey, | ||
} from '@genshin-optimizer/sr/consts' | ||
import chars from './gen/chars' | ||
import lightCones from './gen/lightCones' | ||
import relics from './gen/relic' | ||
type characterAssetKey = 'icon' | 'basic_0' | ||
export function characterAsset( | ||
_ck: CharacterKey, | ||
ck: NonTrailblazerCharacterKey | TrailblazerGenderedKey, | ||
asset: characterAssetKey | ||
): string { | ||
switch (asset) { | ||
case 'icon': | ||
default: | ||
// return chars[ck][asset] ?? '' | ||
throw new Error('TODO') | ||
} | ||
) { | ||
return chars[ck][asset] | ||
} | ||
export function lightConeAsset(_lck: LightConeKey) { | ||
// return lightCones[lck] | ||
throw new Error('TODO') | ||
type LightConeAssetKey = 'icon' | 'cover' | ||
export function lightConeAsset(lck: LightConeKey, asset: LightConeAssetKey) { | ||
return lightCones[lck][asset] | ||
} | ||
|
||
export function relicAsset(rk: RelicSetKey, slotKey: RelicSlotKey) { | ||
const relic = relics[rk] | ||
|
||
return relic[slotKey as keyof typeof relic] | ||
} | ||
// export function artifactAsset( | ||
// ak: ArtifactSetKey, | ||
// slotKey: ArtifactSlotKey | ||
// ): string { | ||
// return artifacts[ak][slotKey] ?? '' | ||
// } |
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,13 @@ | ||
{ | ||
"presets": [ | ||
[ | ||
"@nx/react/babel", | ||
{ | ||
"runtime": "automatic", | ||
"useBuiltIns": "usage", | ||
"importSource": "@emotion/react" | ||
} | ||
] | ||
], | ||
"plugins": ["@emotion/babel-plugin"] | ||
} |
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,21 @@ | ||
{ | ||
"extends": ["plugin:@nx/react", "../../../.eslintrc.json"], | ||
"ignorePatterns": ["!**/*"], | ||
"parserOptions": { | ||
"project": "libs/sr/formula-ui/tsconfig.eslint.json" | ||
}, | ||
"overrides": [ | ||
{ | ||
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"], | ||
"rules": {} | ||
}, | ||
{ | ||
"files": ["*.ts", "*.tsx"], | ||
"rules": {} | ||
}, | ||
{ | ||
"files": ["*.js", "*.jsx"], | ||
"rules": {} | ||
} | ||
] | ||
} |
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,7 @@ | ||
# sr-formula-ui | ||
|
||
This library was generated with [Nx](https://nx.dev). | ||
|
||
## Running unit tests | ||
|
||
Run `nx test sr-formula-ui` to execute the unit tests via [Jest](https://jestjs.io). |
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,8 @@ | ||
{ | ||
"name": "sr-formula-ui", | ||
"$schema": "../../../node_modules/nx/schemas/project-schema.json", | ||
"sourceRoot": "libs/sr/formula-ui/src", | ||
"projectType": "library", | ||
"tags": [], | ||
"targets": {} | ||
} |
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,14 @@ | ||
export type TalentSheetElementKey = | ||
| 'basic' | ||
| 'skill' | ||
| 'ultimate' | ||
| 'talent' | ||
| 'passive1' | ||
| 'passive2' | ||
| 'passive3' | ||
| 'eidolon1' | ||
| 'eidolon2' | ||
| 'eidolon3' | ||
| 'eidolon4' | ||
| 'eidolon5' | ||
| 'eidolon6' |
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,41 @@ | ||
import type { UISheet } from '@genshin-optimizer/pando/ui-sheet' | ||
import { characterAsset } from '@genshin-optimizer/sr/assets' | ||
import type { CharacterKey } from '@genshin-optimizer/sr/consts' | ||
import { formulas } from '@genshin-optimizer/sr/formula' | ||
import { trans } from '../../util' | ||
import type { TalentSheetElementKey } from '../consts' | ||
const key: CharacterKey = 'RuanMei' | ||
const [chg, _ch] = trans('char', key) | ||
const sheet: UISheet<TalentSheetElementKey> = { | ||
basic: { | ||
name: chg('abilities.basic.0.name'), | ||
img: characterAsset(key, 'basic_0'), | ||
documents: [ | ||
{ | ||
type: 'text', | ||
text: chg('auto.fields.normal'), | ||
}, | ||
{ | ||
type: 'fields', | ||
fields: Object.entries(formulas.RuanMei) | ||
.filter(([key]) => key.startsWith('normal')) | ||
.map(([_, { tag }], i) => ({ | ||
title: chg(`auto.skillParams.${i}`), | ||
fieldRef: tag, | ||
})), | ||
}, | ||
{ type: 'text', text: chg(`abilities.basic.0.fullDesc`) }, | ||
{ | ||
type: 'fields', | ||
fields: [ | ||
{ | ||
title: chg('abilities.basic.0.shortDesc'), | ||
fieldRef: formulas.RuanMei.basicDmg_0.tag, | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
} | ||
|
||
export default sheet |
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,7 @@ | ||
import type { UISheet } from '@genshin-optimizer/pando/ui-sheet' | ||
import type { CharacterKey } from '@genshin-optimizer/sr/consts' | ||
import type { TalentSheetElementKey } from '../consts' | ||
import RuanMei from './RuanMei' | ||
export const uiSheets: Partial< | ||
Record<CharacterKey, UISheet<TalentSheetElementKey>> | ||
> = { RuanMei } as const |
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 @@ | ||
export * from './char/sheets' |
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,44 @@ | ||
import type { | ||
LightConeKey, | ||
NonTrailblazerCharacterKey, | ||
RelicSetKey, | ||
TrailblazerGenderedKey, | ||
} from '@genshin-optimizer/sr/consts' | ||
import { Translate } from '@genshin-optimizer/sr/i18n' | ||
import type { ReactNode } from 'react' | ||
export const st = ( | ||
strKey: string, | ||
values?: Record<string, string | number> | ||
) => <Translate ns="sheet" key18={strKey} values={values} /> | ||
export const stg = (strKey: string) => ( | ||
<Translate ns="sheet_gen" key18={strKey} /> | ||
) | ||
|
||
type Translated = [ | ||
trg: (i18key: string) => ReactNode, | ||
tr: (i18key: string, values?: Record<string, string | number>) => ReactNode | ||
] | ||
|
||
export function trans( | ||
typeKey: 'char', | ||
key: NonTrailblazerCharacterKey | TrailblazerGenderedKey | ||
): Translated | ||
export function trans(typeKey: 'lightcone', key: LightConeKey): Translated | ||
export function trans(typeKey: 'relic', key: RelicSetKey): Translated | ||
export function trans( | ||
typeKey: 'char' | 'lightcone' | 'relic', | ||
key: | ||
| NonTrailblazerCharacterKey | ||
| TrailblazerGenderedKey | ||
| LightConeKey | ||
| RelicSetKey | ||
): Translated { | ||
return [ | ||
(strKey: string) => ( | ||
<Translate ns={`${typeKey}_${key}_gen`} key18={strKey} /> | ||
), | ||
(strKey: string, values?: Record<string, string | number>) => ( | ||
<Translate ns={`${typeKey}_${key}`} key18={strKey} values={values} /> | ||
), | ||
] | ||
} |
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,8 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"compilerOptions": { | ||
"outDir": "../../../dist/out-tsc", | ||
"types": ["node"] | ||
}, | ||
"include": ["**/*.ts", "**/*.tsx"] | ||
} |
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 @@ | ||
{ | ||
"compilerOptions": { | ||
"jsx": "react-jsx", | ||
"allowJs": false, | ||
"esModuleInterop": false, | ||
"exactOptionalPropertyTypes": false, | ||
"strict": true, | ||
"jsxImportSource": "@emotion/react" | ||
}, | ||
"files": [], | ||
"include": [], | ||
"references": [ | ||
{ | ||
"path": "./tsconfig.lib.json" | ||
} | ||
], | ||
"extends": "../../../tsconfig.base.json" | ||
} |
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,24 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"compilerOptions": { | ||
"outDir": "../../../dist/out-tsc", | ||
"types": [ | ||
"node", | ||
|
||
"@nx/react/typings/cssmodule.d.ts", | ||
"@nx/react/typings/image.d.ts" | ||
] | ||
}, | ||
"exclude": [ | ||
"jest.config.ts", | ||
"src/**/*.spec.ts", | ||
"src/**/*.test.ts", | ||
"src/**/*.spec.tsx", | ||
"src/**/*.test.tsx", | ||
"src/**/*.spec.js", | ||
"src/**/*.test.js", | ||
"src/**/*.spec.jsx", | ||
"src/**/*.test.jsx" | ||
], | ||
"include": ["src/**/*.js", "src/**/*.jsx", "src/**/*.ts", "src/**/*.tsx"] | ||
} |
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
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