Skip to content

Commit

Permalink
Introduce UI Components documentation (twentyhq#1926)
Browse files Browse the repository at this point in the history
* new contributor guide folder architecture

* update content pass 1

* Prepare UI component folder to receive componentns

* Add component doc example for button

* Fix broken links

* Fix broken links

* Fix images
  • Loading branch information
charlesBochet authored Oct 8, 2023
1 parent 7b6ee4e commit edc060f
Show file tree
Hide file tree
Showing 61 changed files with 872 additions and 1,011 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,5 +134,5 @@ Here’s what you can look forward to:

Dive into Twenty today and experience the power of open-source CRM on your own terms.

🚀 [Get Started with Twenty](https://docs.twenty.com/developer/local-setup).
🚀 [Get Started with Twenty](https://docs.twenty.com/contributor/local-setup).

File renamed without changes.
3 changes: 3 additions & 0 deletions docs/docs/contributor/frontend/_category_.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"position": 3
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
{
"label": "Frontend",
"label": "Advanced",
"position": 3,
"collapsible": true,
"collapsed": false,
"customProps": {
"icon": "TbTerminal2"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ Prop drilling, in the React context, refers to the practice of passing state var

3. **Reduced Component Reusability**: A component receiving numerous props solely for the purpose of passing them down becomes less general-purpose and harder to reuse in different contexts.

If you feel that you are using excessive prop drilling, see [state management best practices](/developer/frontend/best-practices#state-management)
If you feel that you are using excessive prop drilling, see [state management best practices](/contributor/frontend/advanced/best-practices#state-management)

## Imports

Expand Down
File renamed without changes.
7 changes: 7 additions & 0 deletions docs/docs/contributor/frontend/basics/_category_.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"label": "Basics",
"position": 1,
"customProps": {
"icon": "TbTerminal2"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,18 @@ We took care of having a clean and simple stack, with minimal boilerplate code.

We use [React Router](https://reactrouter.com/) for routing.

To avoid unnecessary [re-renders](/developer/frontend/best-practices#managing-re-renders) we handle all the routing logic in a `useEffect` in `PageChangeEffect`.
To avoid unnecessary [re-renders](/contributor/frontend/advanced/best-practices#managing-re-renders) we handle all the routing logic in a `useEffect` in `PageChangeEffect`.

### State Management

We use [Recoil](https://recoiljs.org/docs/introduction/core-concepts) for state management.

See our [best practices](/developer/frontend/best-practices#state-management) for more managing state.
See our [best practices](/contributor/frontend/advanced/best-practices#state-management) for more managing state.

## Testing

We use [Jest](https://jestjs.io/) for unit testing and [Storybook](https://storybook.js.org/) for component testing.

Jest is mainly used for testing utility functions, and not components themselves.

Storybook is used for testing the behavior of isolated components, as well as displaying our [design system](/developer/frontend/design-system).
Storybook is used for testing the behavior of isolated components, as well as displaying our [design system](/contributor/frontend/basics/design-system).
43 changes: 43 additions & 0 deletions docs/docs/contributor/frontend/basics/workflows.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
title: Contributing
sidebar_position: 1
sidebar_custom_props:
icon: TbTopologyStar
---

## Pre-requesites

Make sure that your [IDE is correctly setup](/contributor/local-setup/ide-setup) and that your backend is running on `localhost:3000`.


## Starting a new feature

Make sure your database is running on the URL provided in your `server/.env` file.

```
cd front
yarn
yarn start
```

## Regenerate graphql schema based on API graphql schema

```
yarn graphql:generate
```

## Lint

```
yarn lint
```

## Test

```
yarn test # run jest tests
yarn storybook:dev # run storybook
yarn storybook:test # run tests (needs yarn storybook:dev to be running)
yarn storybook:coverage # run tests (needs yarn storybook:dev to be running)
```
12 changes: 12 additions & 0 deletions docs/docs/contributor/frontend/frontend.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
title: Frontend Development
displayed_sidebar: frontendSidebar
sidebar_position: 0
sidebar_custom_props:
icon: TbTerminal2
isSidebarRoot: true
---

Welcome to the Frontend Development section of the documentation.
Here you will find information about the frontend development process, the tools we use, and the best practices we follow.

7 changes: 7 additions & 0 deletions docs/docs/contributor/frontend/ui-components/_category_.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"label": "UI Components",
"position": 1,
"customProps": {
"icon": "TbTerminal2"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"label": "Forms",
"position": 2,
"collapsible": true,
"collapsed": true,
"customProps": {
"icon": "TbForms"
}
}
15 changes: 15 additions & 0 deletions docs/docs/contributor/frontend/ui-components/forms/button.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
title: Button
sidebar_position: 1
---

import IframeResizer from 'iframe-resizer-react';

<IframeResizer
checkOrigin={false}
inPageLinks
src="http://storybook.twenty.com/iframe.html?id=ui-button-button--docs&viewMode=docs&singleStory=true"
style={{ width: '1px', minWidth: '100%'}}
/>


9 changes: 9 additions & 0 deletions docs/docs/contributor/frontend/ui-components/overview.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
title: Overview
sidebar_position: 0
sidebar_custom_props:
icon: TbBrandFigma
---

WIP

Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---
sidebar_position: 3
title: Glossary
sidebar_position: 2
sidebar_custom_props:
icon: TbVocabulary
---
# Glossary

### Workspace
A `Workspace` usually represents a company using Twenty.
Expand Down
9 changes: 9 additions & 0 deletions docs/docs/contributor/local-setup/_category_.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"label": "Local setup",
"position": 1,
"collapsible": true,
"collapsed": true,
"customProps": {
"icon": "TbDeviceDesktop"
}
}
107 changes: 107 additions & 0 deletions docs/docs/contributor/local-setup/docker-setup.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
---
title: Docker Setup
sidebar_position: 2
sidebar_custom_props:
icon: TbBrandDocker
---

You can also provision the project with Docker. This comes with a few advantages:
- It provides the exact same environment as our core developer team.
- It includes some additional dependencies (such as `playwright`) that you might need if you wish to contribute to some advanced areas of the project.
- It provisions a PostgreSQL database.

## Prerequisites

Make sure you have the latest `Docker` and [git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git) versions installed on your computer.

You can run `docker --version` to verify the installation.

## Step #1: Git Clone
In your terminal, run the following command:

```bash
git clone git@github.com:twentyhq/twenty.git
```

## Step #2: Setup env variables

Twenty requires a few environment variables to be set. Locally, we recommend setting them through `.env` files.

```bash
cp ./front/.env.example ./front/.env
cp ./server/.env.example ./server/.env
```

The default values should work out of the box, except for the postgres URL, which requires a small modification.

Open `./server/.env` and change to the following:

```bash
PG_DATABASE_URL=postgres://twenty:twenty@postgres:5432/default?connection_limit=1
```


## Step #3: Build

We provide an environment containerized with Docker and orchestrated with `docker-compose`.
This installation method will also provision a PostgreSQL container.

**Note:** The configuration for the build is stored in the `infra/dev` folder, but you can run `make` commands directly from the root folder.

```bash
make build
```

## Step #4: Migrate & seed

Before running the project, you need to initialize the database by running the migrations and seed.

Start the containers:
```bash
make up
```

Run database migrations, generate prisma client, and seed:
```bash
make server-prisma-reset
```

## Step #5: Start Twenty

Run the project with the following commands from the `root folder`:

```bash
make server-start
```

```bash
make front-start
```

You should now have:
- **Frontend** available on: [http://localhost:3001](http://localhost:3001)
- **Server** available on: [http://localhost:3000/graphql](http://localhost:3000/graphql)
- **Postgres** available on [http://localhost:5432](http://localhost:5432) and containing database named `default`

Sign in using our seeded demo account `tim@apple.dev` (password: `Applecar2025`) to start using Twenty

### Optional

If you don't want to use the `make` command and work directly from the container, you can also ssh directly into the container:

```bash
make sh
```
Then run commands through yarn:
```bash
cd server
yarn prisma:reset
```


### Troubleshooting

#### Docker throws errors while setting up local environment

If by any chance you will run into problems with Docker, you should change the `docker-compose` to `docker compose` in `./infra/dev/Makefile` as `docker-compose` is old version
becoming slowly obsolete. (More info can be found [here](https://docs.docker.com/compose/migrate/))
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
---
sidebar_position: 0
title: IDE Setup
sidebar_position: 4
sidebar_custom_props:
icon: TbBrandVscode
---

# IDE Setup

This section will help you setup your IDE for the project. If you haven't setup your development environment, please refer to [Development Environment](/developer/local-setup) section.
This section will help you setup your IDE for the project. If you haven't setup your development environment, please refer to [Development Environment](/contributor/local-setup) section.

You can obviously use any IDE you want but we recommend using Visual Studio Code as our internal team uses it and we have a lot of extensions and settings that we can share with you.

Expand All @@ -22,24 +21,24 @@ You can download Visual Studio Code from [here](https://code.visualstudio.com/do
Once you have installed Visual Studio Code, you can open the project by clicking on `File > Open Folder` and selecting `twenty` project root folder.

<div style={{textAlign: 'center'}}>
<img src="/img/developer/ide-project-open.png" alt="Visual Studio Code: Open Twenty project" width="90%" />
<img src="/img/contributor/ide-project-open.png" alt="Visual Studio Code: Open Twenty project" width="90%" />
</div>

### Extensions

You can use the recommended extensions for the project. You will find them in `.vscode/extensions.json` file. VSCode should prompt you to install the recommended extensions when you open the project.

<div style={{textAlign: 'center'}}>
<img src="/img/developer/ide-extensions.png" alt="Visual Studio Code: Install recommended extensions" width="90%" />
<img src="/img/contributor/ide-extensions.png" alt="Visual Studio Code: Install recommended extensions" width="90%" />
</div>


### Docker Setup

If you are using a [Docker setup](/developer/local-setup#docker-install), you will need to run VSCode in the container. You can do that by opening the project, clicking on `Remote Explorer` icon on the left sidebar and then clicking on `Attach in New window` on `dev-twenty-dev` container.
If you are using a [Docker setup](/contributor/local-setup#docker-install), you will need to run VSCode in the container. You can do that by opening the project, clicking on `Remote Explorer` icon on the left sidebar and then clicking on `Attach in New window` on `dev-twenty-dev` container.

<div style={{textAlign: 'center'}}>
<img src="/img/developer/ide-start-dev-container.png" alt="Visual Studio Code: Open in container" width="90%" />
<img src="/img/contributor/ide-start-dev-container.png" alt="Visual Studio Code: Open in container" width="90%" />
</div>

<br />
Expand Down
42 changes: 42 additions & 0 deletions docs/docs/contributor/local-setup/local-setup.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
title: Local Setup
sidebar_position: 0
sidebar_custom_props:
icon: TbDeviceDesktop
---
import ThemedImage from '@theme/ThemedImage';
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

Twenty is designed to be developer-friendly, and your local installation should be up and running in a few minutes.

## Discord

If you have any questions or need help, you can join our [Discord](https://discord.com/invite/cx5n4Jzs57) server.

## MacOS and Linux users

We recommend using [yarn installation](/contributor/local-setup/yarn-setup) as this is the easiest way to get started.
We also provide an easy way to run the project with [Docker](/contributor/local-setup/yarn-setup) that you can use if you are familiar with containerized environments.

## Windows users

Windows users can install install the project through WSL2. We provide a [guide](/contributor/local-setup/wsl-setup) to help you get started.

## Project structure

The repository is structured as follows:
```
twenty
└───docs // contains this documentation
└───front // contains the frontend code for the application
└───server // contains the backend code for the application
└───infra // contains docker configurations for development and production deployments
```

## IDE Setup

Once Twnenty is running on your computer, you will get the best experience by using an IDE that supports TypeScript and ESLint.
You will find a guide for [VSCode](/contributor/local-setup/ide-setup) further in the documentation.
___

Loading

0 comments on commit edc060f

Please sign in to comment.