Skip to content

Elements and resources for use in other front-end code, like the admin and customer portal.

License

Notifications You must be signed in to change notification settings

Foxy/foxy-elements

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Foxy Elements 🦊🏗

Collection of web components powering the new front-end functionality at Foxy with built-in i18n and theming. Works with React, Vue, Svelte and more – or just on its own. Built with LitElement, Tailwind and Vaadin.

You can view all the components in various states, with plenty of examples, at elements.foxy.dev.

Getting started

If you're targeting browsers that support ES6, you can use modules to get started with no additional setup:

<!-- 1. Load polyfills (optional); -->
<script src="https://unpkg.com/@webcomponents/webcomponentsjs@^2/webcomponents-bundle.js"></script>

<!-- 2. Load element (replace "foxy-donation" with the one you need or add more script tags); -->
<script
  type="module"
  src="https://unpkg.com/@foxy.io/elements@1/dist/cdn/foxy-donation.js"
></script>

<!-- 3. Use the element anywhere on your page. -->
<foxy-donation></foxy-donation>

When using a bundler, you have an option of registering elements with a custom name whenever it works for you in your use case. All public elements are available as named exports (PascalCase, no "Foxy" prefix).

import { Donation } from '@foxy.io/elements';
customElements.define('my-donation', Donation);

This also works great with the ScopedElementsMixin by open-wc.org:

import { ScopedElementsMixin } from '@open-wc/scoped-elements';
import { Donation } from '@foxy.io/elements';

class MyElement extends ScopedElementsMixin(LitElement) {
  static get scopedElements() {
    return {
      'my-donation': Donation,
    };
  }
}

Please keep in mind that with this approach you'll also need to take care of loading polyfills and applying necessary optimizations before deploying to production.

If you use es-dev-server, you might run into a few issues depending on the components you import – those are most likely caused by how xstate is processed by the server. We've made a number of plugins (one, two, three) to battle that. They're a bit hacky and may not work in every scenario, so we are not going to publish them on npm, but you can still use them as a starting point to bring your setup back in action.

Development

To run this project locally, you'll need Node.JS installed on your machine. If you don't have it already, we suggest getting the latest LTS release from nodejs.org. Additionally, you can update npm (comes with Node.JS) to the latest version by running the following command in your Terminal:

npm install npm@latest -g

Once that's done, clone or download this repository, switch to the folder you placed it in and install the dependencies with npm:

npm install

There's a number of useful scripts that you might need:

  • npm run storybook runs Storybook;
  • npm run format fixes style errors in your code;
  • npm run lint shows style errors in your code;
  • npm run test runs all test suites with Karma;
  • npm run test:watch -- --group foxy-attribute-card runs tests in watch mode for a specific element;
  • npm run wca generates docs for element slots and attributes;
  • npm run generate-schemas generates JSONSchemas for element translations based on English i18n files;
  • npm run generate-groups generates test groups for elements;

Note: depending on the hardware, some tests may start failing with a timeout error when running the entire test suite with npm run test. If that happens on your machine, try running tests for individual elements instead with npm run test -- --group element-name.

About

Elements and resources for use in other front-end code, like the admin and customer portal.

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

No packages published

Languages