code-connect icon indicating copy to clipboard operation
code-connect copied to clipboard

Support for Web Components

Open cscheffauer opened this issue 1 year ago • 21 comments

First of - thanks for the great work on this! It would be amazing to also support Web Components (Lit, Stencil) to connect.

cscheffauer avatar Apr 16 '24 17:04 cscheffauer

I work on a web component design system.

The way it's built, consumers initialize the entire library before bootstrapping their client side app, so all published custom elements are available everywhere (consumers don't explicitly import/initialize individual components/custom elements).

The output of the React API is very close to what I need. The biggest issue, right now is that I'd need to be able to customize and/or remove the import line above the markup snippet. Additionally, some of our Figma components are implemented via semantic HTML using published CSS classes (no custom elements or components, just CSS).

CITguy avatar Apr 16 '24 17:04 CITguy

Hey, thanks for your interest in Code Connect!

We’re planning to add support for more frameworks in the near future. We can’t say yet exactly which frameworks or when, but it’s helpful for us to hear from the community to help us decide where to focus, so please feel free to add a 👍 to this issue if you are also interested in support for web components. I will leave this issue open to track interest.

Code Connect is also designed to be extensible, and the community will be able to create their own plugins to support frameworks and languages which we don’t natively support. More details about how to build these plugins will be coming soon!

It's interesting what you say about the React support being very close to what you would need @CITguy. It sounds like if we had the ability to support plain HTML (i.e. not specify a React component in the figma.connect call) and the ability to manually specify import statements, this might work for you?

tomduncalf-figma avatar Apr 17 '24 10:04 tomduncalf-figma

+1 one that feature request! Also working on a design system built on web components using Stencil.js! Would be a highly appreciated addition!

timrombergjakobsson avatar Apr 18 '24 08:04 timrombergjakobsson

+1

lau-vt avatar Apr 18 '24 14:04 lau-vt

Hey @tomduncalf-figma!

Thanks for the response on this issue. Like others here, I'm very excited to one day use Code Connect with our Design System being built with Lit Web Components.

It sounds like if we had the ability to support plain HTML (i.e. not specify a React component in the figma.connect call) and the ability to manually specify import statements, this might work for you?

I would say that yeah, this is true! Being able to specify the import statement and then supporting HTML would cover most cases, I believe. Here's an example of a button component in Lit:

import '@namespace/some-design-system/button.js';

// And then usage:

<my-button variant="secondary" disabled>Button</my-button>

A more complex example may be Shoelace's Tree components:

import '@shoelace-style/shoelace/dist/components/tree-item/tree-item.js';
import '@shoelace-style/shoelace/dist/components/tree/tree.js';

<sl-tree>
  <sl-tree-item>
    Deciduous
    <sl-tree-item>Birch</sl-tree-item>
    <sl-tree-item>
      Maple
      <sl-tree-item>Field maple</sl-tree-item>
      <sl-tree-item>Red maple</sl-tree-item>
      <sl-tree-item>Sugar maple</sl-tree-item>
    </sl-tree-item>
    <sl-tree-item>Oak</sl-tree-item>
  </sl-tree-item>

  <sl-tree-item>
    Coniferous
    <sl-tree-item>Cedar</sl-tree-item>
    <sl-tree-item>Pine</sl-tree-item>
    <sl-tree-item>Spruce</sl-tree-item>
  </sl-tree-item>

  <sl-tree-item>
    Non-trees
    <sl-tree-item>Bamboo</sl-tree-item>
    <sl-tree-item>Cactus</sl-tree-item>
    <sl-tree-item>Fern</sl-tree-item>
  </sl-tree-item>
</sl-tree>

There are some concepts that are Lit-specific like property expressions but for most Design Systems, I think supporting string and boolean attributes (HTML!) would be a great start.

ynotdraw avatar Apr 18 '24 14:04 ynotdraw

+1 to this I use StencilJS alongside a Storybook instance. The Storybook instance is set up to use Web Components which uses lit. Either using the StencilJS files or the Storybook stories would be great. Thank you!

jaasum-msft avatar Apr 19 '24 21:04 jaasum-msft

+1 from the Carbon Design System team, we are currently exploring this in React, but also support Web Components.

alisonjoseph avatar May 01 '24 14:05 alisonjoseph

+1 From the Microsoft Fluent Design System

codysorgenfrey avatar Jun 26 '24 16:06 codysorgenfrey

It's interesting what you say about the React support being very close to what you would need @CITguy. It sounds like if we had the ability to support plain HTML (i.e. not specify a React component in the figma.connect call) and the ability to manually specify import statements, this might work for you?

basically... yes 😄

Our library is designed to be consumed whole via precompiled assets, so import functionality isn't necessary nor possible in some cases, for us. Consumers load JS and CSS that defines behavior and appearance, and then just writes HTML.

For example...

<!--
  The following custom elements are defined and registered globally with the 
  custom element registry, so there's no means or need to "import".
  
  - CSS specific to geometry and theming may either be embedded in the 
    ShadowDOM of each element or it could exist in pre-compiled stylesheets.
-->
<ui-button variant="outline">Hello, world!</ui-button>
<ui-icon name="heart"></ui-icon>


<!--
  The following elements get styles applied by globally-available CSS class names. 
  Again, there's no means/need to "import" specific styles.
-->
<h3 class="ui-heading-lg">Large Heading</h3>
<table class="ui-table has-striping">
  <!-- ... -->
</table>

CITguy avatar Jun 26 '24 16:06 CITguy

+1 from Meteomatics team 👋 Also for Storybook & Stencil setup.

Thank you, folks!

PiotrChr avatar Jun 26 '24 17:06 PiotrChr

+1 from the Maersk Design System team too

steveworkman avatar Jun 26 '24 20:06 steveworkman

+1 from Mastercard's Design System team!

olearyb avatar Jun 27 '24 12:06 olearyb

Any news on that? @tomduncalf-figma +1 from ABB Process Automation

kr-tyrcha-abb avatar Jun 27 '24 13:06 kr-tyrcha-abb

Sounds like this should have been first, total no-brainer.

custa1200 avatar Jun 30 '24 07:06 custa1200

  • 1 for the British Airways Design System 🛫

billyhar avatar Jul 04 '24 11:07 billyhar

+1 from the Breuninger's Design System team

Gioni06 avatar Jul 24 '24 08:07 Gioni06

+1 from Migros Multibrand Design System Team

phil-out avatar Jul 31 '24 06:07 phil-out

Mui Would be amazing :)

domshyra avatar Aug 01 '24 21:08 domshyra

+1 from the Grit Design System's team from Progressive Leasing. We exclusively use StencilJS.

MrGrigri avatar Aug 17 '24 00:08 MrGrigri

+1 from Zywave's Booster Design System. We exclusively use Lit!

juliexiong avatar Sep 06 '24 18:09 juliexiong

We are happy to announce that we’ve released Code Connect v1.1.1, which includes a preview of support for HTML-based frameworks (including Web Components, Angular and Vue).

We’d love to get your feedback on this, so please take a look at the docs and try it out, and please reach out to us with any questions or feedback.

Please note that while HTML support is in preview, we reserve the right to make changes to the API, although we hope to not have to make any major changes.

tomduncalf-figma avatar Sep 10 '24 13:09 tomduncalf-figma