-
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
Global Styles Sidebar (Design/Code V2) #293
base: main
Are you sure you want to change the base?
Conversation
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/itsjonq/g2/FPBTZNhJqJNkPeK4fANsTaZ8iEfi |
The prototype code is located here: 🧭 RoutesThe idea behind the project structure is to construct it like a typical router-driven React application. 📱 ScreensContinuing with the router paradigm, individual "views" are labelled as "screens" - borrowing a concept from mobile development. These screens are individual components that are coordinated through the main Not prototyped... In the eventual implementation, these screens may have individual loading/fetching states. In case they need to retrieve data from the global WP data store. ♻️ Get/SetWhen rendering values from the store (e.g. paragraph color), I think it's profoundly important that values can be elegantly retrieved and updated as they are bound to controls. We need to figure out a code pattern to support this. Otherwise, it will get exponentially messy as we attempt to verbosely deconstruct/stitch together getter/setter values. 📦 ComponentsPart of this effort is to create/consolidate Components that's required to construct this new experience. Other component refinements that come to mind would be:
|
Just added a URL sync feature so that changes in the Sidebar screens (routes) is bookmarkable/sharable. |
Potential (Navigator) Router conflictsAt the moment, any instance of I suspect we may run into issues if there are multiple nested In the case of Global Styles, we may have a carousel-like component rendering in the Sidebar. Solution:
|
cc'ing @griffbrad (Who may be interested in progress 🎉 ) |
Screencast of latest(ish) updates: |
* Add Typography tools * Add support for Typography options
Control <-> OptionsPart of this new design introduces a new interaction to the sidebar controls. This dropdown consolidates both a "reset" mechanic and show/hide into a single interaction. If we are to adopt this pattern to other style attributes, we have to come up with a solid (code) design pattern for how to handle this. From my experiments, the most consistent ways I've found to do this resolves around a handful of code patterns (Note: There may be better ones out there).
Assuming we have something like this as the
We'll walk through how we may connect that value with the UI with the design concepts above. get, setThe UI component may look like this: <FormGroup label="Font size">
<UnitInput value={fontSize} onChange={handleOnChangeFontSize} />
</FormGroup> The challenge is getting (or creating) the Instead of manually destructuring (nested) objects and manually creating callbacks per style value, maybe we can have something like this: const [fontSize, setFontSize] = useStyleValue('typography.elements[0]')
<FormGroup label="Font size">
<UnitInput value={fontSize} onChange={setFontSize} />
</FormGroup> Borrowing from const bind = useStyleValue('typography.elements[0]')
<FormGroup label="Font size">
<UnitInput {...bind()} />
</FormGroup> Note: This would only work with the most straight-forward use-cases. RenderWith out Instead of wrapping each UI chunk with something like: {fontSize !== undefined && (
<FormGroup>
...
</FormGroup>
)} Maybe we can do something like this: <RenderControl prop="fontSize">
<FormGroup>
...
</FormGroup>
</RenderControl> And the Dropdown / OptionsThe dropdown of display options synchronize with the controls presented below. With the current implementation of <DropdownMenuItem isSelected={isSelected} /> If we're going to be using this as a common design pattern, we'll need to generalize it enough so that we can do something like this: <Dropdown>
<DropdownTrigger
icon={<FiMoreHorizontal />}
isControl
isSubtle
size="small"
/>
<DropdownMenu>
{options.map((option) => (
<DropdownMenuItem {...option}>
{option.label}
</DropdownMenuItem>
))}
</DropdownMenu>
</Dropdown> Or better yet, something like this: <DisplayOptions options={[...]} /> toggleThis happens when clicking an item from the display options control. If we assume:
We can basically toggle the value like:
For the <DropdownMenuItem onClick={toggleAttribute('fontSize')} {...options}>
Font size
</DropdownMenuItem> defaultValueEstablishing a Ideally, style attributes would have some sort of I know all of this is very abstract. I think it would help by poking at the prototype: And checking out the rough code implementation: Hope this helps!! |
Prototype Links
A revisited attempt to constructing the Global Styles sidebar experience:
WordPress/gutenberg#27473
Created this draft PR to have auto deployed previews 🎉
cc'ing @mtias @pablohoneyhoney @sarayourfriend
Screenshot of Mockups