ColdFusion ReactJS
ColdFusion ReactJS
Solutions to problems you want to solve may not exist in the realm of knowledge
you currently possess.
Exploring will keep us more aware so we can fail quickly and remain flexible.
What did we sign up for?
We’re going to explore a light-hearted example of Interactivity Programming
GOAL: Prove to you the ColdFusion + ReactJS combination is worth your time!
http://draftstudios.com/demo/
What is ReactJS?
JavaScript library in charge of front-end/client-side views.
● An npm package
● Wizard, pre-rigged, pre-configured starter app
○ Webpack (bundler)
○ Babel (compiler / “transpiler”)
○ Pre-selected /node_modules (utility libraries)
○ Dev server with live-reloading (also look into HMR)
○ Linter
○ Build process
/
Note package.json
/node_modules
/src
Where .js/.jsx sits
App.css for now will go here as well
/public ~ specifically CF code and assets will go here
Notice that static .html and .css files here by default. Will be copied
/build
Must be aware… styling
css
this.state = {
wealthy: false,
} (set in the constructor() function of a class)
Must be aware… animations
css animations
● Ternary operators
○ && -> shorthand for if/then… { this.state.wealthy && beHappy(); }
○ condition ? true : false shorthand for if/else… { this.state.wealthy ? beHappy() : beSad() }
● Comments in JSX: {/* comments go here */}
● What are the curly brackets? {} = ## in CF
○ Evaluate your variables
● setTimeout(), setInterval(), requestAnimationFrame()
● ES6 (ECMA Script 2015 spec), specifically arrow function definitions
○ facing = (direction) => { return direction ? "forward" : "backward" }
○ defines and binds function to component’s scope (attach to class prototype)
Technical assumptions
General knowledge of how websites are. CF, JS, JSON, CSS familiarity will help!
75% ReactJS / 25% CF
To illuminate this, I’m adding the next three slides to supplement! - Minh
Breaking out components
/draft-studios-rig/src/Canvas.js is probably easiest example… note the import on
line 1, class Canvas extends Component and export default Canvas;
{this.props.children} also important--putting all nested <Parallax/> inside Canvas.
Breaking out components
/draft-studios-rig/src/Canvas.js could also be written like below, using functional
components (since you don’t need State, class assignment is unnecessary)! You
call these “pure” or “stateless” functions/components. Read this to understand.
And then use them like declarative tags (notice again <Parallax/> children):
Jump to draft-studios-rig code
In the draft-studios-website repository you’ll find the code referenced in the next chunk of
slides. Please follow the directions on the repository’s README.md.
For prod deployment, run `npm run build` (look at package.json if you’re curious).
It will generate a /build directory which is what you’ll upload to your CF app directory.
Fetching data via CFC
CFC Setup: /draft-studios-website/public/services/ds.cfc
***NOTE*** use array notation here instead of dot for keeping case,
older CF upper-cases struct keys which can be an issue during SerializeJSON step
Fetching data via CFC - JS side
CFC Setup: /draft-studios-website/src/FetchColdFusionAssets.js
***NOTE*** This registers an app name and a channel name so we can begin sending messages through it.
Make sure ColdFusion WebSockets are enabled and verify the port it’s running on.
Fetching data via WebSockets - CF side
WS Setup: /draft-studios-website/public/services/ds.cfc
Fetching data via WebSockets - CF side
WS Setup: /draft-studios-website/public/services/ds.cfc
Two <div>’s
● one at the frame height and width with
overflow:hidden.
● bigger one is the entire sheet (ie: 400x800)!
● Explicitly set className to div. Explicitly set width and height to single frame. Set background to
big image. Animation shorthand property set to @keyframe name. Easy peasey!
Let’s take a step back...
illustrator
jimmy@draftstudios.com