Aqua is an open-source project, including but not limited to the Front-end interface and Solidity Smart Contracts. As such, the Contribution Guidelines should facilitate the creation of a collaborative ground for every contributor working on the Aqua code base(s).
We use zenhub.com, if logged in with our Github account, the dashboard should be visible. Zenhub is basically a agile project management which is tightly integrated with Github.
- Every task needs to have an estimated ticket
- If you see something during work which is out of scope of the ticket:
- make a new ticket or reopen a ticket
- finish the old ticket first!
- if not depending on the other ticket, make a new branch from the dev branch, not the branch you are working on.
- No ticket is needed, but a branch, if you can do it under one hour. If you see that it takes longer, make a ticket with estimate.
- You can restimate your tickets if you see its much more work. But do not use it to track hours. It's NOT time tracking.
- One ticket, one branch
- Use /feature/, /bug/, or /chore/ (chore to fix typo and little stuff)
- Avoid working on the
main
branch unless absolutely necessary. Branch names should be named after what they do. - sub-branch like "Feature/stufspecial/otherstuff" should not happen. You can work for yourself in this structur, but please don't get others to work in your sub-branch (It's a sign that something is off. We add to much complexity to non complex stuff. The interface software is still a simple interface)
Some more toughts on branches see Phil Hord's answer on Stack Overflow.
- A PR should never have more the two days of work!
- PR must go to the dev branch
- If a PR is open longer than a day ping the product owner or the person who is responsible for review. Ask in the chat!
- If you make a PR from Feature/stufspecial/otherstuff to Feature/stufspecial/ you should pull it yourself, because I assume it's your sub-branch.
- After a PR is done, you can delete your branch
At Aqua, we are using React to build the frontend. Our current code structure looks like.
A General Component is a React Component that is primitive. A General Component should come with bare minimum styles and configurations. It, however, can be extended as per view/page requirements.
- Directory
src/components
- Component
src/components/<ComponentName>/index.tsx
- Unit tests
src/components/<ComponentName>/index.spec.tsx
- styled-components functions must be stored in the same file
A View is a single page. Each View in the system serves one purpose.
View-Specific Components
To implement DRY in Views, A View can store its Components in within the same directory
- Directory
src/views/<ViewName>/components
- Component
src/views<ViewName>/components/<ComponentName>/index.tsx
- Each Component has its own directory and a
index.tsx
that exports the Component
Layouts can be used to bootstrap a View while maintaining a unity among.
- Directory
src/layouts
- Layout
src/layouts/<LayoutName>/index.tsx
- Unit Tests
src/layouts/<LayoutName>/index.spec.tsx
Aqua uses React 17.
- Directory
src/hooks
- Layout
src/hooks/use<HookName>.tsx
- Unit Tests
src/hooks/use<HookName>.spec.tsx
- Directory
src/assets
- Images in
/src/assets/images
- Videos in
src/assets/videos
- SVG in
src/assets/svg
- Directory
src/redux
- Store in
src/redux/store.ts
- Ducks in
src/redux/<DuckName>.ts
- Directory
src/styles
- Theme in
src/styles/themes.ts
- Global Style (from styled-components) in
src/Global.tsx
- Google fonts in
src/styles.fonts.css
TypeScript interfaces that are used in more than one place should be stored here.
At DXdao, everyone thrives to write high-quality code. And such as every Worker should follow the best practices to achieve their goals.
Use two spaces to intend code. Lint code using Prettier. Configurations are stored in .prettierrc
IDE of choice should be able to format file upon saving file.
Except for external modules, all internal files must avoid default exports in ES6.
Good
// GoodExport.ts
export function GoodExport() {
return 'I am exported using export'
}
// index.ts
import { GoodExport } from './GoodExport.ts'
Bad
// NoSoGoodExport.ts
export function NoSoGoodExport() {
return 'I am exported using export'
}
// index.ts
import VeryGoodExport from './NoSoGoodExport.ts'
As you can see, with the second example, the imported name can be dynamic. Please avoid this.
Imports should be grouped by category and use absolute paths:
- External imports
- functions, objects, interfaces, classes
- Interfaces: imports from
src/interfaces
- Components
- Layouts: layouts defined in
src/layouts
- Hooks: React Hooks defined in
src/hooks
- Helper/Util functions
Good
// Externals
import React from 'react'
// Components
import { Container } from 'src/components/Container'
import { CardBody } from 'src/components/CardBody'
import { Card } from 'src/components/Card'
// Layouts
import { Center } from 'src/layouts/Center'
export function IndexView() {
return (
<Center minHeight="100%">
<Container>
<Card>
<CardBody>Hello world</CardBody>
</Card>
</Container>
</Center>
)
}
Use TitleCase
for Components.
Use camelCase
for variables and functions
Use CAPITAL_CASE
for constants.
The code base uses Jest
Each Component/function/file must be accompanied with approriate tests.