-
Notifications
You must be signed in to change notification settings - Fork 12
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
WP/Components with G2 Adapters #75
Comments
Had a wonderful chat with @griffbrad today! One of the things we talked about was this ContextSystem x Adapter strategy. I thought that was a wonderful way to look at it. Yes! Indeed. ContextSystem x Adapters enables use to "feature flag" our way to safely integrating G2 in Gutenberg 🎉 |
📂 File/Code convention ideaLet's use the
All of the logic and G2 Component "rigging" can happen in that file. For example: // components/src/button/next.js
import { withNextComponent as withNext } from '@wordpress/ui.context';
import { Button } from '@wordpress/ui.components';
function adapter(props) { ... }
export function withNextComponent(current) {
// current - Current WP Button
// Button - The G2 Component Button
// 'WPComponentsButton' - Namespace to register into the Context System
// adapter - Adapter to bridge the props between current Button -> G2 Button
return withNext(current, Button, 'WPComponentsButton', adapter);
} Finally, in the current import { withNextComponent } from './next';
function Button (props) { ... }
export default withNextComponent(Button); With this technique, there's a clear division between:
|
Chatted with @griffbrad today! In addition to the technical implementation, @griffbrad had suggested the idea having guides for developers. Developers who have existing 3rd party block code, and devs who want to build something brand new. I don't think we necessarily need to write a details walkthrough/guide, at least not in the beginning. However, I think we should have a Expanding a bit on the Context/HOC strategy above. It seems like the current plan is to add the G2 packages into Gutenberg as separate packages (e.g. This would certainly make it clearer which parts of the system you're working in (e.g. The question is, should we globally export and expose the G2 component code? I would say no. I propose that G2 Components is surfaced throughout the project, as well as globally ( There will be a (long) period where we'll have 2 component codebases. Overtime, as we've completely migrated over to G2 Components, we'll be able to move the In short, G2 Components should ultimately become And these details should define and influence how we approach best practices and developer guidelines/tutorials. |
Why a separate package? I'd personally prefer a folder in the same package instead. This ensures it's organized properly and at the same time only exposed internally and not externally (through wp.*)
In the Button example above, I believe it means we keep both components working right? How does one consumer switches? Also can't we instead remove the legacy component and have a "prop adapter" instead (rewriting props, triggering deprecations for deprecated props) but still use the G2 components for both usage? |
At the moment, G2 Components has about 8 primary packages (about 6 if you exclude packages that are basically dependency aliases):
Just double checking. Is your suggestion for all of these packages to be moved directly into For context, these packages do very different things (not unlike how many of the current It's also valuable to be able to use/share styles from certain G2 packages (like (e.g. Performant state management/syncing, unit parsing/serializing)
Correct!
With this strategy, there are two primary ways to render the new Button. Inline <Button version="next">...</Button> Or, with a
(Note: We can change the
Unfortunately not, mostly for style conflict reasons. For example, the Replacing the current Having the feature-flag like control of the That being said, I'm 100% open to alternative strategies. This incremental context-based "chunking" migration strategy was something I've used in the past (with great success). Hope this helps! Really appreciate your thoughts @youknowriad ! ❤️ |
I see, I think it seems there's value in these packages being separate (maybe not all, we'll have to see). The important thing though is that they stay as "bundled modules" (like @wordpress/icons and @wordpress/interface right now) to avoid having them leak as public APIs in WordPress. for the components one (I guess the highest level one), I think we should avoid the temporary package and just use a folder in
👌 I wonder if we should mark this prop as unstable, since it's only useful during the migration.
So you're saying, once we migrate all buttons usage in our codebase, we can remove the old implementation. that seems reasonable. |
📁 Modules
Wonderful! 💫 Combined Component Package
I'm open to that. Although, I think there's value in separating the newer G2 Components code in same way. If all of it goes into Perhaps like this:
I feel like the structure above can make code easier to find (since the G2 code is scoped locally to it's named directory), while encapsulating and signifying the "next" version of code that's being worked on. In this above example, I've included For cases like this, I think it would be okay organize the files without using a ⚛️ Version Prop
I'm happy with that :). I think using 🧹 Cleaning up the Old Implementation
That's my hope 🙏 . That these G2 Components eventually become Once all of the previous implementation is removed, all that remains of it are the (now) legacy component APIs. At that point, we can decide if we want to deprecate these component APIs in favour of newer ones that make sense to the ecosystem. |
cc'ing @saramarcondes |
Related: |
Going with out Context System based integration strategy, we need to create a series of "adapters" to bridge the props/markup between the current WordPress components UI and the G2 components UI.
Using the Typography Design Tools as the potential G2 launch candidate/vehicle.. I've identified a list of components we need to pay attention to.
☀️ Required G2 Components
🌔 Existing WP Component equivalents
If we want to bring the G2 Typography tools experience (in it's entirety), we'll need to ensure the above listed components (under 🌔) are 💯 adapted.
The text was updated successfully, but these errors were encountered: