npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

omim

v0.2.3

Published

Material Design for Omi.

Downloads

128

Readme

Omim

Cross frameworks and themes components by Omi.

Features

  • Render by Custom Elements of Web Components
  • Any framework can use the components, such as Omi, React, Preact, Vue and Angular
  • Support both JSX and native HTML elements
  • Each element can be used independently
  • Super easy to change theme colors, fonts and rounded corners
  • Extended HTML capabilities, you can pass false attributes to elements through string '0' or string 'false'

Cross Frameworks

Usage

Via script

<script src="https://unpkg.com/omi"></script>
<script src="https://unpkg.com/omim@latest/button/index.js"></script>

<m-button>I am button</m-button>

Via npm

npm install omim

Then:

import 'omim/button'

Then use the element in Omi, React, Vue or Angular:

<m-button>I am button</m-button>

It can also be used in pure js:

var button = document.createElement('m-button')
button.innerHTML = 'I am button'
document.body.append(button)
button.addEventListener('click', function () {
  console.log('Clicked!')
})

//or
//document.body.innerHTML = '<m-button>I am button</m-button>'

Change Theme

document.body.style.setProperty('--mdc-theme-primary', 'red')
document.body.style.setProperty('--mdc-theme-secondary', 'blue')
document.body.style.setProperty('--mdc-shape-small-component-radius', '2px')

All the config:

--mdc-theme-primary: #0072d9;
--mdc-theme-secondary: #2170b8;
--mdc-theme-error: #f5222d;
--mdc-theme-surface: #ffffff;
--mdc-theme-on-primary: #ffffff;
--mdc-theme-on-secondary: #ffffff;
--mdc-theme-on-error: #ffffff;
--mdc-theme-on-surface: #000000;
--mdc-theme-background: #ffffff;
--mdc-shape-small-component-radius: 4px;
--mdc-shape-medium-component-radius: 4px;
--mdc-shape-large-component-radius: 0px;
--mdc-typography--font-family: Roboto, sans-serif;

HTML Extention

You can set boolean prop to false from markup by 0 or false string.

define('my-element', class extends WeElement {
  static defaultProps = {
    show: true
  }

 static propTypes = {
    show: Boolean
  }

  render(props) {
    ...
    ...
  }
})

Use:

<my-element show="false"></my-element>

or

<my-element show="0"></my-element>

Usage in Vue

<script>
import 'omim/icon-button'

export default {
  name: 'HelloWorld',
  data: function() {
    return {
      result: false
    }
  },
  methods: {
    myEvent: function(evt) {
      this.result = evt.detail.isOn
    }
  }
}
</script>

<template>
  <div class="component">
    <p>The switch is {{result? 'on' : 'off'}}</p>
    <m-icon-button color="red" icons="['favorite', 'favorite_border']" @change="myEvent"></m-icon-button>
  </div>
</template>

Usage in Preact

import { useState } from 'preact'
import 'omim/icon-button'

export default function SomeComponent(props) {
    const [result, setSwitch] = useState(false)

    return (
      <div>
        <p>The switch is {result ? 'on' : 'off'}</p>
        <m-icon-button color="red" icons="['favorite', 'favorite_border']" onChange={e => setSwitch(e.detail.isOn)}>
        </m-icon-button>
      </div>
    )
}

Usage in React

/** @jsx nativeEvents */
import nativeEvents from 'jsx-native-events'
import { useState } from 'react'
import 'omim/icon-button'

export default function SomeComponent(props) {
    const [result, setSwitch] = useState(false)

    return (
      <div>
        <p>The switch is {result ? 'on' : 'off'}</p>
        <m-icon-button color="red" icons="['favorite', 'favorite_border']" onEventChange={e => setSwitch(e.detail.isOn)}>
        </m-icon-button>
      </div>
    )
}

Many thanks to calebdwilliams's jsx-native-events.

Note that in order to display icon in react or vue app, you need to put this in HTML:

<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">

Contribution

CMD

Build component:

npm run build -- component-name

Build all components:

npm run build-all

Build demo:

npm start demo-name

Publish:

npm publish --access public

To prevent duplication of development, PR submission fills in owner to lock the component.

为了防止重复开发,先 PR 提交填下 owner 锁定该组件。

| Components | Owner | State | | ------------------------------- | ----------------------------------- |----------------------------------- | | button | member |done | | icon | member |done | | text-field | member |done | | card | wscats |done | | chip | hulei |done | | dialog | zainchen |done | | elevation | liulinboyi |done | | image-list| member |done | | checkbox| member |done | | radio| lihengjun |done | | select| member |done | | slider| member |done | | switch| zainchen |done | | layout-grid| member |done | | linear-progress| member |done | | list| zainchen |done | | menu| member|done | | snackbar| member |done | | tab | FAKER-A |done | | tag | mtonhuang |done | | top-app-bar| zainchen |done | | typography| member |done | | drawer | zainchen |done | | badge | member |done | | fab | member |done | | icon-button | member |done | | toolbar | hulei |done | | avatar | member |done | | tree | member |done | | table | member |done | | nav | member |done | | action-sheet | member |done | | row | member |done | | chart bar| member |done | | chart line| member |done | | chart scatter| member |done | | chart pie| member |done | | chart doughnut| member |done | | chart radar| member |done | | chart polar area| member |done | | chart bubble| member |done | | chart bar line| member |done | | pagination| member |done | | color-picker| member |done | | loading |member| done | | path-progress | member | done | | popover | member | done | | rate | member | done| | step | member | done | | toast | member | done| | paper | zainchen | done| | transfer list | member | done| | editor | member | done| | input (lable,button)| | | | input-number | | | | input-table | | | | bottom nav | member | done| | expansion | member | done | | toggle buttons | member | done| | locate | member | done| | player | 132yse | done| | finger | member | done | | scroll | member | done | | welcome to add a new element! | | | welcome to add a new element! | | | welcome to add a new element! | |

Todo

TypeScript Auto Complete(todo)

interface ButtonProps {
  href?: string,
  disabled?: boolean,
  type?: 'default' | 'primary' | 'danger',
  onClick?: (e: any) => void
}

const TAG = 'm-button'

declare global {
  namespace JSX {
    interface IntrinsicElements {
      [TAG]: Omi.Props & ButtonProps
    }
  }
}

@tag(TAG)
export default class Button extends WeElement<ButtonProps, {}> {
...
...
...

Omim Page Templates(todo)

Coming!

Bug?(todo)

import Button from '@import/core/button'

The above code cannot register custom elements.

import '@import/core/button'

The above code can register custom elements.

Why??

Links