0.9.1-rc.2 • Published 1 day ago

@photonhealth/elements v0.9.1-rc.2

Weekly downloads
-
License
ISC
Repository
-
Last release
1 day ago

Photon Web Components

Photon's collection of customizable and reusable components to help clients integrate seamlessly with our system.

Creating a WebComponent in SolidJS

We utilize SolidJS ability (solid-element) to author a normal SolidJS component and transpile it to the WebComponent API (ref: https://developer.mozilla.org/en-US/docs/Web/Web_Components).

A SolidJS WebComponent, at it’s most basic, looks like the following contained in an index.tsx:

//Shoelace
import { customElement } from 'solid-element';

//Styles
import tailwind from '../tailwind.css?inline';
import styles from './style.css?inline'; //Inline is required to encapsulate the styles below

customElement(
  'photon-my-first-component', // WebComponent Tag Name
  {
    disabled: false,
    loading: false,
    full: false
  }, // Default Props
  (props: { disabled: boolean; loading: boolean; full: boolean }, options) => {
    return (
      <>
        <style>{tailwind}</style>
        <style>{styles}</style>
        <div>
          <p class="text-blue-500">My first component</p>
        </div>
      </>
    );
  }
);

The API centers around calling the customElement function:

  • First Parameter is the WebComponent Tag Name. This is the name under which your component will be registered and usable from HTML. In this example, photon-my-first-component
  • Second Parameter is the default values of properties. If you have properties a user isn’t supposed to specify, you can declare the defaults here. Any properties that are not kebab case (e.g first-word) are transformed to kebab-case when passed from HTML/JSX (per WebComponent Spec Guidelines)
  • Third Parameter is a function of (props, options) ⇒ JSX.Element. NOTE: Do not de-structure props as in SolidJS this will make your properties (which are a Proxy object) lose reactivity. The second parameter, options contains a singular property element which gives you raw access to your DOM element created by this web-component. This is considered advanced functionality and rarely used (though I use it in our codebase and have examples of when it’s appropriate).
0.9.1-rc.1

3 days ago

0.9.1-rc.2

1 day ago

0.9.1

15 days ago

0.8.9

17 days ago

0.9.0

17 days ago

0.8.8

18 days ago

0.8.6

1 month ago

0.8.5

1 month ago

0.8.4

2 months ago

0.8.3

2 months ago

0.8.2

2 months ago

0.8.1

2 months ago

0.8.0

2 months ago

0.7.3-rc1

2 months ago

0.7.2

2 months ago

0.7.1

3 months ago

0.7.0-rc1

4 months ago

0.7.0-rc2

4 months ago

0.7.0-rc3

4 months ago

0.6.0

4 months ago

0.5.0

4 months ago

0.5.2

4 months ago

0.5.1

4 months ago

0.4.0

4 months ago

0.3.0

5 months ago

0.2.16

5 months ago

0.2.15

5 months ago

0.2.14

6 months ago

0.2.13

6 months ago

0.2.12

7 months ago

0.2.11

7 months ago

0.2.10

7 months ago

0.2.1

10 months ago

0.2.0

10 months ago

0.2.7

8 months ago

0.2.6

9 months ago

0.2.9

8 months ago

0.2.8

8 months ago

0.2.3

10 months ago

0.2.2

10 months ago

0.2.5

9 months ago

0.2.4

9 months ago

0.0.104

1 year ago

0.0.103

1 year ago

0.0.102

1 year ago

0.1.0

12 months ago

0.1.2

11 months ago

0.1.1

11 months ago

0.0.95

1 year ago

0.0.96

1 year ago

0.0.97

1 year ago

0.0.98

1 year ago

0.0.87

1 year ago

0.0.99

1 year ago

0.0.88

1 year ago

0.0.89

1 year ago

0.0.90

1 year ago

0.0.91

1 year ago

0.0.101

1 year ago

0.0.92

1 year ago

0.0.100

1 year ago

0.0.93

1 year ago

0.0.94

1 year ago

0.0.86

1 year ago

0.0.85

1 year ago

0.0.84

1 year ago

0.0.83

1 year ago

0.0.82

1 year ago

0.0.81

1 year ago

0.0.80

1 year ago