Skip to content

Commit

Permalink
fix(UI): style of redpacket conditions (#12043)
Browse files Browse the repository at this point in the history
* fix: mf-6561 footer button

* fix: mf-6560 conditoins style

* fix: mf-6559 style of holding nfts
  • Loading branch information
swkatmask authored Jan 20, 2025
1 parent 58556d3 commit ee98cf6
Show file tree
Hide file tree
Showing 13 changed files with 97 additions and 20 deletions.
38 changes: 33 additions & 5 deletions packages/plugins/RedPacket/src/SiteAdaptor/Conditions/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ const useStyles = makeStyles()((theme) => ({
gap: theme.spacing(1.5),
flexFlow: 'row wrap',
},
collections: {
display: 'grid',
gridTemplateColumns: 'repeat(2,1fr)',
gap: theme.spacing(1.5),
},
asset: {
display: 'flex',
alignItems: 'center',
Expand All @@ -72,21 +77,39 @@ const useStyles = makeStyles()((theme) => ({
fontWeight: 400,
lineHeight: '20px',
color: theme.palette.common.white,
overflow: 'hidden',
textOverflow: 'ellipsis',
display: '-webkit-box',
WebkitLineClamp: 2,
WebkitBoxOrient: 'vertical',
},
tokenIcon: {
width: 24,
height: 24,
marginRight: '0px !important',
},
unsatisfied: {
position: 'absolute',
left: 12,
bottom: 12,
right: 12,
backgroundColor: 'rgba(255, 53, 69, 0.2)',
borderRadius: 4,
padding: 6,
color: theme.palette.maskColor.white,
fontSize: 12,
fontWeight: 700,
lineHeight: '16px',
},
}))

interface Props extends BoxProps {
onClose?(): void
unsatisfied?: boolean
statusList: FireflyRedPacketAPI.ClaimStrategyStatus[]
showResults?: boolean
onClose?(): void
}

export function Conditions({ onClose, statusList, showResults = true, ...props }: Props) {
export function Conditions({ onClose, statusList, unsatisfied = true, ...props }: Props) {
const { classes, cx } = useStyles()
const tokenPayloads = statusList.find((x) => x.type === FireflyRedPacketAPI.StrategyType.tokens)?.payload
const tokenPayload = tokenPayloads?.[0]
Expand Down Expand Up @@ -132,10 +155,10 @@ export function Conditions({ onClose, statusList, showResults = true, ...props }
{collectionPayloads?.length ?
<div className={classes.section}>
<Typography className={classes.sectionTitle}>
<Trans>You need to own at least one of the following NFTs.</Trans>
<Trans>You need to hold any of the following NFTs in your wallet.</Trans>
</Typography>

<div className={classes.assets}>
<div className={classes.collections}>
{collectionPayloads.map((collection) => (
<div className={classes.asset} key={collection.contractAddress}>
<TokenIcon
Expand All @@ -152,6 +175,11 @@ export function Conditions({ onClose, statusList, showResults = true, ...props }
</div>
</div>
: null}
{unsatisfied ?
<Typography className={classes.unsatisfied}>
<Trans>Your wallet does not meet the eligibility criteria for claiming.</Trans>
</Typography>
: null}
</div>
<IconButton className={classes.closeButton} disableRipple onClick={() => onClose?.()} aria-label="Close">
<Icons.BaseClose size={30} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ export const RedPacket = memo(function RedPacket({ payload }: RedPacketProps) {

const outdated = isEmpty || (!canRefund && listOfStatus.includes(RedPacketStatus.expired))

const { classes, theme } = useStyles()
const { classes } = useStyles()

// RedPacket created from Mask has no cover settings
const { data: cover, isLoading: isLoadingCover } = useRedPacketCover({
Expand All @@ -239,8 +239,6 @@ export const RedPacket = memo(function RedPacket({ payload }: RedPacketProps) {
// the red packet can fetch without account
if (!availability || !token || isLoadingCover) return <LoadingStatus minHeight={148} />

const claimedOrEmpty = listOfStatus.includes(RedPacketStatus.claimed) || isEmpty

const card = (
<Card className={classes.root} component="article" elevation={0}>
<RedPacketEnvelope
Expand All @@ -264,7 +262,7 @@ export const RedPacket = memo(function RedPacket({ payload }: RedPacketProps) {
{cover ?
<Grow in={showRequirements} timeout={250}>
<Conditions
showResults={!claimedOrEmpty}
unsatisfied={!!account && claimStrategyStatus?.canClaim === false}
statusList={claimStrategyStatus?.claimStrategyStatus ?? EMPTY_LIST}
className={classes.conditions}
onClose={() => setShowRequirements(false)}
Expand All @@ -288,7 +286,7 @@ export const RedPacket = memo(function RedPacket({ payload }: RedPacketProps) {
</>
)

if (claimStrategyStatus?.canClaim === false) {
if (claimStrategyStatus?.canClaim === false && account) {
return (
<>
{card}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ const useStyles = makeStyles()((theme) => ({
},
collectionName: {
maxWidth: 80,
display: '-webkit-box',
WebkitBoxOrient: 'vertical',
WebkitLineClamp: 2,
overflow: 'hidden',
Expand Down
4 changes: 3 additions & 1 deletion packages/plugins/RedPacket/src/locale/en-US.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion packages/plugins/RedPacket/src/locale/en-US.po

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion packages/plugins/RedPacket/src/locale/ja-JP.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion packages/plugins/RedPacket/src/locale/ja-JP.po

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion packages/plugins/RedPacket/src/locale/ko-KR.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion packages/plugins/RedPacket/src/locale/ko-KR.po

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion packages/plugins/RedPacket/src/locale/zh-CN.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion packages/plugins/RedPacket/src/locale/zh-CN.po

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion packages/plugins/RedPacket/src/locale/zh-TW.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion packages/plugins/RedPacket/src/locale/zh-TW.po

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ee98cf6

Please sign in to comment.