question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Layout: Grouping/Segmenting controls

See original GitHub issue
Screenshot of control clusters with annotations highlighting sections

I think we need some components/conventions to make it simple to create cohesive clusters and groupings of controls. In the screenshot above, things are arbitrarily spaced using <Spacer />. It works as it follows the grid system, but I feel like it should be even more seamless than that.

Maybe something like this?

<FormGroups title="Dimensions">
  <FormGroup label="Width">
    <TextInput />
  </FormGroup>
  <FormGroup label="Height">
    <TextInput />
  </FormGroup>
</FormGroups>

Similar to how iOS handles clusters (groups) of controls via Tables

Screenshot of iOS Tables from their Human Interface Guidelines

https://developer.apple.com/design/human-interface-guidelines/ios/views/tables/

Not only should it handle the typical use-case of Label [ TextInput ], but it should also accommodate custom UI, like a potential color setting (below):

Screenshot of a color setting from a Global Styles design

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10 (8 by maintainers)

github_iconTop GitHub Comments

3reactions
jasmussencommented, Sep 18, 2020

As a prototype, I feel like this definitely suggests the “dim adjacent” feels sufficient. Also, that’s a lot of colors in the test, which suggests a scrolling popover — a scrolling popover inside a sidebar that may also be scrolling would be a really bad experience, which I also feel suggests that opening these inline feels right.

2reactions
ItsJonQcommented, Sep 15, 2020

I think I’ve figured out the Component structure API!

The challenge is that this (generic) ListGroup must accommodate varying control types (sliders, switches, text inputs, etc…). There are some common patterns though for ListGroup usage, such as:

  • Header (title + potential action)
  • Spacing between items (potentially rendering a separator)
  • Footer (caption / help text for section)

With how Gutenberg is evolving, controls will most likely need to be enabled or disabled based on configs. Therefore, the layout components must account for this - whether it’s side margins, bottom margin zero’ing, or grid gaps.

Thankfully, we have some of this stuff figured out with Grid, HStack, and VStack.

Demo

Below is a demo for how a mixture of controls can be grouped, sectioned, and enabled/disabled at will. The margin/spacing between controls maintain the “rules” determined by G2’s grid/spacing systems.

2020-09-15 17-33-38 2020-09-15 17_34_15

Code

Here’s the exciting me (for me at least, haha), check out the code:

<ListGroup>
  <ListGroupHeader>Title</ListGroupHeader>
  <FormGroup label="Some Field">
    <TextInput />
  </FormGroup>
  <FormGroup label="Another Field">
    <TextInput />
  </FormGroup>
</ListGroup>

A cluster using a Grid may look like this:

<ListGroup>
  <ListGroupHeader>Title</ListGroupHeader>
  <Grid>
    <Select prefix={<Icon />} />
    <Select prefix={<Icon />} />
    <FormGroup label="Some Field">
      <Switch />
    </FormGroup>
  </Grid>
</ListGroup>

Here they are combined:

<ListGroups>
  <ListGroup>
    <ListGroupHeader>Title</ListGroupHeader>
    <FormGroup label="Some Field">
      <TextInput />
    </FormGroup>
    <FormGroup label="Another Field">
      <TextInput />
    </FormGroup>
  </ListGroup>

  <ListGroup>
    <ListGroupHeader>Title</ListGroupHeader>
    <Grid>
      <Select prefix={<Icon />} />
      <Select prefix={<Icon />} />
      <FormGroup label="Some Field">
        <Switch />
      </FormGroup>
    </Grid>
  </ListGroup>
</ListGroups>

Notice the ListGroups wrapper

Header + Action

There may be a case where the Header title may be accompanied by an action (right side).

The code to do this is also quite simple!

<ListGroup>
  <ListGroupHeader>
    Title
    <Button size="small">Edit</Button>
  </ListGroupHeader>
  <Grid>
    ...
  </Grid>
</ListGroup>

Context Is King

Certain components that render under ListGroup needed to adjust their behaviour (e.g. spacing). This was all achieved using G2’s Context System, not arbitrary CSS targeting (although the principles are similar).

This is an important distinction.

Components can gain “awareness” based on where they’re placed, and adapt their functionality accordingly.

This is very different compared to CSS where…

HTML elements can gain style rules based on where they’re placed, and adapt their aesthetics accordingly.

A ListGroupHeader knows it’s inside of a ListGroup, and is placed accordingly. If a Grid is rendered as a child within ListGroup, it’s gap spacing is tweaked, (without affecting potential child Grid components).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Arranging the layout of controls - IBM
The layout of components is relative to the other components in a user interface. Use container controls, like sections and tables, to group...
Read more >
The Definitive Guide to Keyword Organization - WordStream
such as clustering, grouping, segmenting and even categorizing. However you describe it, ... meaningful keyword organization plan for your SEM campaigns.
Read more >
10 Tips to Develop Your Holiday Content Marketing Strategy
Let your audience get a glimpse of your company holiday party, and don't be afraid to add festive design touches to your websites, ......
Read more >
Arranging Controls Layout - DocuPhase Platform
Arranging Controls Layout. You can organize and rearrange the controls in your form by dragging controls and dropping them in the appropriate place....
Read more >
Designing Practice: A Review of - jstor
tions related to the design of practice ac- tivities. ... predicting and controlling behavior ... grouping, segmenting, sequencing, or acronyms.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found