Skip to content

Commit a1eb464

Browse files
authored
fix: allow custom style for application entries on app board (#12313)
1 parent b6f96d4 commit a1eb464

File tree

4 files changed

+14
-6
lines changed

4 files changed

+14
-6
lines changed

packages/plugin-infra/src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,7 @@ export namespace Plugin.SiteAdaptor {
370370
disabled: boolean
371371
tooltipHint?: React.ReactNode
372372
onClick?: (walletConnectedCallback?: () => void, requiredSupportPluginID?: NetworkPluginID) => void
373+
style?: React.CSSProperties
373374
}) => JSX.Element | null
374375
/**
375376
* Used to order the applications on the board

packages/shared/src/UI/components/ApplicationEntry/index.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ interface ApplicationEntryProps {
9999
iconFilterColor?: string
100100
tooltipHint?: React.ReactNode
101101
onClick: () => void
102+
style?: React.CSSProperties
102103
}
103104

104105
export function ApplicationEntry(props: ApplicationEntryProps) {
@@ -111,6 +112,7 @@ export function ApplicationEntry(props: ApplicationEntryProps) {
111112
tooltipHint,
112113
recommendFeature,
113114
iconFilterColor,
115+
style,
114116
} = props
115117
const { classes, cx } = useStyles({ disabled, iconFilterColor })
116118
const popperProps = useBoundedPopperProps()
@@ -119,7 +121,7 @@ export function ApplicationEntry(props: ApplicationEntryProps) {
119121
<Button
120122
variant="text"
121123
// do not change to sx. the hover image will be changed in applicationBoxHover
122-
style={{ background: recommendFeature.backgroundGradient }}
124+
style={{ ...style, background: recommendFeature.backgroundGradient }}
123125
disabled={disabled}
124126
className={cx(
125127
classes.recommendFeatureApplicationBox,
@@ -143,7 +145,8 @@ export function ApplicationEntry(props: ApplicationEntryProps) {
143145
className={cx(classes.applicationBox, disabled ? classes.disabled : classes.applicationBoxHover)}
144146
onClick={disabled ? undefined : onClick}
145147
variant="text"
146-
disabled={disabled}>
148+
disabled={disabled}
149+
style={style}>
147150
<div className={classes.iconWrapper}>{icon}</div>
148151
<TextOverflowTooltip
149152
title={title}

packages/shared/src/UI/modals/ApplicationBoardModal/ApplicationBoard.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ function ApplicationBoardPluginsList(props: ApplicationBoardPluginsListProps) {
201201
)
202202
}
203203

204-
function RenderEntryComponent({ application }: { application: Application }) {
204+
function RenderEntryComponent({ application, style }: { application: Application; style?: React.CSSProperties }) {
205205
const Entry = application.entry.RenderEntryComponent!
206206

207207
const ApplicationEntryStatus = useContext(ApplicationEntryStatusContext)
@@ -252,7 +252,7 @@ function RenderEntryComponent({ application }: { application: Application }) {
252252
})()
253253
// #endregion
254254

255-
return <Entry disabled={disabled} tooltipHint={tooltipHint} onClick={clickHandler} />
255+
return <Entry disabled={disabled} tooltipHint={tooltipHint} onClick={clickHandler} style={style} />
256256
}
257257

258258
interface ApplicationEntryStatusContextProps {

packages/shared/src/UI/modals/ApplicationBoardModal/ApplicationRecommendArea.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ const useStyles = makeStyles()(() => {
5555

5656
interface Props extends withClasses<'recommendFeatureAppListWrapper'> {
5757
recommendFeatureAppList: Application[]
58-
RenderEntryComponent: (props: { application: Application }) => JSX.Element
58+
RenderEntryComponent: (props: { application: Application; style?: React.CSSProperties }) => JSX.Element
5959
isCarouselReady?: () => boolean | null
6060
setIsHoveringCarousel: (hover: boolean) => void
6161
isHoveringCarousel: boolean
@@ -105,7 +105,11 @@ export function ApplicationRecommendArea(props: Props) {
105105
</CarouselProvider>
106106
: <Box className={classes.recommendFeatureAppListWrapper}>
107107
{recommendFeatureAppList.map((application) => (
108-
<RenderEntryComponent key={application.entry.ApplicationEntryID} application={application} />
108+
<RenderEntryComponent
109+
key={application.entry.ApplicationEntryID}
110+
application={application}
111+
style={recommendFeatureAppList.length === 1 ? { width: '100%', marginRight: 0 } : undefined}
112+
/>
109113
))}
110114
</Box>
111115
}

0 commit comments

Comments
 (0)