diff --git a/README.md b/README.md index c2591b2bdb36e90284869a927ec9333d0b4c1608..eb0256b3d96cf7bff9ca504e6503f32c9491c85d 100644 --- a/README.md +++ b/README.md @@ -9,24 +9,31 @@ Define and expose self-contained UI patterns as Drupal plugins and use them seam [panels](https://www.drupal.org/project/panels), [field groups](https://www.drupal.org/project/field_group), views, [Display Suite](https://www.drupal.org/project/ds) view modes and field templates. -The module generates a pattern library page to be used as documentation for content editors or as a showcase for -business and clients. - The UI Patterns module also integrates with with tools like [PatternLab](http://patternlab.io/) or modules like [Component Libraries](https://www.drupal.org/project/components) thanks to [definition overrides](http://ui-patterns.readthedocs.io/en/8.x-1.x/content/patterns-definition.html#override-patterns-behavior). - + ## Project overview -The UI Patterns project provides 5 modules: - -- **UI Patterns**: the main module, its purpose is to expose patterns to the Drupal rendering system and provide a pattern library overview page, available at `/patterns`. [Learn more](http://ui-patterns.readthedocs.io/en/8.x-1.x/content/patterns-definition.html) -- **UI Patterns Field Group**: allows to use patterns to format field groups provided by the [Field group](https://www.drupal.org/project/field_group) module. [Learn more](http://ui-patterns.readthedocs.io/en/8.x-1.x/content/field-group.html) -- **UI Patterns Layouts**: allows to use patterns as layouts provided by the [Layout plugin](https://www.drupal.org/project/layout_plugin) module. This allows patterns to be used on [Display Suite](https://www.drupal.org/project/ds) view modes or on [panels](https://www.drupal.org/project/panels) out of the box. [Learn more](http://ui-patterns.readthedocs.io/en/8.x-1.x/content/layout-plugin.html) -- **UI Patterns Display Suite**: allows to use patterns to format [Display Suite](https://www.drupal.org/project/ds) field templates. [Learn more](http://ui-patterns.readthedocs.io/en/8.x-1.x/content/field-templates.html) -- **UI Patterns Views**: allows to use patterns as Views row templates. [Learn more](http://ui-patterns.readthedocs.io/en/8.x-1.x/content/views.html) +The UI Patterns project provides 6 modules: + +- **UI Patterns**: the main module, it exposes the UI Patterns system APIs and it does not do much more than that. +- **UI Patterns Library**: allows to define patterns via YAML and generates a pattern library page available at `/patterns` + to be used as documentation for content editors or as a showcase for business. Use this module if you don't plan to + use more advanced component library systems such as PatternLab or Fractal. + [Learn more](http://ui-patterns.readthedocs.io/en/8.x-1.x/content/patterns-definition.html) +- **UI Patterns Field Group**: allows to use patterns to format field groups provided by the + [Field group](https://www.drupal.org/project/field_group) module. + [Learn more](http://ui-patterns.readthedocs.io/en/8.x-1.x/content/field-group.html) +- **UI Patterns Layouts**: allows to use patterns as layouts. This allows patterns to be used on + [Display Suite](https://www.drupal.org/project/ds) view modes or on [panels](https://www.drupal.org/project/panels) + out of the box. [Learn more](http://ui-patterns.readthedocs.io/en/8.x-1.x/content/layout-plugin.html) +- **UI Patterns Display Suite**: allows to use patterns to format [Display Suite](https://www.drupal.org/project/ds) + field templates. [Learn more](http://ui-patterns.readthedocs.io/en/8.x-1.x/content/field-templates.html) +- **UI Patterns Views**: allows to use patterns as Views row templates. + [Learn more](http://ui-patterns.readthedocs.io/en/8.x-1.x/content/views.html) ## Try it out! diff --git a/docs/content/layout-plugin.rst b/docs/content/layout-plugin.rst index f2cd0e871ea0ba601c6fa4ed68e824d6c9a4a03f..188bfad3f87919606f0ab9647b6246f4f4f56e56 100644 --- a/docs/content/layout-plugin.rst +++ b/docs/content/layout-plugin.rst @@ -1,8 +1,7 @@ -Use patterns with Layout Plugin -=============================== +Use patterns as layouts +======================= -Patterns can be used as `Layout Plugin <https://www.drupal.org/project/layout_plugin>`_'s layouts thanks to the -``ui_patterns_layouts`` module. +Patterns can be used as layouts thanks to the ``ui_patterns_layouts`` module. Once exposed as layouts patterns can be used to arrange fields on entities like nodes, `paragraphs <https://www.drupal.org/project/paragraphs>`_, etc. or to place blocks on a page using diff --git a/docs/content/patterns-definition.rst b/docs/content/patterns-definition.rst index 8e77f78d5380ea8a53499d3bddd37b5d9de440ea..f3916c42b2fce5fae19b25896de36dca2e9208b4 100644 --- a/docs/content/patterns-definition.rst +++ b/docs/content/patterns-definition.rst @@ -1,8 +1,17 @@ Define your patterns ==================== -Patterns can be exposed by both modules and themes: all defined patterns are collected and managed by a centralized -plugin manager, this means that pattern IDs must be unique in order to avoid conflicts. +Patterns can be exposed by both modules and themes by enabling the ``ui_patterns_library`` module. + +Defined patterns will be available at ``/patterns``, only accessible by roles having the ``access patterns page`` +permission. Below an example of a pattern library page styled using the `Bootstrap Patterns <https://github.com/nuvoleweb/bootstrap_patterns>`_ +theme: + +.. image:: ../images/pattern-library.png + :align: center + +Pattern definitions +------------------- To define your patterns simply create a YAML file named ``MY_MODULE.ui_patterns.yml`` or ``MY_THEME.ui_patterns.yml`` and list them using the following format: diff --git a/docs/images/patterns-overview.png b/docs/images/patterns-overview.png new file mode 100644 index 0000000000000000000000000000000000000000..bbe945f9adfe0f4231aa945835f32cd5084f43d5 Binary files /dev/null and b/docs/images/patterns-overview.png differ diff --git a/docs/index.rst b/docs/index.rst index 1a13eee8b9296b563bece20ff2e24feba93cfb60..90ff1669109c3ea93b0c965ebf8fe339f9b1b3d2 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -5,31 +5,30 @@ The UI Patterns module allows developers to define self-contained UI patterns as in their `panels <https://www.drupal.org/project/panels>`_, `field groups <https://www.drupal.org/project/field_group>`_ or `Display Suite <https://www.drupal.org/project/ds>`_ view modes. -The module also generates a pattern library page to be used as documentation for content editors or as a showcase -for business like the one shown below: - -.. image:: images/pattern-library.png +.. image:: images/patterns-overview.png :align: center Project overview ---------------- -The UI Patterns project provides 5 modules: +The UI Patterns project provides 6 modules: -* **UI Patterns**: the main module, its purpose is to expose patterns to the Drupal rendering system and provide a - pattern library overview page, available at ``/patterns``. +* **UI Patterns**: the main module, it exposes the UI Patterns system APIs and it does not do much more than that. +* **UI Patterns Library**: allows to define patterns via YAML and generates a pattern library page available at ``/patterns`` + to be used as documentation for content editors or as a showcase for business. Use this module if you don't plan to + use more advanced component library systems such as PatternLab or Fractal. + `Learn more <http://ui-patterns.readthedocs.io/en/8.x-1.x/content/patterns-definition.html>`_ * **UI Patterns Field Group**: allows to use patterns to format field groups provided by the `Field group <https://www.drupal.org/project/field_group>`_ module. -* **UI Patterns Layouts**: allows to use patterns as layouts provided by the - `Layout plugin <https://www.drupal.org/project/layout_plugin>`_ module. This allows patterns to be used on +* **UI Patterns Layouts**: allows to use patterns as layouts. This allows patterns to be used on `Display Suite <https://www.drupal.org/project/ds>`_ view modes or on `panels <https://www.drupal.org/project/panels>`_ out of the box. * **UI Patterns Display Suite**: allows to use patterns to format `Display Suite <https://www.drupal.org/project/ds>`_ field templates. * **UI Patterns Views**: allows to use patterns as Views row templates. -By the way plugin definitions are handled the UI Patterns module also integrated with with tools like `PatternLab <http://patternlab.io/>`_ -or modules like `Component Libraries <https://www.drupal.org/project/components>`_. +By the way plugin definitions are handled the UI Patterns module also integrates with with tools like +`PatternLab <http://patternlab.io/>`_ or modules like `Component Libraries <https://www.drupal.org/project/components>`_. Try it out ^^^^^^^^^^ diff --git a/modules/ui_patterns_layouts/README.md b/modules/ui_patterns_layouts/README.md index f700c9499c077d42a3609769f8607d7ebec2612a..f133c8dc5dfd5499d42d26aefb71e555d50b4c96 100644 --- a/modules/ui_patterns_layouts/README.md +++ b/modules/ui_patterns_layouts/README.md @@ -1,7 +1,12 @@ # UI Patterns Layouts -Integrates UI Patterns with the [Layout Plugin](https://www.drupal.org/project/layout_plugin) module. +Integrates UI Patterns with the **Layout Discovery** core module. - To use pattern layouts on view modes install the [Display Suite](https://www.drupal.org/project/ds) module. - To use pattern layouts with [Page Manager](https://www.drupal.org/project/page_manager) install the [Panels](https://www.drupal.org/project/panels) module. + +## Note + +Integration with the [Layout Plugin](https://www.drupal.org/project/layout_plugin) module is supported only until +version 1.0-beta6 included. diff --git a/modules/ui_patterns_layouts/ui_patterns_layouts.info.yml b/modules/ui_patterns_layouts/ui_patterns_layouts.info.yml index 400df99101bd971015c618d9bd3984dbfd6f1553..2f50d90c130921d3f373f41350bc6b59aadd2d7a 100644 --- a/modules/ui_patterns_layouts/ui_patterns_layouts.info.yml +++ b/modules/ui_patterns_layouts/ui_patterns_layouts.info.yml @@ -1,6 +1,6 @@ name: UI Patterns Layouts type: module -description: Use patterns as layout plugins. +description: Use patterns as layouts via the Layout Discovery module. core: 8.x package: User interface dependencies: diff --git a/modules/ui_patterns_layouts/ui_patterns_layouts.install b/modules/ui_patterns_layouts/ui_patterns_layouts.install new file mode 100644 index 0000000000000000000000000000000000000000..8e66bd86eec6a95ecc74ba4c0029779051165b63 --- /dev/null +++ b/modules/ui_patterns_layouts/ui_patterns_layouts.install @@ -0,0 +1,18 @@ +<?php + +/** + * @file + * Contains install file. + */ + +/** + * Uninstall layout_plugin and install layout_discovery. + */ +function ui_patterns_layouts_update_8001() { + /** @var \Drupal\Core\Extension\ModuleInstaller $installer */ + $installer = \Drupal::service('module_installer'); + $installer->uninstall(['layout_plugin']); + $installer->install(['layout_discovery']); +} + + diff --git a/modules/ui_patterns_layouts/ui_patterns_layouts.module b/modules/ui_patterns_layouts/ui_patterns_layouts.module index 27b4bdbd1c6e7ff06a418df6c2200118e6575d3a..c1f7d3c7ac455857725c217ceca1f112f79edc39 100644 --- a/modules/ui_patterns_layouts/ui_patterns_layouts.module +++ b/modules/ui_patterns_layouts/ui_patterns_layouts.module @@ -13,6 +13,7 @@ use Drupal\Core\Layout\LayoutDefinition; */ function ui_patterns_layouts_layout_alter(&$definitions) { // @todo: Use layout deriver instead. + // @link https://github.com/nuvoleweb/ui_patterns/issues/94 $pattern_definitions = \Drupal::service('plugin.manager.ui_patterns')->getDefinitions(); foreach ($pattern_definitions as $pattern_definition) { $definition = [ diff --git a/src/Plugin/Deriver/AbstractDeriver.php b/src/Plugin/Deriver/AbstractDeriver.php index c8af320029b8e6eef25e65a92b6bf7cab9e9a910..ff0dece07f09011cf3240600063f4c49ba35ba7a 100644 --- a/src/Plugin/Deriver/AbstractDeriver.php +++ b/src/Plugin/Deriver/AbstractDeriver.php @@ -12,7 +12,7 @@ use Symfony\Component\DependencyInjection\ContainerInterface; * * @package Drupal\ui_patterns\Deriver */ -abstract class AbstractDeriver extends DeriverBase implements DeriverInterface, ContainerDeriverInterface { +abstract class AbstractDeriver extends DeriverBase implements ContainerDeriverInterface { /** * Typed data manager service. diff --git a/tests/composer.json b/tests/composer.json index 488ececdaab4271c8a39321c11a1dd1cf524cab7..e83f88b1a785d4f6c226bf6644ad741f2c52790d 100644 --- a/tests/composer.json +++ b/tests/composer.json @@ -9,7 +9,6 @@ "drupal/core": "~8", "drupal/console": "0.11.3", "drush/drush": "~8.0", - "drupal/layout_plugin": "~1", "drupal/ds": "~3", "drupal/field_group": "~1", "drupal/coffee": "~1", diff --git a/ui_patterns.info.yml b/ui_patterns.info.yml index 813c0b7c7341a110783709487feae8cc9e0f9839..49e106b11d3950e4cff41cdd0c9b527f6b0fb256 100644 --- a/ui_patterns.info.yml +++ b/ui_patterns.info.yml @@ -3,3 +3,5 @@ type: module description: UI patterns core: 8.x package: User interface +dependencies: + - system (>=8.3.0)