1.1.51 • Published 2 days ago

@ribon.io/shared v1.1.51

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
2 days ago

@ribon.io/shared

Small library used to share resources between our frontends

Usage:

  • Install via yarn
    yarn add @ribon.io/shared
- Import and use whatever you want!
```js
import { defaultDisplayLarge, theme } from '@ribon.io/shared/styles';
import { useNonProfits } from '@ribon.io/shared/hooks';

export const Title = styled.h1`
      ${defaultDisplayLarge};
      color: ${({ theme }) => theme.colors.green30};
      font-weight: ${({ theme }) => theme.font.light};
`;

// in a component (check setup hooks for using api hooks)
function MyComponent() {
  const { nonProfits, loading, error } = useNonProfits();
  // ...
}

Setup hooks:

@ribon.io/shared lib uses the react-query lib to make caches of api calls. In order to use the hooks you need to wrap your app with the QueryClientComponent component:

import { QueryClientComponent } from "@ribon.io/shared/hooks";

function App() {
  return (
    <QueryClientProvider>
        ...
    </QueryClientProvider>
  );
}

Developing locally:

  • Clone the repo:
git clone git@github.com:RibonDAO/shared.git  
  • Install dependencies
yarn

You can code and test directly in the project using the jest test runner. To run the tests:

yarn test

If you want to use the lib in another project, you can start the project (it will build the lib and watch for changes) and link it to the other project:

yarn start
cd dist
yarn link

Notice you need to link the dist folder, that is generated after the build process. Observation: This does not work with react-native (see more in here). You can check the section React Native Problems below to see how to use it on the mobile app.

Then in the project you want to test the changes:

yarn link @ribon.io/shared

This will link the local version of the lib to the project. Instead of using the @ribon.io/shared package from npm, it will use from your local machine. When you make changes to the @ribon.io/shared lib locally, it will be reflected in the project you are testing.

Publishing:

To make a new release, you need to bump the version in the package.json and create a new git tag for it. Use the npm version command:

npm version patch //(or other version type command)
git push -u origin main --tags // this will push the new github tag that is correspondent to the npm version

To deploy the new version, you have to create a new release in the github UI. There is a github action to automatically deploy to npm after a new github release is created.

Tips:

  • Normally, before creating a new hook, lib, api call or other resource, you can first create this on the project you are working with, and after if you see a necessity, you can move it to the shared lib. This way you can test it and see if it is really necessary to move it to the shared lib.

What can we share?

  • Types (entities, responses and enums)
  • Styles (theme and typography)
  • Hooks and services
  • Small libs (NOT IMPLEMENTED YET)

React-native problems

React-native doesn't recognize stylized typography (that one using the Gambarino font). So we need to use a different approach to load custom fonts on mobile frontends. It will be implemented until the end of 2022.

React-native doesn't support symlinks, so we cannot use yarn link to build locally. To develop locally, you can use the command yarn dev on the ribon-shared project and create a .env with the relative path to the mobile app project. Example:

RIBON_NATIVE_PATH=../native-dapp

It has to have the RIBON_NATIVE_PATH variable and a relative path from the ribon-shared directory. It will copy the dist folder to the mobile app project and you can use the local version of the lib.

1.1.51

2 days ago

1.1.50

3 days ago

1.1.49

9 days ago

1.1.48

15 days ago

1.1.47

16 days ago

1.1.46

22 days ago

1.1.45

29 days ago

1.1.44

1 month ago

1.1.43

1 month ago

1.1.41

1 month ago

1.1.40

1 month ago

1.1.42

1 month ago

1.1.39

1 month ago

1.1.38

2 months ago

1.1.37

2 months ago

1.1.36

2 months ago

1.1.34

2 months ago

1.1.33

2 months ago

1.1.32

2 months ago

1.1.35

2 months ago

1.1.30

2 months ago

1.1.31

2 months ago

1.1.29

2 months ago

1.1.28

2 months ago

1.1.27

3 months ago

1.1.26

3 months ago

1.1.25

3 months ago

1.1.24

3 months ago

1.1.22

3 months ago

1.1.21

3 months ago

1.1.20

3 months ago

1.1.19

3 months ago

1.1.18

3 months ago

1.1.17

3 months ago

1.1.16

3 months ago

1.1.15

4 months ago

1.1.14

4 months ago

1.0.77

10 months ago

1.0.76

10 months ago

1.0.75

10 months ago

1.0.74

10 months ago

1.0.79

9 months ago

1.0.78

10 months ago

1.1.1

7 months ago

1.1.0

7 months ago

1.1.9

6 months ago

1.1.8

6 months ago

1.1.7

6 months ago

1.1.6

6 months ago

1.1.4

7 months ago

1.1.3

7 months ago

1.1.12

5 months ago

1.1.11

5 months ago

1.1.10

5 months ago

1.1.13

5 months ago

1.0.80

9 months ago

1.0.84

9 months ago

1.0.83

9 months ago

1.0.82

9 months ago

1.0.81

9 months ago

1.0.88

8 months ago

1.0.87

9 months ago

1.0.86

9 months ago

1.0.89

8 months ago

1.0.91

8 months ago

1.0.90

8 months ago

1.0.95

7 months ago

1.0.94

8 months ago

1.0.93

8 months ago

1.0.73

11 months ago

1.0.62

11 months ago

1.0.61

12 months ago

1.0.60

12 months ago

1.0.66

11 months ago

1.0.65

11 months ago

1.0.64

11 months ago

1.0.63

11 months ago

1.0.69

11 months ago

1.0.68

11 months ago

1.0.72

11 months ago

1.0.71

11 months ago

1.0.70

11 months ago

1.0.55

12 months ago

1.0.54

1 year ago

1.0.53

1 year ago

1.0.52

1 year ago

1.0.59

12 months ago

1.0.58

12 months ago

1.0.57

12 months ago

1.0.56

12 months ago

1.0.37

1 year ago

1.0.39

1 year ago

1.0.38

1 year ago

1.0.40

1 year ago

1.0.44

1 year ago

1.0.43

1 year ago

1.0.42

1 year ago

1.0.41

1 year ago

1.0.48

1 year ago

1.0.47

1 year ago

1.0.46

1 year ago

1.0.45

1 year ago

1.0.49

1 year ago

1.0.51

1 year ago

1.0.50

1 year ago

1.0.29

1 year ago

1.0.28

1 year ago

1.0.27

1 year ago

1.0.33

1 year ago

1.0.32

1 year ago

1.0.30

1 year ago

1.0.36

1 year ago

1.0.35

1 year ago

1.0.34

1 year ago

1.0.26

1 year ago

1.0.25

1 year ago

1.0.24

1 year ago

1.0.23

1 year ago

1.0.22

1 year ago

1.0.21

1 year ago

1.0.20

1 year ago

1.0.19

1 year ago

1.0.17

1 year ago

1.0.16

1 year ago

1.0.14

1 year ago

1.0.12

1 year ago

1.0.11

1 year ago

1.0.10

1 year ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago