Skip to content

Instantly share code, notes, and snippets.

View mathewtrivett's full-sized avatar

Mathew Trivett mathewtrivett

View GitHub Profile
@mathewtrivett
mathewtrivett / machine.js
Last active August 20, 2021 09:04
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@mathewtrivett
mathewtrivett / machine.js
Last active March 6, 2021 14:57
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@mathewtrivett
mathewtrivett / media_queries.scss
Last active January 11, 2021 08:30
Testing Print CSS - media_queries.scss
/* Learn more about media queries
* https://developer.mozilla.org/en-US/docs/Web/CSS/@media
*/
@media all {
/*
* Styling rules for all media
*/
}
@mathewtrivett
mathewtrivett / spec_helper.rb
Created January 11, 2021 08:16
Testing Print CSS - spec/spec_helper.rb
RSpec.configure do |config|
.... # The rest of your Rspec configuration
# Here we are going to precompile our assets any time
# we encounter a feature spec group
config.before(:all) do |_config|
case self.class.metadata[:type]
when :feature
@mathewtrivett
mathewtrivett / webpacker.yml
Last active January 11, 2021 08:12
Testing Print CSS - config/webpacker.yml
# Note: You must restart bin/webpack-dev-server for changes to take effect
default: &default
# ....
# The rest of your webpacker.yml config
test:
<<: *default
# The rest of your test config
@mathewtrivett
mathewtrivett / print_styles.rb
Created January 11, 2021 08:03
Testing Print CSS - spec/features/print_styles.rb
# Capybara is designed to test visible HTML elements, i.e. your user interface.
# The link tags used for stylesheets are not visible to Capybara by default.
# We need to pass visible: false to `have_selector` to tell Capybara the link element is not visible.
RSpec.describe 'Print CSS', type: :feature do
context 'with params[:medium] == "print"' do
it 'loads the print stylesheet with the media=screen' do
is_expected.to have_selector(
'link[id="print_styles"][media="screen"]',
visible: false
@mathewtrivett
mathewtrivett / application.html.erb
Last active January 11, 2021 10:29
Testing Print CSS - app/views/layouts/application.html.erb
<!DOCTYPE html>
<html>
<head>
<title>Testing Print CSS</title>
<%= csrf_meta_tags %>
<%= csp_meta_tag %>
<meta name="viewport" content="width=device-width, initial-scale=1">
<% if params[:medium] == 'print' %>
<!-- Load your print.css file with media attribute equal to screen -->
<%= stylesheet_packs_with_chunks_tag 'print', media: 'screen', 'data-turbolinks-track': 'reload', id: 'print_styles' %>
@mathewtrivett
mathewtrivett / keybase.md
Created September 6, 2016 10:38
Keybase Github Proof

Keybase proof

I hereby claim:

  • I am mathewtrivett on github.
  • I am mathewtrivett (https://keybase.io/mathewtrivett) on keybase.
  • I have a public key ASBy2H23Lv_wrYLSBN_h_Q7KcKgnFFfzVG51uK0YIx170Ao

To claim this, I am signing this object: