railwind 0.1.21 → 0.1.23

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: 16d86a6ed36836b89c2564064bb3070d0f1352e9caa2c12995e26bf5b9a5e6ed
4
- data.tar.gz: 4b3837233270a86fe962e91b102aed2c80dae80eb7409232addf2f1d455541ef
3
+ metadata.gz: db5ccd80f2a24cec982ac3275e008927303e0e2b36c3cda6bc196ff59605b3de
4
+ data.tar.gz: 831847785839c6944f4ac0cf1f3f56a0d7e94552b6455defbfcc67c455e13cc7
5
5
  SHA512:
6
- metadata.gz: eb561a4f79a49e08fe60ef3d2b1a208ba5dbbb267c85202d5d238138a17a6b3e9a75e5f023a3c8057d44afd51fa6784d18643c1c7687e25c21b4c1297ea2e42e
7
- data.tar.gz: cd5ebbd53140b012fc88f37b88cea9e7ea9b753f619ff731aed80a3f4a319a2cb444d14e1f29d118d8d5d0f440fb2a984b9c43f36d98b5cb7061d64f5638e83b
6
+ metadata.gz: 5b0884e3517c1c2f0660d6eb6687de37206b8febe2a1af957a22e11fc5e19593c5db0a473240e605facba16c1bee76f30ba504a4a4c440a6ae61c60bc26cd84f
7
+ data.tar.gz: c2cb347554d3e7c684c0be6caff7e8b555a8285ffa9d4c0c2d9bb3f4e98073a7c0e60f3f1072fecb33bc4ea8071d493ea229f11ce16a64309909d95146c61507
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2023-10-27
4
+
5
+ - Initial release
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2023 TODO: Write your name
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,51 @@
1
+ # Railwind
2
+
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.
8
+
9
+
10
+ ## Installation
11
+
12
+ TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
13
+
14
+ Install the gem and add to the application's Gemfile by executing:
15
+
16
+ $ bundle add UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
17
+
18
+ If bundler is not being used to manage dependencies, install the gem by executing:
19
+
20
+ $ gem install UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
21
+
22
+ ## Usage
23
+
24
+ TODO: Write usage instructions here
25
+
26
+ ## Development
27
+
28
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
29
+
30
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
31
+
32
+ ## Contributing
33
+
34
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/railwind.
35
+
36
+ ## License
37
+
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
data/Rakefile ADDED
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ task default: %i[]
@@ -0,0 +1,12 @@
1
+ require 'rails/generators'
2
+
3
+ module Railwind
4
+ class ButtonGenerator < Rails::Generators::Base
5
+ source_root File.expand_path('templates', __dir__)
6
+
7
+ def create_component_file
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
+ end
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ require 'rails/generators'
2
+
3
+ module Railwind
4
+ class CalloutGenerator < Rails::Generators::Base
5
+ source_root File.expand_path('templates', __dir__)
6
+
7
+ def create_component_file
8
+ copy_file "callout/callout_component.rb", "app/components/callout_component.rb"
9
+ copy_file "callout/_callout_component.html.erb", "app/components/callout_component.html.erb"
10
+ end
11
+ end
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
@@ -0,0 +1,23 @@
1
+ <% base_classes =
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
+ variant_classes =
4
+ case @variant
5
+ when "primary"
6
+ "border-black bg-black text-white"
7
+ when "secondary"
8
+ "border-gray-500 bg-gray-500 text-white"
9
+ when "outline"
10
+ "border-gray-500 text-gray-500"
11
+ when "ghost"
12
+ "border-transparent bg-transparent text-gray-500 hover:bg-gray-200"
13
+ when "danger"
14
+ "border-red-500 bg-red-500 text-white"
15
+ else
16
+ "bg-blue-500 text-white"
17
+ end
18
+ tailwind_classes = "#{base_classes} #{variant_classes}" %>
19
+
20
+ <button type="<%= @type %>" class="<%= tailwind_classes %>">
21
+ <%= content %>
22
+ <%= @text %>
23
+ </button>
@@ -0,0 +1,7 @@
1
+ class ButtonComponent < ViewComponent::Base
2
+ def initialize(text:, variant: "primary", type: "button")
3
+ @text = text
4
+ @variant = variant
5
+ @type = type
6
+ end
7
+ end
@@ -0,0 +1,22 @@
1
+ <% base_classes = "border border border-2 rounded-lg p-4 w-full"
2
+
3
+ variant_classes =
4
+ case @variant
5
+ when "success"
6
+ "bg-green-100 border-green-500 text-green-700"
7
+ when "warning"
8
+ "bg-yellow-100 border-yellow-500 text-yellow-700"
9
+ when "danger"
10
+ "bg-red-100 border-red-500 text-red-700"
11
+ else
12
+ "bg-blue-100 border-blue-500 text-blue-700"
13
+ end
14
+
15
+ tailwind_classes = "#{base_classes} #{variant_classes}" %>
16
+
17
+ <div role="alert" class="<%= tailwind_classes %>">
18
+
19
+ <h3 class="font-semibold text-lg"><%= @title %></h3>
20
+ <p><%= @description %></p>
21
+
22
+ </div>
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ class CalloutComponent < ViewComponent::Base
4
+
5
+ VALID_VARIANTS = ['success', 'info', 'warning', 'danger'].freeze
6
+
7
+ def initialize(title:, description:, variant:)
8
+ @title = title
9
+ @description = description
10
+ @variant = validate_variant(variant)
11
+ end
12
+
13
+ private
14
+
15
+ def validate_variant(variant)
16
+ raise ArgumentError, "Invalid variant" unless VALID_VARIANTS.include?(variant)
17
+ variant
18
+ end
19
+
20
+ end
21
+
@@ -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
+ }
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Railwind
4
+ VERSION = "0.1.23"
5
+ end
data/lib/railwind.rb ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "railwind/version"
4
+ require_relative "railwind/generators/button_generator"
5
+ require_relative "railwind/generators/card_generator"
6
+ require_relative "railwind/generators/tab_generator"
7
+ require_relative "railwind/generators/callout_generator"
8
+
9
+ module Railwind
10
+ class Error < StandardError; end
11
+ # Your code goes here...
12
+ end
data/railwind.gemspec ADDED
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/railwind/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "railwind"
7
+ spec.version = Railwind::VERSION
8
+ spec.authors = ["Christian Bryant"]
9
+ spec.email = ["hi@christianlovescode.com"]
10
+
11
+ spec.summary = "a customizeable ViewComponent UI library baked with Tailwind CSS."
12
+ spec.description = "<COMING SOON> 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."
13
+ spec.homepage = "https://github.com/christianlovescode/railwind"
14
+ spec.license = "MIT"
15
+ spec.required_ruby_version = ">= 3.2.0"
16
+
17
+ # spec.metadata["allowed_push_host"] = "https://christianbryant.dev"
18
+
19
+ spec.metadata["homepage_uri"] = spec.homepage
20
+ spec.metadata["source_code_uri"] = "https://github.com/christianlovescode/railwind"
21
+ spec.metadata["changelog_uri"] = "https://github.com/christianlovescode/railwind"
22
+
23
+ # Specify which files should be added to the gem when it is released.
24
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
25
+ spec.files = Dir.chdir(__dir__) do
26
+ `git ls-files -z`.split("\x0").reject do |f|
27
+ (File.expand_path(f) == __FILE__) ||
28
+ f.start_with?(*%w[bin/ test/ spec/ features/ .git .circleci appveyor Gemfile]) ||
29
+ f.end_with?('.gem') # Exclude any .gem files
30
+ end
31
+ end
32
+ spec.bindir = "exe"
33
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
34
+ spec.require_paths = ["lib"]
35
+
36
+ spec.add_dependency "rails", "~> 7.0"
37
+ spec.add_dependency "view_component", "~> 3.0"
38
+
39
+ # For more information and examples about making a new gem, check out our
40
+ # guide at: https://bundler.io/guides/creating_gem.html
41
+ end
data/sig/railwind.rbs ADDED
@@ -0,0 +1,4 @@
1
+ module Railwind
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ 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.21
4
+ version: 0.1.23
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-31 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
@@ -48,7 +48,28 @@ email:
48
48
  executables: []
49
49
  extensions: []
50
50
  extra_rdoc_files: []
51
- files: []
51
+ files:
52
+ - CHANGELOG.md
53
+ - LICENSE.txt
54
+ - README.md
55
+ - Rakefile
56
+ - lib/railwind.rb
57
+ - lib/railwind/generators/button_generator.rb
58
+ - lib/railwind/generators/callout_generator.rb
59
+ - lib/railwind/generators/card_generator.rb
60
+ - lib/railwind/generators/tab_generator.rb
61
+ - lib/railwind/generators/templates/button/_button_component.html.erb
62
+ - lib/railwind/generators/templates/button/button_component.rb
63
+ - lib/railwind/generators/templates/callout/_callout_component.html.erb
64
+ - lib/railwind/generators/templates/callout/callout_component.rb
65
+ - lib/railwind/generators/templates/card/_card_component.html.erb
66
+ - lib/railwind/generators/templates/card/card_component.rb
67
+ - lib/railwind/generators/templates/tabs/_tab_component.html.erb
68
+ - lib/railwind/generators/templates/tabs/tab_component.rb
69
+ - lib/railwind/generators/templates/tabs/tabs_controller.js
70
+ - lib/railwind/version.rb
71
+ - railwind.gemspec
72
+ - sig/railwind.rbs
52
73
  homepage: https://github.com/christianlovescode/railwind
53
74
  licenses:
54
75
  - MIT