Skip to content
This repository has been archived by the owner on Jul 11, 2022. It is now read-only.

Latest commit

 

History

History
124 lines (83 loc) · 5.49 KB

GETTING_STARTED.md

File metadata and controls

124 lines (83 loc) · 5.49 KB

How we develop our interfaces

Artwork by Rocco Lombardi | medium

CommonsPub is a multifunctional federated network that allows communities to coordinate a wide range of needs together and connect to other like-minded communities.

Over the last year we worked hard to define a streamlined and productive development process to code, customize and evolve the user interface (UI) of this open federated network.

Our vision was to achieve modularity through simplicity, an old and ongoing quest, even more important when the product should reflect not only the company brand, ethics and goals, but also be flexible enough to satisfy diverse needs. After all, each instance on the federated networks might be run by people with different goals and values.

As open source software is becoming more and more prominent over the web, we have to deal also with wider issues:

  • How does the design of open source software help shape communities?
  • How do communities shape the open source software?
  • How can this symbiosis can empower both parties? (rather than slowly bind them to an unproductive and frustrating relationship)

The following is a technical documentation to describe how we developed the CommonsPub front-end codebase to accomplish such challenges and a way to encourage designers, developers and instance admins to contribute with ideas and codes to such vision.

Getting started

Get the code

git clone https://gitlab.com/CommonsPub/Client.git commonspub

Install the needed dependencies
cd commonspub
yarn
Setup the local environment
cp .env.example .env
Run the backend

The CommonsPub client connects to a graphql endpoint to perform queries and mutation over the database.

In order to launch locally the client, you’ll need a running backend. Here you will find a detailed documentation about how to run the CommonsPub backend locally (manually or with docker).

Once you’ve got a backend up and running on http://localhost:4000, you can move further running the client. (nd. If you just want to run storybook, there is no need to install and run any backend, as stories are populated with fake data)

Note that if you run the client and the server on the same machine with default settings, the GraphQL server will be listening on port 4004. The environment variable REACT_APP_GRAPHQL_ENDPOINT should be then changed to http://localhost:4004/api/graphql in .env. You will be able to access the Apollo GraphQL Playground at the same address in the browser.

Extract the languages

We use linguijs to provide multi-languages. Before launching the app, make sure you’ve added one or more translations to the app.

Currently CommonsPub is translated in the following languages:

en_GB: 'English, British',
en_US: 'English, USA',
es_MX: 'Español, Méjico',
es_ES: 'Español, España',
fr_FR: 'Français, France',
eu: 'Euskara',
ar_SA: 'العربية, المملكة العربية السعودية'

Apart from en_GB that is the default language, feel free do add the needed translations for your scope, when launching the script:

yarn add-locale en_GB en_US es_MX es_ES fr_FR eu ar_SA
Launch CommonsPub
yarn start

Visit http://localhost:4000 🌱

Launch the Storybook

A storybook is available to document the different UI components and their use cases. You can run it with:

yarn storybook

Visit http://localhost:5000 🍄

The tech stack

(Describe the main libraries we use, and how they are related to each others)

Our main dependencies are:

  • Typescript - a strict syntactical superset of JavaScript
  • React - a JavaScript library for building user interfaces
  • Apollo - a complete state management library for JavaScript apps
  • Rebass - react primitive UI components built with styled-system
  • Styled-components - styled-components allows you to write actual CSS code to style your components
  • Storybook - It makes building stunning UIs organized and efficient
  • Lingui - A readable, automated, and optimized (5 kb) internationalization for JavaScript

How to create a new feature

(Describe our internal flow when dealing with a new feature: how we design the related module and implement the needed business logic to hook it to the Back end)

How to customize CommonsPub

(Describe in which ways and terms a community can adapt CommonsPub FE to their own requirement)

  1. Configure CommonsPub via the admin dashboard

  2. Create a new theme

  3. Edit a module in the component library

  4. Add a new language

  5. ...

Next steps

  1. Export the component library in separate library