Giter Site home page Giter Site logo

massalabs / ui-kit Goto Github PK

View Code? Open in Web Editor NEW
3.0 3.0 8.0 6.83 MB

This repository contains all the frontend components available in all Massalabs products

License: MIT License

JavaScript 0.78% TypeScript 98.83% Shell 0.07% CSS 0.28% HTML 0.04%

ui-kit's Introduction

Massa React TS ui-kit

Tech:

  • React typescript
  • tailwind

How to use it?

  • npm install @massalabs/react-ui-kit -D
  • update your tailwind configuration file tailwind.config.js:
/** @type {import('tailwindcss').Config} */
export default {
  content: [
    "./index.html",
    "./src/**/*.{js,ts,jsx,tsx}",
    "./node_modules/@massalabs/react-ui-kit/src/**/*.{js,ts,jsx,tsx}",
  ],
  presets: [require("@massalabs/react-ui-kit/presets/massa-station-preset.js")],
};
  • update your vite.config.ts file:
export default ({ mode }) => {
  ...
  return defineConfig({
    ...
    optimizeDeps: {
      include: ['react-dom', 'dot-object', 'copy-to-clipboard'],
    },
  • import the global css in you main tsx file (main.tsx or App.tsx):
import "@massalabs/react-ui-kit/src/global.css";
  • use the components:
import { Amount } from "@massalabs/react-ui-kit";

Contribute

You can add global CSS in src/global.css.

How to clean code

  • use tailwind alias to avoid long className string
  • create react function component: export function PrimaryButton(props: PrimaryButtonProps) {}
    • or export const PrimaryButton = (props: PrimaryButtonProps) => {}
  • create one folder per component with
    • component
    • unit tests
    • storybook stories

Theme

To apply a theme, use the class theme-light or theme-dark. All nested elements will apply the theme.

See https://github.com/L-Blondy/tw-colors#nested-themes for details.

Massa's design system color palette in implemented in presets/massa-station-preset.js thanks to tw-colors plugin.

You can now use our custom colors thanks to className:

  • <p className="bg-primary"></p>
  • <p className="text-neutral"></p>

Create your own theme

You can create your own theme by creating a new file in the presets directory.

Copy this file https://github.com/massalabs/ui-kit/blob/main/presets/massa-station-preset.js.

Update the tailwind.config.js file to use your new theme to change preset:

  presets: [require('./src/themes/preset.js')],

Typography

All typographies are defined in the tailwind preset.

To use them, simple add the name of the typography in the className prefixed by mas-:

<h1 className="mas-banner">My title</h1>

Icons

Icons are imported via the react-icons library See https://react-icons.github.io/react-icons/ for details & https://github.com/react-icons/react-icons for specific use cases

ui-kit's People

Contributors

mazmassa avatar pivilartisant avatar thykof avatar maxime-carabina avatar lilyanb avatar dependabot[bot] avatar ben-rey avatar peterjah avatar pierregvx avatar 0xmazout avatar thomas-senechal avatar

Stargazers

George Kontridze avatar Milad avatar Eko krisdianto avatar

Watchers

Adrien LF avatar Naoufal avatar  avatar

Forkers

0xmazout milak47

ui-kit's Issues

Implementation of "spread props" in the PrimaryButton component

Context
For some components like the button, Frontend team want to avoid redefining some properties it receives.
For example, the click function does not need to be redefined inside the component to be applied.

To answer this problem, I will implement the concept of "spread props".

User flow
The user can click on a button to do an action like :

  • go to a page
  • valid operation on your wallet
  • etc...

How to

  1. Open the folder Buttons/primary/
  2. Open file PrimaryButton.tsx and PrimaryButton.stories.tsx
    1. Code the button logic with implementation of spreading props (see technical details)
    2. Create the associate stories

Technical details

wrong URL on the readme

Describe the bug
There is a URL error in the readme. In part "Icons". At the end of the readme.

Create Plugin Store Card

Context
In order to display plugins available on the plugin store, we must have a plugin store card component

Screenshot from 2023-06-12 12-36-20

Technical details
We can either create a variation on the existing plugin component or create a dedicated component

Add new font color for disabled

Context
image

image

The white color for font disabled is missing.
So we can add it in theme.

How to

  • open file presets/massa-station-preset.js
  • add new theme entitled f-disabled-2 with color white in fonts category
  • rename theme entitled f-disabled to f-disabled-1

Buttons

Context
Create the Button component for the ui-kit.

  • it can be in 2 forms :

image

How to

  • Create component in the ui-kit
  • Create Tests
  • Create Stories

Technical details

  • it can contain an icon on the left, on the right or even both
  • it can contain text
  • it can change color according to the theme
  • it has different states :
    • default
    • hover
    • pressed
    • disabled

SwitchIconButton

Switch Icon

  • is an Icon on left

  • is a text on right

  • You give to the component two icons , two text and a state

  • Once click you change state , text and icon

image

dropdownListSelector

Drop Down List Selector:

  • Is a Drop down Icon
  • Is a Text aligned with the Icon
  • Is a modal on click click of the Text or Icon
  • The Modal contains a list of datas separated by a divider
    image

Spinner

Context
Create Spinner component following the design.

image

User flow
User go on page but content from API is not load.
So a spinner is display to inform user about loading data.

Technical details
Follow those steps :

  • create folder Spinner
  • create Spinner.tsx file
  • create Spinner.stories.tsx file
  • create Spinner.test.tsx file
  • create index.ts file to export Spinner component

Add selector

Context
In order to finish the wallet integration, adding the "Choose Acccount" component is a priority.

Screenshot 2023-05-02 at 11 24 44

I will be implementing the account Selector as seen above. I will not be implementing the add account button as that is already being implemented.

User flow
The user clicks on the account they wish to access. On click, the user is directed the the wallet home page.

Technical details

  • Export assets needed (arrow + massa token) & add them to svg folder
  • Create button of the follwoing format : custom img | txt | img | text
  • Implement the different state variations based on the currently selected theme
    Screenshot 2023-05-02 at 11 46 47

Important : the first img is a picto (profile picture) generated by the user, as default I will set it to a generic profile picto :

Screenshot 2023-05-02 at 14 01 55

Add testing-library/jest-dom

Context
We can implement test to find a className in the ClasstList of a component.

How to

  • Open test file (ex: PrimaryButton.test.tsx)
  • Create a test following the same pattern as the others
    • Implement function "toHaveClass" to see if a class is present on the classList
    • Add the associate import (see technical details)

Technical details
Add this import at the top of the test file : import '@testing-library/jest-dom';

Fix UI-Kit Layout with correct padding

Context

The layout in the current Ui-Kit has padding that is not conform to the design layout, we also need to think about the padding needed when there is the side panel, that willl take 48px

Note : there is currently a custom class, but I don't know if it will just add padding over current padding or if it is good practice

Design padding :
Screenshot from 2023-06-12 15-10-44

Screenshot from 2023-06-12 15-11-38

Current padding is 0

Note : tailwind does not have a 72px equivalent, closest is 64px or 80px so we will have to make a choice on that

Technical details
We can either :
/ set the padding to be 72 px horizontal and 48px vertical inside the components
/ Use the custom class and create a story for the use
/ set no padding and manually set the padding the our main tsx file

Update the colors in the storybook

Context
the colors are not up to date in the storybook
User flow

list all the colors in the colors folder of the storybook
How to
update colors.tsx with the states, icols, and fonts
Technical details
N/A
QA testing
check the result in the colors section of the storybook

menuLinkWithIcon

Menu Link with Icon is this :

  • It's a Link to switch to a page
  • It's an icon placed on the left of the Link

image

IconNavigator

Context
We will implement IconNavigator :

image

User flow
You want to switch between pages with a navigator. Each page correspond to an icon in the navigator.

Ex:
image

Add Account Selector

Context
In order to finish the wallet integration, adding the "Choose Acccount" component is a priority.

Screenshot 2023-05-02 at 11 24 44

I will be implementing the account Selector as seen above. I will not be implementing the add account button as that is already being implemented.

User flow
The user clicks on the account they wish to access. On click, the user is directed the the wallet home page.

Technical details

  • Export assets needed (arrow + massa token) & add them to svg folder
  • Create button of the follwoing format : custom img | txt | img | text
  • Implement the different state variations based on the currently selected theme
    Screenshot 2023-05-02 at 11 46 47

Important : the first img is a picto (profile picture) generated by the user, as default I will set it to a generic profile picto :

Screenshot 2023-05-02 at 14 01 55

SecondaryButton

image

-it can contain an icon on the left, on the right or even both
-it can contain text
-it can change color according to the theme
-it has different states :

  • default
  • hover
  • pressed
  • disabled

Add icons to ui-kit

Context
Add icons from design system to Ui-Kit so devs can start implementing components using icons

How to

  • Create icons directory in /assets/svg
  • Export each icon to to TSX
  • Save TSX file in assets/svg dir
  • Create Icons dir in /components
  • Create and icon component, story & test

Technical details

The Icon component will take an imported tsx component as prop. this has to be done because the current version of react does not support svg import and dynamic modifications.

This is needed because we want to be able to switch the icon color easily without any need for duplicate imports.

If you have any question or need precisions on this choice please ping me.

Add alt theme colors

Context
Add colors for Bridge theme.

image

Technical details

  • Add colors in preset folder
  • Add new class in preset folder

add Dashboard component

image

This Dashboard receives component parameters and displays them. It fills the void with subdued images.

SideBarContainer

Create the SideBar container component for the Wallet
image

Maybe we can swap this to the wallet project

TextArea

Context
Create a component enabling the user to enter text (e.g. a description) in a given zone.

image

User flow

  • go on MassaStation
  • go to the "Search" page to access deployed sites
  • click on sidebar for upload a website
  • enter a text in the "description"

Time
Predicted : 2H
Final : 3H

Add colors to the storybook

  • Add the error & warning colors to the tailwing config
  • Display the colors used for both light and dark themes on the storybook

Add Night Mode Button

Context
Frontend team needs to have a button to activate the Night Mode theme.

How To

  1. Export Design System SVG's & store them in /assets
  2. Create nightmodebutton folder in /buttons
  3. Create nightmodebutton.tsx and corresponding .stories.tsx file
    4)Code the button UI & logic (see technical details)
    4)Export them to the Storybook

User flow
There are two themes :

  • The user presses the moon icon to enable dark mode
  • The user presses the sun icon to enable light mode

Technical details
Logic behind the switch between the two themes :

  • Browsers local storage will store the current theme
  • the component will use local storage theme variable to render itself

Create Tabs Component

Context
Create tabs component so we can implement the send coins page
Screenshot from 2023-05-11 11-09-53

User flow
When the user interacts with corresponding states : default, hover, actif

Screenshot from 2023-05-11 11-11-17

How to

  • Create component folder
  • Code Component
  • Send to review

Technical details
Simple div with border that changes color with a corresponding state default, hover, actif

Wallet Send Screen Meta Issue

Context
The objective is to identify and develop all the components that need to be added to the ui-kit.
Screenshot from 2023-05-19 13-51-21

How to

  • Create a global (send & receive compatible component) that will contain all of of the information that will be passed as a parameter in the Tabs component (this is a proposition what do you think @mazmassa @maxime-carabina @Thykof )

  • Create Account Balance Component (To be defined)
    Screenshot from 2023-05-19 13-57-23

  • Verify if the input and dropdown can be combined for this component
    Screenshot from 2023-05-19 14-35-53

  • Define the percentage components and how it works ( @SlnPons @LucasF243 @mazmassa )
    Screenshot from 2023-05-19 14-37-43

  • Verify if the input component can take in a icon which opens the contact list modal
    Screenshot from 2023-05-19 13-47-07

  • Verify that the popup modal component is compatible (take components as param) with contact list and account list components

Screenshot from 2023-05-19 13-55-56

Screenshot from 2023-05-19 13-55-03

Toggle Light Mode

Describe the bug
When clicking on the light mode/dark mode toggle button, on the logo changes colors.

To Reproduce

  1. web/massastation
  2. npm run dev
  3. open localhost link
  4. click multiple time on the toggle

Expected behavior

It should toggle on the light and dark mode correctly

Screenshots

Enregistrement_de_lecran_2023-06-15_a_15.46.18.mov

Add Account Balance Component

Context
In order to develop the send/receive massa wallet we need to add the account balance component
Screenshot from 2023-05-19 12-09-18

User flow
Describe the user flow using user stories so the end result is super clear - PM

How to
List the step-by-step to get it do if needed - PM

Technical details
Give the technical insights so anyone in the team can tackle the tasks - Dev

QA testing
Does this task require some QA tests?
If yes, explain how to validate it

Add cypress

Context
Describe / explain why we should do this: motivations, context or other info. Keep it brief and simple - PM

User flow
Describe the user flow using user stories so the end result is super clear - PM

How to
List the step-by-step to get it do if needed - PM

Technical details
Give the technical insights so anyone in the team can tackle the tasks - Dev

QA testing
Does this task require some QA tests?
If yes, explain how to validate it

Add shareable tailwind preset and dark mode

Context
Describe / explain why we should do this: motivations, context or other info. Keep it brief and simple - PM

This repository is a ui kit for massa react frontend applications.

We need to add a way to share the tailwind config including them and dark mode.

User flow
Describe the user flow using user stories so the end result is super clear - PM

there will be 2 themes: dark and light. The user will be able to switch from one to the other. The default theme is dark.

The designed UI/UX might mix theme for component, meaning you can have a dark page with a light button in it. So we need a way to choose the theme per component.

How to
List the step-by-step to get it do if needed - PM

  • create the preset
  • populate the theme
  • add documentation for how to use that in an application

Technical details
Give the technical insights so anyone in the team can tackle the tasks - Dev

preset will includes:

Doc for the preset: https://tailwindcss.com/docs/presets

QA testing
Does this task require some QA tests?
If yes, explain how to validate it

  • the doc is clear
  • an application use the preset

fix icon button size

Context
The size of the icons for the primary and secondary buttons are not good.

How to
Set size of icon in Button.tsx file to 24px.

Add SVG Component

Context
This will be a component for the following specific uses cases :

Screenshot 2023-05-04 at 11 02 24

&

Screenshot 2023-05-04 at 11 03 40

How to

  • Create add SVG folder in /Icons
  • Create Svg component
  • Write stories & test

Technical Details

The idea is to have a component with a div that will be the circle background. This background will change according to theme.
In this div a svg image will be passed as props and rendered as child. This SVG will has a static color.

Add Sidemenu

Context

  • Create SideBar in the ui-kit
    Divide this into smaller components and smaller pr
  • #19
  • #22

For all of them :

  • Create Tests for Sidebar components
  • Create Stories for Sidebar components

How to
Create components in the ui-kit
Create Tests
Create Stories

Technical details
Responsive and Sharp

QA testing
Use Cypress if it's implemented
or
Ask for a dev to create a component "Test" to test it in another project outside of the ui-kit

Estimation
5-6 days with tests and stuffs like that

PrimaryButton

image

-it can contain an icon on the left, on the right or even both
-it can contain text
-it can change color according to the theme
-it has different states :

  • default
  • hover
  • pressed
  • disabled

server crashes if the store can't be fetched

Describe the bug
If the user doesn't have any connection, the server crashes because the store can't be fetched

to solve : replace the logger.fatal to logger.error if the store can't be fetched
To Reproduce

Steps to reproduce the behavior:
launch massastation without internet access

Expected behavior
launch normally

Screenshots
image

Version
0.2.4-dev
Additional context
Add any other context about the problem here.

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.