-
Add a new unique tab key to the tabs object in
./src/data/tabs.js
file. -
Each key must have a unique value as it is used to render the correct page in the
<App/>
component.export const tabs = { tabKey: "uniqueTabTitle" //This string is used as a heading for the page's component. }
-
Create a page component file in
./src/pages/
directory, this component's tests should go in the./src/pages/__tests__/
directory. -
Add new page's SVG icon to
./src/assets/images/
directory. -
Add icon path to app icons object in
./src/data/appIconsBarrel.js
.import newPageIcon from "../assets/images/newPageIcon.svg"; export const appIcons = { newPage: newPageIcon }
-
Add a
<NavItem />
component to the<nav></nav>
component inApp.jsx
<nav> <ul> <NavItem iconUrl={appIcons.newPage} title={tabs.newPage} selected={currentTab === tabs.newPage} onClick={() => setCurrentTab(tabs.newPage)} /> </ul> </nav>
-
Each page component reuses other components which have their own CSS modules, other styles like containers exist in
./src/styles/App.module.css
. -
Any state used in the CV preview must be moved to the
<App />
component and passed down to the page component the state and its setter. -
(Optional) screen width context. Screen width context contains the current viewport width
window.innerWidth
, it can be used for conditional rendering based on screen width.import ScreenWidthContext from "../App.jsx"; ... function NewPage({}) { const screenWidth = useContext(ScreenWidthContext).screenWidth; }
-
(Optional) Dialog context. Dialog context is used to open a confirm action dialog. It contains a dispatch function that accepts an action object with a type key and other options if required. The dialog closes on its own when the user clicks the cancel button, this is the default behaviour, no extra code is needed.
import DialogContext from "../App.jsx"; ... export default function NewPage({}) { const dispatchDialog = useContext(DialogContext); }
// Open a dialog box with a cancel button and a primary button set to accent color dispatchDialog({ type: "openDefault", actionText: "confirmButtonText", prompt: "dialogDescription", onConfirm: function runOnConfirm() => {} }); //OR // Open a dialog box with a cancel button and a primary button set to danger color dispatchDialog({ type: "openDanger", actionText: "confirmButtonText", prompt: "dialogDescription", onConfirm: function runOnConfirm() => {} });
-
Toggle hide an item in an array
import { toggleHide } from "./src/utils/arrayFunctions.js"; toggleHide(targetId: "string", dataArray: []);
Inverts target item's "hidden" boolean key. Returns a new array with the changes.
-
Update an array / Add an item to an array
import { updateItems } from "./src/utils/arrayFunctions.js"; updateItems(newItem: {}, dataArray: []);
Adds the
newItem
object to the end of the array if it does not already exist in the array (based on ID), if the item already exists, it is replaced with thenewItem
object. Returns a new array with the changes. -
Delete an Item from an array
import { deleteItem } from "./src/utils/arrayFunctions.js"; deleteItem(targetId: "string", dataArray: []);
Removes an item from an array. Returns a new array with the changes.
-
Move an item up in an array
import { moveItemUp } from "./src/utils/arrayFunctions.js"; moveItemUp(targetId: "string", dataArray: []);
Moves an item up in the array (index - 1), if the item is already at index 0, the
dataArray
is returned unchanged. Returns a new array with the changes. -
Toggle hide an entire array.
import { toggleHideSection } from "./src/utils/arrayFunctions.js"; toggleHideSection(itemsArray: [], hide: Boolean);
If the hide flag is true, each item in the array gets its "hidden" key set to true, if the hide flag is false, each item in the array gets its "hidden" key set to false. Returns a new array with the changes.