Skip to content

Commit df7d5ed

Browse files
committed
Additions to tutorial
1 parent 68da4ea commit df7d5ed

1 file changed

Lines changed: 63 additions & 0 deletions

File tree

Eplant/tutorial.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@
3232
- [How to create a new `View`](#how-to-create-a-new-view)
3333
- [Steps to Update `config.ts`](#steps-to-update-configts)
3434
- [Example](#example)
35+
- [View Switching Functionality](#view-switching-functionality)
36+
- [Documentation and Commenting Style](#documentation-and-commenting-style)
37+
- [Eslint Code Standards](#eslint-code-standards)
38+
- [Local Testing Requirements](#local-testing-requirements)
3539
- [Eplant2](#eplant2)
3640
- [API](#api)
3741

@@ -366,6 +370,65 @@ const genericViews = [GetStartedView, FallbackView, NewView]
366370
const views = [...genericViews, ...userViews]
367371
```
368372

373+
#### View Switching Functionality
374+
375+
If your new view has function to swap to a different view and/or gene available on ePlant, you may benefit from the generalized view switching component file (name tbd).
376+
377+
To utilize the component:
378+
1. Import createViewSwitchProvider into your index file and export it:
379+
```
380+
export const ViewSwitchProvider = createViewSwitchProvider();
381+
```
382+
2. Import your exported provider into your view's main component and wrap your component in the view's return statement:
383+
```
384+
const App = () => {
385+
return (
386+
<ViewSwitchProvider>
387+
<YourComponent />
388+
</ViewSwitchProvider>
389+
);
390+
};
391+
```
392+
3. Import and use useViewSwitch in your main component whenever you want to invoke the switching functionality. For example: `switchViewAndGene('Cell eFP', geneName);`
393+
394+
There are 3 main swithing functions you can invoke based on needs.
395+
```
396+
/** Function to switch view only */
397+
switchViewOnly: (viewId: string) => Promise<void>;
398+
399+
/** Function to switch gene only */
400+
switchGeneOnly: (geneName: string, speciesUrl?: string) => Promise<void>;
401+
402+
/** Function to switch both view and gene */
403+
switchViewAndGene: (viewId: string, geneName: string, speciesUrl?: string) => Promise<void>;
404+
```
405+
406+
## Documentation and Commenting Style
407+
408+
It is important to maintain a common standard for commenting code and documentation. If you want to make contributions to the project, we ask that you follow the TSdoc(typescript) commenting style. As an example this includes adding function/class headers and comments as seen below:
409+
```
410+
/**
411+
* Extracts the primary gene identifier from the API URL
412+
*
413+
* @param url - The complete API URL containing query parameters
414+
* @returns The primary gene identifier, or an empty string not found
415+
*
416+
* Uses regex to find the primaryGene parameter in the URL
417+
*/
418+
function extractPrimaryGene(url: string): string {
419+
const match = url.match(/primaryGene=([^&]+)/);
420+
return match ? match[1] : "";
421+
}
422+
```
423+
424+
## ESlint Code Standards
425+
426+
The codebase relies on ESlint to handle automatic checking for issues with the code. With ESlint, you will not need to manually parse all of your code for accurate documentation, imports order, etc. When running ePlant locally in a browser, if there are any outstanding issues, it will be made known to you automatically. A common way to fix any issues without much thought is to run `npx eslint . --fix`. The `.` can be replaced if you do not want to check and fix every file in your current working directory. Documentation issues are not as big of a concern as others and your local site may work as normal, but to keep in line with our standards, please resolve any issues and warnings before making a pull request.
427+
428+
## Local Testing Requirements
429+
430+
To allow ESlint to work, and to run the site locally you are required to install Node.js and NPM on your system. Once installed, you can activate a local connection to the site using `npm run dev` and connecting to the generated web access point.
431+
369432
## Eplant2
370433

371434
https://bar.utoronto.ca/eplant/

0 commit comments

Comments
 (0)