Skip to content

Commit 23c684a

Browse files
authored
[Illustrations]: Add new svgs for chains and refactor (#876)
* chore(Illustrations): refactor WIP * chore(Illustration): replace chain type with common type * chore(Illustration): updating icons WIP * chore: add plop generator for chain logo * chore(Plop): fix minor issues and add comments * fix: plop generator * feat: update svg with new designs * fix: plop file generato name * docs: add step to create new components * add changeset file * chore: fix svg attribute
1 parent a2c2ca8 commit 23c684a

26 files changed

+439
-611
lines changed

.changeset/weak-flowers-double.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@web3uikit/core': patch
3+
---
4+
5+
Add new svg for illustration and plop generator

README.md

+26
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ If you are using `web3uikit` with Next.js, be sure to follow the [official guide
6565
- [🤝 Need help](#-need-help)
6666
- [🚀 Quick start](#-quick-start)
6767
- [🧭 Table of Contents](#-table-of-contents)
68+
- [🏗️ New Components](#-new-components)
6869
<!-- - [👩‍🔬 Advanced setup](#-advanced-setup) -->
6970
- [📦 Packages](#-packages)
7071
- [Core module](#core-module)
@@ -76,6 +77,31 @@ If you are using `web3uikit` with Next.js, be sure to follow the [official guide
7677
7778
It's possible to install all functionalities of web3uikit by installing `web3uikit` as a dependency. But, you may choose to only install certain modules (as listed below). -->
7879

80+
# 🏗️ New Components
81+
82+
Remember to follow steps from [CONTRIBUTE.md](https://github.com/web3ui/web3uikit/blob/master/CONTRIBUTE.md) to setup your local environment.
83+
84+
## Want to add new component ?
85+
86+
- run `pnpm new` in terminal and follow the interactive steps to generate templates for a new component.
87+
88+
## Want to add new icon ?
89+
90+
- Add the svg file(s) to `web3uikit/packages/icons/src/lib/svgs/` (remember to give meaningful filename, as filename gets converted to icon name)
91+
- run `pnpm run icons:create` in terminal and your icon is created. 🔥
92+
- To verify your newly added icon run `pnpm storybook-build`. Once storybook is open, navigate to `8.ICONS/Gallery` and search for your icon.
93+
94+
## Want to add a new Chain Logo ?
95+
96+
- run `pnpm plop "ChainLogo" -- --name "<CHAIN NAME HERE>" --color "<BACKGROUND COLOR HERE>"`
97+
98+
example => `pnpm plop "ChainLogo" -- --name "ethereum" --color "#396993"`
99+
100+
- Now in your code editor navigate to `web3uikit/packages/core/src/lib/Illustrations/images/chains`, here a new file must be created with your chain name, in this file replace `<></>` with your chain `svg code`.
101+
- To verify your newly added chain logo run `pnpm storybook-build`. Once storybook is open:
102+
- navigate to `6.Graphic`, and your chain logo should be added to `Illustration` and `CryptoLogo` component.
103+
- navigate to `4.UI/CryptoCards`, and your chain logo should be added here as well. 😃
104+
79105
# 📦 Packages
80106

81107
## Core module

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
"start:dev": "nx run-many --target=start:dev --all --parallel",
4242
"storybook": "start-storybook -p 6006",
4343
"build-storybook": "build-storybook -o dist/storybook wp5",
44+
"storybook-build": "pnpm build && pnpm storybook",
4445
"analyze": "nx run example:analyze",
4546
"icons:create": "nx run-many --target=icons:create --all --parallel",
4647
"new": "plop",

packages/core/src/interfaces/logo.ts

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
export const chainLogoData = {
2+
arbitrum: {
3+
name: 'arbitrum',
4+
color: '#003470',
5+
},
6+
fantom: {
7+
name: 'fantom',
8+
color: '#0F7FFF',
9+
},
10+
avalanche: {
11+
name: 'avalanche',
12+
color: '#DE0000',
13+
},
14+
polygon: {
15+
name: 'polygon',
16+
color: '#9B22FF',
17+
},
18+
binance: {
19+
name: 'binance',
20+
color: '#EBBB00',
21+
},
22+
ethereum: {
23+
name: 'ethereum',
24+
color: '#396993',
25+
},
26+
cronos: {
27+
name: 'cronos',
28+
color: '#041836',
29+
},
30+
coinbase: {
31+
name: 'coinbase',
32+
color: '#333dfb',
33+
},
34+
ronin: {
35+
name: 'ronin',
36+
color: '#019EC9',
37+
},
38+
optimism: {
39+
name: 'optimism',
40+
color: '#E95557',
41+
},
42+
/* PLOP_INJECT_CHAIN */
43+
} as const;
44+
45+
const logoWalletColors = {
46+
cryptoweb:
47+
'linear-gradient(113.54deg, rgba(45, 91, 104, 0.531738) 14.91%, rgba(0, 4, 48, 0.6) 42.57%, rgba(45, 91, 104, 0.336) 45.98%, rgba(0, 4, 48, 0.03) 55.76%), linear-gradient(160.75deg, #000430 41.37%, #223F47 98.29%), linear-gradient(113.54deg, rgba(117, 183, 251, 0.531738) 14.91%, rgba(10, 41, 255, 0.6) 42.57%, rgba(25, 105, 255, 0.336) 45.98%, rgba(25, 105, 255, 0.03) 55.76%), linear-gradient(160.75deg, #071AFF 41.37%, #45D4FF 98.29%)',
48+
};
49+
50+
export type TChainNames = keyof typeof chainLogoData;
51+
52+
export type TWalletNames = keyof typeof logoWalletColors;
53+
54+
export type TLogoNames = TChainNames | TWalletNames;
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { ComponentStory, ComponentMeta } from '@storybook/react';
2-
import { Cog } from '@web3uikit/icons';
32
import CryptoCards from '../CryptoCards/CryptoCards';
4-
import bgConfig from '../CryptoLogos/bgConfig';
3+
import { chainLogoData } from '../../interfaces/logo';
54

65
export default {
76
title: '4.UI/Crypto Cards',
@@ -17,81 +16,78 @@ export const Ethereum = Template.bind({});
1716
Ethereum.args = {
1817
chain: 'ethereum',
1918
chainType: 'Network',
20-
bgColor: bgConfig.ethereum,
19+
bgColor: chainLogoData['ethereum'].color,
2120
btnText: 'View Endpoints',
2221
};
2322

2423
export const Binance = Template.bind({});
2524
Binance.args = {
2625
chain: 'binance',
2726
chainType: 'Network',
28-
bgColor:
29-
'linear-gradient(113.54deg, rgba(217, 166, 54, 0.6) 14.91%, rgba(230, 166, 26, 0.6) 44.27%, rgba(207, 168, 28, 0) 45.98%, rgba(250, 228, 30, 0) 55.76%, rgba(245, 223, 30, 0) 55.76%), linear-gradient(147.17deg, #F5D116 48.73%, #CD9614 98.22%)',
27+
bgColor: chainLogoData['binance'].color,
3028
btnText: 'View Endpoints',
3129
};
3230

3331
export const Polygon = Template.bind({});
3432
Polygon.args = {
3533
chain: 'polygon',
3634
chainType: 'Network',
37-
bgColor:
38-
'linear-gradient(113.54deg, rgba(103, 58, 194, 0.6) 14.91%, rgba(122, 74, 221, 0.498) 44.27%, rgba(170, 129, 255, 0.222) 45.98%, rgba(209, 103, 255, 0.03) 55.76%), linear-gradient(160.75deg, #7A4ADD 41.37%, #D57BFF 98.29%)',
35+
bgColor: chainLogoData['polygon'].color,
3936
btnText: 'View Endpoints',
4037
};
4138

4239
export const Avalanche = Template.bind({});
4340
Avalanche.args = {
4441
chain: 'avalanche',
4542
chainType: 'Network',
46-
bgColor:
47-
'linear-gradient(113.54deg, rgba(119, 0, 1, 0.5) 14.91%, rgba(216, 43, 44, 0.5) 43.21%, rgba(255, 130, 130, 0.345) 44.27%, rgba(220, 96, 97, 0.185) 55.76%), linear-gradient(151.07deg, #8F0E0F 33.25%, #FA4A4B 98.24%)',
43+
bgColor: chainLogoData['avalanche'].color,
4844
btnText: 'View Endpoints',
4945
};
5046

5147
export const Fantom = Template.bind({});
5248
Fantom.args = {
5349
chain: 'fantom',
5450
chainType: 'Network',
55-
bgColor:
56-
'linear-gradient(113.54deg, rgba(117, 183, 251, 0.531738) 14.91%, rgba(10, 41, 255, 0.6) 42.57%, rgba(25, 105, 255, 0.336) 45.98%, rgba(25, 105, 255, 0.03) 55.76%), linear-gradient(160.75deg, #071AFF 41.37%, #45D4FF 98.29%)',
51+
bgColor: chainLogoData['fantom'].color,
5752
btnText: 'View Endpoints',
5853
};
5954

6055
export const Arbitrum = Template.bind({});
6156
Arbitrum.args = {
6257
chain: 'arbitrum',
6358
chainType: 'Network',
64-
bgColor:
65-
'linear-gradient(113.54deg, rgba(60, 87, 140, 0.5) 14.91%, rgba(70, 86, 169, 0.5) 43.21%, rgba(125, 150, 217, 0.345) 44.27%, rgba(129, 161, 225, 0.185) 55.76%), linear-gradient(151.07deg, #141659 33.25%, #4152A7 98.24%)',
59+
bgColor: chainLogoData['arbitrum'].color,
6660
btnText: 'View Endpoints',
6761
};
6862

6963
export const Cronos = Template.bind({});
7064
Cronos.args = {
7165
chain: 'cronos',
7266
chainType: 'Network',
73-
bgColor: bgConfig.cronos,
67+
bgColor: chainLogoData['cronos'].color,
7468
btnText: 'View Endpoints',
7569
};
7670
export const Coinbase = Template.bind({});
7771
Coinbase.args = {
7872
chain: 'coinbase',
7973
chainType: 'Network',
80-
bgColor: bgConfig.coinbase,
74+
bgColor: chainLogoData['coinbase'].color,
8175
btnText: 'View Endpoints',
8276
};
8377
export const Ronin = Template.bind({});
8478
Ronin.args = {
8579
chain: 'ronin',
8680
chainType: 'Network',
87-
bgColor: bgConfig.ronin,
81+
bgColor: chainLogoData['ronin'].color,
8882
btnText: 'View Endpoints',
8983
};
9084

9185
export const Optimism = Template.bind({});
9286
Optimism.args = {
9387
chain: 'optimism',
9488
chainType: 'Network',
95-
bgColor: bgConfig.optimism,
89+
bgColor: chainLogoData['optimism'].color,
9690
btnText: 'View Endpoints',
9791
};
92+
93+
/* PLOP_INJECT_CHAIN */

packages/core/src/lib/CryptoCards/types.ts

+2-11
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React from 'react';
2+
import { TChainNames } from '../../interfaces/logo';
23

34
export interface CryptoCardProps {
45
/**
@@ -14,17 +15,7 @@ export interface CryptoCardProps {
1415
/**
1516
* The name of the blockchain
1617
*/
17-
chain:
18-
| 'arbitrum'
19-
| 'avalanche'
20-
| 'binance'
21-
| 'ethereum'
22-
| 'fantom'
23-
| 'polygon'
24-
| 'cronos'
25-
| 'coinbase'
26-
| 'ronin'
27-
| 'optimism';
18+
chain: TChainNames;
2819

2920
/**
3021
* The type of the chain / a subtitle below the chain name

packages/core/src/lib/CryptoLogos/CryptoLogos.stories.tsx

+3-6
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,6 @@ Cronos.args = {
5454
size: '48px',
5555
};
5656

57-
export const Crypto = Template.bind({});
58-
Crypto.args = {
59-
chain: 'cryptoweb',
60-
size: '48px',
61-
};
62-
6357
export const Coinbase = Template.bind({});
6458
Coinbase.args = {
6559
chain: 'coinbase',
@@ -71,8 +65,11 @@ Ronin.args = {
7165
chain: 'ronin',
7266
size: '48px',
7367
};
68+
7469
export const Optimism = Template.bind({});
7570
Optimism.args = {
7671
chain: 'optimism',
7772
size: '48px',
7873
};
74+
75+
/* PLOP_INJECT_CHAIN */
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
import styled, { css } from 'styled-components';
22
import { resetCSS } from '@web3uikit/styles';
3-
import type { chainType, CryptoLogoProps, sizeType } from './types';
4-
import bgConfig from './bgConfig';
3+
import { chainType, CryptoLogoProps, sizeType } from './types';
4+
import { chainLogoData } from '../../interfaces/logo';
55

6-
const getBackground = (chain: chainType) => bgConfig[chain];
6+
const getBackground = (chain: chainType) => chainLogoData[chain].color;
77

88
const getSize = (size?: sizeType) => css`
9-
height: ${size};
10-
width: ${size};
9+
height: ${size};
10+
width: ${size};
1111
`;
1212

1313
const DivStyledCryptoLogo = styled.div<CryptoLogoProps>`
14-
${resetCSS};
15-
${(props) => getSize(props.size)}
16-
align-items: center;
17-
border-radius: 100%;
18-
box-sizing: border-box;
19-
display: flex;
20-
justify-content: center;
21-
overflow: hidden;
22-
position: relative;
23-
background: ${(props) => props?.bgColor || getBackground(props.chain)};
14+
${resetCSS};
15+
${(props) => getSize(props.size)}
16+
align-items: center;
17+
border-radius: 100%;
18+
box-sizing: border-box;
19+
display: flex;
20+
justify-content: center;
21+
overflow: hidden;
22+
position: relative;
23+
background: ${(props) => props?.bgColor || getBackground(props.chain)};
2424
`;
2525

2626
export default { DivStyledCryptoLogo };

packages/core/src/lib/CryptoLogos/bgConfig.ts

-22
This file was deleted.
+3-12
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { TChainNames, TWalletNames } from '../../interfaces/logo';
2+
13
export interface CryptoLogoProps {
24
/**
35
* The background color of the crypto logo
@@ -15,17 +17,6 @@ export interface CryptoLogoProps {
1517
size?: sizeType;
1618
}
1719

18-
export type chainType =
19-
| 'arbitrum'
20-
| 'avalanche'
21-
| 'binance'
22-
| 'coinbase'
23-
| 'cronos'
24-
| 'cryptoweb'
25-
| 'ethereum'
26-
| 'fantom'
27-
| 'polygon'
28-
| 'ronin'
29-
| 'optimism';
20+
export type chainType = TChainNames;
3021

3122
export type sizeType = string | number;

packages/core/src/lib/Illustrations/Illustration.stories.tsx

+4-1
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@ import { ComponentMeta, ComponentStory } from '@storybook/react';
22
import { color } from '@web3uikit/styles';
33
import Illustration from './Illustration';
44

5-
export default {
5+
const mainStory = {
66
title: '6.Graphic/Illustration',
77
component: Illustration,
88
} as ComponentMeta<typeof Illustration>;
9+
export default mainStory;
910

1011
const Template: ComponentStory<typeof Illustration> = (args) => (
1112
<Illustration {...args} />
@@ -74,6 +75,8 @@ Optimism.args = {
7475
logo: 'optimism',
7576
};
7677

78+
/* PLOP_INJECT_CHAIN */
79+
7780
export const Crypto = BackgroundColoredTemplate.bind({});
7881
Crypto.args = {
7982
logo: 'cryptoweb',

0 commit comments

Comments
 (0)