From 93a1d5d741592edbb6b73732e4a97cb080afcc2c Mon Sep 17 00:00:00 2001 From: Lukas Obermann Date: Mon, 8 Jan 2024 15:45:28 +0100 Subject: [PATCH] style: add documentation comments for all main window react components --- .../routes/AdventurePointsTooltip.tsx | 4 + src/main_window/routes/NavigationBar.tsx | 3 + src/main_window/routes/NavigationBarBack.tsx | 3 + src/main_window/routes/NavigationBarLeft.tsx | 3 + src/main_window/routes/NavigationBarRight.tsx | 3 + .../routes/NavigationBarSubTabs.tsx | 6 +- src/main_window/routes/NavigationBarTab.tsx | 3 + src/main_window/routes/NavigationBarTabs.tsx | 3 + .../routes/NavigationBarWrapper.tsx | 3 + src/main_window/routes/Root.tsx | 3 + src/main_window/routes/Router.tsx | 3 + src/main_window/routes/about/Imprint.tsx | 3 + src/main_window/routes/about/LastChanges.tsx | 3 + .../routes/about/ThirdPartyLicenses.tsx | 3 + .../routes/characters/Characters.tsx | 3 + .../routes/characters/CharactersItem.tsx | 7 +- .../advantagesAndDisadvantages/Advantages.tsx | 3 + .../AdventurePointsSpent.tsx | 4 + .../Disadvantages.tsx | 3 + .../attributes/AttributeAdjustment.tsx | 3 + .../character/attributes/AttributeBorder.tsx | 3 + .../character/attributes/Attributes.tsx | 3 + .../character/attributes/AttributesList.tsx | 3 + .../attributes/AttributesListItem.tsx | 3 + .../attributes/DerivedCharacteristicsList.tsx | 3 + .../DerivedCharacteristicsListItem.tsx | 4 + ...erivedCharacteristicsListItemPermanent.tsx | 4 + .../attributes/PermanentLossSheet.tsx | 3 + .../attributes/PermanentPointsSheet.tsx | 3 + .../CloseCombatTechniquesListItem.tsx | 3 + .../combatTechniques/CombatTechniques.tsx | 3 + .../RangedCombatTechniquesListItem.tsx | 3 + .../character/profile/OverviewAddAP.tsx | 29 +- .../character/profile/PersonalData.tsx | 156 ++++++---- .../profile/PersonalDataDropdown.tsx | 16 +- .../PersonalDataDropdownWithReroll.tsx | 20 +- .../profile/PersonalDataTextField.tsx | 16 +- .../PersonalDataTextFieldWithReroll.tsx | 24 +- .../character/profile/ProfileOverview.tsx | 266 +++++++++--------- .../characters/character/rules/FocusRules.tsx | 3 + .../character/rules/FocusRulesItem.tsx | 2 +- .../character/rules/OptionalRules.tsx | 3 + .../character/rules/OptionalRulesItem.tsx | 2 +- .../character/rules/RuleSources.tsx | 3 + .../character/rules/RuleSourcesListItem.tsx | 31 +- .../characters/character/rules/Rules.tsx | 3 + .../skills/SkillAdditionalValues.tsx | 7 + .../character/skills/SkillButtons.tsx | 3 + .../character/skills/SkillGroup.tsx | 3 + .../character/skills/SkillImprovementCost.tsx | 3 + .../character/skills/SkillRating.tsx | 3 + .../characters/character/skills/Skills.tsx | 3 + .../specialAbilities/SpecialAbilities.tsx | 3 + 53 files changed, 435 insertions(+), 271 deletions(-) diff --git a/src/main_window/routes/AdventurePointsTooltip.tsx b/src/main_window/routes/AdventurePointsTooltip.tsx index 10f8c61f6..5f40bc2f8 100644 --- a/src/main_window/routes/AdventurePointsTooltip.tsx +++ b/src/main_window/routes/AdventurePointsTooltip.tsx @@ -28,6 +28,10 @@ import { } from "../selectors/traditionSelectors.ts" import { selectTotalAdventurePoints } from "../slices/characterSlice.ts" +/** + * Returns the contents for the adventure points tooltip that displays which + * entry groups adventure points were spent on. + */ export const AdventurePointsTooltip: FC = () => { const translate = useTranslate() diff --git a/src/main_window/routes/NavigationBar.tsx b/src/main_window/routes/NavigationBar.tsx index d84ea05b9..e6b742eb8 100644 --- a/src/main_window/routes/NavigationBar.tsx +++ b/src/main_window/routes/NavigationBar.tsx @@ -23,6 +23,9 @@ import { NavigationBarWrapper } from "./NavigationBarWrapper.tsx" const showSettings = () => ExternalAPI.showSettings() const toggleDevTools = () => ExternalAPI.toggleDevTools() +/** + * Returns a top navigation bar. + */ export const NavigationBar: FC = () => { const translate = useTranslate() const dispatch = useAppDispatch() diff --git a/src/main_window/routes/NavigationBarBack.tsx b/src/main_window/routes/NavigationBarBack.tsx index 3a69df012..c4bb7efec 100644 --- a/src/main_window/routes/NavigationBarBack.tsx +++ b/src/main_window/routes/NavigationBarBack.tsx @@ -5,6 +5,9 @@ interface Props { handleSetTab(): void } +/** + * Returns a back button for the beginning of the navigation bar. + */ export const NavigationBarBack: FC = props => { const { handleSetTab } = props diff --git a/src/main_window/routes/NavigationBarLeft.tsx b/src/main_window/routes/NavigationBarLeft.tsx index b6fd86a64..c70e90f7c 100644 --- a/src/main_window/routes/NavigationBarLeft.tsx +++ b/src/main_window/routes/NavigationBarLeft.tsx @@ -1,6 +1,9 @@ import { FCC } from "../../shared/utils/react.js" import "./NavigationBarLeft.scss" +/** + * Returns a grouping element for the left section of the navigation bar. + */ export const NavigationBarLeft: FCC = ({ children }) => (
{children}
) diff --git a/src/main_window/routes/NavigationBarRight.tsx b/src/main_window/routes/NavigationBarRight.tsx index d10c9dcee..b79462784 100644 --- a/src/main_window/routes/NavigationBarRight.tsx +++ b/src/main_window/routes/NavigationBarRight.tsx @@ -1,6 +1,9 @@ import { FCC } from "../../shared/utils/react.js" import "./NavigationBarRight.scss" +/** + * Returns a grouping element for the right section of the navigation bar. + */ export const NavigationBarRight: FCC = ({ children }) => (
{children}
) diff --git a/src/main_window/routes/NavigationBarSubTabs.tsx b/src/main_window/routes/NavigationBarSubTabs.tsx index 60fe5e021..50fa3bd17 100644 --- a/src/main_window/routes/NavigationBarSubTabs.tsx +++ b/src/main_window/routes/NavigationBarSubTabs.tsx @@ -7,6 +7,10 @@ interface Props { tabs: RoutePath[] } +/** + * Returns a section underneath the main navigation tabs section for switching + * between subtabs. + */ export const NavigationBarSubTabs: FC = props => { const { tabs } = props @@ -16,7 +20,7 @@ export const NavigationBarSubTabs: FC = props => { + /> ))} ) diff --git a/src/main_window/routes/NavigationBarTab.tsx b/src/main_window/routes/NavigationBarTab.tsx index fe5a290c5..17a80c9bc 100644 --- a/src/main_window/routes/NavigationBarTab.tsx +++ b/src/main_window/routes/NavigationBarTab.tsx @@ -97,6 +97,9 @@ type Props = { displayRoute: DisplayRoute } +/** + * Returns a single navigation tab. + */ export const NavigationBarTab: FC = props => { const { className, displayRoute } = props diff --git a/src/main_window/routes/NavigationBarTabs.tsx b/src/main_window/routes/NavigationBarTabs.tsx index 1fff47926..5fcce8e3a 100644 --- a/src/main_window/routes/NavigationBarTabs.tsx +++ b/src/main_window/routes/NavigationBarTabs.tsx @@ -7,6 +7,9 @@ type Props = { tabs: DisplayRoute[] } +/** + * Returns a navigation bar section for displaying navigation tabs. + */ export const NavigationBarTabs: FC = props => { const { tabs } = props diff --git a/src/main_window/routes/NavigationBarWrapper.tsx b/src/main_window/routes/NavigationBarWrapper.tsx index 0a64ec99f..ab19e8d83 100644 --- a/src/main_window/routes/NavigationBarWrapper.tsx +++ b/src/main_window/routes/NavigationBarWrapper.tsx @@ -1,6 +1,9 @@ import { FCC } from "../../shared/utils/react.js" import "./NavigationBarWrapper.scss" +/** + * Returns a wrapper element for the complete navigation bar. + */ export const NavigationBarWrapper: FCC = ({ children }) => (
{children}
diff --git a/src/main_window/routes/Root.tsx b/src/main_window/routes/Root.tsx index fc6644008..cad8ce1cf 100644 --- a/src/main_window/routes/Root.tsx +++ b/src/main_window/routes/Root.tsx @@ -16,6 +16,9 @@ const onRestore = () => ExternalAPI.restore() const onClose = () => ExternalAPI.close() const isMaximized = () => ExternalAPI.isMaximized() +/** + * Returns the React application for the main window. + */ export const Root: FC = () => { const language = useAppSelector(selectLocale) const areAnimationsEnabled = useAppSelector(selectAreAnimationsEnabled) diff --git a/src/main_window/routes/Router.tsx b/src/main_window/routes/Router.tsx index 950d2c1eb..f5d403a83 100644 --- a/src/main_window/routes/Router.tsx +++ b/src/main_window/routes/Router.tsx @@ -17,6 +17,9 @@ import { Skills } from "./characters/character/skills/Skills.tsx" import { SpecialAbilities } from "./characters/character/specialAbilities/SpecialAbilities.tsx" import { Spells } from "./characters/character/spells/Spells.tsx" +/** + * Returns a page based on the currently selected route. + */ export const Router: FC = () => { const route = useAppSelector(selectRoute) diff --git a/src/main_window/routes/about/Imprint.tsx b/src/main_window/routes/about/Imprint.tsx index f5ee4739e..11c50f6b5 100644 --- a/src/main_window/routes/about/Imprint.tsx +++ b/src/main_window/routes/about/Imprint.tsx @@ -4,6 +4,9 @@ import { Page } from "../../../shared/components/page/Page.tsx" import { Scroll } from "../../../shared/components/scroll/Scroll.tsx" import { useTranslate } from "../../../shared/hooks/translate.ts" +/** + * Returns a page containing the imprint. + */ export const Imprint: FC = () => { const translate = useTranslate() return ( diff --git a/src/main_window/routes/about/LastChanges.tsx b/src/main_window/routes/about/LastChanges.tsx index 838a88805..d9607cdb0 100644 --- a/src/main_window/routes/about/LastChanges.tsx +++ b/src/main_window/routes/about/LastChanges.tsx @@ -7,6 +7,9 @@ import { ExternalAPI } from "../../external.ts" let savedText: string | undefined = undefined +/** + * Returns a page that shows the changelog. + */ export const LastChanges: FC = () => { const [text, setText] = useState(savedText ?? "...") diff --git a/src/main_window/routes/about/ThirdPartyLicenses.tsx b/src/main_window/routes/about/ThirdPartyLicenses.tsx index 0615e206a..90e034f14 100644 --- a/src/main_window/routes/about/ThirdPartyLicenses.tsx +++ b/src/main_window/routes/about/ThirdPartyLicenses.tsx @@ -8,6 +8,9 @@ import "./ThirdPartyLicenses.scss" let savedVersion: string | undefined = undefined let savedText: string | undefined = undefined +/** + * Returns a page that shows licenses of third-party software. + */ export const ThirdPartyLicenses: FC = () => { const [version, setVersion] = useState(savedVersion ?? "0.0.0") const [text, setText] = useState(savedText ?? "...") diff --git a/src/main_window/routes/characters/Characters.tsx b/src/main_window/routes/characters/Characters.tsx index 2fd5cb147..8409316e3 100644 --- a/src/main_window/routes/characters/Characters.tsx +++ b/src/main_window/routes/characters/Characters.tsx @@ -19,6 +19,9 @@ import { changeCharactersSortOrder, selectCharactersSortOrder } from "../../slic import "./Characters.scss" import { CharactersItem } from "./CharactersItem.tsx" +/** + * Returns a page for managing characters. + */ export const Characters: FC = () => { const translate = useTranslate() const localeCompare = useLocaleCompare() diff --git a/src/main_window/routes/characters/CharactersItem.tsx b/src/main_window/routes/characters/CharactersItem.tsx index c0d4a0d4a..d0ced3276 100644 --- a/src/main_window/routes/characters/CharactersItem.tsx +++ b/src/main_window/routes/characters/CharactersItem.tsx @@ -26,11 +26,14 @@ import { } from "../../slices/databaseSlice.ts" import { goToTab } from "../../slices/routeSlice.ts" -export type HerolistItemProps = { +type Props = { character: CharacterState } -export const CharactersItem: FC = props => { +/** + * Returns a single character item. + */ +export const CharactersItem: FC = props => { const { character } = props const dispatch = useAppDispatch() diff --git a/src/main_window/routes/characters/character/advantagesAndDisadvantages/Advantages.tsx b/src/main_window/routes/characters/character/advantagesAndDisadvantages/Advantages.tsx index 8bfd3608e..7d3142db2 100644 --- a/src/main_window/routes/characters/character/advantagesAndDisadvantages/Advantages.tsx +++ b/src/main_window/routes/characters/character/advantagesAndDisadvantages/Advantages.tsx @@ -24,6 +24,9 @@ import { } from "../../../../slices/settingsSlice.ts" import { AdventurePointsSpent } from "./AdventurePointsSpent.tsx" +/** + * Returns a page for managing advantages. + */ export const Advantages: FC = () => { const translate = useTranslate() const dispatch = useAppDispatch() diff --git a/src/main_window/routes/characters/character/advantagesAndDisadvantages/AdventurePointsSpent.tsx b/src/main_window/routes/characters/character/advantagesAndDisadvantages/AdventurePointsSpent.tsx index 99ab5f0b2..b5b7e16ea 100644 --- a/src/main_window/routes/characters/character/advantagesAndDisadvantages/AdventurePointsSpent.tsx +++ b/src/main_window/routes/characters/character/advantagesAndDisadvantages/AdventurePointsSpent.tsx @@ -12,6 +12,10 @@ import { } from "../../../../selectors/adventurePointSelectors.ts" import { selectMaximumAdventurePointsForMagicalAdvantagesAndDisadvantages } from "../../../../selectors/traditionSelectors.ts" +/** + * Returns a sidebar widget for showing spent and available adventure points for + * advantages or disadvantages. + */ export const AdventurePointsSpent: FC = () => { const translate = useTranslate() diff --git a/src/main_window/routes/characters/character/advantagesAndDisadvantages/Disadvantages.tsx b/src/main_window/routes/characters/character/advantagesAndDisadvantages/Disadvantages.tsx index d78f07e7f..4e64ecf04 100644 --- a/src/main_window/routes/characters/character/advantagesAndDisadvantages/Disadvantages.tsx +++ b/src/main_window/routes/characters/character/advantagesAndDisadvantages/Disadvantages.tsx @@ -24,6 +24,9 @@ import { } from "../../../../slices/settingsSlice.ts" import { AdventurePointsSpent } from "./AdventurePointsSpent.tsx" +/** + * Returns a page for managing disadvantages. + */ export const Disadvantages: FC = () => { const translate = useTranslate() const dispatch = useAppDispatch() diff --git a/src/main_window/routes/characters/character/attributes/AttributeAdjustment.tsx b/src/main_window/routes/characters/character/attributes/AttributeAdjustment.tsx index ef8115671..d5b91f12c 100644 --- a/src/main_window/routes/characters/character/attributes/AttributeAdjustment.tsx +++ b/src/main_window/routes/characters/character/attributes/AttributeAdjustment.tsx @@ -10,6 +10,9 @@ import { selectAttributeAdjustmentId } from "../../../../slices/characterSlice.t import { changeAttributeAdjustmentId } from "../../../../slices/raceSlice.ts" import "./AttributeAdjustment.scss" +/** + * Returns a widget for changing the attribute adjustment set for the race. + */ export const AttributesAdjustment: FC = () => { const dispatch = useAppDispatch() const translate = useTranslate() diff --git a/src/main_window/routes/characters/character/attributes/AttributeBorder.tsx b/src/main_window/routes/characters/character/attributes/AttributeBorder.tsx index 1f9ea3b1a..521a8c35e 100644 --- a/src/main_window/routes/characters/character/attributes/AttributeBorder.tsx +++ b/src/main_window/routes/characters/character/attributes/AttributeBorder.tsx @@ -11,6 +11,9 @@ type Props = { value: number | string } +/** + * Returns an attribute value block. + */ export const AttributeBorder: FC = props => { const { children, className, label, tooltip, tooltipMargin, value } = props diff --git a/src/main_window/routes/characters/character/attributes/Attributes.tsx b/src/main_window/routes/characters/character/attributes/Attributes.tsx index a1aa23cf0..458608f3a 100644 --- a/src/main_window/routes/characters/character/attributes/Attributes.tsx +++ b/src/main_window/routes/characters/character/attributes/Attributes.tsx @@ -15,6 +15,9 @@ import "./Attributes.scss" import { AttributeList } from "./AttributesList.tsx" import { DerivedCharacteristicsList } from "./DerivedCharacteristicsList.tsx" +/** + * Returns a page for managing attributes. + */ export const Attributes: FC = () => { const translate = useTranslate() const totalPoints = useAppSelector(selectTotalPoints) diff --git a/src/main_window/routes/characters/character/attributes/AttributesList.tsx b/src/main_window/routes/characters/character/attributes/AttributesList.tsx index 4d227379e..60dab9a26 100644 --- a/src/main_window/routes/characters/character/attributes/AttributesList.tsx +++ b/src/main_window/routes/characters/character/attributes/AttributesList.tsx @@ -9,6 +9,9 @@ type Props = { isRemovingEnabled: boolean } +/** + * Returns a list of attribute values. + */ export const AttributeList: FC = props => { const attributes = useAppSelector(selectVisibleAttributes) diff --git a/src/main_window/routes/characters/character/attributes/AttributesListItem.tsx b/src/main_window/routes/characters/character/attributes/AttributesListItem.tsx index 764e92bef..13a826b75 100644 --- a/src/main_window/routes/characters/character/attributes/AttributesListItem.tsx +++ b/src/main_window/routes/characters/character/attributes/AttributesListItem.tsx @@ -14,6 +14,9 @@ type Props = { isRemovingEnabled: boolean } +/** + * Returns a single attribute value item with buttons to adjust the value. + */ export const AttributeListItem: FC = props => { const { attribute, isInCharacterCreation, isRemovingEnabled } = props diff --git a/src/main_window/routes/characters/character/attributes/DerivedCharacteristicsList.tsx b/src/main_window/routes/characters/character/attributes/DerivedCharacteristicsList.tsx index 267a55357..6995656e6 100644 --- a/src/main_window/routes/characters/character/attributes/DerivedCharacteristicsList.tsx +++ b/src/main_window/routes/characters/character/attributes/DerivedCharacteristicsList.tsx @@ -9,6 +9,9 @@ type Props = { isRemovingEnabled: boolean } +/** + * Returns a list of derived characteristic values. + */ export const DerivedCharacteristicsList: FC = props => { const { isInCharacterCreation, isRemovingEnabled } = props diff --git a/src/main_window/routes/characters/character/attributes/DerivedCharacteristicsListItem.tsx b/src/main_window/routes/characters/character/attributes/DerivedCharacteristicsListItem.tsx index fdffdf2d3..27ffd5b4a 100644 --- a/src/main_window/routes/characters/character/attributes/DerivedCharacteristicsListItem.tsx +++ b/src/main_window/routes/characters/character/attributes/DerivedCharacteristicsListItem.tsx @@ -27,6 +27,10 @@ type Props = { isRemovingEnabled: boolean } +/** + * Returns a single derived characterstics value item with optional buttons to + * manage the value. + */ export const DerivedCharacteristicsListItem: FC = props => { const { attribute, isInCharacterCreation, isRemovingEnabled } = props diff --git a/src/main_window/routes/characters/character/attributes/DerivedCharacteristicsListItemPermanent.tsx b/src/main_window/routes/characters/character/attributes/DerivedCharacteristicsListItemPermanent.tsx index 8906065c5..424c5fa68 100644 --- a/src/main_window/routes/characters/character/attributes/DerivedCharacteristicsListItemPermanent.tsx +++ b/src/main_window/routes/characters/character/attributes/DerivedCharacteristicsListItemPermanent.tsx @@ -30,6 +30,10 @@ type Props = { isRemovingEnabled: boolean } +/** + * Returns a value item and buttons to adjust the value for a supplementary + * derived characteristic value. + */ export const DerivedCharacteristicsListItemPermanent: FC = props => { const { attribute, isRemovingEnabled } = props diff --git a/src/main_window/routes/characters/character/attributes/PermanentLossSheet.tsx b/src/main_window/routes/characters/character/attributes/PermanentLossSheet.tsx index e368e3118..39ac83e62 100644 --- a/src/main_window/routes/characters/character/attributes/PermanentLossSheet.tsx +++ b/src/main_window/routes/characters/character/attributes/PermanentLossSheet.tsx @@ -10,6 +10,9 @@ type Props = { remove(value: number): void } +/** + * Returns a sheet for managing permanent energy loss. + */ export const PermanentLossSheet: FC = props => { const { remove, isOpen, close } = props diff --git a/src/main_window/routes/characters/character/attributes/PermanentPointsSheet.tsx b/src/main_window/routes/characters/character/attributes/PermanentPointsSheet.tsx index 04e706c74..694dfda95 100644 --- a/src/main_window/routes/characters/character/attributes/PermanentPointsSheet.tsx +++ b/src/main_window/routes/characters/character/attributes/PermanentPointsSheet.tsx @@ -19,6 +19,9 @@ type Props = { close(): void } +/** + * Returns a sheet for managing lost and redeemed energy points. + */ export const PermanentPointsSheet: FC = props => { const { id, diff --git a/src/main_window/routes/characters/character/combatTechniques/CloseCombatTechniquesListItem.tsx b/src/main_window/routes/characters/character/combatTechniques/CloseCombatTechniquesListItem.tsx index bd30bdc0b..9d170227e 100644 --- a/src/main_window/routes/characters/character/combatTechniques/CloseCombatTechniquesListItem.tsx +++ b/src/main_window/routes/characters/character/combatTechniques/CloseCombatTechniquesListItem.tsx @@ -115,6 +115,9 @@ const CloseCombatTechniquesListItem: FC = props => { ) } +/** + * Displays a close combat technique. + */ const MemoCloseCombatTechniquesListItem = memo(CloseCombatTechniquesListItem) export { MemoCloseCombatTechniquesListItem as CloseCombatTechniquesListItem } diff --git a/src/main_window/routes/characters/character/combatTechniques/CombatTechniques.tsx b/src/main_window/routes/characters/character/combatTechniques/CombatTechniques.tsx index 7a5db979e..83a92cd5c 100644 --- a/src/main_window/routes/characters/character/combatTechniques/CombatTechniques.tsx +++ b/src/main_window/routes/characters/character/combatTechniques/CombatTechniques.tsx @@ -47,6 +47,9 @@ const isTopMarginNeeded = ( mprev: DisplayedCombatTechnique | undefined, ) => sortOrder === "group" && mprev !== undefined && curr.kind !== mprev.kind +/** + * Returns a page for managing combat techniques. + */ export const CombatTechniques: FC = () => { const translate = useTranslate() const translateMap = useTranslateMap() diff --git a/src/main_window/routes/characters/character/combatTechniques/RangedCombatTechniquesListItem.tsx b/src/main_window/routes/characters/character/combatTechniques/RangedCombatTechniquesListItem.tsx index 1bdad7303..24a799377 100644 --- a/src/main_window/routes/characters/character/combatTechniques/RangedCombatTechniquesListItem.tsx +++ b/src/main_window/routes/characters/character/combatTechniques/RangedCombatTechniquesListItem.tsx @@ -113,6 +113,9 @@ const RangedCombatTechniquesListItem: FC = props => { ) } +/** + * Displays a ranged combat technique. + */ const MemoRangedCombatTechniquesListItem = memo(RangedCombatTechniquesListItem) export { MemoRangedCombatTechniquesListItem as RangedCombatTechniquesListItem } diff --git a/src/main_window/routes/characters/character/profile/OverviewAddAP.tsx b/src/main_window/routes/characters/character/profile/OverviewAddAP.tsx index c839a113b..3c04572b7 100644 --- a/src/main_window/routes/characters/character/profile/OverviewAddAP.tsx +++ b/src/main_window/routes/characters/character/profile/OverviewAddAP.tsx @@ -12,29 +12,28 @@ type Props = { close(): void } +/** + * Returns a sheet for adding adventure points to the character. + */ export const OverviewAddAP: FC = props => { const { addAdventurePoints, isRemovingEnabled, isOpen, close } = props const translate = useTranslate() - const [ value, setValue ] = useState("") - const [ prevIsOpen, setPrevIsOpen ] = useState(false) + const [value, setValue] = useState("") + const [prevIsOpen, setPrevIsOpen] = useState(false) if (prevIsOpen !== isOpen) { setValue("") setPrevIsOpen(isOpen) } - const addAP = - useCallback( - () => { - const mvalue = parseInt(value) + const addAP = useCallback(() => { + const mvalue = parseInt(value) - if (mvalue !== undefined) { - addAdventurePoints(mvalue) - } - }, - [ addAdventurePoints, value ] - ) + if (mvalue !== undefined) { + addAdventurePoints(mvalue) + } + }, [addAdventurePoints, value]) return ( = props => { { disabled: isRemovingEnabled ? !isInteger(value) - : (!isNaturalNumber(value) || value === "0"), + : !isNaturalNumber(value) || value === "0", label: translate("Add"), onClick: addAP, }, @@ -54,14 +53,14 @@ export const OverviewAddAP: FC = props => { ]} close={close} isOpen={isOpen} - > + > + /> ) } diff --git a/src/main_window/routes/characters/character/profile/PersonalData.tsx b/src/main_window/routes/characters/character/profile/PersonalData.tsx index b8d756800..2cefd369f 100644 --- a/src/main_window/routes/characters/character/profile/PersonalData.tsx +++ b/src/main_window/routes/characters/character/profile/PersonalData.tsx @@ -9,9 +9,47 @@ import { minus, plusMinus, signStr } from "../../../../../shared/utils/math.ts" import { isEmptyOr, isFloat, isNaturalNumber } from "../../../../../shared/utils/regex.ts" import { assertExhaustive } from "../../../../../shared/utils/typeSafety.ts" import { useAppDispatch, useAppSelector } from "../../../../hooks/redux.ts" -import { selectAvailableEyeColors, selectAvailableEyeColorsIdDice, selectAvailableHairColors, selectAvailableHairColorsIdDice, selectAvailableSocialStatuses, selectRandomHeightCalculation, selectRandomWeightCalculation } from "../../../../selectors/personalDataSelectors.ts" -import { selectAge, selectCharacteristics, selectDateOfBirth, selectFamily, selectOtherInfo, selectPlaceOfBirth, selectPredefinedEyeColor, selectPredefinedHairColor, selectSize, selectSocialStatusId, selectTitle, selectWeight } from "../../../../slices/characterSlice.ts" -import { rerollEyeColor, rerollHairColor, rerollSize, rerollWeight, setAge, setCharacteristics, setDateOfBirth, setFamily, setOtherInfo, setPlaceOfBirth, setPredefinedEyeColor, setPredefinedHairColor, setSize, setSocialStatus, setTitle, setWeight } from "../../../../slices/personalDataSlice.ts" +import { + selectAvailableEyeColors, + selectAvailableEyeColorsIdDice, + selectAvailableHairColors, + selectAvailableHairColorsIdDice, + selectAvailableSocialStatuses, + selectRandomHeightCalculation, + selectRandomWeightCalculation, +} from "../../../../selectors/personalDataSelectors.ts" +import { + selectAge, + selectCharacteristics, + selectDateOfBirth, + selectFamily, + selectOtherInfo, + selectPlaceOfBirth, + selectPredefinedEyeColor, + selectPredefinedHairColor, + selectSize, + selectSocialStatusId, + selectTitle, + selectWeight, +} from "../../../../slices/characterSlice.ts" +import { + rerollEyeColor, + rerollHairColor, + rerollSize, + rerollWeight, + setAge, + setCharacteristics, + setDateOfBirth, + setFamily, + setOtherInfo, + setPlaceOfBirth, + setPredefinedEyeColor, + setPredefinedHairColor, + setSize, + setSocialStatus, + setTitle, + setWeight, +} from "../../../../slices/personalDataSlice.ts" import { PersonalDataDropdown } from "./PersonalDataDropdown.tsx" import { PersonalDataDropdownWithReroll } from "./PersonalDataDropdownWithReroll.tsx" import { PersonalDataTextField } from "./PersonalDataTextField.tsx" @@ -23,6 +61,9 @@ const validateEmptyOrNaturalNumber = (value: string | undefined) => const validateEmptyOrFloat = (value: string | undefined) => value === undefined || isEmptyOr(isFloat, value) +/** + * Returns a page for managing personal data of the character. + */ export const PersonalData: FC = () => { const translate = useTranslate() const translateMap = useTranslateMap() @@ -34,23 +75,27 @@ export const PersonalData: FC = () => { const hairColorOptions = useMemo( () => availableHairColors - .map((hairColor): DropdownOption => ({ - id: hairColor.id, - name: translateMap(hairColor.translations)?.name ?? hairColor.id.toFixed(), - })) + .map( + (hairColor): DropdownOption => ({ + id: hairColor.id, + name: translateMap(hairColor.translations)?.name ?? hairColor.id.toFixed(), + }), + ) .sort(reduceCompare(compareAt(x => x.name, localeCompare))), - [ availableHairColors, localeCompare, translateMap ], + [availableHairColors, localeCompare, translateMap], ) const eyeColorOptions = useMemo( () => availableEyeColors - .map((eyeColor): DropdownOption => ({ - id: eyeColor.id, - name: translateMap(eyeColor.translations)?.name ?? eyeColor.id.toFixed(), - })) + .map( + (eyeColor): DropdownOption => ({ + id: eyeColor.id, + name: translateMap(eyeColor.translations)?.name ?? eyeColor.id.toFixed(), + }), + ) .sort(reduceCompare(compareAt(x => x.name, localeCompare))), - [ availableEyeColors, localeCompare, translateMap ], + [availableEyeColors, localeCompare, translateMap], ) const randomHeightCalculation = useAppSelector(selectRandomHeightCalculation) @@ -58,13 +103,12 @@ export const PersonalData: FC = () => { const heightCalculationString = useMemo(() => { const dice = translate("D") - const randomPart = - randomHeightCalculation.random - .map(({ number, sides }) => ` ${signStr(sides)} ${number}${dice}${sides}`) - .join("") + const randomPart = randomHeightCalculation.random + .map(({ number, sides }) => ` ${signStr(sides)} ${number}${dice}${sides}`) + .join("") return ` (${randomHeightCalculation.base}${randomPart})` - }, [ randomHeightCalculation.base, randomHeightCalculation.random, translate ]) + }, [randomHeightCalculation.base, randomHeightCalculation.random, translate]) const randomWeightCalculation = useAppSelector(selectRandomWeightCalculation) @@ -74,36 +118,40 @@ export const PersonalData: FC = () => { const signStrWeight = (offsetStrategy: WeightDiceOffsetStrategy) => { switch (offsetStrategy) { - case "Add": return "+" - case "Subtract": return minus - case "AddEvenSubtractOdd": return plusMinus - default: return assertExhaustive(offsetStrategy) + case "Add": + return "+" + case "Subtract": + return minus + case "AddEvenSubtractOdd": + return plusMinus + default: + return assertExhaustive(offsetStrategy) } } - const randomPart = - randomWeightCalculation.random - .map(({ number, sides, offset_strategy }) => ` ${signStrWeight(offset_strategy)} ${number}${dice}${sides}`) - .join("") + const randomPart = randomWeightCalculation.random + .map( + ({ number, sides, offset_strategy }) => + ` ${signStrWeight(offset_strategy)} ${number}${dice}${sides}`, + ) + .join("") return ` (${size} ${minus} ${randomWeightCalculation.base}${randomPart})` - }, [ - randomWeightCalculation.base, - randomWeightCalculation.random, - translate, - ]) + }, [randomWeightCalculation.base, randomWeightCalculation.random, translate]) const availableSocialStatuses = useAppSelector(selectAvailableSocialStatuses) const socialStatusOptions = useMemo( () => availableSocialStatuses - .map((socialStatus): DropdownOption => ({ - id: socialStatus.id, - name: translateMap(socialStatus.translations)?.name ?? socialStatus.id.toFixed(), - })) + .map( + (socialStatus): DropdownOption => ({ + id: socialStatus.id, + name: translateMap(socialStatus.translations)?.name ?? socialStatus.id.toFixed(), + }), + ) .sort(reduceCompare(compareAt(x => x.name, localeCompare))), - [ availableSocialStatuses, localeCompare, translateMap ], + [availableSocialStatuses, localeCompare, translateMap], ) const dispatch = useAppDispatch() @@ -112,22 +160,22 @@ export const PersonalData: FC = () => { const handleRerollHairColor = useCallback( () => dispatch(rerollHairColor(availableHairColorsIdDice)), - [ dispatch, availableHairColorsIdDice ] + [dispatch, availableHairColorsIdDice], ) const handleRerollEyeColor = useCallback( () => dispatch(rerollEyeColor(availableEyeColorsIdDice)), - [ dispatch, availableEyeColorsIdDice ] + [dispatch, availableEyeColorsIdDice], ) const handleRerollSize = useCallback( () => dispatch(rerollSize(randomHeightCalculation)), - [ dispatch, randomHeightCalculation ] + [dispatch, randomHeightCalculation], ) const handleRerollWeight = useCallback( () => dispatch(rerollWeight(randomWeightCalculation, randomHeightCalculation)), - [ dispatch, randomWeightCalculation, randomHeightCalculation ] + [dispatch, randomWeightCalculation, randomHeightCalculation], ) return ( @@ -136,23 +184,23 @@ export const PersonalData: FC = () => { label={translate("Family")} selector={selectFamily} action={setFamily} - /> + /> + /> + /> + /> { selector={selectPredefinedHairColor} action={setPredefinedHairColor} onReroll={handleRerollHairColor} - /> + /> { selector={selectPredefinedEyeColor} action={setPredefinedEyeColor} onReroll={handleRerollEyeColor} - /> + /> { action={setSize} onReroll={handleRerollSize} validator={validateEmptyOrFloat} - /> + /> { action={setWeight} onReroll={handleRerollWeight} validator={validateEmptyOrNaturalNumber} - /> - + /> + + /> + /> + />
) } diff --git a/src/main_window/routes/characters/character/profile/PersonalDataDropdown.tsx b/src/main_window/routes/characters/character/profile/PersonalDataDropdown.tsx index eed3973bf..35b7beaa4 100644 --- a/src/main_window/routes/characters/character/profile/PersonalDataDropdown.tsx +++ b/src/main_window/routes/characters/character/profile/PersonalDataDropdown.tsx @@ -5,20 +5,18 @@ import { DropdownOption } from "../../../../../shared/components/dropdown/Dropdo import { useAppDispatch, useAppSelector } from "../../../../hooks/redux.ts" import { RootState } from "../../../../store.ts" -export type Props = { +type Props = { label: string selector: (state: RootState) => number | undefined options: DropdownOption[] action: ActionCreatorWithPayload } +/** + * Returns a dropdown for use with personal data. + */ export const PersonalDataDropdown: FC = props => { - const { - label, - selector, - options, - action, - } = props + const { label, selector, options, action } = props const dispatch = useAppDispatch() const value = useAppSelector(selector) @@ -27,7 +25,7 @@ export const PersonalDataDropdown: FC = props => { (newValue: number) => { dispatch(action(newValue)) }, - [ dispatch, action ] + [dispatch, action], ) return ( @@ -38,7 +36,7 @@ export const PersonalDataDropdown: FC = props => { onChange={handleSetValue} options={options} disabled={options.length === 1 && value === options[0]!.id} - /> + /> ) } diff --git a/src/main_window/routes/characters/character/profile/PersonalDataDropdownWithReroll.tsx b/src/main_window/routes/characters/character/profile/PersonalDataDropdownWithReroll.tsx index c76180971..0140546f6 100644 --- a/src/main_window/routes/characters/character/profile/PersonalDataDropdownWithReroll.tsx +++ b/src/main_window/routes/characters/character/profile/PersonalDataDropdownWithReroll.tsx @@ -7,7 +7,7 @@ import { InputButtonGroup } from "../../../../../shared/components/inputButtonGr import { useAppDispatch, useAppSelector } from "../../../../hooks/redux.ts" import { RootState } from "../../../../store.ts" -export type Props = { +type Props = { label: string rerollLabel: string selector: (state: RootState) => number | undefined @@ -16,15 +16,11 @@ export type Props = { onReroll: () => void } +/** + * Returns a dropdown with a reroll option for use with personal data. + */ export const PersonalDataDropdownWithReroll: FC = props => { - const { - label, - rerollLabel, - selector, - options, - action, - onReroll, - } = props + const { label, rerollLabel, selector, options, action, onReroll } = props const dispatch = useAppDispatch() const value = useAppSelector(selector) @@ -33,7 +29,7 @@ export const PersonalDataDropdownWithReroll: FC = props => { (newValue: number) => { dispatch(action(newValue)) }, - [ dispatch, action ] + [dispatch, action], ) return ( @@ -44,13 +40,13 @@ export const PersonalDataDropdownWithReroll: FC = props => { onChange={handleSetValue} options={options} disabled={options.length === 1 && value === options[0]!.id} - /> + /> + /> ) } diff --git a/src/main_window/routes/characters/character/profile/PersonalDataTextField.tsx b/src/main_window/routes/characters/character/profile/PersonalDataTextField.tsx index 529aac1de..7e895f18c 100644 --- a/src/main_window/routes/characters/character/profile/PersonalDataTextField.tsx +++ b/src/main_window/routes/characters/character/profile/PersonalDataTextField.tsx @@ -4,20 +4,18 @@ import { TextFieldLazy } from "../../../../../shared/components/textField/TextFi import { useAppDispatch, useAppSelector } from "../../../../hooks/redux.ts" import { RootState } from "../../../../store.ts" -export type Props = { +type Props = { label: string selector: (state: RootState) => string | undefined action: ActionCreatorWithPayload validator?: (value: string | undefined) => boolean } +/** + * Returns a textfield for use with personal data. + */ export const PersonalDataTextField: FC = props => { - const { - label, - selector, - action, - validator, - } = props + const { label, selector, action, validator } = props const dispatch = useAppDispatch() const value = useAppSelector(selector) @@ -26,7 +24,7 @@ export const PersonalDataTextField: FC = props => { (newValue: string) => { dispatch(action(newValue)) }, - [ dispatch, action ] + [dispatch, action], ) return ( @@ -36,7 +34,7 @@ export const PersonalDataTextField: FC = props => { value={value} onChange={handleSetValue} valid={validator ? validator(value) : true} - /> + /> ) } diff --git a/src/main_window/routes/characters/character/profile/PersonalDataTextFieldWithReroll.tsx b/src/main_window/routes/characters/character/profile/PersonalDataTextFieldWithReroll.tsx index 27c0d2bc4..324f38514 100644 --- a/src/main_window/routes/characters/character/profile/PersonalDataTextFieldWithReroll.tsx +++ b/src/main_window/routes/characters/character/profile/PersonalDataTextFieldWithReroll.tsx @@ -6,7 +6,7 @@ import { TextFieldLazy } from "../../../../../shared/components/textField/TextFi import { useAppDispatch, useAppSelector } from "../../../../hooks/redux.ts" import { RootState } from "../../../../store.ts" -export type Props = { +type Props = { label: string rerollLabel: string selector: (state: RootState) => string | undefined @@ -15,15 +15,11 @@ export type Props = { validator?: (value: string | undefined) => boolean } +/** + * Returns a textfield with a reroll option for use with personal data. + */ export const PersonalDataTextFieldWithReroll: FC = props => { - const { - label, - rerollLabel, - selector, - action, - onReroll, - validator, - } = props + const { label, rerollLabel, selector, action, onReroll, validator } = props const dispatch = useAppDispatch() const value = useAppSelector(selector) @@ -32,7 +28,7 @@ export const PersonalDataTextFieldWithReroll: FC = props => { (newValue: string) => { dispatch(action(newValue)) }, - [ dispatch, action ] + [dispatch, action], ) return ( @@ -42,12 +38,8 @@ export const PersonalDataTextFieldWithReroll: FC = props => { value={value} onChange={handleSetValue} valid={validator ? validator(value) : true} - /> - + /> + ) } diff --git a/src/main_window/routes/characters/character/profile/ProfileOverview.tsx b/src/main_window/routes/characters/character/profile/ProfileOverview.tsx index 755aabc25..fed3fa34d 100644 --- a/src/main_window/routes/characters/character/profile/ProfileOverview.tsx +++ b/src/main_window/routes/characters/character/profile/ProfileOverview.tsx @@ -18,20 +18,39 @@ import { useProfessionName } from "../../../../hooks/professionName.ts" import { useAppDispatch, useAppSelector } from "../../../../hooks/redux.ts" import { selectCanAddAdventurePoints } from "../../../../selectors/characterSelectors.ts" import { selectCurrentCulture } from "../../../../selectors/cultureSelectors.ts" -import { selectCurrentExperienceLevel, selectStartExperienceLevel } from "../../../../selectors/experienceLevelSelectors.ts" +import { + selectCurrentExperienceLevel, + selectStartExperienceLevel, +} from "../../../../selectors/experienceLevelSelectors.ts" import { selectCurrentProfession } from "../../../../selectors/professionSelectors.ts" -import { selectCanDefineCustomProfessionName, selectCanFinishCharacterCreation, selectShowFinishCharacterCreation } from "../../../../selectors/profileSelectors.ts" +import { + selectCanDefineCustomProfessionName, + selectCanFinishCharacterCreation, + selectShowFinishCharacterCreation, +} from "../../../../selectors/profileSelectors.ts" import { selectCurrentRace, selectCurrentRaceVariant } from "../../../../selectors/raceSelectors.ts" -import { deleteAvatar, finishCharacterCreation, selectAvatar, selectName, selectSex, selectTotalAdventurePoints, setName } from "../../../../slices/characterSlice.ts" +import { + deleteAvatar, + finishCharacterCreation, + selectAvatar, + selectName, + selectSex, + selectTotalAdventurePoints, + setName, +} from "../../../../slices/characterSlice.ts" import { setCustomProfessionName } from "../../../../slices/professionSlice.ts" import { PersonalData } from "./PersonalData.tsx" import "./ProfileOverview.scss" +/** + * Returns a page for managing the character’s profile, including the name, + * adventure points and personal data. + */ export const ProfileOverview: FC = () => { const dispatch = useAppDispatch() const name = useAppSelector(selectName) - const [ isEditingName, setIsEditingName ] = useState(false) - const [ isEditingProfessionName, setIsEditingProfessionName ] = useState(false) + const [isEditingName, setIsEditingName] = useState(false) + const [isEditingProfessionName, setIsEditingProfessionName] = useState(false) const translate = useTranslate() const translateMap = useTranslateMap() @@ -55,7 +74,7 @@ export const ProfileOverview: FC = () => { dispatch(setName(newName)) setIsEditingName(false) }, - [ dispatch ] + [dispatch], ) const handleEditProfessionName = useCallback( @@ -63,79 +82,62 @@ export const ProfileOverview: FC = () => { dispatch(setCustomProfessionName(newName)) setIsEditingProfessionName(false) }, - [ dispatch ] + [dispatch], ) - const handleStartEditName = useCallback( - () => setIsEditingName(true), - [ setIsEditingName ] - ) + const handleStartEditName = useCallback(() => setIsEditingName(true), [setIsEditingName]) - const handleCancelEditName = useCallback( - () => setIsEditingName(false), - [ setIsEditingName ] - ) + const handleCancelEditName = useCallback(() => setIsEditingName(false), [setIsEditingName]) const handleStartEditProfessionName = useCallback( () => setIsEditingProfessionName(true), - [ setIsEditingProfessionName ] + [setIsEditingProfessionName], ) const handleCancelEditProfessionName = useCallback( () => setIsEditingProfessionName(false), - [ setIsEditingProfessionName ] + [setIsEditingProfessionName], ) - const handleDeleteAvatar = useCallback( - () => dispatch(deleteAvatar()), - [ dispatch ] - ) + const handleDeleteAvatar = useCallback(() => dispatch(deleteAvatar()), [dispatch]) const handlFinishCharacterCreation = useCallback( () => dispatch(finishCharacterCreation()), - [ dispatch ] + [dispatch], + ) + + const nameElement = isEditingName ? ( + + ) : ( +

+ {name} + +

) - const nameElement = isEditingName - ? ( + const professionNameElement = canDefineCustomProfessionName ? ( + isEditingProfessionName ? ( - ) - : ( -

- {name} - -

+ text={professionName} + /> + ) : ( + ) - - const professionNameElement = - canDefineCustomProfessionName - ? (isEditingProfessionName - ? ( - - ) - : ( - - )) - : null + ) : null return ( @@ -146,103 +148,89 @@ export const ProfileOverview: FC = () => {
{nameElement} - { - currentProfession === undefined - ? null - : ( - - - {((): string => { - switch (sex.type) { - case "Male": return translate("Male") - case "Female": return translate("Female") - case "BalThani": return translate("Bal’Thani") - case "Tsajana": return translate("Tsajana") - case "Custom": return sex.name - default: return assertExhaustive(sex) - } - })()} - - - {currentRace === undefined - ? "" - : getFullRaceName(translateMap, currentRace, currentRaceVariant)} - - - {currentCulture === undefined - ? "" - : getFullCultureName(translateMap, currentCulture)} - - - {fullProfessionName} - - - ) - } + {currentProfession === undefined ? null : ( + + + {((): string => { + switch (sex.type) { + case "Male": + return translate("Male") + case "Female": + return translate("Female") + case "BalThani": + return translate("Bal’Thani") + case "Tsajana": + return translate("Tsajana") + case "Custom": + return sex.name + default: + return assertExhaustive(sex) + } + })()} + + + {currentRace === undefined + ? "" + : getFullRaceName(translateMap, currentRace, currentRaceVariant)} + + + {currentCulture === undefined + ? "" + : getFullCultureName(translateMap, currentCulture)} + + {fullProfessionName} + + )} - { - startExpLevel === undefined || currentExpLevel === undefined + {startExpLevel === undefined || currentExpLevel === undefined ? "—" : currentExpLevel.id === startExpLevel.id - ? (translateMap(startExpLevel.translations)?.name ?? "—") - : `${(translateMap(currentExpLevel.translations)?.name ?? "—")} (${(translateMap(startExpLevel.translations)?.name ?? "—")})` - } - - - {translate("{0} AP", totalAdventurePoints ?? 0)} + ? translateMap(startExpLevel.translations)?.name ?? "—" + : `${translateMap(currentExpLevel.translations)?.name ?? "—"} (${ + translateMap(startExpLevel.translations)?.name ?? "—" + })`} + {translate("{0} AP", totalAdventurePoints ?? 0)}
- { - canAddAdventurePoints - ? ( - - ) - : null - } + {canAddAdventurePoints ? ( + + ) : null} {professionNameElement} - { - currentProfession === undefined - ? null - : ( - -

{translate("Personal Data")}

- -
- ) - } - { - showFinishCharacterCreation - ? ( - - - - ) - : null - } + {currentProfession === undefined ? null : ( + +

{translate("Personal Data")}

+ +
+ )} + {showFinishCharacterCreation ? ( + + + + ) : null} { // TODO: Maybe.elem(3)(phase) // ? ( diff --git a/src/main_window/routes/characters/character/rules/FocusRules.tsx b/src/main_window/routes/characters/character/rules/FocusRules.tsx index d3e046c5b..9d8dfc2fa 100644 --- a/src/main_window/routes/characters/character/rules/FocusRules.tsx +++ b/src/main_window/routes/characters/character/rules/FocusRules.tsx @@ -11,6 +11,9 @@ import { SelectGetById } from "../../../../selectors/basicCapabilitySelectors.ts import { selectStaticFocusRules } from "../../../../slices/databaseSlice.ts" import { FocusRulesItem } from "./FocusRulesItem.tsx" +/** + * Returns a page section for managing focus rules. + */ export const FocusRules: FC = () => { const translate = useTranslate() const translateMap = useTranslateMap() diff --git a/src/main_window/routes/characters/character/rules/FocusRulesItem.tsx b/src/main_window/routes/characters/character/rules/FocusRulesItem.tsx index 3b795cf9e..cd474b09e 100644 --- a/src/main_window/routes/characters/character/rules/FocusRulesItem.tsx +++ b/src/main_window/routes/characters/character/rules/FocusRulesItem.tsx @@ -17,7 +17,7 @@ type Props = { } /** - * + * Returns a single focus rule item. */ export const FocusRulesItem: FC = props => { const { diff --git a/src/main_window/routes/characters/character/rules/OptionalRules.tsx b/src/main_window/routes/characters/character/rules/OptionalRules.tsx index 2f292ebcb..f5805a2b5 100644 --- a/src/main_window/routes/characters/character/rules/OptionalRules.tsx +++ b/src/main_window/routes/characters/character/rules/OptionalRules.tsx @@ -14,6 +14,9 @@ import { SelectGetById } from "../../../../selectors/basicCapabilitySelectors.ts import { selectStaticOptionalRules } from "../../../../slices/databaseSlice.ts" import { OptionalRulesItem } from "./OptionalRulesItem.tsx" +/** + * Returns a page section for managing optional rules. + */ export const OptionalRules: FC = () => { const translate = useTranslate() const translateMap = useTranslateMap() diff --git a/src/main_window/routes/characters/character/rules/OptionalRulesItem.tsx b/src/main_window/routes/characters/character/rules/OptionalRulesItem.tsx index dddf8e156..bb860a712 100644 --- a/src/main_window/routes/characters/character/rules/OptionalRulesItem.tsx +++ b/src/main_window/routes/characters/character/rules/OptionalRulesItem.tsx @@ -22,7 +22,7 @@ type Props = { } /** - * + * Returns a single optional rule item. */ export const OptionalRulesItem: FC = props => { const { diff --git a/src/main_window/routes/characters/character/rules/RuleSources.tsx b/src/main_window/routes/characters/character/rules/RuleSources.tsx index 1417845b2..4c6b0cc62 100644 --- a/src/main_window/routes/characters/character/rules/RuleSources.tsx +++ b/src/main_window/routes/characters/character/rules/RuleSources.tsx @@ -14,6 +14,9 @@ import { selectStaticPublications } from "../../../../slices/databaseSlice.ts" import { switchIncludeAllPublications } from "../../../../slices/rulesSlice.ts" import { RuleSourcesListItem } from "./RuleSourcesListItem.tsx" +/** + * Returns a page section for managing the publications to use for a character. + */ export const RuleSources: FC = () => { const translate = useTranslate() const translateMap = useTranslateMap() diff --git a/src/main_window/routes/characters/character/rules/RuleSourcesListItem.tsx b/src/main_window/routes/characters/character/rules/RuleSourcesListItem.tsx index b90fbc356..f26f88532 100644 --- a/src/main_window/routes/characters/character/rules/RuleSourcesListItem.tsx +++ b/src/main_window/routes/characters/character/rules/RuleSourcesListItem.tsx @@ -1,8 +1,14 @@ -import { Publication, PublicationTranslation } from "optolith-database-schema/types/source/Publication" +import { + Publication, + PublicationTranslation, +} from "optolith-database-schema/types/source/Publication" import { FC, useCallback } from "react" import { Checkbox } from "../../../../../shared/components/checkbox/Checkbox.tsx" import { useAppDispatch, useAppSelector } from "../../../../hooks/redux.ts" -import { selectIncludeAllPublications, selectIncludePublications } from "../../../../slices/characterSlice.ts" +import { + selectIncludeAllPublications, + selectIncludePublications, +} from "../../../../slices/characterSlice.ts" import { switchIncludePublication } from "../../../../slices/rulesSlice.ts" type Props = { @@ -12,8 +18,13 @@ type Props = { } } +/** + * Returns a single publication item. + */ export const RuleSourcesListItem: FC = props => { - const { publication: { publication, publicationTranslation } } = props + const { + publication: { publication, publicationTranslation }, + } = props const dispatch = useAppDispatch() const includeAllPublications = useAppSelector(selectIncludeAllPublications) === true @@ -21,23 +32,23 @@ export const RuleSourcesListItem: FC = props => { const handleSwitch = useCallback( () => dispatch(switchIncludePublication(publication.id)), - [ dispatch, publication.id ], + [dispatch, publication.id], ) return ( + /> ) } diff --git a/src/main_window/routes/characters/character/rules/Rules.tsx b/src/main_window/routes/characters/character/rules/Rules.tsx index 142e2b8cb..d8be87870 100644 --- a/src/main_window/routes/characters/character/rules/Rules.tsx +++ b/src/main_window/routes/characters/character/rules/Rules.tsx @@ -8,6 +8,9 @@ import { OptionalRules } from "./OptionalRules.tsx" import { RuleSources } from "./RuleSources.tsx" import "./Rules.scss" +/** + * Returns a page for managing a character’s ruleset. + */ export const Rules: FC = () => (
diff --git a/src/main_window/routes/characters/character/skills/SkillAdditionalValues.tsx b/src/main_window/routes/characters/character/skills/SkillAdditionalValues.tsx index bfc8033de..64b351477 100644 --- a/src/main_window/routes/characters/character/skills/SkillAdditionalValues.tsx +++ b/src/main_window/routes/characters/character/skills/SkillAdditionalValues.tsx @@ -1,5 +1,9 @@ import { FC } from "react" +/** + * An additional value for a skill row is defined by a value and a class name + * that can be used to style the value. + */ export type AdditionalValue = { className: string value?: string | number @@ -9,6 +13,9 @@ type Props = { addValues?: AdditionalValue[] } +/** + * Returns a list of additional values for the skill row. + */ export const SkillAdditionalValues: FC = props => { const { addValues } = props diff --git a/src/main_window/routes/characters/character/skills/SkillButtons.tsx b/src/main_window/routes/characters/character/skills/SkillButtons.tsx index d381fe213..9641543fb 100644 --- a/src/main_window/routes/characters/character/skills/SkillButtons.tsx +++ b/src/main_window/routes/characters/character/skills/SkillButtons.tsx @@ -18,6 +18,9 @@ type Props = { selectForInfo(id: number): void } +/** + * Returns a list of buttons for a skill row. + */ export const SkillButtons: React.FC = props => { const { activateDisabled, diff --git a/src/main_window/routes/characters/character/skills/SkillGroup.tsx b/src/main_window/routes/characters/character/skills/SkillGroup.tsx index b08155ff5..69676c2f2 100644 --- a/src/main_window/routes/characters/character/skills/SkillGroup.tsx +++ b/src/main_window/routes/characters/character/skills/SkillGroup.tsx @@ -7,6 +7,9 @@ type Props = { getGroupName?: (id: number) => string } +/** + * Returns a row section that display a skill group. + */ export const SkillGroup: FC = props => { const { addText, group, getGroupName } = props diff --git a/src/main_window/routes/characters/character/skills/SkillImprovementCost.tsx b/src/main_window/routes/characters/character/skills/SkillImprovementCost.tsx index 7eed6dd45..b56a639d9 100644 --- a/src/main_window/routes/characters/character/skills/SkillImprovementCost.tsx +++ b/src/main_window/routes/characters/character/skills/SkillImprovementCost.tsx @@ -8,6 +8,9 @@ type Props = { ic?: ImprovementCost } +/** + * Returns a row section that displays an improvement cost. + */ export const SkillImprovementCost: FC = props => { const { ic } = props diff --git a/src/main_window/routes/characters/character/skills/SkillRating.tsx b/src/main_window/routes/characters/character/skills/SkillRating.tsx index 29e37253a..dfd86aa52 100644 --- a/src/main_window/routes/characters/character/skills/SkillRating.tsx +++ b/src/main_window/routes/characters/character/skills/SkillRating.tsx @@ -7,6 +7,9 @@ type Props = { addPoint?(id: number): void } +/** + * Returns a row section that displays a skill rating. + */ export const SkillRating: FC = props => { const { isNotActive, noIncrease, sr, addPoint } = props diff --git a/src/main_window/routes/characters/character/skills/Skills.tsx b/src/main_window/routes/characters/character/skills/Skills.tsx index b039c28ee..fd8b4f15b 100644 --- a/src/main_window/routes/characters/character/skills/Skills.tsx +++ b/src/main_window/routes/characters/character/skills/Skills.tsx @@ -46,6 +46,9 @@ const isTopMarginNeeded = ( mprev !== undefined && curr.static.group.id.skill_group !== mprev.static.group.id.skill_group +/** + * Returns a page for managing skills. + */ export const Skills: FC = () => { const translate = useTranslate() const translateMap = useTranslateMap() diff --git a/src/main_window/routes/characters/character/specialAbilities/SpecialAbilities.tsx b/src/main_window/routes/characters/character/specialAbilities/SpecialAbilities.tsx index 65317375d..993530530 100644 --- a/src/main_window/routes/characters/character/specialAbilities/SpecialAbilities.tsx +++ b/src/main_window/routes/characters/character/specialAbilities/SpecialAbilities.tsx @@ -19,6 +19,9 @@ import { selectSpecialAbilitiesSortOrder, } from "../../../../slices/settingsSlice.ts" +/** + * Returns a page for managing special abilities. + */ export const SpecialAbilities: FC = () => { const translate = useTranslate() const dispatch = useAppDispatch()