railwind 0.1.15 → 0.1.22

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 674e82eb61752a36f11767cc9b2913b22859bd47c1a286951f156f38dfeb7b4f
4
- data.tar.gz: f9d0378bc8d270c4d72074e81b85767ba6e682a10797e8543055285f6e31c069
3
+ metadata.gz: f6cf837cdb5f28533bc63a94cb9f7514b5a823783dcdc34f94e55584dbe3d110
4
+ data.tar.gz: 90cc46565b4091fd9172fb367c690a7aecbc56dac3e283297e90f4544d2aa888
5
5
  SHA512:
6
- metadata.gz: f5d61e8dfa5a66a9610c6e9903804d5cb0c156e01300823fbdd18a581d303b24c6252a01278aaa899f3ec598aa61826a052739f880665b90183a3bb10ba68ba6
7
- data.tar.gz: 9e348ef0d5027de7b59270784809270c9be406063000054c705fa30152a5dd28bdd8db62fa392323eacf9969ae7a81041800468a70ee2a42f5386dd5ec07000f
6
+ metadata.gz: 42e5379eac7632028eab000f4719ca841654cefa8e909aabd42d248f59a0e77339dcac551a69386db838e52a3bc862e1126403e01aba18f150f2e68f61e0b59b
7
+ data.tar.gz: 22b23867c36cbcc4d7a1fb3afa6799674aceb4f9977716063e5003e9fc9b107f62d0a2a7c96d6ff6fd14696d32288a9f794aea5df64501b8cef4dc0131b695e7
data/README.md CHANGED
@@ -1,8 +1,11 @@
1
1
  # Railwind
2
2
 
3
- TODO: Delete this and the text below, and describe your gem
3
+ [![Gem Version](https://badge.fury.io/rb/railwind.svg)](https://badge.fury.io/rb/railwind)
4
+
5
+ Coming Soon!
6
+
7
+ Railwind is a customizable ViewComponent UI library that leverages the power of Tailwind CSS. It provides a set of reusable and configurable UI components that can be easily integrated into any Rails application. With Railwind, developers can rapidly build beautiful and responsive user interfaces with less effort and time.
4
8
 
5
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/railwind`. To experiment with that code, run `bin/console` for an interactive prompt.
6
9
 
7
10
  ## Installation
8
11
 
@@ -33,3 +36,16 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERN
33
36
  ## License
34
37
 
35
38
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
39
+
40
+
41
+
42
+
43
+ TODO:
44
+
45
+
46
+ - Building the gemspec: gem build railwind.gemspec
47
+
48
+ - Deploying: gem push railwind-<version>.gem
49
+
50
+
51
+ - Updating in consumer app: bundle update railwind
@@ -5,8 +5,8 @@ module Railwind
5
5
  source_root File.expand_path('templates', __dir__)
6
6
 
7
7
  def create_component_file
8
- copy_file "button_component.rb", "app/components/button_component.rb"
9
- copy_file "_button_component.html.erb", "app/components/button_component.html.erb"
8
+ copy_file "button/button_component.rb", "app/components/button_component.rb"
9
+ copy_file "button/_button_component.html.erb", "app/components/button_component.html.erb"
10
10
  end
11
11
  end
12
12
  end
@@ -0,0 +1,12 @@
1
+ require 'rails/generators'
2
+
3
+ module Railwind
4
+ class CardGenerator < Rails::Generators::Base
5
+ source_root File.expand_path('templates', __dir__)
6
+
7
+ def create_component_file
8
+ copy_file "card/card_component.rb", "app/components/card_component.rb"
9
+ copy_file "card/_card_component.html.erb", "app/components/card_component.html.erb"
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,13 @@
1
+ require 'rails/generators'
2
+
3
+ module Railwind
4
+ class TabGenerator < Rails::Generators::Base
5
+ source_root File.expand_path('templates', __dir__)
6
+
7
+ def create_component_file
8
+ copy_file "tabs/tab_component.rb", "app/components/tab_component.rb"
9
+ copy_file "tabs/_tab_component.html.erb", "app/components/tab_component.html.erb"
10
+ copy_file "tabs/tabs_controller.js", "app/javascript/controllers/tabs_controller.js"
11
+ end
12
+ end
13
+ end
@@ -1,5 +1,5 @@
1
1
  <% base_classes =
2
- "px-4 py-2 rounded-full transition hover:opacity-90 hover:shadow border-2 font-semibold"
2
+ "px-4 py-2 rounded-full transition hover:opacity-90 hover:shadow border-2 font-semibold flex items-center justify-center gap-2 w-full"
3
3
  variant_classes =
4
4
  case @variant
5
5
  when "primary"
@@ -18,6 +18,6 @@ variant_classes =
18
18
  tailwind_classes = "#{base_classes} #{variant_classes}" %>
19
19
 
20
20
  <button type="<%= @type %>" class="<%= tailwind_classes %>">
21
- <%= @text %>
22
21
  <%= content %>
22
+ <%= @text %>
23
23
  </button>
@@ -0,0 +1,15 @@
1
+ <div
2
+ class="
3
+ w-full
4
+ rounded-xl
5
+ bg-white
6
+ shadow
7
+ shadow
8
+ border
9
+ border-solid
10
+ borde-gray-300
11
+ p-6
12
+ "
13
+ >
14
+ <%= content %>
15
+ </div>
@@ -0,0 +1,4 @@
1
+
2
+ class CardComponent < ViewComponent::Base
3
+
4
+ end
@@ -0,0 +1,29 @@
1
+ <div data-id="<%= @id %>" class="tabs" data-controller="tabs">
2
+
3
+ <div
4
+ class="
5
+ flex
6
+ items-center
7
+ gap-4
8
+ mb-2
9
+ w-full
10
+ border-b-2
11
+ border-solid
12
+ border-gray-200
13
+ "
14
+ >
15
+ <% @tabs.each_with_index do |tab, index| %>
16
+ <button
17
+ class="border-b-2 border-solid mb-[-2px] font-semibold"
18
+ data-action="tabs#switchTab"
19
+ data-tab-index="<%= index %>"
20
+ >
21
+ <%= tab %>
22
+ </button>
23
+ <% end %>
24
+ </div>
25
+
26
+ <div class="tab-content hidden">
27
+ <%= content %>
28
+ </div>
29
+ </div>
@@ -0,0 +1,7 @@
1
+ class TabComponent < ViewComponent::Base
2
+ def initialize(id:, tabs:)
3
+ @id = id
4
+ @tabs = tabs
5
+ end
6
+ end
7
+
@@ -0,0 +1,48 @@
1
+ import { Controller } from "@hotwired/stimulus";
2
+
3
+ export default class extends Controller {
4
+ activeIndex = 0;
5
+
6
+ connect() {
7
+ this.activeIndex = 0;
8
+ this.showTab();
9
+ const tabs = this.element.querySelectorAll(".tab-content");
10
+ tabs[0].classList.remove("hidden");
11
+ }
12
+
13
+ switchTab(event) {
14
+ this.activeIndex = parseInt(event.currentTarget.dataset.tabIndex);
15
+ this.showTab();
16
+ }
17
+
18
+ showTab() {
19
+ // Get all elements with the class "tab-content".
20
+ // Should only be the one within the tab_component.html.erb partial
21
+ const tabs = this.element.querySelectorAll(".tab-content");
22
+
23
+ // Iterate over each tab
24
+ tabs.forEach((tab, index) => {
25
+ // Get all direct children of the current tab
26
+ const directChildren = Array.from(tab.children);
27
+
28
+ // Iterate over each direct child to hide or show
29
+ directChildren.forEach((child, i) => {
30
+ let element = this.element.querySelector(
31
+ `button[data-tab-index="${i}"]`
32
+ );
33
+
34
+ if (i === this.activeIndex) {
35
+ child.classList.remove("hidden");
36
+ element.classList.add("border-gray-900");
37
+ element.classList.add("text-gray-900");
38
+ element.classList.remove("text-gray-400");
39
+ } else {
40
+ child.classList.add("hidden");
41
+ element.classList.remove("border-gray-900");
42
+ element.classList.remove("text-gray-900")
43
+ element.classList.add("text-gray-400");
44
+ }
45
+ });
46
+ });
47
+ }
48
+ }
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Railwind
4
- VERSION = "0.1.15"
4
+ VERSION = "0.1.22"
5
5
  end
data/lib/railwind.rb CHANGED
@@ -2,6 +2,9 @@
2
2
 
3
3
  require_relative "railwind/version"
4
4
  require_relative "railwind/generators/button_generator"
5
+ require_relative "railwind/generators/callout_generator"
6
+ require_relative "railwind/generators/card_generator"
7
+ require_relative "railwind/generators/tab_generator"
5
8
 
6
9
  module Railwind
7
10
  class Error < StandardError; end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: railwind
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.15
4
+ version: 0.1.22
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christian Bryant
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-10-28 00:00:00.000000000 Z
11
+ date: 2023-11-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -55,8 +55,15 @@ files:
55
55
  - Rakefile
56
56
  - lib/railwind.rb
57
57
  - lib/railwind/generators/button_generator.rb
58
- - lib/railwind/generators/templates/_button_component.html.erb
59
- - lib/railwind/generators/templates/button_component.rb
58
+ - lib/railwind/generators/card_generator.rb
59
+ - lib/railwind/generators/tab_generator.rb
60
+ - lib/railwind/generators/templates/button/_button_component.html.erb
61
+ - lib/railwind/generators/templates/button/button_component.rb
62
+ - lib/railwind/generators/templates/card/_card_component.html.erb
63
+ - lib/railwind/generators/templates/card/card_component.rb
64
+ - lib/railwind/generators/templates/tabs/_tab_component.html.erb
65
+ - lib/railwind/generators/templates/tabs/tab_component.rb
66
+ - lib/railwind/generators/templates/tabs/tabs_controller.js
60
67
  - lib/railwind/version.rb
61
68
  - railwind.gemspec
62
69
  - sig/railwind.rbs