nuvoleweb / ui_patterns

[NOTE] Development has moved to https://drupal.org/project/ui_patterns
https://drupal.org/project/ui_patterns
GNU General Public License v2.0
85 stars 56 forks source link

Request: Views support for whole view (format) #123

Open bserem opened 7 years ago

bserem commented 7 years ago

It would ideal to have support to style the whole view using UI patterns.

I know that we can use views for the row styling, which is pretty amazing. What I would like to see on top of that is the option to select patterns as the view format (alongside 'unformatted/html list', 'table' and 'grid').

I'll try to describe my thoughts giving an example, in order to make things easier to understand.

Lets say I have a pattern called card with fields image, title, content, action and a twig like:

<div class='card' style='background-image:url("{{ image }}")'>
  <div class="card__body">
    <h2 class="card__title">{{ title }}</h2>
    <p class="card__content">{{ content }}</p>
    <div class="card__actions">{{ actions }}</div>
  </div>
</div>

This works fine as a row plugin with ui_patterns.

Now, I have an extra pattern, called cards with one field, named card and a twig file with something like the following:

<div id="cards" class="cards other-fancy-stuff">

{# VIEWS ROWS GET PRINTED HERE #}

</div>

This way, I can pre-style my views in ui_patterns, and then assign the pattern to the view and have the expected output (see: https://www.drupal.org/files/project-images/components_combo.png)

Do you believe something like that is possible? Does it make sense to anybody else?

Hope I explained it well

ademarco commented 6 years ago

This is totally possible, it's about building yet another Views plugin (a display plugin in this case) that would use patterns to format the view.

BTW: since patterns are exposed as layouts too have you tried using something along the line of https://www.drupal.org/project/layout_plugin_views ?

bserem commented 6 years ago

I didn't knew about layout_plugin_views, but it seems pretty old for D8 standards.

Anyway, I am giving a try for a views plugin right right now.

ademarco commented 6 years ago

Yep, have a look, if not then we can just add it to UI Patterns, it's totally in the scope of the core module.

joshuaboltzmc commented 6 years ago

FYI - since you'll probably hit these when installing layout_plugin_views (since it depends on layout_plugin), here is a layout_plugin patch: https://www.drupal.org/project/layout_plugin/issues/2871585

Error: Cannot use object of type Drupal\Core\Layout\LayoutDefinition as array in Drupal\layout_plugin\Plugin\Layout\LayoutPluginManager->getThemeImplementations() (line 162 of modules/contrib/layout_plugin/src/Plugin/Layout/LayoutPluginManager.php).

tonystar commented 6 years ago

Would be great to have deeper support/control for Views:

  1. Select component to render whole View (say, Accordion for list of nodes).
  2. Define mapping on per-item basis (say, node title goes to Accordion pane header and node description goes to Accordion pane body).

This would require additional metadata in pattern definition (Accordion have panes, each pane have header and body) - kind of substructures.

manuel-adan commented 4 years ago

I wrote a custom views plugin style for that:

imagen

The settings

imagen