-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #95 from eessex/webpack
Migrate asset pipeline to Webpack, use TS & React
- Loading branch information
Showing
38 changed files
with
10,132 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
defaults |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
module.exports = { | ||
env: { | ||
browser: true, | ||
es6: true, | ||
jest: true, | ||
node: true, | ||
}, | ||
extends: [ | ||
"eslint:recommended", | ||
"plugin:@typescript-eslint/recommended", | ||
"prettier/@typescript-eslint", | ||
"plugin:react/recommended", | ||
"prettier", | ||
], | ||
parser: "@typescript-eslint/parser", | ||
parserOptions: { | ||
ecmaFeatures: { | ||
jsx: true, | ||
}, | ||
ecmaVersion: 6, | ||
sourceType: "module", | ||
}, | ||
plugins: ["@typescript-eslint", "eslint-plugin-import"], | ||
root: true, | ||
rules: { | ||
"no-console": 1, | ||
"sort-imports": 1, | ||
"sort-keys": 1, | ||
"spaced-comment": ["error", "always", { block: { balanced: true } }], | ||
}, | ||
settings: { | ||
react: { | ||
version: "detect", | ||
}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
/* eslint-disable spaced-comment */ | ||
|
||
//= link_tree ../images | ||
//= link_directory ../javascripts .js | ||
//= link_directory ../stylesheets .css |
This file was deleted.
Oops, something went wrong.
Empty file.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 2 additions & 9 deletions
11
app/assets/javascripts/cable.js → app/javascript/channels/consumer.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,6 @@ | ||
// Action Cable provides the framework to deal with WebSockets in Rails. | ||
// You can generate new channels where WebSocket features live using the `rails generate channel` command. | ||
// | ||
//= require action_cable | ||
//= require_self | ||
//= require_tree ./channels | ||
|
||
(function() { | ||
this.App || (this.App = {}); | ||
import { createConsumer } from "@rails/actioncable" | ||
|
||
App.cable = ActionCable.createConsumer(); | ||
|
||
}).call(this); | ||
export default createConsumer() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// Load all the channels within this directory and all subdirectories. | ||
// Channel files must be named *_channel.ts. | ||
|
||
const channels = require.context(".", true, /_channel\.ts$/) | ||
channels.keys().forEach(channels) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import $ from "jquery" | ||
import consumer from "./consumer" | ||
|
||
consumer.subscriptions.create( | ||
{ | ||
channel: "ProjectChannel", | ||
organization_id: $("#organization_subscription_identifier").val(), | ||
}, | ||
{ | ||
connected() { | ||
// Called when the subscription is ready for use on the server | ||
}, | ||
disconnected() { | ||
// Called when the subscription has been terminated by the server | ||
}, | ||
received(data) { | ||
// Called when there's incoming data on the websocket for this channel | ||
if (data.newSnapshots || data.updatedBlocks) { | ||
location.reload() | ||
} | ||
}, | ||
}, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { ArtsyMarkIcon, Box, Flex, Link, Sans, Theme } from "@artsy/palette" | ||
import React from "react" | ||
|
||
export const MainLayout: React.FC = () => { | ||
return ( | ||
<Theme> | ||
<NavBar /> | ||
<Box id="body" /> | ||
</Theme> | ||
) | ||
} | ||
|
||
export const NavBar: React.FC = () => { | ||
return ( | ||
<Box width="100%"> | ||
<Link href="/" noUnderline display="inline-block"> | ||
<Flex px={3} py={1} width="min-content"> | ||
<ArtsyMarkIcon width="25" height="25" /> | ||
<Sans size="5" weight="medium" pl={0.5}> | ||
Horizon | ||
</Sans> | ||
</Flex> | ||
</Link> | ||
</Box> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* eslint-disable @typescript-eslint/no-var-requires */ | ||
|
||
// This file is automatically compiled by Webpack, along with any other files | ||
// present in this directory. You're encouraged to place your actual application logic in | ||
// a relevant structure within app/javascript and only use these pack files to reference | ||
// that code so it'll be compiled. | ||
// | ||
// To reference this file, add <%= javascript_pack_tag 'application' %> to the appropriate | ||
// layout file, like app/views/layouts/application.html.erb | ||
|
||
// Uncomment to copy all static images under ../images to the output folder and reference | ||
// them with the image_pack_tag helper in views (e.g <%= image_pack_tag 'rails.png' %>) | ||
// or the `imagePath` JavaScript helper below. | ||
// | ||
// const images = require.context('../images', true) | ||
// const imagePath = (name) => images(name, true) | ||
|
||
require("turbolinks").start() | ||
require("@rails/ujs").start() | ||
require("@rails/activestorage").start() | ||
|
||
// ActionCable | ||
require("channels") | ||
// Theme + NavBar | ||
require("./main_layout") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { MainLayout } from "components/MainLayout" | ||
import React from "react" | ||
import ReactDOM from "react-dom" | ||
|
||
document.addEventListener("turbolinks:load", () => { | ||
ReactDOM.render(<MainLayout />, document.getElementById("main-layout")) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.