Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: AddSolutionsModal #1334

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
69f05a8
feat: AddSolutionsModal
FBalint Jul 1, 2024
df165e4
feat: add new icons
FBalint Jul 1, 2024
033aa7c
fix: change description font settings
FBalint Jul 1, 2024
0182d90
fix: linter warnings
FBalint Jul 1, 2024
7b55c3d
fix: more contrast on text icon for light mode
FBalint Jul 1, 2024
7d7ff5e
fix: allow only one polygon id
FBalint Jul 1, 2024
0b2a480
fix boolean
FBalint Jul 1, 2024
b5430b4
merge main
FBalint Jul 3, 2024
341d5d0
feat: add SolutionCard
FBalint Jul 3, 2024
72f6f58
add all solutions
FBalint Jul 3, 2024
0076a68
fix: back button on polygon id reward
FBalint Jul 3, 2024
a17974f
optimize images
FBalint Jul 3, 2024
02317d4
add category selector
FBalint Jul 3, 2024
df834f1
v1 - with unblurred backgrounds
FBalint Jul 3, 2024
9100a89
v1 - with unblurred backgrounds fixed
FBalint Jul 3, 2024
6192803
v2 - with blurred backgrounds
FBalint Jul 3, 2024
9c59652
add gradient to bottom on hover
FBalint Jul 3, 2024
07e58ad
style tweaks
FBalint Jul 4, 2024
710d2ab
add filter for ploygonid
FBalint Jul 4, 2024
1d7cc83
refactor: move category to separate file
FBalint Jul 4, 2024
f1b480f
merge feature branch
FBalint Jul 4, 2024
a89358f
refactor: decompose
FBalint Jul 4, 2024
d89f00a
fix(DynamicRewardModal): use a lighter `blackAlpha` color
BrickheadJohnny Jul 4, 2024
2258d63
merge feature branch
FBalint Jul 4, 2024
71c4df0
Merge branch 'guild-3400-add-solutions-to-the-current-add-reward-moda…
BrickheadJohnny Jul 4, 2024
7ae3d08
fix(constants): remove dots
BrickheadJohnny Jul 4, 2024
ebc0064
fix(AddSolutionsButton): remove `data-test` attribute
BrickheadJohnny Jul 4, 2024
9d85c22
refactor(SegmentedControl): simple return instead of switch case
FBalint Jul 4, 2024
31dd858
remove unnecessary fragment
FBalint Jul 4, 2024
e7637cf
refactor(PlatformSelectButton): remove unnecessary icon color variable
FBalint Jul 4, 2024
a8f6cb1
refactor: replace AddPanel state WIP
FBalint Jul 4, 2024
bd48b23
fix(PointsPreview): handle CREATE_NEW_OPTION
FBalint Jul 4, 2024
bb7a051
fix(ExistingPointsTypeSelect): select first available point type by d…
FBalint Jul 4, 2024
d7049d2
feat(SolutionCard): make card keyboard accessible
FBalint Jul 4, 2024
e14b4e5
fix(SegmentedControl): label fills container height
FBalint Jul 4, 2024
8fa8f97
fix: lint warnings
FBalint Jul 4, 2024
e6fa675
UI(SolutionsPanel): new header style
dovalid Jul 5, 2024
370998d
UI(SolutionsPanel): remove bg in dark mode
dovalid Jul 5, 2024
8c9cca7
cleanup: move static variable out of render function
dovalid Jul 5, 2024
3a68163
UI(SolutionCard): finetune styling, add gradient
dovalid Jul 7, 2024
87697ae
Merge branch 'feat-liquidity-incentive-solution' into guild-3400-add-…
dovalid Jul 8, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added public/platforms/form.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/platforms/nft.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/platforms/points.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/platforms/text.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/solutions/discord-bg.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/solutions/form-bg.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/solutions/gather-bg.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/solutions/github-bg.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/solutions/google-bg.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/solutions/liquidity-bg.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/solutions/liquidity.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/solutions/nft-bg.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/solutions/poap-bg.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/solutions/points-bg.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/solutions/polygon-bg.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/solutions/telegram-bg.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/solutions/text-bg.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 2 additions & 24 deletions src/components/[guild]/AddRewardAndCampaign.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ import {
} from "@chakra-ui/react"
import { CaretDown, Plus } from "@phosphor-icons/react"
import CreateCampaignModal from "components/[guild]/CreateCampaignModal"
import LiquidityIncentiveSetupModal from "solutions/LiquidityIncentive/LiquidityIncentiveSetupModal"
import AddRewardButton from "./AddRewardButton"
import AddSolutionsButton from "solutions/components/AddSolutionsButton"
import { useIsTabsStuck } from "./Tabs"
import { useThemeContext } from "./ThemeContext"

Expand All @@ -24,16 +23,10 @@ const AddRewardAndCampaign = () => {
const { isStuck } = useIsTabsStuck()
const { textColor = null, buttonColorScheme = null } = useThemeContext() || {}

const {
isOpen: isSolutionOpen,
onClose: onSolutionClose,
onOpen: onSolutionOpen,
} = useDisclosure()

return (
<>
<ButtonGroup isAttached>
<AddRewardButton />
<AddSolutionsButton />
<Divider orientation="vertical" h="8" />
<Menu placement="bottom-end" autoSelect={false}>
<MenuButton
Expand All @@ -55,17 +48,6 @@ const AddRewardAndCampaign = () => {
zIndex="popover"
overflow="hidden"
>
<MenuItem
onClick={onSolutionOpen}
icon={<Icon as={Plus} mt="1" />}
alignItems="start"
py={4}
>
<Text as="span" fontWeight="semibold" fontSize="sm">
Add solution
</Text>
</MenuItem>
<Divider />
<MenuItem
onClick={onOpen}
icon={<Icon as={Plus} mt="1" />}
Expand All @@ -87,10 +69,6 @@ const AddRewardAndCampaign = () => {
</Menu>
</ButtonGroup>
<CreateCampaignModal isOpen={isOpen} onClose={onClose} />
<LiquidityIncentiveSetupModal
isOpen={isSolutionOpen}
onClose={onSolutionClose}
/>
</>
)
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/[guild]/AddRewardButton/SelectRolePanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ const SelectRolePanel = ({

const goBack = () => {
if (!rewards[selection].autoRewardSetup) methods.reset(defaultValues)
setStep("REWARD_SETUP")
setStep(selection === "POLYGON_ID" ? "HOME" : "REWARD_SETUP")
}

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ const AddPointsPanel = ({ onAdd, onCancel }: AddRewardPanelProps) => {
selectedExistingId={selectedExistingId}
showCreateNew
mb="5"
onDone={(idToSet) => {
setValue("data.guildPlatformId", idToSet)
onDone={(selectionId) => {
setValue("data.guildPlatformId", selectionId)
}}
/>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,11 @@ const ExistingPointsTypeSelect = ({
(option) => option.value === selectedExistingId
)?.img

const methods = useForm<{ selectedId?: number }>()
const methods = useForm<{ selectedId?: number | null }>({
defaultValues: {
selectedId: options?.[0]?.value || null,
},
})
const {
formState: { errors },
control,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const DynamicPointsAmountForm = ({ imageUrl, baseFieldPath }) => {
return () => {
setIsSubmitDisabled?.(false)
}
}, [requirementId])
}, [requirementId, setIsSubmitDisabled])

return (
<>
Expand Down
66 changes: 51 additions & 15 deletions src/components/common/SegmentedControl.tsx
Original file line number Diff line number Diff line change
@@ -1,34 +1,42 @@
import {
Box,
Flex,
HStack,
FlexProps,
RadioProps,
Text,
UseRadioGroupProps,
chakra,
useBreakpointValue,
useColorModeValue,
useRadio,
useRadioGroup,
} from "@chakra-ui/react"
import { motion } from "framer-motion"
import { useId } from "react"
import { useId, useMemo } from "react"

type SegmentedControlOption = {
label: string
value: unknown
isFullWidth?: boolean
}
type Props<TOption extends SegmentedControlOption> = {
options: TOption[]
size?: "md" | "sm"
isFullWidth?: boolean
styleProps?: FlexProps
onChange?: (nextValue: TOption["value"]) => void
value?: TOption["value"]
defaultValue?: TOption["value"]
} & Omit<UseRadioGroupProps, "onChange" | "value" | "defaultValue">

const SegmentedControl = <TOption extends SegmentedControlOption>({
options,
size = "md",
isFullWidth = true,
styleProps,
...useRadioGroupProps
}: Props<TOption>) => {
const bgColor = useColorModeValue("white", "blackAlpha.300")
const bgColor = useColorModeValue("gray.100", "blackAlpha.300")
const borderWidth = useColorModeValue(1, 0)

const { getRadioProps, getRootProps } = useRadioGroup({
Expand All @@ -39,15 +47,22 @@ const SegmentedControl = <TOption extends SegmentedControlOption>({

const uid = useId()

const height = useMemo(() => {
if (size === "md") return { base: "fit", md: 10 }
return { base: "fit", md: 9 }
}, [size])

return (
<HStack
<Flex
width="full"
borderWidth={borderWidth}
alignItems={"center"}
bgColor={bgColor}
borderRadius="lg"
height={10}
height={height}
padding={1}
spacing={1}
gap={1}
{...styleProps}
{...getRootProps()}
>
{options.map((option) => (
Expand All @@ -57,9 +72,11 @@ const SegmentedControl = <TOption extends SegmentedControlOption>({
{...getRadioProps({ value: option.value })}
label={option.label}
value={option.value as any}
size={size}
isFullWidth={isFullWidth}
/>
))}
</HStack>
</Flex>
)
}

Expand All @@ -68,36 +85,47 @@ const MotionBox = motion(Box)
const SegmentedControlButton = ({
uid,
label,
size = "md",
isFullWidth,
...useRadioProps
}: SegmentedControlOption & RadioProps & { uid: string }) => {
}: SegmentedControlOption & RadioProps & { uid: string; size?: "md" | "sm" }) => {
const { state, getInputProps, getRadioProps, htmlProps } = useRadio(useRadioProps)

const inputProps = getInputProps({})

const activeBgColor = useColorModeValue("blackAlpha.100", "whiteAlpha.200")
const activeBgColor = useColorModeValue("white", "whiteAlpha.200")

const isMobile = useBreakpointValue({ base: true, md: false })

return (
<chakra.label {...htmlProps} cursor="pointer" position="relative" h={8} w="full">
<chakra.label
{...htmlProps}
cursor="pointer"
position="relative"
h="full"
w={isFullWidth ? "full" : "auto"}
>
<input {...inputProps} hidden />

{state.isChecked && (
<MotionBox
position="absolute"
inset={0}
borderRadius="md"
borderRadius="lg"
backgroundColor={activeBgColor}
boxShadow={"0 0.5px 2px 0 rgba(0, 0, 0, 0.2)"}
layoutId={`${uid}-segmented-bg`}
transition={{
duration: 0.2,
}}
// Don't animate on the Y axis
style={{ originY: "0px" }}
style={isMobile ? {} : { originY: "0px" }}
/>
)}
<Flex
alignItems="center"
justifyContent="center"
h={8}
h="full"
borderRadius="md"
w="full"
fontWeight="medium"
Expand All @@ -119,9 +147,17 @@ const SegmentedControlButton = ({
}
}}
textAlign="center"
px={2}
px={3}
pos="relative"
zIndex="1"
>
<Text as="span" noOfLines={1}>
<Text
as="span"
noOfLines={1}
fontSize={size}
fontWeight={!isFullWidth ? "semibold" : undefined}
colorScheme={!state.isChecked ? "gray" : ""}
>
{label}
</Text>
</Flex>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ const PlatformSelectButton = ({
platformName === platform && !platformUserData?.readonly
)

const circleBgColor = useColorModeValue("gray.700", "gray.600")
const circleBgColor = useColorModeValue("gray.100", "gray.600")

const DynamicCtaIcon = useMemo(
() => dynamic(async () => (!isPlatformConnected ? ArrowSquareIn : CaretRight)),
[isPlatformConnected]
Expand Down Expand Up @@ -104,7 +105,12 @@ const PlatformSelectButton = ({
>
<HStack spacing={4}>
{imageUrl ? (
<Circle size="12" pos="relative" overflow="hidden">
<Circle
size="12"
pos="relative"
overflow="hidden"
bgColor={circleBgColor}
>
<Image src={imageUrl} alt="Guild logo" fill sizes="3rem" />
</Circle>
) : (
Expand All @@ -114,7 +120,7 @@ const PlatformSelectButton = ({
pos="relative"
overflow="hidden"
>
<Icon as={icon} boxSize={5} weight="regular" color="white" />
<Icon as={icon} boxSize={5} weight="regular" />
</Circle>
)}
<VStack
Expand All @@ -133,7 +139,7 @@ const PlatformSelectButton = ({
{title}
</Heading>
{description && (
<Text letterSpacing="wide" colorScheme="gray">
<Text colorScheme="gray" lineHeight={1.33}>
{(isLoading && `${loadingText}...`) || description}
</Text>
)}
Expand Down
10 changes: 5 additions & 5 deletions src/rewards/ContractCall/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { PlatformAsRewardRestrictions, RewardData } from "rewards/types"
import useContractCallCardProps from "./useContractCallCardProps"
import ContractCallRewardCardButton from "./ContractCallRewardCardButton"
import ContractCallCardMenu from "./ContractCallCardMenu"
import Photo from "static/icons/photo.svg"
import dynamic from "next/dynamic"
import { AddRewardPanelLoadingSpinner } from "rewards/components/AddRewardPanelLoadingSpinner"
import LoadingRewardPreview from "rewards/components/LoadingRewardPreview"
import { PlatformAsRewardRestrictions, RewardData } from "rewards/types"
import Photo from "static/icons/photo.svg"
import ContractCallCardMenu from "./ContractCallCardMenu"
import ContractCallRewardCardButton from "./ContractCallRewardCardButton"
import useContractCallCardProps from "./useContractCallCardProps"

export default {
icon: Photo,
Expand Down
8 changes: 4 additions & 4 deletions src/rewards/SecretText/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import dynamic from "next/dynamic"
import { AddRewardPanelLoadingSpinner } from "rewards/components/AddRewardPanelLoadingSpinner"
import LoadingRewardPreview from "rewards/components/LoadingRewardPreview"
import { PlatformAsRewardRestrictions, RewardData } from "rewards/types"
import Box from "static/icons/box.svg"
import SecretTextCardMenu from "./SecretTextCardMenu"
import TextCardButton from "./TextCardButton"
import useSecretTextCardProps from "./useSecretTextCardProps"
import Box from "static/icons/box.svg"
import dynamic from "next/dynamic"
import { AddRewardPanelLoadingSpinner } from "rewards/components/AddRewardPanelLoadingSpinner"
import LoadingRewardPreview from "rewards/components/LoadingRewardPreview"

export default {
icon: Box,
Expand Down
2 changes: 1 addition & 1 deletion src/rewards/Token/DynamicRewardModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ const DynamicRewardModal = ({
onClose: editOnClose,
onOpen: editOnOpen,
} = useDisclosure()
const footerBg = useColorModeValue("blackAlpha.100", "blackAlpha.600")
const footerBg = useColorModeValue("blackAlpha.100", "blackAlpha.300")

return (
<>
Expand Down
8 changes: 5 additions & 3 deletions src/rewards/components/PointsPreview.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { CREATE_NEW_OPTION } from "components/[guild]/RolePlatforms/components/AddRoleRewardModal/components/AddPointsPanel/components/ExistingPointsTypeSelect"
import useGuildPlatform from "components/[guild]/hooks/useGuildPlatform"
import { useWatch } from "react-hook-form"
import RewardPreview from "./RewardPreview"
Expand All @@ -14,9 +15,10 @@ const PointsPreview = (): JSX.Element => {
})

const { guildPlatform } = useGuildPlatform(guildPlatformId)
const { name, imageUrl } = guildPlatformId
? guildPlatform.platformGuildData ?? {}
: platformGuildData ?? {}
const { name, imageUrl } =
guildPlatformId && guildPlatformId !== CREATE_NEW_OPTION
? guildPlatform.platformGuildData ?? {}
: platformGuildData ?? {}

return (
<RewardPreview
Expand Down
Loading