-
Notifications
You must be signed in to change notification settings - Fork 274
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
Add the components
package with PathMappingControl
#1608
Conversation
packages/playground/components/src/PathMappingControl/PathMappingControl.tsx
Outdated
Show resolved
Hide resolved
}; | ||
|
||
const handlePathChange = (value: string) => { | ||
updateNodeState(path, { playgroundPath: value }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed on validation, although a space is a valid path:
$ echo "test" > " "
$ cat " "
test
In fact, almost everything is a valid path. There are some characters that can't be used in paths, such as :
. AFAIR paths are bytes and don't conform to any specific encoding like UTF-8. More research is needed here to figure out how to validate paths.
On your screenshot I see another problem – we're removing whitespaces from the user input, I no longer think we should do that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we are going to support less common values like directory names with trailing spaces, perhaps we should display some kind of outline around the text to clearly mark its bounds, at least in cases where the bounds cannot be visually ascertained.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
although a space is a valid path
I learned something new today 😀
Co-authored-by: Bero <berislav.grgicak@gmail.com>
…ingControl.tsx Co-authored-by: Bero <berislav.grgicak@gmail.com>
I'll remove this from the board for now. We'll need it sooner than later but let's not occupy a space in a queue. |
UX idea: display select boxes for path selection, not inputs. Options:
In v2 we could also add a magic "guess" button to infer the role of every path in the tree. |
Nice. This would reduce the opportunity for typos, and selection sounds less stressful to me than having to remember and type the correct path. |
There are improvements we could do here, but I'll go ahead and merge as it's not used anywhere and I'd like to play with it in a draft branch. |
Motivation for the change, related issues
Adds a
PathMappingControl
React component:The goal is to eventually replace the current mapping control based on text inputs:
The long-term goal is to create a library of dependency-free components (well, aside of React) to reuse between Playground webapp, WordPress plugins, WordPress blocks, and the Blueprints builder. This path mapping widget will make a good fit for all these places.
Implementation details
The PathMappingControl uses WordPress components under the hood. Most notably, TreeGrid and Button. I considered using web components for portability, but decided against it because they:
Testing Instructions (or ideally a Blueprint)
nx dev playground-components
Follow-up work
Absolute path in Playground
with a UI-based picker or path autocompletion./wordpress/wp-content
and/wordpress/wp-content/plugins
.