Skip to content
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

Add a Sample Engine with Schema Support to Pattern Lab #1005

Open
cybtachyon opened this issue Apr 11, 2019 · 27 comments
Open

Add a Sample Engine with Schema Support to Pattern Lab #1005

cybtachyon opened this issue Apr 11, 2019 · 27 comments

Comments

@cybtachyon
Copy link

As requested, moving from pattern-lab/patternlab-php-core#117

Summary:

  • Upgrade the data display engine to a full sample engine with schema support
  • Upgrade existing Pattern Lab "Pattern Info" display to support an editor
  • Add an interactive schema editor to PatternLab UI, matching existing standards

Benefits:

  • Developers can quickly run through multiple iterations in the GUI when tweaking styles
  • Stakeholders can preview exact text in the GUI without updating files
  • Stakeholders can share that preview with a simple generated link

To Do:

  • Validate use case with community
  • Add patch porting over PatternKit's schema editor UI & functionality
  • Review & Test

Demo of this functionality in action: http://patternkit.info/schema/keynote_quote

PatternLab already has an existing set of functionality dedicated to providing sample data via pre-configured JSON or YAML. However, it does not support easy on the fly composition and editing.
We have found that the ability to edit sample data in a GUI on the fly not only aids in pattern development, but also leads to easier demoing with stakeholders.

We propose adding support for JSON/YAML schema files that allow a GUI to provide an edit interface for populating patterns. We already have this GUI working with PatternKit and are looking at porting it over.

This issue is a part of a series to fold functionality present in the nearly identical tool PatternKit in an effort to coalesce the development communities and deprecate PatternKit in favor of PatternLab. We plan on moving forwards with development starting August 21st.

Related Reading:

@micahgodbolt was the original architect

Noting that if accepted we would also need a PR to https://github.com/pattern-lab/the-spec/ to update the spec.

@waynetheisinger
Copy link

This would be very cool

@sghoweri
Copy link
Contributor

We've also done some prior work in this direction in the Bolt Design System (albeit, we're still using Pattern PHP till we migrate over) but same overall idea with component schemas + multiple ways to consume and take advantage of that schema data: https://boltdesignsystem.com/pattern-lab/?p=viewall-components-button

@sghoweri
Copy link
Contributor

@cybtachyon is there a more up to date URL of this working in Pattern Kit? The link in the original ticket's description is broken 🙁

@micahgodbolt
Copy link

Im sorry. That was my patternkit url from many years ago. I have since cancelled that domain and hosting

@cybtachyon
Copy link
Author

I'll attempt to see if we can publish our internal Pattern Kit URL - it may have sample data that's more internal-oriented and not anonymized enough.

Worst case I'll spin up a new instance with a sample set of patterns - or even better get a PR up ;)

@stale
Copy link

stale bot commented Jun 13, 2019

It's hard to keep track of everything. This issue has been automatically marked as stale because it has not had recent activity, neither from the team nor the community. It will be closed if no further activity occurs. Please consider adding additional info, volunteering to contribute a fix for this issue, or making a further case that this is important to you, the team, and the project as a whole. Thanks!

@cybtachyon
Copy link
Author

Shhh stale bot. This is actively being worked on at Red Hat.

@cybtachyon
Copy link
Author

This is the library we are improving and working on integrating: https://github.com/json-editor/json-editor

@stale
Copy link

stale bot commented Oct 4, 2019

It's hard to keep track of everything. This issue has been automatically marked as stale because it has not had recent activity, neither from the team nor the community. It will be closed if no further activity occurs. Please consider adding additional info, volunteering to contribute a fix for this issue, or making a further case that this is important to you, the team, and the project as a whole. Thanks!

@mfranzke
Copy link
Contributor

mfranzke commented Oct 4, 2019

fight the bot !

@stale
Copy link

stale bot commented Dec 3, 2019

It's hard to keep track of everything. This issue has been automatically marked as stale because it has not had recent activity, neither from the team nor the community. It will be closed if no further activity occurs. Please consider adding additional info, volunteering to contribute a fix for this issue, or making a further case that this is important to you, the team, and the project as a whole. Thanks!

@sghoweri
Copy link
Contributor

sghoweri commented Dec 3, 2019

Bump!

@cybtachyon
Copy link
Author

Appreciate the bump. We have a team with this as a task, however there's a ton on our plate so this has not been slotted for release yet.

@stale
Copy link

stale bot commented Mar 5, 2020

It's hard to keep track of everything. This issue has been automatically marked as stale because it has not had recent activity, neither from the team nor the community. It will be closed if no further activity occurs. Please consider adding additional info, volunteering to contribute a fix for this issue, or making a further case that this is important to you, the team, and the project as a whole. Thanks!

@mfranzke
Copy link
Contributor

mfranzke commented Mar 5, 2020

Bump

@mfranzke
Copy link
Contributor

@cybtachyon, that‘s probably one of the coolest new features for the product. Do you even already have an ETA for that? Do you need any support?

@cybtachyon
Copy link
Author

cybtachyon commented Apr 7, 2020

I agree! Thanks so mcuh.

I have no ETA right now as the pandemic situation has drastically reset our team's priorities.

I may return to pattern ecosystem development this week but it's up in the air right now.

Here's the library we're using: https://github.com/json-editor/json-editor

@mfranzke
Copy link
Contributor

mfranzke commented May 26, 2020

I’d like to open another discussion on this topic.

Managing the schema of a pattern would be at least relevant for three reasons / use cases:

  • Providing a visual sample engine to the PL users
  • Resulting in a rendered table as a pattern specification (like e.g. the one by Bolt Design System)
  • Enabling IDEs to understand the patterns structure e.g. for autocompletion, syntax highlighting, linting etc. (compare to e.g. VS Code "HTML and CSS custom data support")

These aspects are quite nicely comparable with Custom Elements, that could as well be seen as a successor (at least equivalent) to what we’re doing regarding custom pattern development in general.

So I thought about having a looking into that field and the existing technical solutions that are being build around those challenges.

Two of the more prominent tools seem to be, that work quite nicely in combination:

  • web-component-analyzer / CLI that analyzes web components (mainly out of the JS code and JSDocs) and emits documentation (JSON or Markdown or VSCode format)
  • api-viewer-element / API documentation and live playground for Web Components (actually what we’re referring to as sample engine)

Thinking out loudly, what about using api-viewer-element for displaying the sample engine? We would need to use the web-component-analyzer JSON format to achieve that, which could be either handwritten, or even generated in case of that users might be using Web Components anyhow (or at least JSDocs) and that for probably use web-component-analyzer to handle the transformation to this JSON file (and .md and VSCode).
In case of the latter we would even also be able to retrieve the pattern documentation table with all of the attributes etc.

In other words, I do like the solution that json-editor could provide, but I'm thinking about whether it "only" enables the UI for a sample engine regarding the schema files, or does it (or some other even already implemented solution, like in Bolt Design System) even also achieve the second and third goals (pattern specification and IDE schema files)? Or would it make sense to have a second look at other options like the ones I’ve provided?

@cybtachyon
Copy link
Author

cybtachyon commented May 31, 2020

I love the direction you're taking with this.

The issue I have with...

We would need to use the web-component-analyzer JSON format to achieve that

...is that JSON Schema is already a well-documented and popular format for providing schemas. Instead, I would take the tact of adding JSON Schema support for web-component-analyzer.

JSON Schema was our choice for a couple reasons:

  • Based on survey results, it's the most popular choice for defining portable schemas is JSON Schema ( https://json-schema.org/ ) - Draft 07 being the most popular version
  • The competing most popular choice, Google's Protocol Buffers, is very cool but not as widely used and requires a compiled library to work with them in vanilla JS ( https://github.com/protobufjs/protobuf.js )
  • The most popular editor for JSON Schema, as you mentioned, json-editor, has a very strong implementation with a plethora of features ( https://github.com/json-editor/json-editor )
  • I've written test code that generates JSON Schema from well-commented Twig, React, and Web Components. You do need to be a little verbose with those comments to take full advantage of all the schema offers though, so most libraries just include a .json schema file with basic variables in their pattern generator and let the author write the rest.

That said, I'm not against making the whole pattern schema and editor system pluggable so that multiple systems could be supported and used - in fact, that's how I'd prefer to implement it, with the default being JSON Schema and other standards as easy drop-ins.

Web technologies don't last forever, and who knows, tomorrow JSON Schema could be dropped by everyone for Protocol Buffers or some sort of standard based on rich metadata for XML attributes like you've linked above.

@mfranzke
Copy link
Contributor

mfranzke commented Jun 1, 2020

@cybtachyon, sounds great! I‘ve even also just found a lot of other scripts that could help on the jsonschema2md transformation, which is an additional plus: https://duckduckgo.com/?q=%22JSON+Schema%22+to+markdown&t=iphone&ia=web

@stale
Copy link

stale bot commented Aug 1, 2020

It's hard to keep track of everything. This issue has been automatically marked as stale because it has not had recent activity, neither from the team nor the community. It will be closed if no further activity occurs. Please consider adding additional info, volunteering to contribute a fix for this issue, or making a further case that this is important to you, the team, and the project as a whole. Thanks!

@mfranzke
Copy link
Contributor

mfranzke commented Aug 17, 2020

@cybtachyon, this is probably one of the hottest awaited features, that is additionally one of the only remaining features that Storybook is even already delivering at.
How could we support you regarding the implementations ?

@cybtachyon
Copy link
Author

@mfranzke you offering to pay for it? ;)

The PatternLab / Knapsack Schema Editor is low priority vs the roadmap listed on https://drupal.org/project/patternkit at this time.

That could shift as more sites and themes begin shipping JSON schema for their patterns, for example Microsoft's https://explore.fast.design which includes JSON schema for all of their components.

@mfranzke
Copy link
Contributor

@mfranzke you offering to pay for it? ;)

The PatternLab / Knapsack Schema Editor is low priority vs the roadmap listed on https://drupal.org/project/patternkit at this time.

That could shift as more sites and themes begin shipping JSON schema for their patterns, for example Microsoft's https://explore.fast.design which includes JSON schema for all of their components.

@cybtachyon ;-)
mainly brain and time, as always with open source ...

But thanks a lot for the outlook, especially regarding the acceptance and wider spread usage of JSON schema; great news regarding Microsoft especially ! Didn't notice that aspect so far.

@cybtachyon
Copy link
Author

Hahah, for sure!

Where we plan to start is by adding a pane that loads https://github.com/json-editor/json-editor into the DOM per-pattern. Basically, writing wrapping JS that instantiates an instance for each Pattern Lab pattern on the page, and then making sure config options are exposed to patternlabrc.js - from there it's making sure the schema is loaded and preset properly from any provided YML or MD sample data and that changes reflect in the component.

@stale
Copy link

stale bot commented Dec 19, 2020

It's hard to keep track of everything. This issue has been automatically marked as stale because it has not had recent activity, neither from the team nor the community. It will be closed if no further activity occurs. Please consider adding additional info, volunteering to contribute a fix for this issue, or making a further case that this is important to you, the team, and the project as a whole. Thanks!

@stale
Copy link

stale bot commented Jan 9, 2022

It's hard to keep track of everything. This issue has been automatically marked as stale because it has not had recent activity, neither from the team nor the community. It will be closed if no further activity occurs. Please consider adding additional info, volunteering to contribute a fix for this issue, or making a further case that this is important to you, the team, and the project as a whole. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants