Closed Mist3rBru closed 1 year ago
Latest commit: 62939c8500ad38c6738b378ac63c8b2b9a3fd4a2
The changes in this PR will be included in the next version bump.
Not sure what this means? Click here to learn what changesets are.
Click here if you're a maintainer who wants to add another changeset to this PR
I don't see how to implement it on @clack/core
, since it strict resolves the issue when a new line doesn't start with its corresponding symbol from @clack/prompts
Maybe we can add formatTextWithMaxWidth
as an util function on @clack/core
, to use it on a future Textarea
prompt, and import this util from @clack/core
to @clack/prompts
I think we will need to pass a custom formatter func within the render
function or expose a way for core to understand what is input vs styling.
As I think this could fix support temporary for prompts
, I do feel like core
will have to know so it can easily extended for other people not wanting to use @clack/prompts
.
Or we need to a way to expose what is the input text coming from core then do some special format around the input. I'm trying to think a neat way to handle it.
@Mist3rBru I think for now you can keep this PR open and create a new draft pr that will mutate core functionality for a POW if you want. So we can get @natemoo-re to check it out.
I'll do some more testing for the time being.
@cpreston321 what if we create a method on core
Prompt called format
or style
, then all prompts can call render: () => this.format(msg)
?
Are you thinking of creating a new function within prompt called format: (msg: string) => string
like validator: ()
? If we go this route -- I think it would be good to make it super flexible.
I am thinking of something that has a template then having a replacer for input styling. To keep things streamed line. (thinking out loud). Almost like template replacer with variables {{title}}
, {{input}}
. So it can be reused.
@Mist3rBru Found some formatting issues and also a bug with the format function. It's a dim color for the | below the input and when selecting yes on install it errored out.
....
@cpreston321 now must be right.
Hey @Mist3rBru something still seems off:
@cpreston321 I forgot the cancel prompt
Hey @Mist3rBru it looks like the default state looks off too it should look like this:
┌ create-app
│
◇ Where should we create your project?
│ ./sparkling-solid
│
not
┌ create-app │
◆ Where should we create your project?
└ ./sparkling-solid
@cpreston321 now must be right 🙏.
@Mist3rBru I fixed the styles in this branch but if you want to copy them over then fix them here you can!
https://github.com/natemoo-re/clack/commit/e365d606fe46d7c8e05703a63eabffafa5ee704f
Thanks @cpreston321, it is merged!
Now what should I do? Keep with this branch, merge it with the #143, or look for another approach to implement this feature.
@Mist3rBru #143,
I think it's a step in the right direction. I also think it might need some fine tuning for it to be fully there.
In my head I would think there would be a template and spot for input to support the multi line support for formatting in the terminal almost like a wrapper and within a input. I just an easy way to leave styling up to the user and we can focus on core functionality.
Within prompts we create a lot of duplicate styles but really the only thing that is the variant of the input
and colors. If there was to define a base template/wrapper around the input, so that we can control the input with multi line support.
I would think people would want to setup a custom wrapper for each prompt including state variants but also making the api very simple and easy to understand. Which I don't think is fully there.
My thought (will fallback to base @clack/core template/wrapper
) :
__________________________________
|
| custom style template/wrapper
|
| |-----------------------------|
| | input (core formating) |
| |-----------------------------|
|
|
|__________________________________
I am just thinking out loud here but this is something I would imagine. I don't want the user to think about it too much.
Making the api feel really easy, fluent, customizable is key.
Also @Mist3rBru While playing around with multiline support I encounter this
https://github.com/natemoo-re/clack/assets/6619884/bf828677-2ea9-465b-b2ed-c14f579a3117
Have any idea ?
@cpreston321 It is almost fixed, there is an annoying [7m
from cursor that shows only when the prev line is on last char that i coundn't solve
@cpreston321 inner line break and cursor are fixed. I am going to close it, and focus on PR #143
That sounds good, I think that will a better direction for the library -- since it will be at the core. I will add my input over there.
Hopefully Nate can get some input over there too!
Thanks, CP 🚀
Multiline Support
Support multiline texts either with
\n
, or long ones that exceed terminal width, without breaking the layoutList of supported prompts:
yes
/no
How to test
Closes #101 Closes #132 Relates #135 #111 #35