Open ademarco opened 7 years ago
As first users of the UI Patterns module your input would be of great help! π \cc @drupol @pixelwhip @hctom @aleksip @haringsrob @bircher @kclarkson @capriosa @hctom @tanc
@ademarco This looks absolutely fantastic! ;)
Here are some of my thoughts/questions regarding your topics:
pattern-carousel--large.html.twig
or how will those be realized?type: pattern:whatever
or type: string
is single value field and type: pattern:whatever[]
or type: string[]
is a multivalue field.And last but not least, here is a little addon for your list: I would really appreciate something to be able to group components on the preview page. Right now every pattern is just listed and rendered, but with large component libraries this might run into problems really fast (e.g. rendering tons of components on a single page and some of them might even use a lot of JavaScript which might even crash the browser). What do you think about having something that allows setting a "path" of a specific component in a tree structure that is used to render a component menu (e.g. KSS uses something similar with its Styleguide
syntax feature)?
... but all in all, this module is really heading the right way! Thanx a lot for that!
Your ideas sounds really cool. Especially the type:pattern will be very useful. Btw. do you know that UI-Patterns works very well in conjunction with the Stacks module? And with the new features from above this will even get better.
+1 for @hctom suggestion for grouping patterns on the overview page. This is desperately needed for organization!
Also agree that this feature list looks very promising. A few comments:
Excited to see where this goes and looking forward to following along.
Now pattern definitions are actual TypedData objects, this will allow us to introduce things like variants or tags in a much easier and maintainable way. Check PR #79 for more details.
To all those involved in this discussion you might be interested in this issue: Allow multiple sources to be mapped to the same destination #81
I'm planning to work on this issue before our talk on UI Patterns on DDD in Seville
As first we could maybe tackle tags and a better overview page, I'm actually thinking to move out the overview page on its own module, say ui_patterns_overview
so that we can isolate complex logic there.
It would be also good to have a pattern definition property dedicated to the overview, for example:
button:
...
overview:
parent: Buttons
weight: 10
Or maybe we reverse it and we have a YAML file describing the overview page? Such YAML plugin could be exposed by the ui_patterns_overview
module, so that we don't clutter the pattern definitions?
@hctom which one would you prefer?
Hm, thats quite tough to decide. On the one hand, a dedicated file is of course good to keep the actual pattern definition short and simple, but on the other hand, the pattern definition itself already contains information that is used in the overview (e.g. label
and description
).
For now, I think it should all reside in the same file, so you don't have to search different files for metadata information used in the overview or other places that display pattern information (e.g. select lists when assigning patterns).
At DDD17 we discussed a litte further. This is what we came up with:
ui_patterns
and it default Styleguide, that can be used for writing test and demo purpose.*.ui_pattern.yml
) with minimal setup, like
[file_name _base].ui_pattern.yml
)label
(for the select inside of Drupal, translation via interface translation)tags
(eg. hidden, view_row, node, taxonomy) to filter dropdownlibraries
define related assets as current implementationfields
consisting of a list of machine names with label
and optionally a type
(still unsure about the actual usage)use
, preview
, description
, variants
variants
from base definition in contrast to drupal view_modes
. They are not the same. A "variant" (fractal) or "pseudo-pattern" (patternlab.io) are just a set of special information to the very same fields of one single template. Whereas a drupal view_mode maybe handles different fields.List of possible styleguides ;-) github.com/davidhund/styleguide-generators
My proposed structure would be the following:
[pattern_description].pattern.yml
-file (aka pattern description) for every pattern to be discovered.[pattern_description].html.twig
) will be automatically discovered in the very same folder as the pattern description file..html.twig
-extension of the target file needs to be a config. for other style guides as patternlab, may use only the .twig
-extension. E.g. defined/overwritten in the my_theme.info.yml
since the components
settings (from the component library module) are situated there as well.1.1. A [pattern_description].pattern.yml
-file contains only one describable pattern target. Meaning all assets described in the pattern description belong to the very same library. Thus there can only be one library per pattern (ui_patterns/[pattern_description]
). Unique pattern_description
-names are implied.
1.2. A [pattern_description].pattern.yml
-file may target multiple files and libraries. For this scenario I can not really make up a good usage for naming things. E.g. referencing a library with ui_patterns/[pattern_description]--[custom_name]
.
Discussion:
I think version 1. is somehow limiting but it can bring the most clarity. So instead of searching in a file for exact patterns and creating somewhat obscure library names, we stick to basic principles:
βββ components
β βββ shiny-buttons
β β βββ buttons.css
β β βββ button-default.html.twig
β β βββ button-default.pattern.yml
β β βββ button-primary.html.twig
β β βββ button-primary.pattern.yml
β βββ contact
β βββ contact-base.css // may also be a compiled file
β βββ contact-base.scss
β βββ contact-actions.js
β βββ contact.config.js // belongs to style guide
β βββ contact.html.twig
β βββ contact.pattern.yml
β βββ contact-preview
β βββ contact-preview.html.twig
β βββ contact-preview.pattern.yml
button-default.pattern.yml
label: Button Default
fields:
url: Url
title: Link title
library:
css:
# The SMACSS category (base, layout, component, state or theme)
base:
# The path relative to the css file.
buttons.css: {}
contact.pattern.yml
label: Contact information
fields:
title: Contact title
emails: Emails
phones: Telephones
# ...
library:
css:
base:
'//fonts.googleapis.com/css?family=Lato': { external: true }
component:
contact-base.css: {}
js:
contact-actions.js: {}
dependencies:
- ui_patterns/button-default
- core/jquery
contact-preview.pattern.yml
label: Contact information preview
fields:
title: Contact title
emails: Emails
phones: Telephones
# ...
library:
dependencies:
- ui_patterns/contact
How to the style guides will reference their templates is nothing we can influence. E.g. whether ID like include (Fractal: @box
for a files situated under components/boxes/box/box.twig
) or fully qualified (@components/boxes/box/box.twig
). This may not be our problem, because other contrib modules, like components
, can take care of that.
Our problem is rather, what if the contact
-pattern references the button
-pattern with an {% include %}
statement? how does the button library get loaded if not directly addressed by our pattern description file? This may be a easy case, but I can think of a article having multiple optional includes...
Thank you @pheadeaux ! I'll follow up tomorrow, for the moment https://github.com/nuvoleweb/ui_patterns/pull/84 will add support for any sort of file extension in the use:
property, so we can just have:
image:
label: Image
use: '@molecules/media/image/image.twig'
fields:
image: Image
caption: Caption
credit: Credit
Hi all, Just passing by this thread, few thoughts:
I'm totally for [ID].pattern.yml
, although we have been using [ID].ui_patterns.yml
for now, but I guess we can support both and slowly fade out [ID].ui_patterns.yml
.
Target file can be automatically discovered too, only I'm wondering what would happen with -
separators as patterns IDs should not support that, maybe we can convert -
into _
or allow it and see how the Drupal theme system reacts to that. For sure we cannot allow double-dash --
as it has a specific meaning for Drupal (i.e. theme suggestion components are separated by a double-dash).
Maybe the best would be to allow a redefinition of pattern ID in the YAML file, for example:
βββ components
β βββ shiny-buttons
β β βββ buttons.css
β β βββ button.twig
β β βββ button.pattern.yml
β β βββ button-primary.twig
β β βββ button-primary.pattern.yml
then:
# button-primary.pattern.yml
id: button_primary
use: button-primary.twig
fields:
label: Label
url: URL
While for button
it could simply be:
# button.pattern.yml
fields:
label: Label
url: URL
Pattern names are required to be globally unique too, so I guess allowing developers to re-define IDs is useful or even required.
Libraries already receive the following custom notation:
ui_patterns/[ID].[LOCAL_LIBRARY_NAME]
So if we have (note that the following is the correct way of defining local libraries):
image:
label: Image
fields:
...
libraries:
- library_name:
css: ...
js: ...
- another_library:
css: ...
js: ...
Then UI Patterns module will expose its libraries as follow:
- ui_patterns/image.library_name
- ui_patterns/image.another_library
Also with new PR #84 this is now possible already:
use: '@molecules/media/image/image.twig'
@ademarco I agree. also the way of referencing the libraries works for me.
About the use
-key: please be very cautious about that one, since we might introduce an alias system, that can be hard to grasp:
in Drupal we might use @molecules/media/image/image.html.twig
but inside the (whatever) styleguide the include may also go for the .twig
version. I mean, we should enforce the parity of the reference methods - otherwise reusing patterns might not work correctly.
These are all great improvements, but as development has slowed down in the past few months, I'd vote for releasing 1.0 as soon as possible. beta7 is already good enough for a lot of use cases (I've used it on several production websites), and a 1.0 release would be much more attractive for people considering the module.
Ditto to the 1.0 release.
I am also planning on using this module for a production website and have some development cycles to share. Do you have a development plan outside of this issue or a contributing document?
A first effort at the variant functionality can be found here: https://github.com/nuvoleweb/ui_patterns/pull/105
The following is a list of improvements we wish to include in the first stable release. We would like to hear your thoughts about it.
type:
property. Subfields can be patterns themselves so that mappers will be also enabled to map views or entity fields when suing patterns with views, layouts, etc.All issues above can be summarized in the following example of a carousel definition, we can use this to drive our discussion: