Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
frontend
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vicotor
frontend
Commits
f79c40d6
Commit
f79c40d6
authored
Jan 10, 2025
by
tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix Network logo
parent
a65cca1d
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
79 additions
and
29 deletions
+79
-29
eslint.config.mjs
eslint.config.mjs
+1
-0
button.tsx
toolkit/chakra/button.tsx
+25
-14
image.tsx
toolkit/chakra/image.tsx
+46
-0
NetworkLogo.tsx
ui/snippets/networkMenu/NetworkLogo.tsx
+7
-15
No files found.
eslint.config.mjs
View file @
f79c40d6
...
...
@@ -406,6 +406,7 @@ export default tseslint.config(
'
boolean
'
:
true
,
string
:
true
,
}
],
'
no-nested-ternary
'
:
'
error
'
,
'
no-multi-str
'
:
'
error
'
,
'
no-spaced-func
'
:
'
error
'
,
'
no-with
'
:
'
error
'
,
...
...
toolkit/chakra/button.tsx
View file @
f79c40d6
...
...
@@ -21,30 +21,41 @@ export interface ButtonProps extends ChakraButtonProps, ButtonLoadingProps {
export
const
Button
=
React
.
forwardRef
<
HTMLButtonElement
,
ButtonProps
>
(
function
Button
(
props
,
ref
)
{
const
{
loading
,
disabled
,
loadingText
,
children
,
active
,
selected
,
highlighted
,
...
rest
}
=
props
;
return
(
<
ChakraButton
{
...
(
active
?
{
'
data
-
active
':
true
}
:
{})
}
{
...
(
selected
?
{
'
data
-
selected
':
true
}
:
{})
}
{
...
(
highlighted
?
{
'
data
-
highlighted
':
true
}
:
{})
}
disabled=
{
loading
||
disabled
}
ref=
{
ref
}
{
...
rest
}
>
{
loading
&&
!
loadingText
?
(
const
content
=
(()
=>
{
if
(
loading
&&
!
loadingText
)
{
return
(
<>
<
AbsoluteCenter
display=
"inline-flex"
>
<
Spinner
size=
"inherit"
color=
"inherit"
/>
</
AbsoluteCenter
>
<
Span
opacity=
{
0
}
>
{
children
}
</
Span
>
</>
)
:
loading
&&
loadingText
?
(
);
}
if
(
loading
&&
loadingText
)
{
return
(
<>
<
Spinner
size=
"inherit"
color=
"inherit"
/>
{
loadingText
}
</>
)
:
(
children
)
}
);
}
return
children
;
})();
return
(
<
ChakraButton
{
...
(
active
?
{
'
data
-
active
':
true
}
:
{})
}
{
...
(
selected
?
{
'
data
-
selected
':
true
}
:
{})
}
{
...
(
highlighted
?
{
'
data
-
highlighted
':
true
}
:
{})
}
disabled=
{
loading
||
disabled
}
ref=
{
ref
}
{
...
rest
}
>
{
content
}
</
ChakraButton
>
);
},
...
...
toolkit/chakra/image.tsx
0 → 100644
View file @
f79c40d6
import
type
{
ImageProps
as
ChakraImageProps
}
from
'
@chakra-ui/react
'
;
import
{
Image
as
ChakraImage
}
from
'
@chakra-ui/react
'
;
import
React
from
'
react
'
;
import
{
Skeleton
}
from
'
./skeleton
'
;
export
interface
ImageProps
extends
ChakraImageProps
{
fallback
?:
React
.
ReactNode
;
}
export
const
Image
=
React
.
forwardRef
<
HTMLImageElement
,
ImageProps
>
(
function
Image
(
props
,
ref
)
{
const
{
fallback
,
src
,
...
rest
}
=
props
;
const
[
loading
,
setLoading
]
=
React
.
useState
(
true
);
const
[
error
,
setError
]
=
React
.
useState
(
false
);
const
handleLoadError
=
React
.
useCallback
(()
=>
{
setError
(
true
);
setLoading
(
false
);
},
[]);
const
handleLoadSuccess
=
React
.
useCallback
(()
=>
{
setLoading
(
false
);
},
[]);
if
(
!
src
&&
fallback
)
{
return
fallback
;
}
if
(
error
)
{
return
fallback
;
}
return
(
<
Skeleton
loading=
{
loading
}
>
<
ChakraImage
ref=
{
ref
}
src=
{
src
}
onError=
{
handleLoadError
}
onLoad=
{
handleLoadSuccess
}
{
...
rest
}
/>
</
Skeleton
>
);
});
ui/snippets/networkMenu/NetworkLogo.tsx
View file @
f79c40d6
import
{
Image
,
Skeleton
,
chakra
}
from
'
@chakra-ui/react
'
;
import
{
chakra
}
from
'
@chakra-ui/react
'
;
import
React
from
'
react
'
;
import
{
route
}
from
'
nextjs-routes
'
;
import
config
from
'
configs/app
'
;
import
{
useColorModeValue
}
from
'
toolkit/chakra/color-mode
'
;
import
{
Image
}
from
'
toolkit/chakra/image
'
;
import
IconSvg
from
'
ui/shared/IconSvg
'
;
interface
Props
{
...
...
@@ -14,9 +15,6 @@ interface Props {
}
const
LogoFallback
=
({
isCollapsed
,
isSmall
}:
{
isCollapsed
?:
boolean
;
isSmall
?:
boolean
})
=>
{
const
field
=
isSmall
?
'
icon
'
:
'
logo
'
;
const
logoColor
=
useColorModeValue
(
'
blue.600
'
,
'
white
'
);
const
display
=
isSmall
?
{
base
:
'
none
'
,
lg
:
isCollapsed
===
false
?
'
none
'
:
'
block
'
,
...
...
@@ -27,29 +25,23 @@ const LogoFallback = ({ isCollapsed, isSmall }: { isCollapsed?: boolean; isSmall
xl
:
isCollapsed
?
'
none
'
:
'
block
'
,
};
if
(
config
.
UI
.
navigation
[
field
].
default
)
{
return
<
Skeleton
w=
"100%"
borderRadius=
"sm"
display=
{
display
}
/>;
}
return
(
<
IconSvg
name=
{
isSmall
?
'
networks/icon-placeholder
'
:
'
networks/logo-placeholder
'
}
width=
"auto"
height=
"100%"
color=
{
logoColor
}
color=
{
{
base
:
'
blue.600
'
,
_dark
:
'
white
'
}
}
display=
{
display
}
/>
);
};
// TODO @tom2drum implement image with fallback
const
INVERT_FILTER
=
'
brightness(0) invert(1)
'
;
const
NetworkLogo
=
({
isCollapsed
,
onClick
,
className
}:
Props
)
=>
{
const
logoSrc
=
useColorModeValue
(
config
.
UI
.
navigation
.
logo
.
default
,
config
.
UI
.
navigation
.
logo
.
dark
||
config
.
UI
.
navigation
.
logo
.
default
);
const
iconSrc
=
useColorModeValue
(
config
.
UI
.
navigation
.
icon
.
default
,
config
.
UI
.
navigation
.
icon
.
dark
||
config
.
UI
.
navigation
.
icon
.
default
);
const
darkModeFilter
=
{
filter
:
'
brightness(0) invert(1)
'
};
const
logoStyle
=
useColorModeValue
({},
!
config
.
UI
.
navigation
.
logo
.
dark
?
darkModeFilter
:
{});
const
iconStyle
=
useColorModeValue
({},
!
config
.
UI
.
navigation
.
icon
.
dark
?
darkModeFilter
:
{});
return
(
<
chakra
.
a
...
...
@@ -71,7 +63,7 @@ const NetworkLogo = ({ isCollapsed, onClick, className }: Props) => {
alt=
{
`${ config.chain.name } network logo`
}
fallback=
{
<
LogoFallback
isCollapsed=
{
isCollapsed
}
/>
}
display=
{
{
base
:
'
block
'
,
lg
:
isCollapsed
===
false
?
'
block
'
:
'
none
'
,
xl
:
isCollapsed
?
'
none
'
:
'
block
'
}
}
style=
{
logoStyle
}
filter=
{
{
_dark
:
INVERT_FILTER
}
}
/>
{
/* small logo */
}
<
Image
...
...
@@ -81,7 +73,7 @@ const NetworkLogo = ({ isCollapsed, onClick, className }: Props) => {
alt=
{
`${ config.chain.name } network logo`
}
fallback=
{
<
LogoFallback
isCollapsed=
{
isCollapsed
}
isSmall
/>
}
display=
{
{
base
:
'
none
'
,
lg
:
isCollapsed
===
false
?
'
none
'
:
'
block
'
,
xl
:
isCollapsed
?
'
block
'
:
'
none
'
}
}
style=
{
iconStyle
}
filter=
{
{
_dark
:
INVERT_FILTER
}
}
/>
</
chakra
.
a
>
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment