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

uncool

v0.0.15

Published

Vue.js plugin that allows page elements to be easily mutable using Firebase.

Downloads

23

Readme

uncool

Prepare to be unimpressed.


What is it

Uncool is a Vue plugin that allows copy and images to be updated on the fly.

Prereqs

  • Must be using Vue CLI
  • Must have initialized a Firebase Project that includes the following:
    • Firestore enabled
    • Storage bucket enabled and declared in Firebase config
    • Authentication enabled and Email/Password is enabled

Instructions

Install

$ npm install uncool --save

Include

In src/main.js:

import Vue from 'vue'
...
import * as uninitializedFirebase from 'firebase/app'
import 'firebase/auth'
import 'firebase/firestore'
import 'firebase/storage'

export const firebase = uninitializedFirebase.initializeApp(*firebase_config*)
...
// must be included after Firebase has been imported and initialized
import uncool from 'uncool'
Vue.use(uncool)
import 'uncool/src/style.sass' // styling to denote editable items

In src/App.vue, include the following import, component declaration, and addition to the template:

<script>
import { UncoolAdmin } from 'uncool' // <--- Import at the top of the javascript
export default {
  name: 'App',
  components: {
    'uncool-admin': UncoolAdmin, // <--- declare the component
  },
}
</script>

<template>
  <div id="app">
    <uncool-admin></uncool-admin> // <--- include in the template at the top
    ...
  </div>
</template>

If you would like to access the login page for uncool via url, in your router file, include the following route, using whatever path works for your site (here, we used /edit):

const routes = [
  ...
  {
    path: '/edit', // this can be whatever you need it to be
    name: 'UncoolAdmin', // this needs to be 'UncoolAdmin'
  },
  ...
]

In firestore.rules, include the following rules:

rules_version = '2';
service cloud.firestore {
  match /databases/{database}/documents {
    ...
    ... // Include from here...
    match /uncool/{uncoolId} {
      allow read: if true
      allow write: if exists(/databases/$(database)/documents/uncool_users/$(request.auth.uid))
    }
    match /uncool_users/{userId} {
      allow read: if userId == request.auth.uid;
    }
    ... // to here.
    ...
  }
}

Add authorized editor:

If you already know the User uid you would like to authorize, skip to 2.

  1. Create user
  • Go to the authentication tab in the Firebase console of your project.
  • Since Email/Password authorization should already be enabled, click Add User.
  • Choose an email and password you would like to use.
  • Click Add user and you should see the new user appear on the list of users.
  • Copy the User uid of the new user.
  1. Add Uncool Editor
  • Go to the database tab in the Firebase console of your project.
  • Create a collection named uncool_users.
  • When prompted to create a doc, as the uid, use the User uid you are authorizing.
  • For the data, in the field, input role and as the value input EDITOR
  • Save the data

How to use (as a developer):

In any Vue component, include the uncool directive on any element in the template to have it's content mutable by any authorized user.

Edit text example:

<template>
  <div class="hello">
    <div
     v-uncool='"a-unique-id"'
     > I serve as a placeholder unless no data is found in the database.
    </div> 
  </div>
</template>

Edit image example (be sure to include image on your directive):

<template>
  <div class="hello">
    <div
     style='height:400px;width:400px;'
     v-uncool.image='"a-unique-image-id"'
     >
    </div> 
  </div>
</template>

How to use (as an Uncool editor):

To acquire your Uncool editor authorization:

  • Sign in:
    • press Cmd + u (or visit your uncool admin url).
    • enter username and password.
    • press login
  • Edit element:
    • find an editable element which can be denoted in the following ways
      • a red EDIT in the upper right hand of the element
      • the cursor styling turns to context-menu
    • click on the editable element
    • edit innerHTML (or choose new img) of element and click save
    • changes should propogate
  • Sign out (if you would like):
    • press Cmd + u (or visit your uncool admin url).
    • press logout

See, not that cool.