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: List of Cairo examples to select from - Issue #109 #116

Merged

Conversation

melnikga
Copy link
Contributor

#109
Added select with Cairo code examples.

menuPlacement="auto"
value={exampleNameValue}
options={examplesOptionos}
instanceId="exampleSelect"
Copy link
Contributor

Choose a reason for hiding this comment

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

when my PR is merged you can use the React 18 useId() hook instead of hard-coded one

https://github.com/walnuthq/cairovm.codes/pull/105/files#diff-d7703e6081738cd218c05e03cfc118115be2b7200de2f7f55ec1f2f25bd33df9R40


import { Button, Input } from 'components/ui'

type EditorControlsProps = {
isCompileDisabled: boolean
programArguments: string
areProgramArgumentsValid: boolean
exampleName: number
handleChangeExampleOption: (option: OnChangeValue<any, any>) => void
Copy link
Contributor

Choose a reason for hiding this comment

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

for better typing, you can define a SelectOption type, for ex

type SelectOption = { value: number label: string }

and use it to type the handler

OnChangeValue<SelectOption, boolean>

It will ensure that the options provided are valid

[],
)

const examplesOptionos = examples.Cairo.map((example, i) => ({
Copy link
Contributor

Choose a reason for hiding this comment

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

typo here

@matthieuauger
Copy link
Contributor

Really cool feature! It seems that the select for examples hasn't a fixed width so when you change the example, the layout kind of move and for large example names (Variables & mutability for example), the "Compile and run" button takes two lines. Maybe we could have a solution to keep a fixed visual appearance for example with a fixed width

@melnikga
Copy link
Contributor Author

@matthieuauger Thanks for the comments, I made some small changes

Copy link
Contributor

@matthieuauger matthieuauger left a comment

Choose a reason for hiding this comment

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

Really nice, LGTM 🚀

@mazurroman
Copy link
Contributor

@melnikga looking really good!! after playing with it I think it would be great to reshuffle the elements a little to make the UX better.

Following this thought process: first I select cairo code, then I enter arguments and then I run the code; I think we should position the elements in this order (from left to right).

Moreover, we can make some small improvements to get more space:

  1. Rename the button from "Compile and run" to "Run"
  2. Rename the input from "Enter program arguments" to "Program arguments"
  3. Make the "Program arguments" input much smaller, i.e. reduce the width by 50%

It would also be nice to put some space between the code dropdown and the program arugments, to separate the two sections (permalink with code dropdown; arguments with run button) from each other. See my drawing attached:

image

@mazurroman mazurroman linked an issue Mar 21, 2024 that may be closed by this pull request
@mazurroman
Copy link
Contributor

@melnikga great job! 👏

@mazurroman mazurroman merged commit 6d5ef26 into walnuthq:main Mar 21, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat: List of Cairo examples to select from
3 participants