GithubHelp home page GithubHelp logo

rsksmart / rif-ui Goto Github PK

View Code? Open in Web Editor NEW
5.0 10.0 3.0 14.93 MB

React library for RIF projects

Home Page: https://www.rifos.org/

HTML 0.49% JavaScript 11.44% CSS 13.03% TypeScript 75.04%
rif react react-lib

rif-ui's Introduction

RIF logo

RIF-UI

This is a React library written in Typescript and based on Material-UI. It exposes common components, services and assets to be re used in RIF projects.

license MIT npm package CircleCI Managed by tAsEgir Follow on Twitter Dependabot Status

Warning: This project is in alpha state. There might (and most probably will) be changes in the future to its working. Also, no guarantees can be made about its stability, efficiency, and security at this stage.


Lead Maintainer

Alvaro Fariña

See what "Lead Maintainer" means here.

Installation

npm i @rsksmart/rif-ui

Getting Started

Basic Usage

In order to experience all the benefits of this library, we recommend to wrap your application with the ThemeProvider component from Material-UI and pass in our Material-UI theme.

import React, { FC } from 'react'
import { ThemeProvider } from '@material-ui/core/styles'
import { theme, Typography } from '@rsksmart/rif-ui'
import '@rsksmart/rif-ui/dist/index.css'

const App = () => {
  return (
    <ThemeProvider theme={theme}>
      <Typography color='primary'>Hello world :)</Typography>
    </ThemeProvider>
  )
}

export default App

Using Header and PageTemplate components

The Header and PageTemplate components were styled and designed to work together. So, whenever you need one of them, we suggest to follow the next example

import { Header, PageTemplate, theme, Typography } from '@rsksmart/rif-ui'
import { ThemeProvider } from '@material-ui/core/styles'
import { BrowserRouter } from 'react-router-dom'

const App = () => (
  <ThemeProvider theme={theme}>
    <BrowserRouter>
      <Header />
      <PageTemplate>
        <Typography color='primary'>Hello world :)</Typography>
      </PageTemplate>
    </BrowserRouter>
  </ThemeProvider>
)

Web3Provider

On the Web3Provider you can set the property requiredNetworkId and the actions onConnectedAccountChange, onConnectedNetworkChange that will get triggered once the user wallet is connected and there is a change on the account or network. As an example

<Web3Provider.Provider 
  requiredNetworkId={requiredNetworkId}
  actions={{
    onConnectedAccountChange: onConnectedAccountChange,
    onConnectedNetworkChange: onConnectedNetworkChange
  }}>

  {/* Your stuff here */}
  
</Web3Provider.Provider >

Development - Example folder

A sandbox project is provided in order to test the library or try new features locally without having to release a new version. It lives at the example folder. In order to run it, follow the next steps:

  1. At rif-ui:
npm i
npm start
  1. Wait until it compiles to the dist folder. Then, in another terminal:
cd example/ && npm start
  1. (Optional) Import the components, assets or services that you want in the example/src/App.js file following the Usage section to see them in action.

Testing

To run unit test and build the library, you can use

npm run test

If you only want to run the unit test, you can use

npm run test:unit

License

MIT © rsksmart

Acknowledgments

  • This library was created with create-react-library. A great project to start you own library.
  • Thanks to EVM Networks for providing the data source of network objects as a JSON, which inspired us to create the NetworkInfo interface

rif-ui's People

Contributors

auhau avatar dependabot-preview[bot] avatar itofarina avatar julianmrodri avatar jurajpiar avatar vojtechsimetka avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rif-ui's Issues

Remove Typography component

The Typography component does not add much value to the Material-UI Typography component and leads to confusion when using both libraries.

[BUG] Ask user to log in to their wallet when connects the provider

Describe the bug
When the user is logged out from the wallet and connects the provider, the Account component displays "Wrong Network". We need to display proper message for this, something like "Provide an account"

To Reproduce
Steps to reproduce the behavior:

  1. Switch to the correct network
  2. Log out in the provider
  3. You will see a check ("You are on the right network") while the account text says "Wrong Network"

Expected behavior
Should tell the user to provide an account or log in to the wallet

Screenshots
Screen Shot 2020-06-25 at 16 22 04

Additional information
Should be tackled after #89

The inputs in RangeSliderWithInputs do not get updated.

Changes to edge values for the RangeSliderWithInputs component do not trigger the change of the input fields. It seems that the min max values are not actually being used to set the input component values. I suggest revising the RangeSliderWithInputs component.

Screenshot 2020-05-04 at 11 20 55

web3: identify browser wallet

Right now we are saying every browser wallet is metamask. We should detect this fact and correctly show to user the name and ideally icon of the wallet they are using (at least for the most known wallets)

web3: detect networkChanged

At the moment, the browser reloads the page when the network changes. But MetaMask will soon stop doing that. We should detect this and the Web3Provider should act upon that.

Console warning when switching networks

MetaMask will soon stop reloading pages on network change. If you rely upon this behavior, add a 'networkChanged' event handler to trigger the reload manually: https://metamask.github.io/metamask-docs/API_Reference/Ethereum_Provider#ethereum.on(eventname%2C-callback)

web3: detect account changed

The page no longer reloads in many wallet when switching between accounts in the same wallet (e.g. metamask, nifty). This should be detected and the Web3Provider should appropriately provide new information.

[BUG] Account indicator misleads when not logged in

Describe the bug
The account indicator in the top right corner shows a green tick after clicking on connect to wallet even if the user is not logged in in the said wallet. Note, that the indicator reflects the state correctly textually, just not visually.

To Reproduce
Steps to reproduce the behavior:

  1. Close down browser completely and reopen
  2. Do not login to your wallet
  3. Click on "connect wallet"

Expected behavior
The indicator should show an icon reflecting the incompleteness of the action performed, such as warning sign.

Screenshots
Screenshot 2020-10-16 at 14 23 50

Compilation error when deploying

Issue moved from rif-marketplace-ui

The project is not running when deployed locally. The following error gets shown ,related to RIF-UI probably.

image

Split Header component

Right now we have HeaderComponent and AppBarComponent, the first one is the parent of desktop and has mobile component inside, the second one is for desktop.
We need architectural change to integrate them into 3 separated components

Changes to Header

Modify the Marketplace Header component based on the provided designs in the US

Add RIF blue logo image

Description
We need to be able to consume the blue logo from the library

Describe the solution you'd like
Export the image

[BUG] Broken MUI styles

Describe the bug
When a component that uses MUI styles is added as a sibling to the RUI Footer some of the components' styles are being overwritten by MUI default styles.

To Reproduce
Steps to reproduce the behaviour:

  1. Go to marketplace-ui repo
  2. Checkout staging branch
  3. Reset (hard) on commit 9391efe311842e13416c7767da0fe2ab2d1ecaa9
  4. Run the application
  5. The login button will have incorrect styling
  6. The main title will have incorrect styling
  7. Go to FAQ page
  8. The title will have incorrect styling

Expected behaviour
A clear and concise description of what you expected to happen.

Screenshots
Screenshot 2021-04-06 at 09 14 00

The effects of the bug have been captured in https://rsklabs.atlassian.net/browse/RMKT-512?focusedCommentId=19495 during QA review.

Create LoginOptionTemplate component

Right now we only have LoginOption component. When no props are passed it suggests to install Nifty wallet, otherwise it list the provider option.

It would be nice to extract this template for separation of concerns

Update rif logo

We need to update update the black and blue and full white logos

Account component should behave depending on the connection status

Problem
When the provider is set and the user clicks on the Account component, we still show the set provider options.

Solution
We should show something relevant in these situations:

  • If the user is properly logged in, the modal doesn't add any value
  • If the user is on the wrong network, we should ask to switch network

Implementation idea
Our Web3Provider could have ConnectionStatus prop on the state that would tell the components how to act depending on the situation

Screenshots
Screen Shot 2020-08-17 at 17 17 40
Screen Shot 2020-08-17 at 17 17 56

Export components props at root level

Problem

Right now we are not exporting the interfaces that define the props needed by the components. So for example when using the library and want to import the TooltipIconButtonProps, the user needs to do import { TooltipIconButtonProps } from '@rsksmart/rif-ui/dist/components/molecules/TooltipIconButton'.

Solution

Export types at root level so users can do import { TooltipIconButtonProps } from '@rsksmart/rif-ui

[BUG] WithSpinner HOC is not spinning

Describe the bug
The WithSpinner HOC should be spinning, it looks like we lost some css animations.

To Reproduce
Use WithSpinner HOC

Expected behavior
The spinner should spin

Expose typings

Description
Right now we are not exposing the typings of the components. This makes it difficult to work with the library as users need to look at the source code to know which props a component should get

Tell user to switch network while on wrong network

Problem

When the user is on the wrong network, the LoginModal shows a wallet to connect, even if the wallet is already connected.

Solution

The modal should display a message asking the user to switch to the proper network.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.