Forge repo instructions - 02-add-ui-elements-solution

Customizing the Issue Panel by adding UI Kit elements

Now that we have our app template, let’s start getting familiar with different UI elements by updating our app.

There are two common routes when building your Forge UI: UI Kit and Custom UI. In this exercise, we will use UI Kit components to add UI elements to our app.

Updating the project

  1. In your preferred IDE, open the frontend file to update: src/frontend/index.jsx

  2. In the App component, delete the existing Text components as we will not be using them. Be careful not to delete too much as we’ll be needing the closing tags and brackets.

    return (
      <>
      {/* Delete the lines below */}
      {/* <Text>Hello world!</Text> */}
      {/* <Text>{data ? data : 'Loading...'}</Text> */}
      </>
    );    
    
    
  3. Add a title to text to our app by including Heading to the imports and updating the return statement to use the Heading component

    import ForgeReconciler, { Text, Heading } from '@forge/react';
    
    ...
    
    return (
      <>
        <Heading size='medium'>Welcome, InsertDogBreedHere!</Heading>
      </>
    );    
    
    
  4. Deploy the changes first

    • Ensure that you are in your project directory and run the Forge deployment command

      forge deploy
      
      
    • For this exercise let’s use the tunnel to make the UI development experience much better

      forge tunnel
      
      
  5. Once the tunnel is running, add the information we want to display like temperature and humidity. Use the Text component to add this information.

    • Update the return statement by adding the Text components to display the information

      return (
        <>
          <Heading size='medium'>Welcome, InsertDogBreedHere!</Heading>
      
          <Text>Height: </Text>
          <Text>Weight: </Text>
        </>
      );    
      
      
    • Once the edits are done, save the file and do not do a deployment. Go back to your browser, refresh the work item view, and notice that the UI changes are already reflected in the UI. (Thank you Forge tunnel!)

    • Add another Text component to show “Life expectancy” then save the file again

      return (
        <>
          <Heading size='medium'>Welcome, InsertDogBreedHere!</Heading>
      
          <Text>Life expectancy: </Text>
          <Text>Height: </Text>
          <Text>Weight: </Text>
        </>
      );