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

feature: grid actions #1

Open
jonschlinkert opened this issue May 28, 2017 · 1 comment
Open

feature: grid actions #1

jonschlinkert opened this issue May 28, 2017 · 1 comment

Comments

@jonschlinkert
Copy link
Member

I'm considering adding left/right support using the grid logic for actions in prompt-grid.

Here is what I think it would entail:

  • if options.grid is not undefined, enable grid support. the option might be set on prompt-base options or prompt-choices, I'm not sure yet. Depending on which, it could either be a boolean or an object of arrays (for actually defining the grid choices)
  • add left, right, moveLeft and moveRight actions

@doowb thoughts?

@doowb
Copy link
Member

doowb commented May 28, 2017

I like this idea...

We can do something in prompt-choices where if options.grid is true, then we handle the choices array in a special way. Since .position on prompt-choices is the position in the choices array, I think we can either keep the choices array flat and add helper methods for doing grid math for moving the position, or we can make the choices array a nested array for row and column elements and make position an object: {row: 0, col: 0} or array: [0,0] for grid points.

I prefer the first choice if we many grid elements on the choices object (since this will just add functionality and still be compatible with other prompt types).

If we want to add a new grid property that handles grids differently than choices, then I think the second option would be the way to go.


After typing it out, I think the first choice (a single choices array and methods for doing grid operations) would be the best way to go. These methods would be similar to what's in prompt-grid like toPosition and toIndex. We may be able to offer transform methods to transform a nested array (grid) into the array of choices and back into a grid so users can populate their question choices more easily.

So yeah, I think it's a good idea to include "grid" methods in prompt-choices and include some default actions that use those methods here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants