bulma_view_components 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: d89ea252c3bb28694fd30679b26fef0d04e3a6633fc5b6f318edd810e9eeb91f
4
+ data.tar.gz: 3d076d6cfc8f1a531402e8dc7e2dbcf3815e3c56c7cee7a52d42ab0dc06ea66b
5
+ SHA512:
6
+ metadata.gz: f33dbd76070427d7f0f4b3320b0b1b40ed8eaa9108ac45b07c16676ba4156ff7f4cfa5b31f4387e7a45a4d74285304b3889cfc666923369c204ca95ab594428e
7
+ data.tar.gz: b8aacf38e15fef673a32fe7f5455e2dd4142d14adfb11d4efcaba1e85e0d5ee6d6279b1b02f43e061fb9109aed146b908f96e4334ae3ca4f1b09a3ed5e299c9b
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2023 Diego Toral
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,49 @@
1
+ # BulmaViewComponents
2
+
3
+ `BulmaViewComponents` is a set of components for the [Bulma](https://bulma.io) CSS framework using [ViewComponent](https://viewcomponent.org/).
4
+
5
+ ## Installation
6
+
7
+ Install the gem and add to the application's Gemfile by executing:
8
+
9
+ bundle add bulma_view_components
10
+
11
+ If bundler is not being used to manage dependencies, install the gem by executing:
12
+
13
+ gem install bulma_view_components
14
+
15
+ ## Dependencies
16
+
17
+ TODO: Write dependencies list
18
+
19
+ ## Usage
20
+
21
+ `BulmaViewComponents` can be used directly:
22
+
23
+ ```erb
24
+ <%= render Bulma::TitleComponent.new(size: 1) do %>
25
+ Hi, there
26
+ <% end %>
27
+ ```
28
+
29
+ or more clearer through helpers:
30
+
31
+ ```erb
32
+ <%= bulma_title(size: 1) do %>
33
+ Hi, there
34
+ <% end %>
35
+ ```
36
+
37
+ ## Development
38
+
39
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
40
+
41
+ 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).
42
+
43
+ ## Contributing
44
+
45
+ Bug reports and pull requests are welcome on GitHub at https://github.com/diegotoral/bulma_view_components.
46
+
47
+ ## License
48
+
49
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bulma
4
+ class BoxComponent < Component
5
+ def call
6
+ content_tag :div, content, class: 'box'
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bulma
4
+ class Component < ViewComponent::Base
5
+ end
6
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bulma
4
+ class TagComponent < Component
5
+ def initialize(color: nil, size: :normal, light: false)
6
+ @size = size
7
+ @color = color
8
+ @light = light
9
+ end
10
+
11
+ def call
12
+ content_tag :span, content, class: class_names(
13
+ 'tag',
14
+ 'is-light' => @light,
15
+ "is-#{@color}" => @color,
16
+ "is-#{@size}" => @size
17
+ )
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bulma
4
+ class TitleComponent < Component
5
+ def initialize(as: :h1, size: 1)
6
+ raise ArgumentError, 'invalid value to size' if size > 6
7
+
8
+ @as = as
9
+ @size = size
10
+ end
11
+
12
+ def call
13
+ content_tag @as, content, class: class_names(
14
+ 'title',
15
+ "is-#{@size}"
16
+ )
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,71 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bulma
4
+ class InvalidColor < StandardError
5
+ def initialize(name)
6
+ super "Invalid color name #{name}"
7
+ end
8
+ end
9
+
10
+ module Colors
11
+ class Color
12
+ def initialize(name)
13
+ @name = name
14
+ end
15
+
16
+ def to_s
17
+ "is-#{@name}"
18
+ end
19
+ end
20
+
21
+ def self.white
22
+ @white ||= Color.new :white
23
+ end
24
+
25
+ def self.black
26
+ @black ||= Color.new :black
27
+ end
28
+
29
+ def self.light
30
+ @light ||= Color.new :light
31
+ end
32
+
33
+ def self.dark
34
+ @dark ||= Color.new :dark
35
+ end
36
+
37
+ def self.primary
38
+ @primary ||= Color.new :primary
39
+ end
40
+
41
+ def self.link
42
+ @link ||= Color.new :link
43
+ end
44
+
45
+ def self.info
46
+ @info ||= Color.new :info
47
+ end
48
+
49
+ def self.success
50
+ @success ||= Color.new :success
51
+ end
52
+
53
+ def self.warning
54
+ @warning ||= Color.new :warning
55
+ end
56
+
57
+ def self.danger
58
+ @danger ||= Color.new :danger
59
+ end
60
+
61
+ def self.[](name)
62
+ return nil if name.nil?
63
+
64
+ method_name = name.to_sym
65
+
66
+ raise InvalidColor.new(name) unless respond_to?(method_name)
67
+
68
+ send(method_name)
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bulma
4
+ module ViewComponents
5
+ class Engine < ::Rails::Engine
6
+ config.autoload_paths += [
7
+ root.join('app/components')
8
+ ]
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bulma
4
+ module Sizes
5
+ def self.[](name)
6
+
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bulma
4
+ module ViewComponents
5
+ VERSION = "0.1.0"
6
+ end
7
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bulma/view_components/version"
4
+ require "bulma/view_components/engine"
5
+
6
+ module Bulma
7
+ module ViewComponents
8
+ end
9
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "bulma/view_components"
4
+
5
+ module BulmaViewComponents
6
+ end
metadata ADDED
@@ -0,0 +1,86 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bulma_view_components
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Diego Toral
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2023-12-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 5.0.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 5.0.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: view_component
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '3.7'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '3.7'
41
+ description:
42
+ email:
43
+ - diegotoral@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - LICENSE.txt
49
+ - README.md
50
+ - app/components/bulma/box_component.rb
51
+ - app/components/bulma/component.rb
52
+ - app/components/bulma/tag_component.rb
53
+ - app/components/bulma/title_component.rb
54
+ - lib/bulma/colors.rb
55
+ - lib/bulma/view_components.rb
56
+ - lib/bulma/view_components/engine.rb
57
+ - lib/bulma/view_components/sizes.rb
58
+ - lib/bulma/view_components/version.rb
59
+ - lib/bulma_view_components.rb
60
+ homepage: https://github.com/diegotoral/bulma_view_components
61
+ licenses:
62
+ - MIT
63
+ metadata:
64
+ allowed_push_host: https://rubygems.org
65
+ homepage_uri: https://github.com/diegotoral/bulma_view_components
66
+ source_code_uri: https://github.com/diegotoral/bulma_view_components
67
+ post_install_message:
68
+ rdoc_options: []
69
+ require_paths:
70
+ - lib
71
+ required_ruby_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: 2.7.0
76
+ required_rubygems_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ requirements: []
82
+ rubygems_version: 3.3.7
83
+ signing_key:
84
+ specification_version: 4
85
+ summary: ViewComponents for Bulma
86
+ test_files: []