Skip to content

Instantly share code, notes, and snippets.

View RyanCCollins's full-sized avatar

Ryan Collins RyanCCollins

View GitHub Profile
// Main.elm
module Main exposing (main)
import AppModel exposing (..)
import View exposing (view)
import Html exposing (Html)
main : Program Never Model Msg
main =
import React, { Component } from 'react';
import Elm from 'react-elm-components';
import Heading from 'grommet-udacity/components/Heading';
import Section from 'grommet-udacity/components/Section';
import Markdown from 'grommet-udacity/components/Markdown';
import Box from 'grommet-udacity/components/Box';
import { StyledWrapper, StyledArticle } from './styles';
import { Main } from 'elm/src/Main';
import { Divider } from 'components';
// From https://github.com/RyanCCollins/ryancollinsio/blob/feat_rc_elm/client/webpack.config.babel.js
const webpack = require('webpack');
const path = require('path');
const ROOT_PATH = path.resolve(__dirname);
module.exports = {
devtool: 'eval',
entry: [
'react-hot-loader/patch',
@RyanCCollins
RyanCCollins / actions.js
Created October 12, 2016 01:35
App Actions
export const authenticateUser = (user) => ({
type: types.AUTHENTICATE_USER,
user,
});
export const invalidateUser = () => ({
type: types.INVALIDATE_USER,
});
export const logoutUser = () => (dispatch) => {
module UserMutations
// removed for brevity, see the rest
// here: https://github.com/RyanCCollins/meetup-event-planner/blob/master/app/graph/mutations/user_mutations.rb
UpdateProfile = GraphQL::Relay::Mutation.define do
name 'UpdateProfile'
description 'Update the user profile'
input_field :auth_token, !types.String
input_field :profile, ProfileInputType
return_field :user, AuthUserType
@RyanCCollins
RyanCCollins / UserProfile.js
Last active October 12, 2016 01:51
User profile container, with mutations
class Profile extends Component {
// Removed for brevity. View the whole component
// here: https://github.com/RyanCCollins/meetup-event-planner/tree/master/client/app/src/containers/ProfileContainer
handleSaving() {
const {
updateProfile,
bioInput,
avatarInput,
employerInput,
actions,
class CreateEvent extends Component {
// ...
handleSubmit() {
const {
actions,
mutate,
fields,
guestList,
user,
} = this.props;
module EventMutations
Create = GraphQL::Relay::Mutation.define do
name 'CreateEvent'
input_field :event, EventInputType
input_field :auth_token, !types.String
return_field :event, EventType
resolve -> (inputs, ctx) do
event_inputs = inputs[:event]
start_date = Date.strptime(event_inputs[:start_date], '%m/%d/%Y').to_datetime
field :events, types[EventType] do
argument :first, types.Int
resolve -> (obj, args, ctx) {
events = Event.all.sort_by(&:start_date).reverse
if args[:first]
events = events.first(args[:first])
end
events
}
end
// import dependencies here
class EventsContainer extends Component {
constructor() {
super();
this.handleMore = this.handleMore.bind(this);
}
handleMore() {
const {
actions,
refetch,