Giter Site home page Giter Site logo

pi-ui's Introduction

pi-ui

Build Status

Politeia UI library documentation

NPM JavaScript Style Guide

Install

Make sure you have nodejs 8+ and yarn or npm installed.

yarn

yarn add pi-ui

npm

npm install --save pi-ui

Usage

In the index file of your app make sure to import the styles for the lib:

  • index.js:
import "pi-ui/dist/index.css";
  • Component.js:
import React, { Component } from "react";

import { Button } from "pi-ui";

class Example extends Component {
  render() {
    return <Button />;
  }
}

Breakpoints

Pi-ui's custom breakpoints make use of the postcss-preset-env plugin. In order to use the breakpoints you have to add the plugin to your environment. For this, see the postcss install page.

In your postcss.config.js, you will have to importFrom pi-ui's export.css file. If you are developing with a linked pi-ui, import from your local pi-ui. Example:

const { resolveOwn } = require("../../utils");

module.exports = {
  plugins: [
    [
      "postcss-preset-env",
      {
        // When developing with a linked `pi-ui`
        // Point the importFrom to the path of the linked package in your env
        importFrom: resolveOwn("../../../../pi-ui/dist/exports.css")
      }
    ]
  ]
};

If you are developing with a npm/yarn installed pi-ui package, import from your node-modules. Example:

module.exports = {
  plugins: [
    [
      "postcss-preset-env",
      {
        // When developing with an installed `pi-ui`
        // Point the importFrom to the path of the package in your node_modules
        importFrom: "./node_modules/pi-ui/dist/exports.css"
      }
    ]
  ]
};

Developing

  • Clone this repository

  • Install all deps by running: yarn

  • If you're developing only on pi-ui, serving the live documentation should be enough: yarn storybook

  • If you want to see your changes reflected in a project consuming pi-ui, you can use yarn link:

    • Go to the pi-ui directory on your machine and run: yarn link
    • Go to the project using pi-ui and run: yarn link pi-ui

Troubleshooting: If you find some kind of incompatibility between react versions, link the react package from the main repository into pi-ui:

  • Go to the main repository which is using the pi-ui lib, access the react folder inside its node_modules:
    • cd /some/project/node_modules/react && yarn link
    • cd /pi-ui && yarn link react

pi-ui's People

Contributors

amass01 avatar bgptr avatar blaltarriba avatar brunaazambuja avatar crypto-rizzo avatar dajohi avatar dependabot[bot] avatar fernandoabolafio avatar guilhermemntt avatar h4murabi avatar joegruffins avatar matheusd avatar thi4go avatar tiagoalvesdulce avatar vctt94 avatar vibros68 avatar victorgcramos avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pi-ui's Issues

Buttons needs a loading state

The Button with a loading state displaying a spinner is vastly used on politeiagui. We need that option in the buttons component.

Add pre-set values for the card padding

Would be good to have a few pre-sets for card padding to use in the props API accordingly to the design specs.
Something like `paddingSize="small"|"medium"|"big".

Granular layout components

We need some granular layout components to build custom "on-demand" layouts in the consumer repository. Those parts need to be based in the grid system to be responsive when composed. Something Like:

<Col width={3}>one third length col</Col>
<Col width={3}>one third length col</Col>
<Col width={6}>half length col</Col>

Use name as a "identifier" property for text inputs instead of id

To ease the integration in the politeiagui repository would be better to have the name as a mandatory identifier property and then generate an internal ID for the field adding some random suffix. This wanted in order to avoid duplicated IDs in the DOM which can lead to bugs and dev alerts in the console.

Compile warnings

Browserslist: caniuse-lite is outdated. Please run next command `yarn upgrade`
{ parser: "babylon" } is deprecated; we now treat it as { parser: "babel" }.

[Form] Add Vertical Spacing prop to control spaces between form elements

This Vertical Spacing prop was a suggestion from @fernandoabolafio on decred/politeiagui#1317:

What I thought of doing is to expose a prop in the LoginForm such as verticalSpacing which we can set a value to propagate the mentioned paddings accordingly.

As discussed with Fernando, we found out that the best way to coordinate those spaces between form elements is by having a prop that controls it.

For example, the following image describes a Vertical Spacing of 30px:

src/componentsv2/ModalLogin.jsx

Correctly handle font assets

Right now we are bundling the font assets into javascript bundle and this isn't working for clients of this lib to have the font loaded. After spending a good amount of time on this problem I think we have two solutions available:

  • Export the static assets and delegate to the consumer to import it as it, please. In that case, we copy the static assets we want the client to import into the dist folder.
  • Add an option in the useTheme function to specify the font assets. That way, the consumer can import whatever font he wants and then pass the paths into the useTheme function which will then correctly link then with the library. Something along the lines:
const useTheme = (theme, fontSources) => {
    ...
}

Where the fontSources something like:

{
 regular: "fontSourcePathRegular",
 semiBold: "fontSourcePathString"
 light: "fontSourcePathLight"
}

Then from this fontSources object, the lib can generate the font-faces accordingly.

Layout container needs a better API

A few things we should be able to accomplish passing props to the 'Container' component:

  • Set header height
  • Set the top banner height
  • Set the spacing between main and top banner

Floating message box component

The lib needs a floating message box like the image linked below. I don't know if it is described anywhere else in the new design, but it will be a handy component to have on the lib.

Would be nice to have some default positioning options and a dismiss function callback.

messagebox

It needs to hover on top of other components and layouts, so I'm not sure how complex this will be to do with the current implementation.

It is described by Maria in here.

Coordination: components and general requirements

This issue compiles a list of the required components and other general requirements for the pi-ui library. This library should comply with this design specs.

This guide is separated by components. Each component in the list has a WCBF which stands for "Where can be found" in the design specs. The other bullets specify other minimal functional requirements of the component.

Atomic UI Components

  • Tooltip
    WCBF: hovering the voting progress bar

  • Mardkown text editor
    WCBF: submit proposal page / comments area
    Done on politeiagui

  • Comment & Comments tree
    WCBF: proposal detail
    Done on politeiagui

  • Select box
    WCBF: Sort comments
    Done on politeiagui

  • Dropdown
    WCBF: Under username in the header (missing design spec)

  • Text input
    WCBF: Inputs from login and signup forms

    • Errored/Valid state
  • Search input box
    WCBF: search vote tickets

    • Errored state
  • Button
    WCBF: submit button for login/signup forms

    • Handy primary and secondary options accordingly to the theme provided
  • Card
    WCBF: proposal cards

  • Tab selector
    WCBF: public proposal tabs

  • Table
    WCBF: Account history

  • Status tags
    WCBF: proposals cards status (approved, rejected, pending, etc)

  • Link
    WCBF: bottom of login/signup forms

  • Icon
    WCBF: proposal cards: comments link and github link

    • A JSX tag with ease specification of the available icons.
  • Message
    WCBF: submit page error / cannot submit comments message

    • Error/Info/Warning
  • Modal
    WCBF: welcome modal / purchase credits modal

  • Progress bar
    WCBF: proposal cards voting results

Integration Components

  • useTheme
    • A react hook that updates CSS properties according to the theme passed.

Layout components

  • Grid
    • A functional grid system to create responsive views easily.
  • Header
    • A simple and customisable header.
  • Sidebar
    • A simple and customisable sidebar.
  • Main Section
    • A wrapper for the app main section.
  • Top Banner
    • A wrapper for the top banner section.

Resources

Add prop to make modal unclosable

We need a prop to control if the modal can be closed or not. This is especially useful when performing requests inside the modal.

Icons request

  • Error (times)
  • Search
  • Pending
  • Waiting
  • Copy to clipboard

Add "icon" option for modals

Floating badge component

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.