File tree 11 files changed +442
-26
lines changed
11 files changed +442
-26
lines changed Original file line number Diff line number Diff line change 14
14
/out /
15
15
/public /assets /
16
16
/public /envs.js
17
+ /public /icons /sprite.svg
18
+ /public /icons /README.md
17
19
/analyze
18
20
19
21
# production
Original file line number Diff line number Diff line change 265
265
},
266
266
{
267
267
"type" : " npm" ,
268
- "script" : " format- svg" ,
268
+ "script" : " svg:format " ,
269
269
"problemMatcher" : [],
270
270
"label" : " format svg" ,
271
271
"detail" : " format svg files with svgo" ,
Original file line number Diff line number Diff line change @@ -182,7 +182,8 @@ We have 3 pre-configured projects. You can run your test with the desired projec
182
182
| ` yarn lint:eslint` | lint project files with ESLint |
183
183
| ` yarn lint:eslint:fix` | lint project files with ESLint and automatically fix problems |
184
184
| ` yarn lint:tsc` | compile project typescript files using TypeScript Compiler |
185
- | ` yarn format-svg` | format and optimize SVG icons in the ` /icons` folder using SVGO tool |
185
+ | ` yarn svg:format` | format and optimize SVG icons in the ` /icons` folder using SVGO tool |
186
+ | ` yarn svg:build-sprite` | build SVG icons sprite |
186
187
| ** Testing** |
187
188
| ` yarn test:jest` | run all Jest unit tests |
188
189
| ` yarn test:jest:watch` | run all Jest unit tests in watch mode |
Original file line number Diff line number Diff line change 20
20
"lint:tsc" : " tsc -p ./tsconfig.json" ,
21
21
"lint:envs-validator:test" : " cd ./deploy/tools/envs-validator && ./test.sh" ,
22
22
"prepare" : " husky install" ,
23
- "format-svg" : " svgo -r ./icons" ,
23
+ "svg:format" : " svgo -r ./icons" ,
24
+ "svg:build-sprite" : " icons build -i ./icons -o ./public/icons --optimize" ,
24
25
"test:pw" : " ./tools/scripts/pw.sh" ,
25
26
"test:pw:local" : " export NODE_PATH=$(pwd)/node_modules && yarn test:pw" ,
26
27
"test:pw:docker" : " docker run --rm --network host -v $(pwd):/work/ -w /work/ -it mcr.microsoft.com/playwright:v1.35.1-focal ./tools/scripts/pw.docker.sh" ,
137
138
"lint-staged" : " >=10" ,
138
139
"mockdate" : " ^3.0.5" ,
139
140
"style-loader" : " ^3.3.1" ,
141
+ "svg-icons-cli" : " ^0.0.5" ,
140
142
"svgo" : " ^2.8.0" ,
141
143
"ts-jest" : " ^29.0.3" ,
142
144
"ts-node" : " ^10.9.1" ,
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import React from 'react';
6
6
import * as serverTiming from 'nextjs/utils/serverTiming' ;
7
7
8
8
import theme from 'theme' ;
9
+ import * as svgSprite from 'ui/shared/IconSvg' ;
9
10
10
11
class MyDocument extends Document {
11
12
static async getInitialProps ( ctx : DocumentContext ) {
@@ -48,6 +49,8 @@ class MyDocument extends Document {
48
49
< link rel = "icon" sizes = "16x16" type = "image/png" href = "/favicon/favicon-16x16.png" />
49
50
< link rel = "apple-touch-icon" href = "/favicon/apple-touch-icon-180x180.png" />
50
51
< link rel = "mask-icon" href = "/favicon/safari-pinned-tab.svg" />
52
+
53
+ < link rel = "preload" as = "image" href = { svgSprite . href } />
51
54
</ Head >
52
55
< body >
53
56
< ColorModeScript initialColorMode = { theme . config . initialColorMode } />
Original file line number Diff line number Diff line change
1
+ // This file is generated by npm run build:icons
2
+
3
+ export type IconName =
4
+ | "ABI"
5
+ | "API"
6
+ | "apps"
7
+ | "arrows/down-right"
8
+ | "arrows/east-mini"
9
+ | "arrows/east"
10
+ | "arrows/north-east"
11
+ | "arrows/south-east"
12
+ | "arrows/up-down"
13
+ | "block_slim"
14
+ | "block"
15
+ | "brands/safe"
16
+ | "burger"
17
+ | "check"
18
+ | "clock-light"
19
+ | "clock"
20
+ | "coins/bitcoin"
21
+ | "collection"
22
+ | "contract_verified"
23
+ | "contract"
24
+ | "copy"
25
+ | "cross"
26
+ | "delete"
27
+ | "discussions"
28
+ | "docs"
29
+ | "donate"
30
+ | "edit"
31
+ | "email-sent"
32
+ | "email"
33
+ | "empty_search_result"
34
+ | "error-pages/404"
35
+ | "error-pages/422"
36
+ | "error-pages/429"
37
+ | "error-pages/500"
38
+ | "explorer"
39
+ | "files/csv"
40
+ | "files/image"
41
+ | "files/json"
42
+ | "files/placeholder"
43
+ | "files/sol"
44
+ | "files/yul"
45
+ | "filter"
46
+ | "finalized"
47
+ | "flame"
48
+ | "gas"
49
+ | "gear"
50
+ | "globe-b"
51
+ | "globe"
52
+ | "graphQL"
53
+ | "info"
54
+ | "key"
55
+ | "link"
56
+ | "lock"
57
+ | "minus"
58
+ | "moon-with-star"
59
+ | "moon"
60
+ | "networks"
61
+ | "networks/icon-placeholder"
62
+ | "networks/logo-placeholder"
63
+ | "nft_shield"
64
+ | "output_roots"
65
+ | "plus"
66
+ | "privattags"
67
+ | "profile"
68
+ | "publictags_slim"
69
+ | "publictags"
70
+ | "qr_code"
71
+ | "repeat_arrow"
72
+ | "restAPI"
73
+ | "rocket"
74
+ | "RPC"
75
+ | "scope"
76
+ | "score/score-not-ok"
77
+ | "score/score-ok"
78
+ | "search"
79
+ | "social/canny"
80
+ | "social/coingecko"
81
+ | "social/coinmarketcap"
82
+ | "social/defi_llama"
83
+ | "social/discord_filled"
84
+ | "social/discord"
85
+ | "social/facebook_filled"
86
+ | "social/git"
87
+ | "social/github_filled"
88
+ | "social/linkedin_filled"
89
+ | "social/medium_filled"
90
+ | "social/opensea_filled"
91
+ | "social/reddit_filled"
92
+ | "social/slack_filled"
93
+ | "social/stats"
94
+ | "social/telega"
95
+ | "social/telegram_filled"
96
+ | "social/tweet"
97
+ | "social/twitter_filled"
98
+ | "star_filled"
99
+ | "star_outline"
100
+ | "stats"
101
+ | "status/error"
102
+ | "status/pending"
103
+ | "status/success"
104
+ | "status/warning"
105
+ | "sun"
106
+ | "testnet"
107
+ | "token-placeholder"
108
+ | "token"
109
+ | "tokens"
110
+ | "tokens/xdai"
111
+ | "top-accounts"
112
+ | "transactions_slim"
113
+ | "transactions"
114
+ | "txn_batches_slim"
115
+ | "txn_batches"
116
+ | "unfinalized"
117
+ | "uniswap"
118
+ | "verified_token"
119
+ | "verified"
120
+ | "verify-contract"
121
+ | "vertical_dots"
122
+ | "wallet"
123
+ | "wallets/coinbase"
124
+ | "wallets/metamask"
125
+ | "wallets/token-pocket"
126
+ | "watchlist" ;
127
+
Original file line number Diff line number Diff line change 1
1
module . exports = {
2
2
plugins : [
3
- {
4
- name : 'preset-default' ,
5
- params : {
6
- overrides : {
7
- removeViewBox : false ,
8
- } ,
9
- } ,
10
- } ,
3
+ // TODO @tom 2drum pick up plugins from default preset
4
+ // {
5
+ // name: 'preset-default',
6
+ // params: {
7
+ // overrides: {
8
+ // removeViewBox: false,
9
+ // cleanupIds: false,
10
+ // removeUselessDefs: false,
11
+ // collapseGroups: false,
12
+ // },
13
+ // },
14
+ // },
11
15
'removeDimensions' ,
12
- 'prefixIds' ,
13
16
] ,
14
17
js2svg : {
15
18
indent : 2 ,
Original file line number Diff line number Diff line change @@ -19,6 +19,9 @@ dotenv \
19
19
-e $config_file \
20
20
-- bash -c ' ./deploy/scripts/download_assets.sh ./public/assets'
21
21
22
+ yarn svg:build-sprite
23
+ echo " "
24
+
22
25
# generate envs.js file and run the app
23
26
dotenv \
24
27
-v NEXT_PUBLIC_GIT_COMMIT_SHA=$( git rev-parse --short HEAD) \
Original file line number Diff line number Diff line change 8
8
-e .env \
9
9
-- bash -c ' ./deploy/scripts/download_assets.sh ./public/assets'
10
10
11
+ yarn svg:build-sprite
12
+ echo " "
13
+
11
14
# generate envs.js file and run the app
12
15
dotenv \
13
16
-v NEXT_PUBLIC_GIT_COMMIT_SHA=$( git rev-parse --short HEAD) \
Original file line number Diff line number Diff line change
1
+ import { Skeleton , chakra } from '@chakra-ui/react' ;
2
+ import { type IconName } from 'public/icons/name' ;
3
+ import React from 'react' ;
4
+
5
+ export const href = '/icons/sprite.svg' ;
6
+
7
+ interface Props {
8
+ name : IconName ;
9
+ isLoading ?: boolean ;
10
+ className ?: string ;
11
+ }
12
+
13
+ const IconSvg = ( { name, isLoading, className } : Props ) => {
14
+ return (
15
+ < Skeleton isLoaded = { ! isLoading } className = { className } >
16
+ < chakra . svg w = "100%" h = "100%" >
17
+ < use href = { `${ href } #${ name } ` } />
18
+ </ chakra . svg >
19
+ </ Skeleton >
20
+ ) ;
21
+ } ;
22
+
23
+ export default chakra ( IconSvg ) ;
You can’t perform that action at this time.
0 commit comments