components
1 year ago
images
1 year ago
types
1 year ago
utils
1 year ago
App.tsx
1 year ago
index.tsx
1 year ago
App.tsx
124 lines
| 1 | import { __ } from '@wordpress/i18n'; |
| 2 | import React, { useState, useMemo } from "react"; |
| 3 | import { |
| 4 | ChakraProvider, |
| 5 | Box, |
| 6 | HStack, |
| 7 | Text, |
| 8 | Tabs, |
| 9 | TabList, |
| 10 | Tab, |
| 11 | Button, |
| 12 | Icon, |
| 13 | Divider, |
| 14 | VStack, |
| 15 | Heading, |
| 16 | } from "@chakra-ui/react"; |
| 17 | import Main from "./components/Main"; |
| 18 | |
| 19 | const EVFIcon = (props) => ( |
| 20 | <Icon viewBox="0 0 24 24" {...props}> |
| 21 | <path |
| 22 | fill="#7e3bd0" |
| 23 | d="M21.23,10H17.79L16.62,8h3.46ZM17.77,4l1.15,2H15.48L14.31,4Zm-15,16L12,4l5.77,10H10.85L12,12h2.31L12,8,6.23,18H20.08l1.16,2Z" |
| 24 | /> |
| 25 | </Icon> |
| 26 | ); |
| 27 | |
| 28 | const TabFilters = ({ onTabChange }) => { |
| 29 | const filters = useMemo(() => [__("All", "everest-forms"), __("Free", "everest-forms"), __("Premium", "everest-forms")], []); |
| 30 | |
| 31 | return ( |
| 32 | <Tabs variant="unstyled" ml="auto" onChange={onTabChange}> |
| 33 | <TabList> |
| 34 | {filters.map((label) => ( |
| 35 | <Tab |
| 36 | key={label} |
| 37 | _selected={{ |
| 38 | color: "purple.500", |
| 39 | fontWeight: "bold", |
| 40 | borderBottom: "2px solid", |
| 41 | borderColor: "purple.500", |
| 42 | }} |
| 43 | fontSize={{ base: "sm", md: "md", lg: "lg" }} |
| 44 | px={{ base: 1, md: 2 }} // Add horizontal padding to tabs |
| 45 | > |
| 46 | {label} |
| 47 | </Tab> |
| 48 | ))} |
| 49 | </TabList> |
| 50 | </Tabs> |
| 51 | ); |
| 52 | }; |
| 53 | |
| 54 | const App = () => { |
| 55 | const [selectedTab, setSelectedTab] = useState<string>(__("All", "everest-forms")); |
| 56 | |
| 57 | // Handle tab changes |
| 58 | const handleTabChange = (index: number) => { |
| 59 | const filters = [__("All", "everest-forms"), __("Free", "everest-forms"), __("Premium", "everest-forms")]; |
| 60 | setSelectedTab(filters[index]); |
| 61 | }; |
| 62 | |
| 63 | // Handle refresh button click |
| 64 | const handleRefreshTemplates = () => { |
| 65 | const url = new URL(window.location.href); |
| 66 | url.searchParams.set('refresh', Date.now().toString()); |
| 67 | window.location.href = url.toString(); |
| 68 | }; |
| 69 | |
| 70 | return ( |
| 71 | <ChakraProvider> |
| 72 | <Box bg="white" margin="20px" padding="0px 24px 50px" boxShadow="0px 4px 50px rgba(0, 0, 0, 0.06)"> |
| 73 | <HStack |
| 74 | spacing={{ base: 4, md: 6 }} |
| 75 | align="center" |
| 76 | mb={0} |
| 77 | borderBottom="1px solid #CDD0D8" |
| 78 | padding="20px 10px" |
| 79 | direction={{ base: "column", md: "row" }} |
| 80 | > |
| 81 | <EVFIcon boxSize="12" /> |
| 82 | <Divider orientation="vertical" height="40px" borderColor="#CDD0D8" /> |
| 83 | <Text fontSize="18px" fontWeight="semibold" lineHeight="26px" color="#383838" textAlign={{ base: "center", md: "left" }} margin="0px"> |
| 84 | {__("Add New Form", "everest-forms")} |
| 85 | </Text> |
| 86 | <Button |
| 87 | colorScheme="purple" |
| 88 | variant="outline" |
| 89 | onClick={handleRefreshTemplates} |
| 90 | width={{ base: "full", md: "auto" }} |
| 91 | display={{ base: "none", md: "inline-flex" }} |
| 92 | fontSize= "15px" |
| 93 | lineHeight="20px" |
| 94 | padding="8px 16px" |
| 95 | height="auto" |
| 96 | borderRadius="4px" |
| 97 | > |
| 98 | {__("Refresh Templates", "everest-forms")} |
| 99 | </Button> |
| 100 | <TabFilters onTabChange={handleTabChange} /> |
| 101 | </HStack> |
| 102 | |
| 103 | {/* Main Content Area */} |
| 104 | <Box bg="white" > |
| 105 | <VStack align="start" padding="20px 0px 32px" gap="12px"> |
| 106 | <Heading as="h1" fontSize="24px"lineHeight="34px" letterSpacing="0.4px" fontWeight="semibold" m={0}> |
| 107 | {__("Select a Template", "everest-forms")} |
| 108 | </Heading> |
| 109 | <Text fontSize="14px" lineHeight="24px" color="#4D4D4D" fontWeight="400" margin="0px" > |
| 110 | {__( |
| 111 | "To get started quickly, you can pick from our ready-made templates, begin with a blank form, or design your own.", |
| 112 | "everest-forms" |
| 113 | )} |
| 114 | </Text> |
| 115 | </VStack> |
| 116 | <Main filter={selectedTab} /> |
| 117 | </Box> |
| 118 | </Box> |
| 119 | </ChakraProvider> |
| 120 | ); |
| 121 | }; |
| 122 | |
| 123 | export default App; |
| 124 |