1.40.3-33 • Published 2 years ago

@gustavoedny/crypto-ui v1.40.3-33

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

crypto-ui

What's this package?

Crypto-ui was created with the intent of share our business logic although our front-end repositories. As we have the need of a web mobile application, and a web desktop application, rewrite some features, vue components and business logic is not a option.

So we've created this NPM private package currently published at @gustavoedny/crypto-ui to share all our vue components, api services, vuex store and much more.

It also works as a Vuejs plugin, so we can share on any Vuejs 2 app.

Project setup

Docker environment

We highly recommend use our Docker + docker-compose environment, you will need Docker and docker-compose installed and then follow these steps:

  • Create the docker env file that will be used by docker-compose
cp .env.docker.example .env.docker

Then update the NPM_TOKEN value in your .env.docker file

  • Build the docker image with docker-compose
docker-composer build --no-cache

Running containers

  • To start the containers:
docker-composer up

it will start the development server at localhost:8082

To STOP the container just type CTRL+C or CMD+C in your terminal

Running containers in background

  • Running in background (Note that it will take a few seconds to the development server start at localhost:8082)
docker-composer up -d
  • To stop the container in background run:
docker-compose down

Local environment

To set up this project you will have to set up the NPM private token firstly, so when you have the token run the command bellow and make sure to replace the "NPM_TOKEN" by the provided token:

npm config set //registry.npmjs.org/:_authToken "NPM_TOKEN"

Once you have the private token configured you should install the package dependencies:

yarn global add @vue/cli @vue/cli-service-global && yarn install

Once dependencies have been installed you can start the development server:

yarn dev

Folder Structure

├── dev
│   ├── App.vue (The root component used on main.js and also the playground, where we can test /src components)
│   ├── main.js (Vue instance entrypoint, setup the plugin and dependencies including Vuetify)
│   ├── store.js (A fresh Vuex store)
│   ├── crypto-ui.js (Installs the crypto-ui plugin on the Vue instance)
│   ├── BetSlipWrapper.vue (BetSlip plug-and-play component to add on App.vue)
│   ├── betslip-state.json (Bet Slip dummy data)
├── dist (or build)
├── node_modules (NPM dependencies)
├── public (Developement server public folder)
├── src
│   ├── bus (Global event bus that can be used to comunicate events between components)
│   ├── components (All the library components, including Bet Slip)
│       ├── Small Component (Eg.: ShowMore)
│           ├── __tests__ (Component test suite)
│               ├── Component.spec.js
│           ├── Component.scss (Component styles)
│           ├── Component.vue (Component styles)
│           ├── index.js (Component entrypoint, will expose Component.vue publicly)
│       ├── Big Component (Eg.: BetSlip)
│           ├── SubComponent
│               ├── __tests__
│                   ├── SubComponent.spec.js
│               ├── SubComponent.vue
│               ├── SubComponent.scss
│               ├── index.js (SubComponent entrypoint)
│           ├── AnotherSubComponent
│           ├── BigComponent.vue
│           ├── BigComponent.scss
│           ├── index.js (BigComponent entrypoint, will make it public)
│   ├── exceptions (Http Errors and other exceptions)
│   ├── __tests__
│       ├── index.spec.hs
│       ├── index.js (All the exeptions)
│   ├── filters (Vuejs filters)
│       ├── index (Module entrypoint)
│       ├── install.js (Install module, allow globally install filters)
│   ├── input-rules (Form field validation rules, eg.: Password validation)
│       ├── field (example)
│           ├── __tests__
│               ├── field.spec.js
│           ├── index.js (Module entrypoint)
│           ├── field.js (Rules/Form field validation)
│   ├── mixins (Re-usable business logic and common features)
│       ├── Autencicable
│       ├── InteractsWithBetSlip
│       ├── Pagination
│       ├── Selectable
│       ├── Etc
│       ├── index.js (Module entrypoint)
│   ├── plugins (Plugins that should be shared on all platforms)
│       ├── i18n.js
│   ├── resources (Static Resources)
│       ├── img
│       ├── lang
│       ├── icons.js (Material Design icons mapper)
│   ├── services (HTTP API, Storage and Locale services, etc)
│       ├── API (The base API service)
│           ├── APIService.js
│           ├── index.js (Entrypoint)
│       ├── BetSlip (Bet Slip services)
│       ├── Etc
│       ├── index.js (Services entrypoint)
│   ├── store (Vuex Plugin module)
│       ├── modules
│           ├── auth.js
│           ├── betslip.js
│           ├── user.js
│       ├── index.js (Module entrypoint + Install function)
│   ├── styles
│       ├── main.sass (Global styles shared at all platforms)
│   ├── views (Shared base views)
│       ├── View
│           ├── __tests__ (Tests for the View component)
│               ├── Vue.spec.js
│       ├── View.vue
│       ├── View.scss
│       ├── index.js (Entrypoint - Will publicly exopose the components that should be shared, in that case View.vue)
│   ├── main.js
│   ├── setupTests.js (Setup the Vue instance for testing)
├── .env.local (Development server env vars)
├── README.md (This file)
├── package.json (Package dependencies and config)
└── .gitignore
└── .jest.config.js
└── Dockerfile
└── docker-compose.yml

Dev server, testing components and making changes

In this section I'm going to show you how to use the development server to test components, see your code changes in real-time and also be able to test component behavior with fake data.

  • So firstly let's start the development server (Skip this step if you are using Docker environment)
yarn dev

it will look like this

Imgur

  • Now go to your localhost server address un this case http://localhost:8080
  • As we are running it for the first time, there are no components registered on our dev/App.vue so you will see a black screen that's our component playground where we can test the components manually. So the page will look like this Imgur
  • So now open dev/App.vue in your code editor and make the following changes
<template>
  <v-app :dark="true">
    <v-container fluid>
      <v-content>
        <div class="playground-wrapper elevation-3">
          <v-row>
            <v-col>
              <BetSlipWrapper></BetSlipWrapper>
            </v-col>
          </v-row>
        </div>
      </v-content>
    </v-container>
  </v-app>
</template>

<script>
import '@/styles/main.sass'
import BetSlipWrapper from './BetSlipWrapper'
export default {
  name: 'App.vue',

  components: { BetSlipWrapper },

  data: () => ({}),

  methods: {}
}
</script>

<style scoped>
.playground-wrapper {
  background-color: #232323;
  border-radius: 5px;
  padding: 0px;
  margin-top: 50px;
}
</style>

Now our page will load the BetSlipWrapper component and will look like this

Imgur

As you can see the bet slip is empty, and we need to add some fake data to test it. If you to /dev folder you will see that we have a betslip-state.json file that has fake data to pupulate the betslip. The betslip data is managed by Vuex which is Vuejs official package to handle the application state. This package comes with Vuex Store module at /src/store, and there's a betslip module at /src/store/modules/betslip.js which has all the bet slip business logic and manage it's data.

So let's have a look at the Bet Slip Vuex module, it should look like this:

Imgur

As you can see the betslip.js module state is load by BetSlipStorageService.load() method. Which loads data from the localStorage API. So to populate the betslip data we just need to add it's data on our localStorage, So you have to run this on your browser:

localStorage.setItem('betslip', `{
  "placed": false,
  "visible": false,
  "selections": [
    {
      "eventName": "Novak Djokovic v Andrej Martin",
      "marketName": "Total Games",
      "id": 353062584,
      "market_id": 1606,
      "match_id": 122877,
      "match_market_id": 470280,
      "odds": 1.909,
      "name": "16.5",
      "header": "Over",
      "handicap": null,
      "is_suspended": false,
      "is_live": true,
      "order": 0
    },
    {
      "eventName": "Timofey Skatov v Nikolas S Izquierdo",
      "marketName": "Total Games",
      "id": 353062626,
      "market_id": 1606,
      "match_id": 122875,
      "match_market_id": 470282,
      "odds": 1.833,
      "name": "21.5",
      "header": "Over",
      "handicap": null,
      "is_suspended": false,
      "is_live": true,
      "order": 0
    },
    {
      "eventName": "Evan Furness v Jenson Brooksby",
      "marketName": "To Win",
      "id": 353048564,
      "market_id": 1605,
      "match_id": 122781,
      "match_market_id": 470275,
      "odds": 4.333,
      "name": "Match",
      "header": "Evan Furness",
      "handicap": null,
      "is_suspended": false,
      "is_live": true,
      "order": 0
    },
    {
      "eventName": "Kurumi Nara v Stefanie Voegele",
      "marketName": "To Win",
      "id": 353119101,
      "market_id": 1605,
      "match_id": 122821,
      "match_market_id": 470292,
      "odds": 2,
      "name": "Match",
      "header": "Kurumi Nara",
      "handicap": null,
      "is_suspended": false,
      "is_live": true,
      "order": 0
    },
    {
      "eventName": "Hua/Zhang v Cash/Stalder",
      "marketName": "To Win",
      "id": 353035402,
      "market_id": 1605,
      "match_id": 122706,
      "match_market_id": 470271,
      "odds": 2.2,
      "name": "Match",
      "header": "Hua/Zhang",
      "handicap": null,
      "is_suspended": false,
      "is_live": true,
      "order": 0
    }
  ],
  "changes": [
    {
      "id": 353062584,
      "match_id": 122877,
      "odds": 1.833,
      "changed": true,
      "suspended": false,
      "available": true
    },
    {
      "id": 353048564,
      "match_id": 122781,
      "odds": 3.75,
      "changed": true,
      "suspended": false,
      "available": true
    }
  ],
  "multipleStake": null
}`)

Now that you've set the betslip data on your localStorage, reload your page and the your betslip will look like this:

Imgur

Making changes on components

Now that we have the betslip working on our dev server we can do any code change we need on it's components at /src/components/BetSlip, to give you a example let's change the betslip backgrond color to white by changing the BetSlip.scss file:

...
.bet-slip-wrapper {
  ...
  background-color: #ffffff !important;
  ...
}
...

It will look like this now:

Imgur

To make changes on other components you should follow a similar process, but it will be easier than set up the betslip for testing since its one of our biggest components. So you have to:

  • Import the component on /dev/App.vue
  • Populate it with data if needed
  • Do your changes on the components and test it, use unit testing if needed
  • Commit your changes and make sure to do not commit the changes on /dev/App.vue. So this way other developers will have the playground always clean to test.

Running your unit tests

yarn test:unit

Lints and fixes files

yarn lint

Customize configuration

See Configuration Reference.

1.40.3-33

2 years ago

1.40.3-32

2 years ago

1.40.3-31

2 years ago

1.40.3-30

2 years ago

1.40.3-22

2 years ago

1.40.3-26

2 years ago

1.40.3-25

2 years ago

1.40.3-24

2 years ago

1.40.3-23

2 years ago

1.40.3-29

2 years ago

1.40.3-28

2 years ago

1.40.3-27

2 years ago

1.40.3-2

2 years ago

1.40.3-1

2 years ago

1.40.3-4

2 years ago

1.40.3-3

2 years ago

1.40.3-6

2 years ago

1.40.3-5

2 years ago

1.40.3-8

2 years ago

1.40.3-7

2 years ago

1.40.3-9

2 years ago

1.40.3-11

2 years ago

1.40.3-10

2 years ago

1.40.3-15

2 years ago

1.40.3-14

2 years ago

1.40.3-13

2 years ago

1.40.3-12

2 years ago

1.40.3-19

2 years ago

1.40.3-18

2 years ago

1.40.3-17

2 years ago

1.40.3-16

2 years ago

1.40.3-21

2 years ago

1.40.3-20

2 years ago

1.40.2-beta-106

2 years ago

1.40.2-beta-105

2 years ago

1.40.2-beta-104

2 years ago

1.40.2-beta-103

2 years ago

1.40.2-beta-102

2 years ago

1.40.2-beta-84

2 years ago

1.40.2-beta-86

2 years ago

1.40.2-beta-85

2 years ago

1.40.2-beta-88

2 years ago

1.40.2-beta-87

2 years ago

1.40.2-beta-89

2 years ago

1.40.2-beta-101

2 years ago

1.40.2-beta-100

2 years ago

1.40.2-beta-95

2 years ago

1.40.2-beta-94

2 years ago

1.40.2-beta-97

2 years ago

1.40.2-beta-96

2 years ago

1.40.2-beta-99

2 years ago

1.40.2-beta-98

2 years ago

1.40.2-beta-91

2 years ago

1.40.2-beta-90

2 years ago

1.40.2-beta-93

2 years ago

1.40.2-beta-92

2 years ago

1.40.2-beta-83

2 years ago

1.40.2-beta-80

2 years ago

1.40.2-beta-82

2 years ago

1.40.2-beta-81

2 years ago

1.40.2-beta-77

2 years ago

1.40.2-beta-76

2 years ago

1.40.2-beta-79

2 years ago

1.40.2-beta-78

2 years ago

1.40.2-beta-75

2 years ago

1.40.2-beta-74

2 years ago

1.40.2-beta-73

2 years ago

1.40.2-beta-72

2 years ago

1.40.2-beta-71

2 years ago

1.40.2-beta-70

2 years ago

1.40.2-beta-69

2 years ago

1.40.2-beta-68

2 years ago

1.40.2-beta-67

2 years ago

1.40.2-beta-66

2 years ago

1.40.2-beta-65

2 years ago

1.40.2-beta-64

2 years ago

1.40.2-beta-63

2 years ago

1.40.2-beta-62

2 years ago

1.40.2-beta-61

2 years ago

1.40.2-beta-60

2 years ago

1.40.2-beta-59

2 years ago

1.40.2-beta-58

2 years ago

1.40.2-beta-57

2 years ago

1.40.2-beta-56

2 years ago

1.40.2-beta-55

2 years ago

1.40.2-beta-54

2 years ago

1.40.2-beta-53

2 years ago

1.40.2-beta-52

2 years ago

1.40.2-beta-51

2 years ago

1.40.2-beta-50

2 years ago

1.40.2-beta-49

2 years ago

1.40.2-beta-48

2 years ago

1.40.2-beta-47

2 years ago

1.40.2-beta-46

2 years ago

1.40.2-beta-45

2 years ago

1.40.2-beta-44

2 years ago

1.40.2-beta-43

2 years ago

1.40.2-beta-42

2 years ago

1.40.2-beta-41

2 years ago

1.40.2-beta-40

2 years ago

1.40.2-beta-39

2 years ago

1.40.2-beta-38

2 years ago

1.40.2-beta-37

2 years ago

1.40.2-beta-36

2 years ago

1.40.2-beta-35

2 years ago

1.40.2-beta-34

2 years ago

1.40.2-beta-33

2 years ago

1.40.2-beta-32

2 years ago

1.40.2-beta-31

2 years ago

1.40.2-beta-30

2 years ago

1.40.2-beta-29

2 years ago

1.40.2-beta-28

2 years ago

1.40.2-beta-27

2 years ago

1.40.2-beta-26

2 years ago

1.40.2-beta-25

2 years ago

1.40.2-beta-24

2 years ago

1.40.2-beta-23

2 years ago

1.40.2-beta-22

2 years ago

1.40.2-beta-21

2 years ago

1.40.2-beta-20

2 years ago

1.40.2-beta-19

2 years ago

1.40.2-beta-18

2 years ago

1.40.2-beta-17

3 years ago

1.40.2-beta-16

3 years ago

1.40.2-beta-15

3 years ago

1.40.2-beta-14

3 years ago

1.40.2-beta-13

3 years ago

1.40.2-beta-12

3 years ago

1.40.2-beta-11

3 years ago

1.40.2-beta-10

3 years ago

1.40.2-beta-9

3 years ago

1.40.2-beta-8

3 years ago

1.40.2-beta-7

3 years ago

1.40.2-beta-6

3 years ago

1.40.2-beta-5

3 years ago

1.40.2-beta-3

3 years ago

1.40.2-beta-2

3 years ago

1.40.2-beta-1

3 years ago

1.40.2-beta

3 years ago

1.40.1

3 years ago

1.40.0

3 years ago

1.39.6

3 years ago

1.39.5

3 years ago

1.39.4

3 years ago

1.39.3

3 years ago

1.39.2

3 years ago

1.39.1

3 years ago

1.39.0

3 years ago

1.38.3

3 years ago

1.38.2

3 years ago

1.38.1

3 years ago

1.38.0

3 years ago

1.37.7

3 years ago

1.37.6

3 years ago

1.37.5

3 years ago

1.37.4

3 years ago

1.37.3

3 years ago

1.37.2

3 years ago

1.37.1

3 years ago

1.37.0-3

3 years ago

1.37.0-2

3 years ago

1.37.0-1

3 years ago

1.37.0

3 years ago

1.36.4

3 years ago

1.36.3

3 years ago

1.36.2

3 years ago

1.36.1

3 years ago

1.36.0

3 years ago

1.35.5

3 years ago

1.35.4

3 years ago

1.35.3

3 years ago

1.35.2

3 years ago

1.35.1

3 years ago

1.35.0

3 years ago

1.34.1

3 years ago

1.34.0

3 years ago

1.33.1

3 years ago

1.33.0

3 years ago

1.32.9

3 years ago

1.32.8

3 years ago

1.32.7

3 years ago

1.32.6

3 years ago

1.32.6-beta-14

3 years ago

1.32.6-beta-13

3 years ago

1.32.6-beta-12

3 years ago

1.32.6-beta-11

3 years ago

1.32.6-beta-10

3 years ago

1.32.6-beta-9

3 years ago

1.32.6-beta-8

3 years ago

1.32.6-beta-7

3 years ago

1.32.6-beta-6

3 years ago

1.32.6-beta-5

3 years ago

1.32.6-beta-4

3 years ago

1.32.6-beta-3

3 years ago

1.32.6-beta-2

3 years ago

1.32.6-beta-1

3 years ago

1.32.6-beta

3 years ago

1.32.5

3 years ago

1.32.5-beta

3 years ago

1.32.4

3 years ago

1.32.3

3 years ago

1.32.2-beta-1

3 years ago

1.32.2

3 years ago

1.32.1

3 years ago

1.32.0

3 years ago

1.31.9

3 years ago

1.31.8

3 years ago

1.31.7

3 years ago

1.31.6

3 years ago

1.31.5

3 years ago

1.31.4

3 years ago

1.31.3

3 years ago

1.31.2

3 years ago

1.31.1

3 years ago

1.31.0

3 years ago

1.30.9

3 years ago

1.30.8

3 years ago

1.30.7

3 years ago

1.30.6

3 years ago

1.30.5

3 years ago

1.30.4

3 years ago

1.30.3

3 years ago

1.30.2

3 years ago

1.30.1

3 years ago

1.30.0

3 years ago

1.29.0

3 years ago

1.28.1

3 years ago

1.28.0

3 years ago

1.27.1

3 years ago

1.27.0

3 years ago

1.26.0

3 years ago

1.25.0

3 years ago

1.24.8

3 years ago

1.24.7

3 years ago

1.24.6

3 years ago

1.24.5

3 years ago

1.24.4

3 years ago

1.24.3

3 years ago

1.24.2

3 years ago

1.24.1

3 years ago

1.24.0

3 years ago

1.21.1

3 years ago

1.21.0

3 years ago

1.20.9

3 years ago

1.20.8

3 years ago

1.20.7

3 years ago

1.20.6

3 years ago

1.20.5

3 years ago

1.20.4

3 years ago

1.20.3

3 years ago

1.20.2

3 years ago

1.20.1

3 years ago

1.20.0

3 years ago

1.19.9

3 years ago

1.19.8

3 years ago

1.19.7

3 years ago

1.19.6

3 years ago

1.19.5

3 years ago

1.19.4

3 years ago

1.19.3

3 years ago

1.19.2

3 years ago

1.19.1

3 years ago

1.19.0

3 years ago

1.18.9

3 years ago

1.18.8

3 years ago

1.18.7

3 years ago

1.18.6

3 years ago

1.18.5

3 years ago

1.18.4

3 years ago

1.18.3

3 years ago

1.18.2

3 years ago

1.18.1

3 years ago

1.18.0

3 years ago

1.17.0

3 years ago

1.16.0

3 years ago

1.15.0

3 years ago

1.14.0

3 years ago

1.13.3

3 years ago

1.13.2

3 years ago

1.13.1

3 years ago

1.13.0

3 years ago

1.12.6

3 years ago

1.12.5

3 years ago

1.12.4

3 years ago

1.12.3

3 years ago

1.12.2

3 years ago

1.12.1

3 years ago

1.11.3

3 years ago

1.11.2

3 years ago

1.11.1

3 years ago

1.11.0

3 years ago

1.10.9

3 years ago

1.10.8

3 years ago

1.10.7

4 years ago

1.10.6

4 years ago

1.10.5

4 years ago

1.10.4

4 years ago

1.10.3

4 years ago

1.10.2

4 years ago

1.10.1

4 years ago

1.10.0

4 years ago

1.9.3

4 years ago

1.9.2

4 years ago

1.9.1

4 years ago

1.9.0

4 years ago

1.8.1

4 years ago

1.8.0

4 years ago

1.7.9

4 years ago

1.7.8

4 years ago

1.7.7

4 years ago

1.7.6

4 years ago

1.7.5

4 years ago

1.7.4

4 years ago

1.7.3

4 years ago

1.7.2

4 years ago

1.7.1

4 years ago

1.7.0

4 years ago

1.6.9

4 years ago

1.6.8

4 years ago

1.6.7

4 years ago

1.6.6

4 years ago

1.6.5

4 years ago

1.6.4

4 years ago

1.6.3

4 years ago

1.6.2

4 years ago

1.6.1

4 years ago

1.6.0

4 years ago

1.5.9

4 years ago

1.5.8

4 years ago

1.5.7

4 years ago

1.5.6

4 years ago

1.5.5

4 years ago

1.5.4

4 years ago

1.5.3

4 years ago

1.5.2

4 years ago

1.5.1

4 years ago

1.5.0

4 years ago

1.4.9

4 years ago

1.4.8

4 years ago

1.4.7

4 years ago

1.4.6

4 years ago

1.4.5

4 years ago

1.4.4

4 years ago

1.4.3

4 years ago

1.4.2

4 years ago

1.4.1

4 years ago

1.4.0

4 years ago

1.3.2

4 years ago

1.3.1

4 years ago

1.3.0

4 years ago

1.2.1

4 years ago

1.2.0

4 years ago

1.1.0

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago

0.9.0

4 years ago

0.8.6

4 years ago

0.8.5

4 years ago

0.8.4

4 years ago

0.8.3

4 years ago

0.8.2

4 years ago

0.8.1

4 years ago

0.8.0

4 years ago

0.7.1

4 years ago

0.7.0

4 years ago

0.6.0

4 years ago

0.5.9

4 years ago

0.5.8

4 years ago

0.5.7

4 years ago

0.5.6

4 years ago

0.5.5

4 years ago

0.5.4

4 years ago

0.5.3

4 years ago

0.5.2

4 years ago

0.5.1

4 years ago

0.4.4

4 years ago

0.4.3

4 years ago

0.4.2

4 years ago

0.4.1

4 years ago

0.4.0

4 years ago

0.3.2

4 years ago

0.3.1

4 years ago

0.3.0

4 years ago

0.2.0

4 years ago

0.1.3

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago