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

fix(components): add transition and fix ux writing on dev features #529

Merged
merged 2 commits into from
Sep 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Improvements

- [#529](https://github.com/alleslabs/celatone-frontend/pull/529) Improve developer features ux writing and transition
- [#528](https://github.com/alleslabs/celatone-frontend/pull/528) Improve developer features toggle for a smoother ux
- [#519](https://github.com/alleslabs/celatone-frontend/pull/519) Validate schema input when initialFormData has changed
- [#513](https://github.com/alleslabs/celatone-frontend/pull/513) Disable simulating fee when JSON input is invalid
Expand Down
126 changes: 72 additions & 54 deletions src/lib/layout/SubHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ import {
Button,
Heading,
} from "@chakra-ui/react";
import { AnimatePresence } from "framer-motion";
import type { CSSProperties, Dispatch, SetStateAction } from "react";
import { useEffect, useRef } from "react";

import { usePoolConfig, useGovConfig, useWasmConfig } from "lib/app-provider";
import { AppLink } from "lib/components/AppLink";
import type { IconKeys } from "lib/components/icon";
import { CustomIcon } from "lib/components/icon";
import { MotionBox } from "lib/components/MotionBox";
import { Tooltip } from "lib/components/Tooltip";
import { useIsCurrentPage } from "lib/hooks";
import type { Option } from "lib/types";
Expand All @@ -30,41 +32,57 @@ const FirstLandPrompt = ({
}: {
setIsDevMode: Dispatch<SetStateAction<Option<boolean>>>;
}) => (
<Flex
position="absolute"
right="24px"
mt={1}
gap={2}
p={6}
direction="column"
bg="gray.800"
w="430px"
borderRadius={4}
boxShadow={boxShadow}
zIndex="popover"
>
<Flex>
<Heading as="h6" variant="h6" fontWeight={600}>
Want to
<Text as="span" color="accent.main" pl={1}>
Deploy, Query, or Execute?
<AnimatePresence>
<MotionBox
key="modal"
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
exit={{ opacity: 0 }}
transition={{
delay: "1",
duration: "0.5",
ease: "easeInOut",
}}
position="absolute"
right="24px"
mt={1}
gap={2}
p={6}
display="flex"
flexDirection="column"
bg="gray.800"
w="430px"
borderRadius={4}
boxShadow={boxShadow}
zIndex="popover"
>
<Flex>
<Heading as="h6" variant="h6" fontWeight={600}>
Want to
<Text as="span" color="accent.main" pl={1}>
Deploy, Query, or Execute?
</Text>
</Heading>
</Flex>
<Text variant="body2" color="text.main" my={1}>
Turn on Dev Features to get full access to our deploy, query, execute
and other developer features through{" "}
<Text as="span" fontWeight={600}>
sidebar navigation
</Text>
</Heading>
</Flex>
<Text variant="body2" color="text.main" my={1}>
Turn on Dev Features to access to our deploy, query, execute and other
developer features through side bar navigation.
</Text>
<Flex direction="column" gap={2}>
<Button onClick={() => setIsDevMode(true)}>Turn on Dev Feature!</Button>
<Button variant="outline-primary" onClick={() => setIsDevMode(false)}>
Use Celatone as Explorer
</Button>
<Text variant="body2" textAlign="center" color="text.dark">
You can change it back anytime
.
</Text>
</Flex>
</Flex>
<Flex direction="column" gap={2}>
<Button onClick={() => setIsDevMode(true)}>Turn on Dev Feature!</Button>
<Button variant="outline-primary" onClick={() => setIsDevMode(false)}>
Use Celatone as Explorer
</Button>
<Text variant="body3" textAlign="center" color="text.dark">
You can change it back anytime
</Text>
</Flex>
</MotionBox>
</AnimatePresence>
);

interface SubHeaderProps {
Expand Down Expand Up @@ -162,31 +180,31 @@ const SubHeader = ({
</AppLink>
))}
</Flex>
<FormControl
display="flex"
alignItems="center"
width="fit-content"
style={isDevMode === undefined ? switchHighlight : undefined}
<Tooltip
label="Enable to access to our deploy, query, execute, and other developer features."
placement="bottom"
isDisabled={isDevMode === undefined}
>
<FormLabel mb={0} cursor="pointer" mr={2}>
<Tooltip
label="Toggle to enable or disable access to our deploy, query, execute, and other developer features."
placement="bottom"
isDisabled={isDevMode === undefined}
>
<FormControl
display="flex"
alignItems="center"
width="fit-content"
style={isDevMode === undefined ? switchHighlight : undefined}
>
<FormLabel mb={0} cursor="pointer" mr={2}>
<Text variant="body2" color="text.dark" fontWeight={600}>
Dev Features
</Text>
</Tooltip>
</FormLabel>
<Switch
size="md"
isChecked={isDevMode}
onChange={(e) => {
setIsDevMode(e.target.checked);
}}
/>
</FormControl>
</FormLabel>
<Switch
size="md"
isChecked={isDevMode}
onChange={(e) => {
setIsDevMode(e.target.checked);
}}
/>
</FormControl>
</Tooltip>
</Flex>
{isDevMode === undefined && (
<FirstLandPrompt setIsDevMode={setIsDevMode} />
Expand Down
2 changes: 1 addition & 1 deletion src/lib/layout/navbar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const Navbar = ({ isExpand, isDevMode, setIsExpand }: NavbarProps) => {
...(isDevMode && wasm.enabled
? [
{
category: "Quick Actions",
category: "Dev Features",
submenu: [
{
name: "Deploy Contract",
Expand Down
3 changes: 0 additions & 3 deletions src/lib/pages/home/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,6 @@ const Home = () => {
{!isMobile && (
<section style={{ marginBottom: "48px" }}>
<Flex gap={4} direction="column">
<Heading as="h5" variant="h5">
Dev Shortcuts
</Heading>
<ConnectWalletAlert
title={`Connect wallet to start using ${CURR_THEME.branding.seo.appName}`}
subtitle="Specific use cases such as deploying new contract or sending execute messages require a wallet connection."
Expand Down