BibliothecaDAO / eternum

onchain eternal game
https://alpha-eternum.realms.world
MIT License
36 stars 30 forks source link

Enh/hints #1059

Closed cwastche closed 1 week ago

cwastche commented 1 week ago

PR Type

Enhancement, Documentation


Description


Changes walkthrough πŸ“

Relevant files
Enhancement
12 files
SelectPreviewBuilding.tsx
Simplify SelectPreviewBuildingMenu component structure     

client/src/ui/components/construction/SelectPreviewBuilding.tsx
  • Removed redundant div wrapper around HintModalButton and Tabs.
  • +2/-2     
    utils.tsx
    Add utility function for table of contents                             

    client/src/ui/components/hints/utils.tsx
  • Added utility function tableOfContents for generating a table of
    contents.
  • +13/-0   
    EntityList.tsx
    Add className prop to EntityList component                             

    client/src/ui/components/list/EntityList.tsx
  • Added className prop to EntityList for additional styling flexibility.

  • +12/-2   
    Config.tsx
    Add hintSection prop to OSInterface                                           

    client/src/ui/components/navigation/Config.tsx - Added `hintSection` prop to `OSInterface`.
    +1/-0     
    OSWindow.tsx
    Enhance OSWindow with hintSection prop and HintModalButton

    client/src/ui/components/navigation/OSWindow.tsx
  • Added hintSection prop to OSWindow component.
  • Updated SecondaryPopup.Head to include HintModalButton if hintSection
    is provided.
  • +4/-2     
    LeaderboardPanel.tsx
    Remove HintModalButton from LeaderboardPanel                         

    client/src/ui/components/worldmap/leaderboard/LeaderboardPanel.tsx - Removed `HintModalButton` from `LeaderboardPanel`.
    +0/-4     
    SecondaryPopup.tsx
    Update SecondaryPopup.Head to include HintModalButton       

    client/src/ui/elements/SecondaryPopup.tsx
  • Updated SecondaryPopup.Head to include HintModalButton if hintSection
    is provided.
  • +11/-6   
    Guilds.tsx
    Add hintSection prop to OSWindow in Guilds component         

    client/src/ui/modules/guilds/Guilds.tsx - Added `hintSection` prop to `OSWindow` in `Guilds` component.
    +1/-1     
    LeaderBoard.tsx
    Add hintSection prop to OSWindow in Leaderboard component

    client/src/ui/modules/leaderboard/LeaderBoard.tsx - Added `hintSection` prop to `OSWindow` in `Leaderboard` component.
    +1/-1     
    Military.tsx
    Add className prop to EntityList in Military component     

    client/src/ui/modules/military/Military.tsx - Added `className` prop to `EntityList` in `Military` component.
    +1/-2     
    BottomNavigation.tsx
    Update conditions for showing leaderboard and guilds buttons

    client/src/ui/modules/navigation/BottomNavigation.tsx
  • Updated conditions for showing leaderboard and guilds buttons based on
    quest status.
  • +3/-3     
    WorldStructuresMenu.tsx
    Add HintModalButton to WorldStructuresMenu                             

    client/src/ui/modules/world-structures/WorldStructuresMenu.tsx - Added `HintModalButton` to `WorldStructuresMenu`.
    +2/-0     
    Documentation
    10 files
    Buildings.tsx
    Remove storage of food section from Buildings hints           

    client/src/ui/components/hints/Buildings.tsx - Removed the section on storage of food.
    +0/-5     
    Combat.tsx
    Enhance and restructure Combat hints content                         

    client/src/ui/components/hints/Combat.tsx
  • Added Headline and tableOfContents for better structure.
  • Reorganized and expanded content on combat concepts.
  • +87/-45 
    GettingStarted.tsx
    Improve GettingStarted hints with table of contents and expanded
    content

    client/src/ui/components/hints/GettingStarted.tsx
  • Added tableOfContents for better navigation.
  • Expanded content on key concepts.
  • +18/-13 
    HintModal.tsx
    Rename Hyperstructures section to World Structures in HintModal

    client/src/ui/components/hints/HintModal.tsx - Renamed `Hyperstructures` section to `World Structures`.
    +3/-3     
    Hyperstructures.tsx
    Remove Hyperstructures component                                                 

    client/src/ui/components/hints/Hyperstructures.tsx - Removed the entire Hyperstructures component.
    +0/-11   
    Resources.tsx
    Enhance Resources hints with table of contents and reorganized content

    client/src/ui/components/hints/Resources.tsx
  • Added tableOfContents for better navigation.
  • Reorganized content on resource production and storage.
  • +75/-49 
    TheMap.tsx
    Improve TheMap hints with table of contents and expanded content

    client/src/ui/components/hints/TheMap.tsx
  • Added tableOfContents for better navigation.
  • Expanded content on exploration and travel costs.
  • +76/-5   
    Trading.tsx
    Enhance Trading hints with table of contents and expanded content

    client/src/ui/components/hints/Trading.tsx
  • Added Headline and tableOfContents for better structure.
  • Expanded content on marketplace and AMM.
  • +47/-4   
    Transport.tsx
    Improve Transport hints with table of contents and expanded content

    client/src/ui/components/hints/Transport.tsx
  • Added Headline and tableOfContents for better structure.
  • Expanded content on transport and donkeys.
  • +54/-24 
    WorldStructures.tsx
    Add new WorldStructures component with detailed tables     

    client/src/ui/components/hints/WorldStructures.tsx
  • Added new component for World Structures.
  • Included detailed tables for Hyperstructure creation and construction
    costs.
  • +133/-0 

    πŸ’‘ PR-Agent usage: Comment /help on the PR to get a list of all available PR-Agent tools and their descriptions

    vercel[bot] commented 1 week ago

    The latest updates on your projects. Learn more about Vercel for Git β†—οΈŽ

    Name Status Preview Comments Updated (UTC)
    eternum βœ… Ready (Inspect) Visit Preview πŸ’¬ Add feedback Jul 2, 2024 3:03pm
    github-actions[bot] commented 1 week ago

    PR Reviewer Guide πŸ”

    ⏱️ Estimated effort to review [1-5] 4
    πŸ§ͺ Relevant tests No
    πŸ”’ Security concerns No
    ⚑ Key issues to review Possible Bug:
    The removal of the
    wrapper in SelectPreviewBuilding.tsx and replacing it with React fragments (<>) might affect styling or event handling that relies on the div being present.
    Redundancy and Maintenance:
    The introduction of tableOfContents in multiple components could be refactored into a more centralized approach to avoid redundancy and ease future maintenance.
    Performance Concern:
    The dynamic generation of components and frequent use of map in rendering methods (e.g., in Combat.tsx and Resources.tsx) could lead to performance issues, especially if these components are re-rendered often.
    github-actions[bot] commented 1 week ago

    PR Code Suggestions ✨

    CategorySuggestion                                                                                                                                    Score
    Enhancement
    Replace fragment shorthand with a div element to maintain consistent styling ___ **Replace the fragment shorthand (<>...) with a div element that has appropriate styling to
    maintain the original layout and styling context. This ensures that the component's style
    remains consistent with the rest of the application, especially since the original code
    used a div with specific classes.** [client/src/ui/components/construction/SelectPreviewBuilding.tsx [275-295]](https://github.com/BibliothecaDAO/eternum/pull/1059/files#diff-c6a222463602fe87932fbbc060d2d99cdd1b151dcb9fcd9be42b602a77f18d97R275-R295) ```diff -<> +
    +
    ```
    Suggestion importance[1-10]: 9 Why: The suggestion correctly identifies the need to maintain consistent styling by replacing the fragment shorthand with a `div` element that includes the original classes. This ensures that the component's layout and appearance remain consistent with the rest of the application.
    9
    Possible bug
    Enhance key uniqueness to prevent rendering issues ___ **To avoid potential issues with key uniqueness which can lead to rendering bugs, consider
    using a more unique key for the list items in the HyperstructureConstructionTable.
    Currently, the key is based on the index, which might not be unique if the data changes. A
    combination of resource ID and index could be a better choice.** [client/src/ui/components/hints/WorldStructures.tsx [114-118]](https://github.com/BibliothecaDAO/eternum/pull/1059/files#diff-fd691959c413d4c715c44e2aef3397de6ab93b337cdd8761faec5332a080d9d6R114-R118) ```diff {constructionCost.slice(colIndex * 6, (colIndex + 1) * 6).map((cost, index) => ( -
    +
    ))} ```
    Suggestion importance[1-10]: 9 Why: Using a more unique key for list items helps prevent potential rendering bugs. This is crucial for ensuring the stability and correctness of the component's rendering logic.
    9
    Performance
    Optimize rendering by memoizing the static data array ___ **Consider using React's useMemo hook to optimize the rendering of the concepts array. This
    array is derived from static data and does not change unless the component re-renders for
    other reasons. By memoizing it, you can avoid unnecessary recalculations and re-renders.** [client/src/ui/components/hints/WorldStructures.tsx [14-32]](https://github.com/BibliothecaDAO/eternum/pull/1059/files#diff-fd691959c413d4c715c44e2aef3397de6ab93b337cdd8761faec5332a080d9d6R14-R32) ```diff -const concepts = [ +const concepts = useMemo(() => [ { name: "Hyperstructures", content: ( <> ), }, { name: "Mines", content: (
    Naturally occurring structures discovered during exploration, enabling players to harvest precious resources from the world.
    ), }, -]; +], []); ```
    Suggestion importance[1-10]: 8 Why: Using React's useMemo hook to memoize the static data array can improve performance by preventing unnecessary recalculations and re-renders. This is a significant optimization for components that rely on static data.
    8
    Accessibility
    Improve accessibility by using semantic HTML tags ___ **To improve accessibility and semantic HTML structure, replace the generic div elements
    with section tags in the component rendering. This change will help screen readers and
    other assistive technologies better understand the structure of the page.** [client/src/ui/components/hints/WorldStructures.tsx [42-47]](https://github.com/BibliothecaDAO/eternum/pull/1059/files#diff-fd691959c413d4c715c44e2aef3397de6ab93b337cdd8761faec5332a080d9d6R42-R47) ```diff {concepts.map((concept) => ( -
    +

    {concept.name}

    {concept.content} -
    + ))} ```
    Suggestion importance[1-10]: 7 Why: Replacing generic div elements with section tags enhances the semantic structure of the HTML, which improves accessibility for screen readers and other assistive technologies. This is a good practice for better accessibility.
    7
    Maintainability
    Break down large JSX blocks into smaller components for better readability and maintainability ___ **To improve the readability and maintainability of the JSX code, consider breaking down the
    large JSX blocks into smaller, more manageable components. This will make the code easier
    to understand and maintain, especially as the application scales.** [client/src/ui/components/hints/WorldStructures.tsx [37-49]](https://github.com/BibliothecaDAO/eternum/pull/1059/files#diff-fd691959c413d4c715c44e2aef3397de6ab93b337cdd8761faec5332a080d9d6R37-R49) ```diff return ( <> World Structures {tableOfContents(conceptNames)} - {concepts.map((concept) => ( -
    -

    {concept.name}

    - {concept.content} -
    - ))} + {concepts.map((concept) => )} ); +// New Component +const ConceptSection = ({ concept }) => ( +
    +

    {concept.name}

    + {concept.content} +
    +); + ```
    Suggestion importance[1-10]: 6 Why: Breaking down large JSX blocks into smaller components improves code readability and maintainability. While this is beneficial, it is a minor improvement compared to performance or bug fixes.
    6