Giter VIP home page Giter VIP logo

foxy-elements's Introduction

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.