From 5ee5960e849890275b9c4c70dc9b5b39d1bb8eb2 Mon Sep 17 00:00:00 2001 From: Jan Bajena Date: Thu, 30 Jul 2020 21:43:39 +0200 Subject: [PATCH] Support multiple tab components Hi, first of all thank you for your cool framework. I really have fun working with it :) I'm building an app for building flashcard sets in which I decided to use tabs component for switching between different languages. However I've noticed that current version assumes that there'll only be a single tab component on the page. I overcame it in my project by changing `=` (attribute equals) selector to `$=` (attribute ends with) selector. This allows me to generate different tab IDs for different flashcards, like this: ```ruby <% tab_name = "tabs_#{word.id}" %> <% tab1_id = "#{tab_name}_tab1" %> <% tab2_id = "#{tab_name}_tab2" %>

<%= word.question %>

<% if word.question_example %>

<%= word.question_example %>

<% end %>

<%= word.answer %>

<% if word.answer_example %>

<%= word.answer_example %>

<% end %>
``` Here's a video to present how it works after the change: https://www.loom.com/share/6de1e443314f44f49c7b91e9b5875c93 Hope someone finds it useful --- src/components/_tabs.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/_tabs.scss b/src/components/_tabs.scss index 1d8fb84..1c15e46 100644 --- a/src/components/_tabs.scss +++ b/src/components/_tabs.scss @@ -13,7 +13,7 @@ } @for $num from 1 through 5 { - &[id='tab#{$num}']:checked~div[id='content#{$num}'] { + &[id$='tab#{$num}']:checked~div[id$='content#{$num}'] { display: block; } }