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(import): add disable logic to import ui #61

Merged
merged 1 commit into from
Jan 17, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ export interface NetworkSelectProps {
options: NetworkOption[];
placeholder?: React.ReactNode;
className?: string;
disabled?: boolean;
}

export const NetworkSelect = ({
value,
options: networkOptions,
placeholder = 'Select Network',
disabled,
...props
}: NetworkSelectProps) => {
const options = useMemo(() => {
Expand Down Expand Up @@ -51,6 +53,7 @@ export const NetworkSelect = ({
options={options}
placeholder={placeholder}
addon={addon}
disabled={disabled}
{...props}
/>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export interface SelectProps<T extends unknown = string> {
placeholder?: React.ReactNode;
addon?: React.ReactNode;
className?: string;
disabled?: boolean;
}

export const Select = <T extends unknown = string>({
Expand All @@ -24,6 +25,7 @@ export const Select = <T extends unknown = string>({
placeholder,
addon,
className,
disabled = false,
}: SelectProps<T>) => {
const [isSelecting, setIsSelecting] = useState(false);
const current = useMemo(() => {
Expand All @@ -33,8 +35,9 @@ export const Select = <T extends unknown = string>({
return options.find((option) => option.value === value);
}, [value, options]);
const handleClick = useCallback(() => {
if (disabled) return;
setIsSelecting(!isSelecting);
}, [isSelecting]);
}, [isSelecting, disabled]);
const handleSelect = useCallback(
(option: Option<T>) => {
setIsSelecting(false);
Expand All @@ -50,6 +53,7 @@ export const Select = <T extends unknown = string>({
className={cn(
'flex justify-between items-center text-sm text-black-500 font-primary bg-black-brand rounded-1 px-2.5 py-1.5 cursor-pointer min-h-9 ring-primary-500 hover:ring-1',
isSelecting && 'ring-1',
disabled && 'opacity-50 cursor-not-allowed hover:ring-0',
className,
)}>
<div className="flex-1 flex justify-between items-center">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { ActionButton } from '../components/ActionButton';
import { NetworkSelect, type NetworkOption } from '../components/NetworkSelect';
import NamefiBrandText from "../../../Core/NamefiBrandText";
import TokenIcon from "../../../Core/icons/TokenIcon";
import { cn } from '../../../../utils/cn';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

import from @utils/cn

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@luistv-swe do you know if path alias is configured in this repo? I could not find any usage of it or in any config in tsconfig.json


export type { NetworkOption };

Expand All @@ -18,6 +19,7 @@ export interface GetStartedProps {
onClickStart?: () => void;
onBack?: () => void;
className?: string;
disabled?: boolean;
}

export const GetStarted = ({
Expand All @@ -29,6 +31,7 @@ export const GetStarted = ({
onClickStart,
onBack,
className,
disabled = false,
}: GetStartedProps) => {
return (
<ImportFlowLayout.Main
Expand All @@ -39,7 +42,7 @@ export const GetStarted = ({
}
description="Mint your domain NFT and start trading it hassle-free."
onBack={onBack}
className={className}>
className={cn(className, disabled && 'opacity-50')}>
<div className="mt-6 mb-12">
<ImportFlowLayout.Field
label="Import costs"
Expand All @@ -58,6 +61,7 @@ export const GetStarted = ({
value={network}
onChange={onChangeNetwork}
options={networkOptions}
disabled={disabled}
/>
</ImportFlowLayout.Field>
)}
Expand All @@ -67,7 +71,7 @@ export const GetStarted = ({
icon={<ArrowRightIcon />}
className="w-auto"
onClick={onClickStart}
disabled={!!networkOptions?.length && !network}>
disabled={disabled || (!!networkOptions?.length && !network)}>
Start Import
</ActionButton>
</ImportFlowLayout.Actions>
Expand Down
Loading