Skip to content

Instantly share code, notes, and snippets.

View Justineo's full-sized avatar

GU Yiling Justineo

View GitHub Profile

Using Icon Components in Vue.js

Icon fonts and SVG sprite are not included here. I'm talking about an icon system that can let users import icons by demand.

There are three major ways of exposing API of an icon component in Vue.js and each one of them has its own pros & cons:

  1. A single component (eg. <v-icon>), let users pass a name/type prop to specify the actual icon.

    Icon data are registered into a global “pool” like:

@Justineo
Justineo / veui-with-vue-cli-3.md
Last active September 19, 2018 14:10
Vue CLI 3 配置 VEUI

安装:

npm i --save veui veui-theme-one
npm i --save-dev veui-loader babel-plugin-veui babel-plugin-lodash

创建 vue.config.js

@Justineo
Justineo / error.js
Created April 29, 2015 03:00
fire error from Gist
throw new Error('Error from Gist!');
@Justineo
Justineo / sort-nodes.js
Last active August 29, 2015 14:07
Sort Nodes
// sort an array of DOM nodes according to the HTML tree order
// http://www.w3.org/TR/html5/infrastructure.html#tree-order
function sortNodes(nodes) {
nodes.sort(function (a, b) {
var posCompare = a.compareDocumentPosition(b);
if (posCompare & 4 || posCompare & 16) {
// a < b
return -1;
} else if (posCompare & 2 || posCompare & 8) {
@Justineo
Justineo / baidu.json
Created September 23, 2014 07:06
CSScomb sort-order config for Baidu
[
[
"content"
],
[
"position",
"z-index",
"top",
"right",
"bottom",
@Justineo
Justineo / createStyle.js
Last active November 24, 2016 09:05
Correct way to create stylesheets dynamically
function createStyle(styleText) {
var style = document.createElement('style');
style.type = 'text/css';
// <style> element must be appended into DOM before setting `cssText`
// otherwise IE8 will interpret the text in IE7 mode.
document.body.appendChild(style);
if (style.styleSheet) {
style.styleSheet.cssText = styleText;
} else {
@Justineo
Justineo / start.html
Created July 17, 2012 14:52
HTML: reveal.js Slideshow Starting Template
<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<title></title>
<meta name="description" content="">
<meta name="author" content="Gu Yiling">