{"id":10163,"date":"2025-10-15T23:32:39","date_gmt":"2025-10-15T23:32:39","guid":{"rendered":"https:\/\/hellonitish.com\/blog\/?p=10163"},"modified":"2025-12-10T04:47:44","modified_gmt":"2025-12-10T04:47:44","slug":"a-shopify-section-that-bends-light-literally","status":"publish","type":"post","link":"https:\/\/hellonitish.com\/blog\/a-shopify-section-that-bends-light-literally\/","title":{"rendered":"A Shopify Section That Bends Light (Literally)"},"content":{"rendered":"\n<p>Every now and then a client asks for something that sounds simple and turns into a mini physics experiment. This time, it was a custom Shopify section from my long term client Charles. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">The Brief<\/h2>\n\n\n\n<p>Charles wanted an eye-catching section that highlighted his brand&#8217;s unique Trinitas Botanica<sup>TM<\/sup> Methodus philosophy. <\/p>\n\n\n\n<p>He had two major requirements:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Some text has to wrap around a prism and the text can vary in length.<\/li>\n\n\n\n<li>A light ray enters the prism from the left and emerges as a rainbow on the right.<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">My Process<\/h2>\n\n\n\n<p>I always try to strike a good balance of performance, extensibility, and maintainability when working on a client project. This requires careful planning before I start writing the actual code.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Creating the Incoming Ray and the Rainbow<\/h3>\n\n\n\n<p>In this case, my first instinct was to use <strong>Canvas<\/strong> or <strong>WebGL<\/strong> to animate the rainbow with JavaScript. But after a bit of thought, I realized I could pull off the same effect more cleanly with just some clever CSS.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\" class=\"n-bshadow n-round-x2\"><img decoding=\"async\" width=\"1024\" height=\"565\" loading=\"lazy\" src=\"https:\/\/hellonitish.com\/blog\/wp-content\/uploads\/2025\/12\/blank-rainbow-1024x565.webp\" alt=\"\" class=\"wp-image-10310\" srcset=\"https:\/\/hellonitish.com\/blog\/wp-content\/uploads\/2025\/12\/blank-rainbow-1024x565.webp 1024w, https:\/\/hellonitish.com\/blog\/wp-content\/uploads\/2025\/12\/blank-rainbow-320x176.webp 320w, https:\/\/hellonitish.com\/blog\/wp-content\/uploads\/2025\/12\/blank-rainbow-460x254.webp 460w, https:\/\/hellonitish.com\/blog\/wp-content\/uploads\/2025\/12\/blank-rainbow-640x353.webp 640w, https:\/\/hellonitish.com\/blog\/wp-content\/uploads\/2025\/12\/blank-rainbow-800x441.webp 800w, https:\/\/hellonitish.com\/blog\/wp-content\/uploads\/2025\/12\/blank-rainbow-1200x662.webp 1200w, https:\/\/hellonitish.com\/blog\/wp-content\/uploads\/2025\/12\/blank-rainbow.webp 1393w\" sizes=\"auto, (max-width: 767px) 100vw, (min-width: 768px) and (max-width: 1300px) 66.67vw, 765px\" \/><\/figure>\n\n\n\n<p>I created two <code>div<\/code> elements: one for the <strong>incoming ray<\/strong> and one for the <strong>emergent rainbow<\/strong>.<\/p>\n\n\n\n<p>The incoming ray was simple enough as it was just a thin white rectangle. However, getting its <strong>rotation and alignment<\/strong> right took some trial and error.<\/p>\n\n\n\n<p>For the rainbow, I used a <strong>linear gradient background<\/strong> to simulate the colors of refracted light. Then I shaped it so that it\u2019s <strong>narrow at one end and wider at the other<\/strong> using a mix of <code>perspective<\/code> and <code>rotateY<\/code>. That gave it the illusion of spreading light. This adjustment was very tricky to get right and required plenty of fine-tuning.<\/p>\n\n\n\n<p>Finally, I added <strong>subtle rotation animations<\/strong> with <code>rotateZ<\/code> and <code>@keyframes<\/code> to make both rays oscillate slightly. Synchronizing both animations was simply a matter of adjusting the animation values so that the rays always move in opposite directions. Once that clicked, the whole thing came alive. A tiny prism made of pure CSS!<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Making the Text Flow Around the Prism<\/h3>\n\n\n\n<p>The prism itself was an image that Charles provided. My job was to make the text flow around it instead of just filling up a flat, rectangular block.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\" class=\"n-bshadow n-round-x2\"><img decoding=\"async\" width=\"1024\" height=\"560\" loading=\"lazy\" src=\"https:\/\/hellonitish.com\/blog\/wp-content\/uploads\/2025\/12\/rainbow-with-text-1024x560.webp\" alt=\"\" class=\"wp-image-10311\" srcset=\"https:\/\/hellonitish.com\/blog\/wp-content\/uploads\/2025\/12\/rainbow-with-text-1024x560.webp 1024w, https:\/\/hellonitish.com\/blog\/wp-content\/uploads\/2025\/12\/rainbow-with-text-320x175.webp 320w, https:\/\/hellonitish.com\/blog\/wp-content\/uploads\/2025\/12\/rainbow-with-text-460x252.webp 460w, https:\/\/hellonitish.com\/blog\/wp-content\/uploads\/2025\/12\/rainbow-with-text-640x350.webp 640w, https:\/\/hellonitish.com\/blog\/wp-content\/uploads\/2025\/12\/rainbow-with-text-800x438.webp 800w, https:\/\/hellonitish.com\/blog\/wp-content\/uploads\/2025\/12\/rainbow-with-text-1200x656.webp 1200w, https:\/\/hellonitish.com\/blog\/wp-content\/uploads\/2025\/12\/rainbow-with-text.webp 1521w\" sizes=\"auto, (max-width: 767px) 100vw, (min-width: 768px) and (max-width: 1300px) 66.67vw, 765px\" \/><\/figure>\n\n\n\n<p>I wrapped the entire prism visual in a container element and used the <strong>CSS <code>shape-outside<\/code><\/strong> property to match the slope of the prism. This made the text curve naturally around its edges, giving the layout a more organic flow.<\/p>\n\n\n\n<p>The incoming and outgoing rays were only meant to animate <em>behind<\/em> the text, not push it out of place, so I positioned them carefully using <strong>absolute positioning<\/strong>.<\/p>\n\n\n\n<p>Since <code>shape-outside<\/code> requires the element to float, the wrapper naturally jumped out of the document flow, which collapsed the parent element that had the text and the prism visual container. Instead of over-engineering it, I simply cleared the next sibling. Quick, clean, and reliable.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Giving Charles Full Control<\/h3>\n\n\n\n<p>Charles wanted this section on all pages of his website. That meant I needed a setup where he could <strong>update the text in one central place<\/strong> and have it propagate everywhere automatically.<\/p>\n\n\n\n<p>I tackled this by leveraging Shopify\u2019s <strong>theme settings<\/strong>. The section pulls default text from the theme\u2019s central configuration, so any updates there automatically reflect across the site.<\/p>\n\n\n\n<p>At the same time, I wanted Charles to have the option to <strong>override the content on individual pages<\/strong>. I added per-page overrides in the section settings, allowing custom changes without breaking the global defaults.<\/p>\n\n\n\n<p>I also gave him the flexibility to <strong>add up to three additional points<\/strong> on any individual page, in addition to Essentia, Viriditas, and Allevatio, if he chooses.<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Every now and then a client asks for something that sounds simple and turns into a mini physics experiment. This time, it was a custom Shopify section from my long term client Charles. The Brief Charles wanted an eye-catching section that highlighted his brand&#8217;s unique Trinitas BotanicaTM Methodus philosophy. He had two major requirements: My [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":10173,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23],"tags":[],"class_list":["post-10163","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-case-studies"],"_links":{"self":[{"href":"https:\/\/hellonitish.com\/blog\/wp-json\/wp\/v2\/posts\/10163","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hellonitish.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hellonitish.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hellonitish.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/hellonitish.com\/blog\/wp-json\/wp\/v2\/comments?post=10163"}],"version-history":[{"count":5,"href":"https:\/\/hellonitish.com\/blog\/wp-json\/wp\/v2\/posts\/10163\/revisions"}],"predecessor-version":[{"id":10312,"href":"https:\/\/hellonitish.com\/blog\/wp-json\/wp\/v2\/posts\/10163\/revisions\/10312"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/hellonitish.com\/blog\/wp-json\/wp\/v2\/media\/10173"}],"wp:attachment":[{"href":"https:\/\/hellonitish.com\/blog\/wp-json\/wp\/v2\/media?parent=10163"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hellonitish.com\/blog\/wp-json\/wp\/v2\/categories?post=10163"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hellonitish.com\/blog\/wp-json\/wp\/v2\/tags?post=10163"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}