diff --git a/components/Editor/EditorControls.tsx b/components/Editor/EditorControls.tsx index 42bbf59..81dfc35 100644 --- a/components/Editor/EditorControls.tsx +++ b/components/Editor/EditorControls.tsx @@ -1,9 +1,9 @@ -import { useRef } from 'react' +import { useRef, useState } from 'react' -import { RiLinksLine } from '@remixicon/react' +import { RiLinksLine, RiQuestionLine } from '@remixicon/react' import cn from 'classnames' -import { Button, Input } from 'components/ui' +import { Button, Input, Modal } from 'components/ui' type EditorControlsProps = { isCompileDisabled: boolean @@ -23,6 +23,68 @@ const EditorControls = ({ onProgramArgumentsUpdate, }: EditorControlsProps) => { const inputRef = useRef(null) + const [showArgumentsHelper, setShowArgumentsHelper] = useState(false) + + const argumentHelperModal = ( + +
e.stopPropagation()} + onKeyDown={(e) => e.stopPropagation()} + > +

+ This input field accepts a list of program arguments separated by a{' '} + whitespace. +

+

Each argument could be:

+
    +
  • + a single + felt252, +
  • +
  • + an array of + felt252 where items + are also separated by a{' '} + whitespace. +
  • +
+

+ Note that only decimal values are supported for{' '} + felt252. That means + neither hexadecimal value nor short string are supported yet. +

+

+ Of course, the signature of your{' '} + main() function must be + adapted accordingly. +

+

+ For example,{' '} + 1 [3 4 5] 9{' '} + contains 3 arguments and the corresponding main function should be{' '} + + main(x: felt252, y: Array<felt252>, z: felt252) + + . +

+
+
+ ) + const argumentHelperIcon = ( + <> + + {showArgumentsHelper && argumentHelperModal} + + ) return (
@@ -42,12 +104,13 @@ const EditorControls = ({ { onProgramArgumentsUpdate(e.target.value) }} readOnly={isCompileDisabled} value={programArguments} - placeholder={`Enter program parameters...`} + placeholder={`Enter program arguments...`} className={cn('grow border bg-gray-200 dark:bg-gray-800', { 'dark:border-gray-800 border-gray-200': areProgramArgumentsValid, 'border-red-500': !areProgramArgumentsValid, @@ -56,7 +119,6 @@ const EditorControls = ({ 'text-red-500': !areProgramArgumentsValid, })} /> -
+
+ {children} +
+ + + ) : ( + <> + ) +} diff --git a/components/ui/index.ts b/components/ui/index.ts index 59fcaf7..d5b8f16 100644 --- a/components/ui/index.ts +++ b/components/ui/index.ts @@ -9,3 +9,4 @@ export * from './Message' export * from './Radio' export * from './RelativeLink' export * from './StackBox' +export * from './Modal' diff --git a/types/index.ts b/types/index.ts index 832436f..5d3d787 100644 --- a/types/index.ts +++ b/types/index.ts @@ -1,5 +1,3 @@ -import { LogType } from '../components/Editor/types' - declare global { interface Window { EvmCodes: any