Articles

Rails recipes, tutorials, and development logs.

Filtered by tag: tailwindcss
Clear filter

Loud, Then Calm: Redesigning VegasSims in 10 PRs with Rails 8.1 and Tailwind CSS v4

When you run a sports simulation platform, trust is the entire product. Every day, VegasSims runs 10,000+ Monte Carlo simulations per game built on confirmed daily lineups across MLB, NFL, NBA, NHL, WNBA, and MLS, comparing model probabilities against sportsbook odds to surface betting edges. If the data is sharp but the interface feels chaotic, readers bounce. Over three days—November 24 through November 26, 2026—we shipped a complete redesign of VegasSims across 10 single-purpose pull requests (#34 through #43). The story of those three days comes down to four words: loud, then calm. We started by swinging hard at a bold, high-voltage aesthetic, lived with it for a day, realized it was too loud for a serious data tool, and pivoted to a calmer, content-first architecture. Because we built on plain Rails, Hotwire, and Tailwind CSS v4 design tokens, that pivot didn't require a rewrite—just a few edits to a single CSS file. The Stack: Zero New GemsEverything in this redesign was built using the existing VegasSims stack, adding zero new gems and zero JavaScript packages: • Backend & Database: Ruby on Rails 8.1 backed solely by SQLite, running the Solid trifecta (Solid Cache, Solid Queue, Solid Cable) and Active Storage for article covers. • Frontend: Hotwire (Turbo + Stimulus) with importmap (no Node build step) and Tailwind CSS v4. • Testing & CI: Minitest paired with GitHub Actions running RuboCop, Brakeman, an importmap JavaScript audit, and the full test suite (which grew from 270 to 295 passing tests during the sprint). • Deployment & Mobile: Auto-deployed on merge via Hatchbox, with Hotwire Native iOS and Android apps wrapping the web views. Each PR was developed on its own branch, verified in a browser across desktop, tablet, and phone viewports in both dark and light modes, and merged to main—meaning merging equaled shipping. Making a Re-Theme a One-File ChangeIn PR #34, our first instinct was to avoid looking like every other green-and-slate betting dashboard. We launched a volt yellow-green and violet palette alongside a new "coin" brand mark (a green coin with a white ring and lightning bolt, replacing an old bell-curve icon that turned into a smudge at favicon size). After 24 hours with it, the volt-and-violet theme felt overly aggressive. Taking cues from established sports data platforms like Sportsline and Action Network, PRs #35 and #36 pulled the palette back to near-neutral charcoal surfaces (ink) with a single, disciplined accent color (brand green) reserved strictly for primary actions, favored-side indicators, and positive edge chips. Because Tailwind CSS v4 configures design tokens directly in CSS via @theme, pivoting the entire application's look came down to redefining two custom color scales in app/assets/tailwind/application.css: @theme { --font-sans: "Inter", ui-sans-serif, system-ui, sans-serif; --font-weight-extrabold: 700; --font-weight-black: 800; --color-brand-500: #15a35a; --color-brand-600: #11864a; --color-ink-900: #17161f; --color-ink-950: #0e0d14; /* ...full brand and ink scales... */ }Instead of guessing by eye, we checked contrast ratios with numbers: • brand-400 text on dark cards: 6.0:1 • brand-600 (#11864a) text on white: 4.6:1 (the brightest green on our hue that clears the 4.5:1 AA threshold) • brand-500 (#15a35a) large text on white: 3.3:1 (clearing the 3:1 requirement for large stats and wordmarks) Dark mode remains the default experience, and setting the CSS color-scheme property ensures native form controls follow the active site theme rather than fighting the user's OS setting. A 40-Line Minitest Guardrail for Invisible TextOne subtle trap with Tailwind CSS is that referencing a shade that doesn't exist in your palette—like text-red-650—doesn't throw an error. Tailwind silently omits the utility class, leaving text uncolored and effectively invisible in one theme. During the redesign, we caught several real instances of this on our Log out and Cancel Subscription buttons, as well as light-mode loss figures. To prevent regressions, we wrote a ~40-line Minitest check (test/views/color_classes_test.rb) with zero external dependencies. It parses the shades defined inside our @theme block, scans every ERB template and Stimulus controller for color utility classes, and fails the build if any view references a nonexistent shade. If you maintain a custom palette in Tailwind v4, this is one of the highest-leverage tests you can add to your suite. Typography Built for Odds and ScoresSports analytics interfaces live and die by dense numbers. We standardized on two self-hosted variable web fonts totaling roughly 78 KB on a first visit: 1. Inter (400–800): Used for all UI copy and articles thanks to its tall x-height and clear distinction between 1/l/I and 0/O in compact odds tables. 2. Outfit (800–900): Reserved strictly for scoreboard numerals and headline stats via a custom Tailwind v4 @utility rule: @utility font-score { font-family: "Outfit", "Inter", ui-sans-serif, system-ui, sans-serif; font-weight: 900; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }We also remapped --font-weight-extrabold to 700 and --font-weight-black to 800 inside @theme. That single token adjustment toned down heavy headings across dozens of existing templates without touching a single ERB file. Team-Color Win Bars and Color-Math Edge CasesPreviously, our win-probability bars always colored the away team's segment. In PRs #35 and #38, we replaced that with a shared shared/_win_bar partial that fills both sides with each team's actual primary color so the larger block visually anchors the favorite. Real-world team palettes introduce immediate edge cases, which we encapsulated in a tested TeamColorsHelper: • Look-alike matchups: When two navy-blue teams play each other (an RGB Euclidean distance under 90), the home side automatically falls back to its secondary color. • Near-black primaries: Teams like the Spurs, Nets, or Penguins vanish against dark charcoal cards, so they switch to their secondary color—or a neutral grey if their secondary is white. • Sliver thresholds: Percentage labels are omitted on segments narrower than 18% so text never overflows. • Dynamic label contrast: Labels (DET 60.1%) switch between white and near-black based on the fill color's WCAG relative luminance: def win_bar_label_color(hex) r, g, b = rgb(hex).map do |c| c /= 255.0 c <= 0.03928 ? c / 12.92 : ((c + 0.055) / 1.055)**2.4 end luminance = (0.2126 * r) + (0.7152 * g) + (0.0722 * b) luminance > 0.35 ? "#0e0d14" : "#ffffff" endContent First: The Home Hub and Hybrid Game RowA sports betting site's product is the daily slate, not a hero banner. In PRs #38, #39, and #41, we restructured the information architecture around immediate utility: • Daily Home Hub: The root URL is no longer a marketing landing page (which moved to /about). Visitors now land directly on a live score strip of today's and tomorrow's games, featured analysis, top model edges, and a right rail highlighting the Game of the Day alongside a preview card for our upcoming Bet Tracker. • Flatter Surfaces: We stripped large drop shadows from 51 spots across 27 views, replacing them with flat surfaces and crisp 1px borders that read cleanly in light mode. • One Hybrid Game Row: On the Matchups board, we eliminated the old card-versus-list view toggle (and its tracking cookie) in favor of a single box-score-style game row. Desktop displays aligned column headers; mobile stacks the line and model pick cleanly beneath the matchup. Pro-locked games still display the teams and sportsbook line while gating projections, picks, and win probabilities—matching the amber lock-and-"Pro" badges we added to gated articles on the home page (#43). • Two-Column Board: On desktop, the Matchups board pairs league/date filters and projections on the left with a contextual right rail housing our NRFI/YRFI and BTTS screeners (shown only when viewing relevant leagues) and a concise methodology card. Using plain CSS flex-wrap, the rail drops naturally below the board on narrow screens. Small Stimulus, Big Polish: The Score StripFor the horizontal score strip at the top of the home hub (#39), we wanted native touch scrolling on mobile without ugly scrollbars on desktop. With scrollbar-width: none and a (hover: none) media query hiding controls on touch devices, a ~40-line Stimulus controller (scroller_controller.js) paired with a ResizeObserver handles keyboard-focusable paging arrows that only appear on hover when there is actually more content to scroll: update() { const track = this.trackTarget const maxScroll = track.scrollWidth - track.clientWidth this.prevTarget.hidden = track.scrollLeft <= 2 this.nextTarget.hidden = track.scrollLeft >= maxScroll - 2 }Three Production Lessons from the TrenchesShipping 10 PRs straight to production surfaced three classic Rails and infrastructure gotchas worth keeping in your back pocket: 1. Turbo + Heavy CSS Filters: Our initial hero section used blurred, masked background layers. Navigating back via Turbo in WebKit left those glows half-rendered until a hard refresh. Swapping them for standard CSS radial-gradient backgrounds solved the repaint issue immediately. 2. Purge Cloudflare for Favicons: Updating favicon.ico and favicon.svg in public/ wasn't enough in production—Cloudflare kept serving the cached icon until we explicitly purged /favicon.ico at the CDN edge. 3. Active Storage vs. String URLs: After deploying the new home hub (#40), our featured article cover vanished in production because the template only checked the image_url column while production articles used Active Storage uploads (cover_image). Consolidating rendering into a single helper fixed it everywhere—with a subtle reminder that image_tag treats plain strings as asset-pipeline paths, so external URLs need tag.img: def article_cover_tag(article, **options) if article.cover_image.attached? image_tag(article.cover_image, **options) elsif article.image_url.present? tag.img(src: article.image_url, **options) end endAdmin Tooling for Full-Slate AnalysisFinally, PR #42 streamlined how we generate daily slate breakdowns. Individual game pages already included an admin-only text export containing projections, odds, edges, betting splits, starting pitchers, and injury notes. We extended MatchupsController#index to respond to a third format—format.text alongside HTML and CSV—so clicking Slate report (TXT) exports the entire filtered day's slate in one download, prefixed with a one-line-per-game summary formatted for quick multi-game analysis. Wrapping UpYou don't need a component library, a SPA framework, or a multi-month rewrite to modernize a Rails app. Defining clear design tokens in Tailwind CSS v4 lets you test bold visual ideas and dial them back in hours instead of weeks, while small Minitest assertions catch the silent CSS mistakes that slip past code review. Explore the redesigned boards and daily simulation projections live at vegassims.com.