bsvc 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 2856d5ea8ea38c3ca3a4a0d550bc8dbe67d078998e6a07d614ea677dea89b49a
4
+ data.tar.gz: 7d0173c3461403d830628ce47a85d8f609a91485d64b2e55dd97169a49a09249
5
+ SHA512:
6
+ metadata.gz: d361e0170595f59b984bd654e1ef07e333d3e8730236fa4a984580b9523a1dce172b4cd4e6c6d8bae8faa66d8fc9f96804ff4e19c5d4175bb7526b3b9c316fa2
7
+ data.tar.gz: ab225fd11a3841c4818fff35a61c24512634c765b083888e7f93585ad6dca8c1c68561920b2adaee22afa8e087cb95c13c754d800e8580b1feeb75d09e72592a
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.6.3
7
+ before_install: gem install bundler -v 1.17.2
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in bsvc.gemspec
6
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2023 nmcneany
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,59 @@
1
+ # Bootstrap ViewComponents (BSVC)
2
+
3
+ Bootstrap ViewComponents is a component library built on [Bootstrap](https://github.com/twbs/bootstrap) and [VeiwComponent](https://github.com/viewcomponent/view_component).
4
+
5
+ BSVC offers a component based development workflow similar to React or Vue by neatly packaging Bootstrap into components to make your Rails UI development faster, easier and more fun!
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'bsvc'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install bsvc
22
+
23
+ ## Usage
24
+
25
+ TODO: Examples for using components coming soon.
26
+
27
+ ## Customizing Components
28
+
29
+ If you need to customize components you can copy them into your application.
30
+
31
+ ### All Components
32
+
33
+ To copy all compoents into your app run:
34
+
35
+ ```ruby
36
+ rails g bsvc:components
37
+ ```
38
+
39
+ This will copy over all of BSVC components and helpers. It will create a `components/` directory inside of `app/`. All helpers will be placed inside `app/helpers/`.
40
+
41
+ ### A Single Component
42
+
43
+ ```ruby
44
+ rails g bsvc:component --name COMPONENT_NAME
45
+ ```
46
+ `--name` should be the top level directory of the coponent you want in `app/components/`
47
+
48
+ ## Roadmap
49
+ - Continue building out components
50
+ - Continue creating usage doc
51
+ - Continue add to README.md
52
+
53
+ ## Contributing
54
+
55
+ Bug reports and pull requests are welcome on GitHub at https://github.com//Nickiam7/bsvc. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
56
+
57
+ ## License
58
+
59
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,11 @@
1
+ <div class="card <%= @classes %>" style="<%= @styles %>">
2
+ <% if header? %>
3
+ <%= header %>
4
+ <% end %>
5
+ <div class="card-body">
6
+ <%= content %>
7
+ </div>
8
+ <% if footer? %>
9
+ <%= footer %>
10
+ <% end %>
11
+ </div>
@@ -0,0 +1,63 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Card
4
+ def default_plus_passed_classes(defaults, classes)
5
+ "#{defaults} #{classes}".strip
6
+ end
7
+
8
+ module_function :default_plus_passed_classes
9
+
10
+ class CardComponent < ViewComponent::Base
11
+ renders_one :header, 'HeaderComponent'
12
+ renders_one :footer, 'FooterComponent'
13
+
14
+ def initialize(**options)
15
+ @classes = options[:classes]
16
+ @styles = options[:styles]
17
+ end
18
+
19
+ class HeaderComponent < ViewComponent::Base
20
+
21
+ def initialize(**options)
22
+ @tag = options[:tag] || :h2
23
+ @classes = options[:classes]
24
+ @styles = options[:styles]
25
+
26
+ @default_classses = 'card-header'
27
+ end
28
+
29
+ def call
30
+ content_tag(@tag,
31
+ content,
32
+ class: Card.default_plus_passed_classes(
33
+ @default_classses,
34
+ @classes
35
+ ),
36
+ style: @styles
37
+ )
38
+ end
39
+ end
40
+
41
+ class FooterComponent < ViewComponent::Base
42
+
43
+ def initialize(**options)
44
+ @tag = options[:tag] || :div
45
+ @classes = options[:classes]
46
+ @styles = options[:styles]
47
+
48
+ @default_classses = 'card-footer text-muted'
49
+ end
50
+
51
+ def call
52
+ content_tag(@tag,
53
+ content,
54
+ class: Card.default_plus_passed_classes(
55
+ @default_classses,
56
+ @classes
57
+ ),
58
+ style: @styles
59
+ )
60
+ end
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Grid
4
+ module Columns
5
+ class ColumnsComponent < ViewComponent::Base
6
+ BREAK_POINTS = [:xs, :sm, :md, :lg, :xl, :xxl]
7
+
8
+ def initialize(**options)
9
+ @columns = options[:col]
10
+ @offsets = options[:offset]
11
+ @classes = options[:classes]
12
+ @styles = options[:styles]
13
+ end
14
+
15
+ def call
16
+ content_tag(:div,
17
+ content,
18
+ class: column_class_builder,
19
+ style: @styles,
20
+ )
21
+ end
22
+
23
+ private
24
+
25
+ def column_class_builder
26
+ "#{column_breakpoint} #{column_offset} #{@classes}"
27
+ end
28
+
29
+ def class_parser(option, klass)
30
+ option.map do |key, value|
31
+ if BREAK_POINTS.include?(key)
32
+ "#{klass}-#{key}-#{value} "
33
+ end
34
+ end.join('').strip
35
+ end
36
+
37
+ def column_breakpoint
38
+ class_parser(@columns, 'col')
39
+ end
40
+
41
+ def column_offset
42
+ class_parser(@offsets, 'offset')
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,3 @@
1
+ <div class="<%= container_class %> <%= @classes %>">
2
+ <%= content %>
3
+ </div>
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Grid
4
+ module Container
5
+ class ContainerComponent < ViewComponent::Base
6
+ def initialize(**options)
7
+ @container = options[:container]
8
+ @classes = options[:classes]
9
+
10
+ @container_class = container_class
11
+ end
12
+
13
+ private
14
+
15
+ def container_class
16
+ @container.present? ? @container : 'container'
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Grid
4
+ module Row
5
+ class RowComponent < ViewComponent::Base
6
+ renders_many :columns, Columns::ColumnsComponent
7
+
8
+ def initialize(**options)
9
+ @classes = options[:classes]
10
+ @styles = options[:styles]
11
+ end
12
+
13
+ def call
14
+ content_tag(:div,
15
+ content,
16
+ class: default_plus_passed_classes,
17
+ style: @styles
18
+ )
19
+ end
20
+
21
+ private
22
+
23
+ def default_plus_passed_classes
24
+ "row #{@classes}".strip
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Heading
4
+ class HComponent < ViewComponent::Base
5
+ def initialize(**options)
6
+ @text = options[:text]
7
+ @tag = options[:tag]
8
+ @classes = options[:classes]
9
+ @styles = options[:styles]
10
+ end
11
+
12
+ def call
13
+ content_tag(@tag,
14
+ content || @text,
15
+ class: @classes,
16
+ style: @styles
17
+ )
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_strin_literal: true
2
+
3
+ module Card
4
+ module CardHelper
5
+ def card(**options)
6
+ render(Card::CardComponent.new(**options)) do |c|
7
+ yield(c)
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,9 @@
1
+ module Grid
2
+ module ContainerHelper
3
+ def container(**options)
4
+ render(Container::ContainerComponent.new(**options)) do
5
+ yield
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module Grid
2
+ module RowHelper
3
+ def row(**options)
4
+ render(Row::RowComponent.new(**options)) do |c|
5
+ yield(c)
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal :true
2
+
3
+ module Heading
4
+ module HeadingHelper
5
+ def h(**options)
6
+ if block_given?
7
+ render(Heading::HComponent.new(**options)) do
8
+ yield
9
+ end
10
+ else
11
+ render(Heading::HComponent.new(**options))
12
+ end
13
+ end
14
+ end
15
+ end
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "bsvc"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/bsvc.gemspec ADDED
@@ -0,0 +1,36 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "bsvc/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "bsvc"
8
+ spec.version = Bsvc::VERSION
9
+ spec.authors = ["Nick McNeany"]
10
+ spec.email = ["nmcneany@gmail.com"]
11
+
12
+ spec.summary = %q{A Bootstrap and ViewComponent library for Rails views.}
13
+ spec.description = %q{A Bootstrap and ViewComponent library for Rails views.}
14
+ spec.homepage = "https://github.com/Nickiam7/bsvc"
15
+ spec.license = "MIT"
16
+
17
+
18
+ spec.metadata["homepage_uri"] = spec.homepage
19
+ spec.metadata["source_code_uri"] = spec.homepage
20
+ spec.metadata["changelog_uri"] = spec.homepage
21
+
22
+ # Specify which files should be added to the gem when it is released.
23
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
24
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
25
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
26
+ end
27
+ spec.bindir = "exe"
28
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
29
+ spec.require_paths = ["lib"]
30
+
31
+ spec.add_development_dependency "bundler", "~> 1.17"
32
+ spec.add_development_dependency "rake", "~> 10.0"
33
+ spec.add_development_dependency "rspec", "~> 3.0"
34
+
35
+ spec.add_dependency "view_component", "~> 2.75"
36
+ end
@@ -0,0 +1,9 @@
1
+ module Bsvc
2
+ class Engine < ::Rails::Engine
3
+ initializer('bsvc.load_helpers') do
4
+ ActiveSupport.on_load(:action_controller) do
5
+ helper(Bsvc::Engine.helpers)
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,3 @@
1
+ module Bsvc
2
+ VERSION = "0.1.0"
3
+ end
data/lib/bsvc.rb ADDED
@@ -0,0 +1,3 @@
1
+ require "bsvc/version"
2
+ require "bsvc/engine"
3
+ require "view_component"
@@ -0,0 +1,16 @@
1
+ require "rails/generators"
2
+
3
+ module Bsvc
4
+ module Generators
5
+ class ComponentGenerator < Rails::Generators::Base
6
+ source_root(File.expand_path("../../../../", __FILE__))
7
+
8
+ class_option :name, type: :string, default: ''
9
+
10
+ def copy_single_component
11
+ directory("app/components/#{@options[:name]}", "app/components/#{@options[:name]}")
12
+ directory("app/helpers/#{@options[:name]}", "app/helpers/#{@options[:name]}")
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,14 @@
1
+ require "rails/generators"
2
+
3
+ module Bsvc
4
+ module Generators
5
+ class ComponentsGenerator < Rails::Generators::Base
6
+ source_root(File.expand_path("../../../../", __FILE__))
7
+
8
+ def copy_components
9
+ directory('app/components', 'app/components')
10
+ directory('app/helpers', 'app/helpers')
11
+ end
12
+ end
13
+ end
14
+ end
metadata ADDED
@@ -0,0 +1,128 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bsvc
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Nick McNeany
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2023-01-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.17'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.17'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: view_component
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '2.75'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '2.75'
69
+ description: A Bootstrap and ViewComponent library for Rails views.
70
+ email:
71
+ - nmcneany@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - ".rspec"
78
+ - ".travis.yml"
79
+ - Gemfile
80
+ - LICENSE.txt
81
+ - README.md
82
+ - Rakefile
83
+ - app/components/card/card_component.html.erb
84
+ - app/components/card/card_component.rb
85
+ - app/components/grid/columns/columns_component.rb
86
+ - app/components/grid/container/container_component.html.erb
87
+ - app/components/grid/container/container_component.rb
88
+ - app/components/grid/row/row_component.rb
89
+ - app/components/heading/h_component.rb
90
+ - app/helpers/card/card_helper.rb
91
+ - app/helpers/grid/container_helper.rb
92
+ - app/helpers/grid/row_helper.rb
93
+ - app/helpers/heading/heading_helper.rb
94
+ - bin/console
95
+ - bin/setup
96
+ - bsvc.gemspec
97
+ - lib/bsvc.rb
98
+ - lib/bsvc/engine.rb
99
+ - lib/bsvc/version.rb
100
+ - lib/generators/bsvc/component_generator.rb
101
+ - lib/generators/bsvc/components_generator.rb
102
+ homepage: https://github.com/Nickiam7/bsvc
103
+ licenses:
104
+ - MIT
105
+ metadata:
106
+ homepage_uri: https://github.com/Nickiam7/bsvc
107
+ source_code_uri: https://github.com/Nickiam7/bsvc
108
+ changelog_uri: https://github.com/Nickiam7/bsvc
109
+ post_install_message:
110
+ rdoc_options: []
111
+ require_paths:
112
+ - lib
113
+ required_ruby_version: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ required_rubygems_version: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
123
+ requirements: []
124
+ rubygems_version: 3.0.3
125
+ signing_key:
126
+ specification_version: 4
127
+ summary: A Bootstrap and ViewComponent library for Rails views.
128
+ test_files: []