-
Notifications
You must be signed in to change notification settings - Fork 30
Site Architecture
Guide: https://github.com/hackforla/website/wiki/Hack-for-LA's-Site-Architecture
Civic Tech Index (CTI) uses React, a JavaScript library for building user interfaces, to generate the CTI website. One sentence summary of site architecture.
This guide provides a description of the folders and files in the Civic Tech Index repository and how to work with them. Helpful documentation if you're new to insert technology or front-end development:
-
Repository Overview
- Configuration Files
- React Pages
- React Components
- Assets
- [Cypress / Testing] ()
- [Material-UI] ()
- [ESLint / Prettier] ()
- Pages
- Redirections
- Projects
- Organizations
- Guide Pages
- Styling
- API Endpoints
All components and pages that make up the site are located in src/, so that will be the "root" reference in this Overview description. The entry point into the site application is index.js, which applies Google Analytics tracking through GA4React and Material UI styling theme through createMuiTheme (along with importing theme-mui.js). Site-wide styling that does not belong in the theme is defined in styles.js. The actual site application is defined in the App component in App.js.
The App component imports a Layout that consists of a Header, the current page being displayed, and a Footer. Navigation menu structure in the Header and Footer is defined in navigation.js. The other major part of App is list of routes that provides info on how to navigate to all pages on the site. App also contains cookie popup functionality.
Any components that are used in multiple places throughout the site or are part of the general site layout are in components/. Components that make up the pages of the site are reside in pages/.
Purpose: current home page that will be the landing page at site launch
Path: src/pages/Home
Structure:
-
index.jsis the parent file that contains its own style section andHome,MarketingSection, andCallToActioncomponents -
sectionssubdirectory containsNotableUsersSection.jsandTrendingTopicsSection.jscomponents - There is a
notableUserslist that is defined inNotableUsersSection.jsthat contains info for CTI contributor orgs -
index.jsimportsNotableUsersSectionandTrendingTopicsSection. It also importsGetStartedCardfromsrc/components -
Homecomponent contains all of the home page and displays the following components from top to bottom:MarketingSection,CallToActionSection,NotableUsersSection,TrendingTopicsSection,GetStartedCard
Purpose: It shows the steps how to add topic tags to your project.
Path: src/pages/HowToAdd
Structure:
-
HowToAddcomponent in the main fileindex.js, which contains its own style section andImageComponentcomponent,SettingsGearIconcomponent. -
ImageComponentcomponent insrc/componentsusesCardMediaMaterial UI component for displaying the images. -
SettingGearIconcomponent insrc/componentsuses svg which is used to define vector-based-graphics and path is an element in svg library which defines a path that starts from a position and ends to a particular position. The path element uses attribute d which uses M which is used for moving a point to a certain location.
Purpose: provides information on the organization's project
Path: src/pages/About
Structure:
-
Aboutis the parent component that is exported toApp.jsto render this page in the DOM. -
index.jsis the parent file containing formatting and an object for mapping the images of the page - A
Gridcomponent contains aniframeslideshow explaining various aspects of the project -
styles.jscontains the styling for the page
Purpose: provides site navigation Links and subLinks in two display sizes
Path: src/components/Header
Structure:
-
Headeris the parent component exported from theindex.jsfile contained within the Header folder. - Header is exported to the
Layoutcomponent found undersrc/components/common/Layout.jswhere it is exported usingwithRouterfromreact-router-dom. The Layout component wraps theSwitchcomponent imported from thereact-router-dompackage in theAppcomponent which handles the routing insrc/App.js. - The
Headercomponent is broken down into several smaller components with separate files:index,HeaderLarge,HeaderSmall,DropdownList,SearchContainer,NavLinkandNavSublink. Several files make use of thenavigationarray exported from thesrc/navigation.jsfile. The Header folder also contains a separatestyles.jssheet which provides styling to each of the components. -
index.jsexports theHeadercomponent as default and is also where the switch between large and small displays is handled utilizing theHiddencomponent from themuilibrary. -
HeaderLargefeeds the values to theNavLinkandNavSublinkcomponents from thenavigationarray via the.mapmethod. It also houses the image link of the CTI logo to the landing page and a button link to theSearch Projectsscreen. -
HeaderSmallcontains the same links to search and the landing page as HeaderLarge, as well as passing values using the navigation array, but handles the display via ahamburgerbutton allowing for visible or hidden links. -
SearchContaineris a component that exports a button link toSearch Projectsscreen. -
DropdownListutilizes severalmuipackages to handle the functionality, display and style of the sublinks under each page heading. -
NavLinkis a component built off theLinkcomponent frommuiand theNavLinkcomponent (imported as 'NaviLink') fromreact-router-dom. The styling is built using hooks from thematerial-ui-popup-statepackage. - The
NavSublinkcomponent decides between external and internal links, with internal links being handled by a modifiedLinkcomponent (imported as RouterLink) fromreact-router-dom. Styling of thehover stateof links in the large display dropdown menus are handled in this file.
Purpose: provides site navigation links in three configurations at the foot of each page
Path: src/components/Footer
Structure:
-
Footeris the parent component exported from theindex.jsfile contained within the Footer folder. - The Footer component is imported into the
Layoutcomponent found undersrc/components/common/Layout.jswhere it is exported usingwithRouterfromreact-router-dom. The Layout component wraps theSwitchcomponent imported from thereact-router-dompackage in theAppcomponent which handles the routing insrc/App.js. - The
Footercomponent is broken down into several smaller components with separate files:index,FooterLarge,FooterSmall,LinkList,DropdownList,SocialSection,SubscribeSection, andAnnotation. Several files make use of thenavigationarray exported from thesrc/navigation.jsfile. The Footer folder also contains a separatestyles.jssheet which provides styling to each of the components. -
index.jsexports theFootercomponent and is also where the switch between large and small displays is handled utilizing theHiddencomponent from themuilibrary. -
FooterLargefeeds values to theLinkListcomponent from thenavigationarray via the.mapmethod, which is used for medium and larger displays. It also houses the large display versions of theSocialSectionand theSubscribeSection.FooterSmallfeeds the same links as FooterLarge, only passes them to theDropdownListcomponent which is designed for small and extra small displays. It uses the small display versions of theSocialSectionand theSubscribeSection. BothDropdownList`` andLinkListcreate custom links built off theLinkcomponent from thereact-router-dom``` library. -
SocialSectionis a component that houses links for the Civic Tech Index social media sites. - The
SubscribeSectioncomponent usesaxiosto add users’ email addresses to the CTI database. - The
Annotationis a simple component providing a message at the bottom of the footer as well as links to CTI’s GitHub page and privacy policy.
Purpose: provides the list of frequently asked questions and their corresponding answers
Path: src/pages/Faq
Structure:
-
Faqcomponent is the main file it hasindex.jsanduseSearchFaq.js. -
index.jsfile has its own style section and it fetches the FAQ questions from axios.get(url) with a URL from an API endpoint which returns a response object and axios.post(url, requestBody) , with an URL from API endpoint and requestBody is passed which has question, answer and view_count attributes. -
index.jsimportsFAQCardComponent fromsrc/componentsandSearchBarfrom/SearchProjects/SearchBar. -
FAQCardcomponent hasaccordianSection.jswhich has its own style section and it uses material UI accordion component which shows and hide sections of content on a page andindex.jsimportsaccordianSection.jswhich is used to display the Faq questions and answers and it also uses Pagination material UI component for displaying the Faq questions page wise. -
SearchProjectsfolder fromsrc/pages/is the main file and it hasSearchBar.jswhich has its own style section and search bar component implemented for displaying the search bar on header.
Purpose: provides contact form for collecting the contact information.
Path: src/pages/Contact
Structure:
-
Contactcomponent is the main file and it hasindex.js. -
index.jsfile has its own style section and importsGenericHeaderSectionfromsrc/componentswhich is used for displaying mainTitle,
children and breadCrumbLinks. -
index.jsfile uses CardMedia component which embeds google docs for displaying the contact form.
Purpose: Provides information on how to make a donation as well as a link to the Code for America donation form.
Path: src/pages/Donate
Structure:
-
Donateis the exported component from the main fileindex.jscontained within the Donate folder that contains the entire view for the Donate page. -
index.jsis the file that contains the functionality of the Donate component. It is formatted using @mui’sGridcomponent and draws its styling from thestyles.jsfile. The file importsGenericHeaderSectionfromsrc/componentswhich is used for displayingmainTitle,childrenandbreadCrumbLinksthrough props.BottomCallToActionwhich links to theContactpage. - The
styles.jsfile contains the styling for theDonatecomponent and imported by theindex.jsfile.
Purpose: It displays the unaffiliated, affiliated organizations and index contributors.
Path: src/pages/Contributors
Structure:
-
index.jsis the main file which importsNavBreadcrumbs,TitleSectionandGetStartedCardall from/componentsandOrganizationSearch,AffiliatedandUnaffiliatedOrganizationsfrom/Contributors. -
NavBreadcrumbsin/componentsis used for displaying the navbreadcrumbs. -
TitleSectionin/componentsfor displaying the title of the page. -
GetStartedCardin/componentsfor displaying the bottom section of the page. -
OrganizationSearchin/Contributorsis used for searching affiliated and unaffiliated organizations. -
UnaffiliatedOrganizationscomponent in/Contributorsis used for displaying unaffiliated organizations. -
Affiliatedcomponent in/Contributorsis used for displaying the affiliated organizations, it also importsAffiliatedOrganizationswhich is used to filtering the parent and child data and displaying on the page.
Purpose: It displays the ways we can collaborate with Civic Tech Index project.
Path: src/pages/Collaborate
Structure:
-
Collaborate componentis the main component and it hasindex.js,LeftTextRightImageandRightTextLeftImagecomponent. -
index.jsfile importsGenericHeaderSection,BottomCallToAction,LeftTextRightImageandRightTextLeftImagecomponent. -
GenericHeaderSectionfromsrc/componentswhich is used for displaying mainTitle, children and breadCrumbLinks. -
BottomCallToActionfromsrc/componentswhich is used for displaying footer text and button text. -
LeftTextRightImagefromsrc/Collaborateis used for displaying the text on left and image on right component on the page. -
RightTextLeftImagefromsrc/Collaborateis used for displaying the right text and image on left component on the page.
The Wiki is a working document and we would love to improve it. Please compile any questions and suggestions you may have and submit it via creating an issue on our project board.