Skip to content

Instantly share code, notes, and snippets.

View mitchell-garcia's full-sized avatar

Mitchell Garcia mitchell-garcia

View GitHub Profile
@mitchell-garcia
mitchell-garcia / kc.js
Created April 8, 2016 17:06
Example of binding attribute to style
export default Ember.Component.extend({
attributeBindings: ['background:style'],
size: 'medium',
background: computed('user.[]', function() {
const email = this.get('user.email');
const size = this.get('size');
const defaultAvatar = `//www.gravatar.com/avatar/${md5(email)}.jpg`;
const avatar_path = this.get('user.avatar') ? this.get('user.avatar') : defaultAvatar;
// most literally copied from https://github.com/preboot/angular-webpack/blob/master/webpack.config.js - view for reference
var webpack = require('webpack');
var autoprefixer = require('autoprefixer');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var CopyWebpackPlugin = require('copy-webpack-plugin');
/**
* Env
* Get npm lifecycle event to identify the environment
@mitchell-garcia
mitchell-garcia / vue.d.ts
Last active October 1, 2017 05:29
Vue Typescript Typings for Typescript Version 2.4+
declare module "*.vue" {
import Vue from "vue";
import { ComponentOptions } from "vue";
export default typeof Vue as ComponentOptions<Vue>;
}
@mitchell-garcia
mitchell-garcia / vuex.d.ts
Created October 25, 2017 13:35
Manually Typed Vuex Typescript Definition
/**
* Static vuex typings copied from ones included in node_modules.
*
* We need to do this in order to get typings for this.$store in components.
* Once this Feature is added, we can remove this + the custom mapping in tsconfig.json
* https://github.com/vuejs/vuex/issues/994
*/
import Vue, { WatchOptions } from 'vue';
type Dictionary<T> = { [key: string]: T };
[Thu Nov 09 2017 15:23:28 GMT-0500 (EST)] DEBUG Mounting folder `/Users/e006707/Projects/test-project/dist` at `/`
[Thu Nov 09 2017 15:23:28 GMT-0500 (EST)] INFO Static server running at http://localhost:8081
Debugger listening on [::]:5859
[15:23:32] COMMAND POST "/wd/hub/session"
[15:23:32] DATA {"desiredCapabilities":{"javascriptEnabled":true,"locationContextEnabled":true,"handlesAlerts":true,"rotatable":true,"browser":"chrome","browserstack.debug":"true","browserstack.local":"true","browserName":"firefox","loggingPrefs":{"browser":"ALL","driver":"ALL"},"requestOrigins":{"url":"http://webdriver.io","version":"4.9.5","name":"webdriverio"}}}
[15:23:37] INFO SET SESSION ID 580859e74c3200e092d47c6173618125eabd9b32
[15:23:37] RESULT {"applicationCacheEnabled":false,"rotatable":false,"mobileEmulationEnabled":false,"networkConnectionEnabled":false,"chrome":{"chromedriverVersion":"2.33.506120 (e3e53437346286c0bc2d2dc9aa4915ba81d9023f)","userDataDir":"C:\\Windows\\pro
@mitchell-garcia
mitchell-garcia / index.ts
Last active December 18, 2017 04:35
Store Module Example with vuex-typex
import Vue from 'vue'
import { getStoreBuilder } from 'vuex-typex';
import Vuex, { Store } from 'vuex'
import { UserModule } from "./userModule";
export interface RootState {
user: UserModule;
}
Vue.use(Vuex);
@mitchell-garcia
mitchell-garcia / TestComponent.vue
Last active January 15, 2018 15:11
Typing Props
<script lang="ts">
import Vue from "vue"
interface TestComponentData {
testingProp: string
theme: "white" | "red"
}
export default Vue.extend({
data() {
Feature vue-class-component Vue.extend
Autocomplete For Component Props In Templates x
Type-safety for Props x
Type-safety for Data Properties
Type-safety for Computed Properties
Type-safety for Methods
@mitchell-garcia
mitchell-garcia / ComponentName.vue
Last active January 16, 2018 01:43
Single File Component Example
<script lang="ts">
import Component from "vue-class-component"
import { Prop } from "vue-property-decorator"
type ComplexObjectInterface = {
testProp: string
modelName: number
}
@Component
<script lang="ts">
import Vue, { PropTypes } from "vue"
type ComplexObjectInterface = {
testProp: string
modelName: number
}
export default Vue.extend({
props: {