Giter Club home page Giter Club logo

bulmil's Introduction

bulmil

Built with Stencil Code Style npm version License MIT
dependencies Circle CI npm downloads Package Phobia Bundle Phobia

Bulmil is an agnostic UI library based on Web Components, made with Bulma.io & Stencil.js.

Bulmil was created as a proof of concept to introduce an easy way to consume common reusable web components for use with various modern application frameworks (Angular, Vue, React, Ember) or simply with pure Javascript.

โš ๏ธ Currently in Alpha, beta will be available once this issue is resolved.

Why Stencil?

Stencil is a compiler for building fast web apps using Web Components.

Stencil combines the best concepts of the most popular frontend frameworks into a compile-time rather than run-time tool. Stencil takes TypeScript, JSX, a tiny virtual DOM layer, efficient one-way data binding, an asynchronous rendering pipeline (similar to React Fiber), and lazy-loading out of the box, and generates 100% standards-based Web Components that run in any browser supporting the Custom Elements v1 spec.

Stencil components are just Web Components, so they work in any major framework or with no framework at all.

Getting Started

# Using npm
npm i @bulmil/core

# Using yarn
yarn add @bulmil/core

Usage

Without a javascript framework

Integrating a component built with Stencil to a project without a JavaScript framework is straight forward. If you're using a simple HTML page, you can add your component via a script tag. For example, if we published a component to npm, we could load the component through a CDN like this:

<!DOCTYPE html>
<html lang="en">
  <head>
    <link rel="stylesheet" href="https://unpkg.com/@bulmil/core@latest/dist/css/bulmil.min.css" />
    <script src="https://unpkg.com/@bulmil/core@latest/dist/bulmil/bulmil.js"></script>
  </head>
  <body>
    <bm-button>Button</bm-button>
  </body>
</html>

Alternatively, if you wanted to take advantage of ES Modules, you could include the components using an import statement. Note that in this scenario applyPolyfills is needed if you are targeting Edge or IE11.

<!DOCTYPE html>
<html lang="en">
  <head>
    <link rel="stylesheet" href="https://unpkg.com/@bulmil/core@latest/dist/css/bulmil.min.css" />
    <script type="module">
      import {
        applyPolyfills,
        defineCustomElements,
      } from 'https://unpkg.com/@bulmil/core@latest/dist/loader/index.es2017.js';
      applyPolyfills().then(() => {
        defineCustomElements(window);
      });
    </script>
  </head>
  <body>
    <bm-button>Button</bm-button>
  </body>
</html>

Try this example on Codesandbox


Frameworks

Unfortunately the experience of integrating web components into existing applications can be tricky at times. More about this can be read at https://custom-elements-everywhere.com/. In order to accommodate the various issues the Stencil team has created new output target plugins to make the process simpler.

The plugins add additional output targets for each framework binding that is included. This output target will emit a native angular/react/vue library, just like if your components were originally written using any of these frameworks.

There are framework specific bindings for:

Keep in mind, that at its core Bulmil is still simply web components. Even if your framework is not mentioned in the list above, it most likely still supports Bulmil natively. You can check here if your framework has complete support for web components.

There are also examples for loading and using Bulmil with:


React

Unfortunately React has poor web components support ... but we have you covered with our @bulmil/react package, which wraps all the Bulmil web components inside React components so it feels natural to interact with, and it removes all the limitations of working with web components inside React.

Let's first load the CSS for the application, the css file includes:

  • Bulma base
  • Bulma helpers
  • Other components & elements not fitting in any components or not implemented yet.

Add the following to the root of your application:

// Global CSS (includes base & helpers). ~50KB
// We recommend to use purgecss to remove the unused css styles from your application.
import '@bulmil/core/dist/css/bulmil.min.css';

Now let's install the @bulmil/react package by running the following in your terminal:

# Using npm
npm i @bulmil/react

# Using yarn
yarn add @bulmil/react

And ... we're all done ๐ŸŽ‰

Vue

You have two options with Vue due to it having perfect web components support. You can either follow the instructions here for loading the web components in their natural form, or you can use the Vue bindings from the @bulmil/vue package, which wraps all the web components inside Vue components so you can feel right at home. Some other advantages for using @bulmil/vue include typed + documented components, and additional helpers for extending Bulmil with custom components.

Let's first load the CSS for the application, the css file includes:

  • Bulma base
  • Bulma helpers
  • Other components & elements not fitting in any components or not implemented yet.

Add the following to the root of your application:

// Global CSS (includes base & helpers). ~50KB
// We recommend to use purgecss to remove the unused css styles from your application.
import '@bulmil/core/dist/css/bulmil.min.css';

Now let's install the @bulmil/vue package by running the following in your terminal:

# Using npm
npm i @bulmil/vue

# Using yarn
yarn add @bulmil/vue

And ... we're all done ๐ŸŽ‰

Using Nuxt

Create a plugin, (e.g plugins/bulmil.ts):

import Vue from 'vue';

import { applyPolyfills, defineCustomElements } from '@bulmil/core/dist/loader';

Vue.config.productionTip = false;
Vue.config.ignoredElements = [/bm-\w*/];

// Bind the custom elements to the window object
applyPolyfills().then(() => {
  defineCustomElements(window);
});
// nuxt.config.ts
{
  plugins: [
    { src: '~/plugins/bulmil.ts', mode: 'client' },
  ],
}

The components should then be available in any of the Vue components

render() {
  return (
    <div>
      <bm-button>Button</bm-button>
    </div>
  )
}

Angular

You have two options with Angular due to it having perfect web components support. You can either follow the instructions here for loading the web components in their natural form, or you can use the Angular bindings from the @bulmil/angular package, which wraps all the web components inside Angular components so you can feel right at home. Some other advantages for using @bulmil/angular include typed + documented components, and additional helpers for extending Bulmil with custom components.

Let's first load the CSS for the application, the css file includes:

  • Bulma base
  • Bulma helpers
  • Other components & elements not fitting in any components or not implemented yet.

Add the following to the root of your application styles:

// Global CSS (includes base & helpers). ~50KB
// We recommend to use purgecss to remove the unused css styles from your application.
import '@bulmil/core/dist/css/bulmil.min.css';

Now let's install the @bulmil/angular package by running the following in your terminal:

# Using npm
npm i @bulmil/angular

# Using yarn
yarn add @bulmil/angular

And ... we're all done ๐ŸŽ‰

Svelte

You have two options with Svelte due to it having perfect web components support. You can either follow the instructions for loading it from the CDN and use the Bulmil web components in their natural form, or you can use the Svelte bindings from the @bulmil/svelte package, which wraps all the web components inside Svelte components so you can feel right at home. Some other advantages for using @bulmil/svelte include typed + documented components, and additional helpers for extending Bulmil with custom components.

Let's first load the CSS for the application, the css file includes:

  • Bulma base
  • Bulma helpers
  • Other components & elements not fitting in any components or not implemented yet.

Add the following to the <head> element of your HTML file:

// Global CSS (includes base & helpers). ~50KB
// We recommend to use purgecss to remove the unused css styles from your application.
import '@bulmil/core/dist/css/bulmil.min.css';

Now let's install the @bulmil/svelte package by running the following in your terminal:

# Using npm
npm i @bulmil/svelte

# Using yarn
yarn add @bulmil/svelte

And ... we're all done ๐ŸŽ‰

Ember

Working with Stencil components in Ember is really easy thanks to the ember-cli-stencil addon. It handles:

  • Importing the required files into your vendor.js
  • Copying the component definitions into your assets directory
  • Optionally generating a wrapper component for improved compatibility with older Ember versions

Start off by installing the Ember addon

ember install ember-cli-stencil

Now, when you build your application, Stencil collections in your dependencies will automatically be discovered and pulled into your application. You can just start using the custom elements in your hbs files with no further work needed. For more information, check out the ember-cli-stencil documentation.


Development

  1. Clone this repository
  2. Install dependencies using yarn install or npm install
  3. Start development server using yarn storybook or npm run storybook

๐Ÿ“‘ License

MIT License

bulmil's People

Contributors

4aficiona2 avatar dependabot-preview[bot] avatar gomah avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

bulmil's Issues

Disabled checkbox

In bulma's form checkbox, the disabled attribute is passed to the label element, however, disabled is not a valid attribute for label.

<label class="checkbox" disabled>
  <input type="checkbox" disabled>
  Save my preferences
</label>

React 16 as peer dependency

Hi. I very appreciate your work. But you put peerDependency react@"16.12.0" for last versions of @bulmil/[email protected] and 0.35.0, while I see react 18.0.15 in dev dependencies.
It's in deep conflict with libraries I use and they heed to have react 18.2.0.

Could @bulmil/react have a bit higher dependencies?

Invalid last-child / last-type / ntn:x selectors

As bulma components & elements are wrapped in Stencil components, some selectors might not work.

e.g for Buttons:

.buttons {
  .button {
    &:not(:last-child):not(.is-fullwidth) {
      margin-right: 0.5rem;
    }
  }
}

Work around:

b-buttons {
  b-button {
    &:not(:last-child):not(.is-fullwidth) {
      margin-right: 0.5rem;
    }
  }
}

Prepare Bulma components (markup)

Layout

  • Container
  • Section
  • Footer

Grid

  • Columns
  • Tiles

Form

  • General
  • Input
  • Textarea
  • Select
  • Checkbox
  • Radio
  • File

Elements

  • Box
  • Button
  • Buttons
  • Content
  • Icon
  • Image
  • Notification
  • Progress
  • Table
  • Tag
  • Tags

Components

  • Breadcrumb
  • Card
  • Dropdown
  • Menu
  • Message
  • Modal
  • Navbar
  • Pagination
  • Panel
  • Tabs

Dependabot can't resolve your JavaScript dependency files

Dependabot can't resolve your JavaScript dependency files.

As a result, Dependabot couldn't update your dependencies.

The error Dependabot encountered was:

Error whilst updating @types/storybook__addon-knobs in /yarn.lock:
Couldn't find package "storybook__addon-knobs@*" required by "@types/[email protected]" on the "npm" registry.

If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.

Runing issues with installing react example

When trying to test the react application example and after running below commands

$: git clone https://github.com/gomah/bulmil
$: cd bulmil/examples/react
$: npm install

below error is thrown:

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: undefined@undefined
npm ERR! Found: [email protected]
npm ERR! node_modules/react
npm ERR!   peer react@"^16.8.0 || ^17.0.0 || ^18.0.0" from @storybook/[email protected]
npm ERR!   node_modules/@storybook/addons
npm ERR!     peer @storybook/addons@"^6.4.0" from @storybook/[email protected]
npm ERR!     node_modules/@storybook/addon-knobs
npm ERR!       dev @storybook/addon-knobs@"6.4.0" from the root project
npm ERR!   dev react@"18.2.0" from @bulmil/[email protected]
npm ERR!   packages/react
npm ERR!     @bulmil/[email protected]
npm ERR!     node_modules/@bulmil/react
npm ERR!       workspace packages/react from the root project
npm ERR!       2 more (@bulmil/react-example, @bulmil/next-example)
npm ERR!   4 more (react-dom, @storybook/api, @storybook/components, @storybook/theming)
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peerOptional react@"^16.8.0 || ^17.0.0" from @storybook/[email protected]
npm ERR! node_modules/@storybook/addon-knobs
npm ERR!   dev @storybook/addon-knobs@"6.4.0" from the root project
npm ERR! 
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR! 
npm ERR! See /Users/i774615/.npm/eresolve-report.txt for a full report.

even if running npm install --force causes

118 vulnerabilities (1 low, 91 moderate, 16 high, 10 critical)

no package-lock.json is created and cannot run

npm run serve

the package.json looks like this:

{
  "name": "@bulmil/react-example",
  "version": "0.48.1",
  "private": true,
  "dependencies": {
    "@bulmil/core": "0.48.1",
    "@bulmil/react": "0.48.1",
    "react": "17.0.2",
    "react-dom": "17.0.2",
    "react-scripts": "4.0.3",
    "typescript": "5.2.2"
  },
  "scripts": {
    "build": "react-scripts build",
    "eject": "react-scripts eject",
    "serve": "react-scripts start"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}

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.