|
| 1 | +--- |
| 2 | +title: "Implementing Custom Figma Designs in Rails" |
| 3 | +publishedAt: 2025-08-12 |
| 4 | +description: "A technical overview of the challenges faced when translating highly customized Figma designs into a Rails application. This article discusses layout issues, the limitations of CSS frameworks like Bootstrap and Tailwind, and suggests a GUI editor design for more efficient component positioning." |
| 5 | +tags: ["rails", "css", "figma", "gui-editor"] |
| 6 | +--- |
| 7 | + |
| 8 | +# Challenges in Implementing the [hackts.ch](https://hackts.ch) Design |
| 9 | + |
| 10 | +While building the hackts.ch site, I encountered layout issues that I did not anticipate. The design came from a highly customised Figma file with precise alignments, irregular shapes and spacing patterns. |
| 11 | + |
| 12 | +I chose Rails with custom Sass stylesheets because of the abundance of unique styling across the page. [Bootstrap](https://getbootstrap.com/) felt difficult to adapt to the design, and [Tailwind’s utility classes](https://tailwindcss.com/docs/utility-first) were not flexible enough for the level of customisation required. |
| 13 | + |
| 14 | +## The Design Gap |
| 15 | + |
| 16 | +As you can see in the box model view, the layout contains many irregular spacings, varying element sizes, and non-uniform alignments. These characteristics made it difficult to implement using flexbox or grid with simple gaps, margins, and paddings, and required precise, element by element positioning. |
| 17 | + |
| 18 | + |
| 19 | +*A draft of the hackts.ch page with box model inspection, showing the irregular spacing and alignment requirements.* |
| 20 | + |
| 21 | +I also experimented with Figma to code tools such as [Builder.io’s Figma plugin](https://www.builder.io/c/docs/figma-to-builder) but the results were disappointing. The generated markup was verbose and composed of inline styles, with font styling defined multiple times instead of integrating with the existing font definitions. There was no clear component structure or hierarchy, which made the output unpleasant to read. |
| 22 | + |
| 23 | +## Retrospective Approaches |
| 24 | + |
| 25 | +Looking back, several methods might have eased the process: |
| 26 | + |
| 27 | +- Rendering sections as images with defined clickable areas using [`<area>`](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/area) elements |
| 28 | +- Using background images with text overlays |
| 29 | +- Exporting directly from Figma as SVGs to keep both vector shapes and text, applying CSS classes to [SVG elements](https://developer.mozilla.org/en-US/docs/Web/SVG/Reference/Element/style) for consistent styling ([MDN: Styling SVG with CSS](https://developer.mozilla.org/en-US/docs/Web/SVG/Tutorial/SVG_and_CSS)) |
| 30 | +- Adding overlays for pixel accurate alignment adjustments |
| 31 | + |
| 32 | +While each could have been useful, all still required manual editing of pixel values. |
| 33 | + |
| 34 | +## A Possible Solution |
| 35 | + |
| 36 | +A more efficient solution could be to build a GUI editor in Rails for placing visual components. |
| 37 | +Such an editor could work similarly to [JavaFX Scene Builder](https://openjfx.io/scenebuilder/) or other drag and drop UI layout tools. Developers could place images, text, and overlays directly in the browser, adjusting positions interactively instead of editing CSS values and refreshing the page. |
| 38 | + |
| 39 | +The implementation could store element coordinates and properties in the database, with `position: relative` containers handling placement in the final rendering. This would allow pixel accurate adjustments without touching the stylesheets for every change. |
| 40 | + |
| 41 | +An approach could borrow concepts from [Herb LSP](https://marcoroth.dev/posts/introducing-herb), which proposes a language server for HTML and embedded Ruby, but adapt them to support live visual positioning of components. |
| 42 | +As [David Heinemeier Hansson](https://world.hey.com/dhh/finding-the-last-editor-dae701cc) has noted, there is value in keeping the development process grounded in simple, direct editing environments. A GUI editor should complement text based workflows, not replace them, allowing developers to maintain clean and maintainable code while benefiting from faster layout adjustments. |
| 43 | + |
| 44 | +## Conclusion |
| 45 | + |
| 46 | +Highly customised designs often make standard frameworks and layout approaches less effective. Even with Sass for flexibility, aligning to the Figma design became a slow and manual process. A GUI editor for Rails, inspired by tools like Scene Builder, could provide an efficient and interactive way to place and adjust components, reducing the need for repetitive code edits while keeping the underlying code approachable. |
0 commit comments