element_component 0.1.0 → 0.4.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 +4 -4
- data/.rspec +1 -1
- data/.rubocop.yml +22 -0
- data/LICENSE.txt +1 -1
- data/README.md +33 -13
- data/Rakefile +7 -3
- data/lib/element_component/core/element.rb +56 -76
- data/lib/element_component/core/maker.rb +13 -0
- data/lib/element_component/version.rb +1 -1
- data/lib/element_component.rb +5 -33
- data/sig/element_component.rbs +4 -0
- metadata +14 -35
- data/Gemfile +0 -12
- data/Gemfile.lock +0 -73
- data/bin/console +0 -15
- data/bin/setup +0 -8
- data/lib/element_component/bulma/datagrid.rb +0 -9
- data/lib/element_component/bulma/menu.rb +0 -26
- data/lib/element_component/bulma/pagination.rb +0 -101
- data/lib/element_component/core/a.rb +0 -10
- data/lib/element_component/core/article.rb +0 -10
- data/lib/element_component/core/aside.rb +0 -10
- data/lib/element_component/core/form.rb +0 -13
- data/lib/element_component/core/input.rb +0 -12
- data/lib/element_component/core/li.rb +0 -10
- data/lib/element_component/core/nav.rb +0 -10
- data/lib/element_component/core/span.rb +0 -10
- data/lib/element_component/core/table.rb +0 -10
- data/lib/element_component/core/tbody.rb +0 -10
- data/lib/element_component/core/td.rb +0 -10
- data/lib/element_component/core/tfoot.rb +0 -10
- data/lib/element_component/core/th.rb +0 -10
- data/lib/element_component/core/thead.rb +0 -10
- data/lib/element_component/core/tr.rb +0 -10
- data/lib/element_component/core/ul.rb +0 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fb69cb724b6274a5f95967fbabef32f6e1f5fb9bbf2428775a3237708cc7d6da
|
4
|
+
data.tar.gz: 50b2252d0c9315efc8c660910d0924dc6506552d09cbd1fc2f49e2309174f2ba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 98abc01a0787f60a2998f7f62c611fe51a58eaa8ee629e4bfc885da7ccf6b3a11a9e1f2539d206cfa379222caf5d821206f31558e9f7c47afe1ffa9a3addcaf8
|
7
|
+
data.tar.gz: bb664c8ad1a7f627f43f1f44898937efeb9c3fc916fca6a65c0b6ae01e1267326d0cff703e476f3748f41cb589b4c0f7c40f236b4787849efcb2029897b3ce78
|
data/.rspec
CHANGED
data/.rubocop.yml
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
AllCops:
|
2
|
+
TargetRubyVersion: 3.1
|
3
|
+
SuggestExtensions: false
|
4
|
+
NewCops: enable
|
5
|
+
|
6
|
+
Documentation:
|
7
|
+
Enabled: false
|
8
|
+
|
9
|
+
Metrics/MethodLength:
|
10
|
+
Enabled: false
|
11
|
+
|
12
|
+
Metrics/BlockLength:
|
13
|
+
Enabled: false
|
14
|
+
|
15
|
+
Style/MissingRespondToMissing:
|
16
|
+
Enabled: false
|
17
|
+
|
18
|
+
Style/StringLiterals:
|
19
|
+
EnforcedStyle: double_quotes
|
20
|
+
|
21
|
+
Style/StringLiteralsInInterpolation:
|
22
|
+
EnforcedStyle: double_quotes
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -1,28 +1,43 @@
|
|
1
1
|
# ElementComponent
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
3
|
+
HTML builder
|
6
4
|
|
7
5
|
## Installation
|
8
6
|
|
9
|
-
|
7
|
+
Install the gem and add to the application's Gemfile by executing:
|
10
8
|
|
11
|
-
```
|
12
|
-
|
9
|
+
```bash
|
10
|
+
bundle add element_component
|
13
11
|
```
|
14
12
|
|
15
|
-
|
13
|
+
If bundler is not being used to manage dependencies, install the gem by executing:
|
16
14
|
|
17
|
-
|
15
|
+
```bash
|
16
|
+
gem install element_component
|
17
|
+
```
|
18
18
|
|
19
|
-
|
19
|
+
## Usage
|
20
20
|
|
21
|
-
|
21
|
+
```ruby
|
22
|
+
maker = ElementComponent::Core::Maker.new
|
23
|
+
form = maker.form(attribute: { class: 'has-background-color', method: 'GET', action: '/', turbo: false }) do |form|
|
24
|
+
input = maker.input(attribute: { type: 'text', name: 'email', value: nil })
|
25
|
+
form.add_content input
|
22
26
|
|
23
|
-
|
27
|
+
button = maker.button(content: 'Save', attribute: { type: 'submit'})
|
28
|
+
div = maker.div(content: button, attribute: { class: 'buttons' })
|
24
29
|
|
25
|
-
|
30
|
+
form.add_content div
|
31
|
+
end
|
32
|
+
|
33
|
+
puts form.build
|
34
|
+
```
|
35
|
+
|
36
|
+
## Output
|
37
|
+
|
38
|
+
```html
|
39
|
+
<form class="has-background-color" method="GET" action="/" turbo="false"><input type="text" name="email" value=""></input><div class="buttons"><button type="submit">Save</button></div></form>
|
40
|
+
```
|
26
41
|
|
27
42
|
## Development
|
28
43
|
|
@@ -30,9 +45,14 @@ After checking out the repo, run `bin/setup` to install dependencies. Then, run
|
|
30
45
|
|
31
46
|
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).
|
32
47
|
|
48
|
+
## TODO
|
49
|
+
[ ] - Cache
|
50
|
+
[ ] - Bulma components
|
51
|
+
[ ] - Bootstrap components
|
52
|
+
|
33
53
|
## Contributing
|
34
54
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
55
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/joaopaulocorreia/element_component.
|
36
56
|
|
37
57
|
## License
|
38
58
|
|
data/Rakefile
CHANGED
@@ -1,8 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require "bundler/gem_tasks"
|
4
|
+
require "rspec/core/rake_task"
|
5
5
|
|
6
6
|
RSpec::Core::RakeTask.new(:spec)
|
7
7
|
|
8
|
-
|
8
|
+
require "rubocop/rake_task"
|
9
|
+
|
10
|
+
RuboCop::RakeTask.new
|
11
|
+
|
12
|
+
task default: %i[spec rubocop]
|
@@ -1,100 +1,80 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
module
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
3
|
+
module ElementComponent
|
4
|
+
module Core
|
5
|
+
class Element
|
6
|
+
attr_reader :element, :attributes, :contents
|
7
|
+
|
8
|
+
def initialize(element, content: [], attribute: {}, closing_tag: true)
|
9
|
+
@element = element
|
10
|
+
@closing_tag = closing_tag
|
11
|
+
@objects = []
|
12
|
+
|
13
|
+
reset_attributes!
|
14
|
+
reset_contents!
|
15
|
+
|
16
|
+
if content.is_a? Array
|
17
|
+
content.each { |item| add_content item }
|
18
|
+
else
|
19
|
+
add_content content
|
20
|
+
end
|
21
|
+
|
22
|
+
attribute.each_key { |key| add_attribute key, attribute[key] }
|
18
23
|
end
|
19
24
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
end
|
24
|
-
|
25
|
-
def add_content(content, reset: false)
|
26
|
-
reset_contents! if reset
|
27
|
-
@contents.push(content)
|
28
|
-
|
29
|
-
content
|
30
|
-
end
|
31
|
-
|
32
|
-
def add_component(identifier, component)
|
33
|
-
identifier = identifier.to_sym
|
34
|
-
@components.store identifier, component
|
35
|
-
end
|
25
|
+
def add_content(content, reset: false)
|
26
|
+
reset_contents! if reset
|
27
|
+
@contents.push(content)
|
36
28
|
|
37
|
-
|
38
|
-
|
39
|
-
@components.fetch identifier
|
40
|
-
end
|
29
|
+
content
|
30
|
+
end
|
41
31
|
|
42
|
-
|
43
|
-
|
32
|
+
def add_attribute(attribute, value, reset: false)
|
33
|
+
attribute = attribute.to_sym
|
44
34
|
|
45
|
-
|
35
|
+
@attributes.delete attribute if reset
|
46
36
|
|
47
|
-
|
37
|
+
return @attributes[attribute].push(value) if @attributes.key?(attribute)
|
48
38
|
|
49
|
-
|
50
|
-
|
39
|
+
@attributes[attribute] = [value]
|
40
|
+
end
|
51
41
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
42
|
+
def remove_attribute!(attribute)
|
43
|
+
attribute = attribute.to_sym
|
44
|
+
@attributes = @attributes.except(attribute)
|
45
|
+
end
|
56
46
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
47
|
+
def remove_attribute_value(attribute, value)
|
48
|
+
attribute = attribute.to_sym
|
49
|
+
attributes[attribute].delete(value)
|
50
|
+
end
|
61
51
|
|
62
|
-
|
63
|
-
|
64
|
-
|
52
|
+
def reset_contents!
|
53
|
+
@contents = []
|
54
|
+
end
|
65
55
|
|
66
|
-
|
67
|
-
|
68
|
-
|
56
|
+
def reset_attributes!
|
57
|
+
@attributes = {}
|
58
|
+
end
|
69
59
|
|
70
|
-
|
71
|
-
|
72
|
-
|
60
|
+
def build
|
61
|
+
html = "<#{@element}"
|
62
|
+
html << (mount_attributes.empty? ? ">" : " #{mount_attributes}>")
|
73
63
|
|
74
|
-
|
75
|
-
partial = open_tag
|
64
|
+
html << mount_content
|
76
65
|
|
77
|
-
|
78
|
-
partial << (content.is_a?(Element) ? content.build : content.to_s)
|
66
|
+
html << "</#{@element}>" if @closing_tag
|
79
67
|
end
|
80
68
|
|
81
|
-
|
82
|
-
partial
|
83
|
-
end
|
84
|
-
|
85
|
-
private
|
69
|
+
private
|
86
70
|
|
87
|
-
|
88
|
-
|
89
|
-
@attributes.to_a.inject(partial) do |acc, attr|
|
90
|
-
acc << " #{attr[0].to_sym}=\"#{attr[1].join(' ')}\""
|
71
|
+
def mount_attributes
|
72
|
+
@attributes.map { |attr| "#{attr[0].to_sym}=\"#{attr[1].join(" ")}\"" }.join(" ")
|
91
73
|
end
|
92
74
|
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
def close_tag
|
97
|
-
"</#{@element}>"
|
75
|
+
def mount_content
|
76
|
+
@contents.map { |content| content.is_a?(Element) ? content.build : content.to_s }.join
|
77
|
+
end
|
98
78
|
end
|
99
79
|
end
|
100
80
|
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ElementComponent
|
4
|
+
module Core
|
5
|
+
class Maker
|
6
|
+
def method_missing(method, **args, &block)
|
7
|
+
new_element = ElementComponent::Core::Element.new(method.to_s.gsub("_", "-"), **args)
|
8
|
+
block.call new_element if block_given?
|
9
|
+
new_element
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
data/lib/element_component.rb
CHANGED
@@ -1,38 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
require_relative
|
5
|
-
require_relative
|
6
|
-
require_relative 'element_component/core/input'
|
7
|
-
require_relative 'element_component/core/form'
|
8
|
-
require_relative 'element_component/core/nav'
|
9
|
-
require_relative 'element_component/core/a'
|
10
|
-
require_relative 'element_component/core/article'
|
11
|
-
require_relative 'element_component/core/li'
|
12
|
-
require_relative 'element_component/core/ul'
|
13
|
-
require_relative 'element_component/core/span'
|
14
|
-
require_relative 'element_component/core/table'
|
15
|
-
require_relative 'element_component/core/tr'
|
16
|
-
require_relative 'element_component/core/th'
|
17
|
-
require_relative 'element_component/core/td'
|
18
|
-
require_relative 'element_component/core/aside'
|
3
|
+
require_relative "element_component/version"
|
4
|
+
require_relative "element_component/core/element"
|
5
|
+
require_relative "element_component/core/maker"
|
19
6
|
|
20
|
-
|
21
|
-
require_relative 'element_component/bulma/pagination'
|
22
|
-
require_relative 'element_component/bulma/menu'
|
23
|
-
|
24
|
-
# Tailwind components
|
25
|
-
|
26
|
-
module El
|
27
|
-
class Error < StandardError; end
|
28
|
-
end
|
29
|
-
|
30
|
-
module Bulma
|
31
|
-
class Error < StandardError; end
|
32
|
-
|
33
|
-
CDN = 'https://cdn.jsdelivr.net/npm/bulma@0.9.4/css/bulma.min.css'
|
34
|
-
end
|
35
|
-
|
36
|
-
module Tailwind
|
7
|
+
module ElementComponent
|
37
8
|
class Error < StandardError; end
|
9
|
+
# Your code goes here...
|
38
10
|
end
|
metadata
CHANGED
@@ -1,57 +1,37 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: element_component
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- João Paulo Correia
|
8
|
-
autorequire:
|
9
8
|
bindir: exe
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
12
11
|
dependencies: []
|
13
|
-
description:
|
12
|
+
description: HTML Builder
|
14
13
|
email:
|
15
|
-
-
|
14
|
+
- ijoohn@hotmail.com
|
16
15
|
executables: []
|
17
16
|
extensions: []
|
18
17
|
extra_rdoc_files: []
|
19
18
|
files:
|
20
19
|
- ".rspec"
|
21
|
-
-
|
22
|
-
- Gemfile.lock
|
20
|
+
- ".rubocop.yml"
|
23
21
|
- LICENSE.txt
|
24
22
|
- README.md
|
25
23
|
- Rakefile
|
26
|
-
- bin/console
|
27
|
-
- bin/setup
|
28
24
|
- lib/element_component.rb
|
29
|
-
- lib/element_component/bulma/datagrid.rb
|
30
|
-
- lib/element_component/bulma/menu.rb
|
31
|
-
- lib/element_component/bulma/pagination.rb
|
32
|
-
- lib/element_component/core/a.rb
|
33
|
-
- lib/element_component/core/article.rb
|
34
|
-
- lib/element_component/core/aside.rb
|
35
25
|
- lib/element_component/core/element.rb
|
36
|
-
- lib/element_component/core/
|
37
|
-
- lib/element_component/core/input.rb
|
38
|
-
- lib/element_component/core/li.rb
|
39
|
-
- lib/element_component/core/nav.rb
|
40
|
-
- lib/element_component/core/span.rb
|
41
|
-
- lib/element_component/core/table.rb
|
42
|
-
- lib/element_component/core/tbody.rb
|
43
|
-
- lib/element_component/core/td.rb
|
44
|
-
- lib/element_component/core/tfoot.rb
|
45
|
-
- lib/element_component/core/th.rb
|
46
|
-
- lib/element_component/core/thead.rb
|
47
|
-
- lib/element_component/core/tr.rb
|
48
|
-
- lib/element_component/core/ul.rb
|
26
|
+
- lib/element_component/core/maker.rb
|
49
27
|
- lib/element_component/version.rb
|
50
|
-
|
28
|
+
- sig/element_component.rbs
|
29
|
+
homepage: https://github.com/joaopaulocorreia/element_component
|
51
30
|
licenses:
|
52
31
|
- MIT
|
53
|
-
metadata:
|
54
|
-
|
32
|
+
metadata:
|
33
|
+
homepage_uri: https://github.com/joaopaulocorreia/element_component
|
34
|
+
rubygems_mfa_required: 'true'
|
55
35
|
rdoc_options: []
|
56
36
|
require_paths:
|
57
37
|
- lib
|
@@ -59,15 +39,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
59
39
|
requirements:
|
60
40
|
- - ">="
|
61
41
|
- !ruby/object:Gem::Version
|
62
|
-
version:
|
42
|
+
version: 3.1.0
|
63
43
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
64
44
|
requirements:
|
65
45
|
- - ">="
|
66
46
|
- !ruby/object:Gem::Version
|
67
47
|
version: '0'
|
68
48
|
requirements: []
|
69
|
-
rubygems_version: 3.
|
70
|
-
signing_key:
|
49
|
+
rubygems_version: 3.6.9
|
71
50
|
specification_version: 4
|
72
|
-
summary:
|
51
|
+
summary: HTML Builder
|
73
52
|
test_files: []
|
data/Gemfile
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
source 'https://rubygems.org'
|
4
|
-
|
5
|
-
# Specify your gem's dependencies in element_component.gemspec
|
6
|
-
gemspec
|
7
|
-
|
8
|
-
gem 'debug'
|
9
|
-
gem 'rake', '~> 13.0'
|
10
|
-
gem 'rspec', '~> 3.0'
|
11
|
-
gem 'rubocop'
|
12
|
-
gem 'simplecov', require: false, group: :test
|
data/Gemfile.lock
DELETED
@@ -1,73 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
element_component (0.1.0)
|
5
|
-
|
6
|
-
GEM
|
7
|
-
remote: https://rubygems.org/
|
8
|
-
specs:
|
9
|
-
ast (2.4.2)
|
10
|
-
debug (1.5.0)
|
11
|
-
irb (>= 1.3.6)
|
12
|
-
reline (>= 0.2.7)
|
13
|
-
diff-lcs (1.5.0)
|
14
|
-
docile (1.4.0)
|
15
|
-
io-console (0.5.11)
|
16
|
-
irb (1.4.1)
|
17
|
-
reline (>= 0.3.0)
|
18
|
-
parallel (1.22.1)
|
19
|
-
parser (3.1.2.0)
|
20
|
-
ast (~> 2.4.1)
|
21
|
-
rainbow (3.1.1)
|
22
|
-
rake (13.0.6)
|
23
|
-
regexp_parser (2.3.1)
|
24
|
-
reline (0.3.1)
|
25
|
-
io-console (~> 0.5)
|
26
|
-
rexml (3.2.5)
|
27
|
-
rspec (3.11.0)
|
28
|
-
rspec-core (~> 3.11.0)
|
29
|
-
rspec-expectations (~> 3.11.0)
|
30
|
-
rspec-mocks (~> 3.11.0)
|
31
|
-
rspec-core (3.11.0)
|
32
|
-
rspec-support (~> 3.11.0)
|
33
|
-
rspec-expectations (3.11.0)
|
34
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
35
|
-
rspec-support (~> 3.11.0)
|
36
|
-
rspec-mocks (3.11.1)
|
37
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
38
|
-
rspec-support (~> 3.11.0)
|
39
|
-
rspec-support (3.11.0)
|
40
|
-
rubocop (1.28.2)
|
41
|
-
parallel (~> 1.10)
|
42
|
-
parser (>= 3.1.0.0)
|
43
|
-
rainbow (>= 2.2.2, < 4.0)
|
44
|
-
regexp_parser (>= 1.8, < 3.0)
|
45
|
-
rexml
|
46
|
-
rubocop-ast (>= 1.17.0, < 2.0)
|
47
|
-
ruby-progressbar (~> 1.7)
|
48
|
-
unicode-display_width (>= 1.4.0, < 3.0)
|
49
|
-
rubocop-ast (1.17.0)
|
50
|
-
parser (>= 3.1.1.0)
|
51
|
-
ruby-progressbar (1.11.0)
|
52
|
-
simplecov (0.21.2)
|
53
|
-
docile (~> 1.1)
|
54
|
-
simplecov-html (~> 0.11)
|
55
|
-
simplecov_json_formatter (~> 0.1)
|
56
|
-
simplecov-html (0.12.3)
|
57
|
-
simplecov_json_formatter (0.1.4)
|
58
|
-
unicode-display_width (2.1.0)
|
59
|
-
|
60
|
-
PLATFORMS
|
61
|
-
ruby
|
62
|
-
x86_64-linux
|
63
|
-
|
64
|
-
DEPENDENCIES
|
65
|
-
debug
|
66
|
-
element_component!
|
67
|
-
rake (~> 13.0)
|
68
|
-
rspec (~> 3.0)
|
69
|
-
rubocop
|
70
|
-
simplecov
|
71
|
-
|
72
|
-
BUNDLED WITH
|
73
|
-
2.1.2
|
data/bin/console
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
require 'bundler/setup'
|
5
|
-
require 'element_component'
|
6
|
-
|
7
|
-
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
-
# with your gem easier. You can also use a different console, if you like.
|
9
|
-
|
10
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
-
# require "pry"
|
12
|
-
# Pry.start
|
13
|
-
|
14
|
-
require 'irb'
|
15
|
-
IRB.start(__FILE__)
|
data/bin/setup
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Bulma
|
4
|
-
class Menu < El::Aside
|
5
|
-
def initialize
|
6
|
-
super()
|
7
|
-
|
8
|
-
menu_label = El::Element.new('p')
|
9
|
-
menu_label.add_content 'General'
|
10
|
-
|
11
|
-
menu_list = El::Ul.new
|
12
|
-
menu_item = menu_list.add_content El::Li.new
|
13
|
-
menu_link = El::A.new contents: ['Dashboard']
|
14
|
-
menu_item.add_content menu_link
|
15
|
-
|
16
|
-
add_content menu_label.build
|
17
|
-
add_content menu_list.build
|
18
|
-
|
19
|
-
menu_label.add_content 'Administration', reset: true
|
20
|
-
add_content menu_label.build
|
21
|
-
|
22
|
-
menu_link.add_content 'Team Settings', reset: true
|
23
|
-
add_content menu_list.build
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
@@ -1,101 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Bulma
|
4
|
-
class Pagination < El::Nav
|
5
|
-
attr_reader :url, :current_page, :first_page, :last_page
|
6
|
-
|
7
|
-
def initialize(url:, current_page:, first_page: 1, last_page:)
|
8
|
-
super()
|
9
|
-
|
10
|
-
@url, @current_page, @first_page, @last_page = url, current_page, first_page, last_page
|
11
|
-
|
12
|
-
add_attribute :class, 'pagination'
|
13
|
-
add_attribute :role, 'navigation'
|
14
|
-
add_attribute 'aria_label', 'pagination'
|
15
|
-
|
16
|
-
add_content previous_link
|
17
|
-
add_content next_link
|
18
|
-
|
19
|
-
# adds first link to list
|
20
|
-
li = list.add_content El::Li.new
|
21
|
-
li.add_content make_link(first_page)
|
22
|
-
|
23
|
-
# adds separator
|
24
|
-
list.add_content El::Li.new(contents: [separator])
|
25
|
-
|
26
|
-
# adds the center links
|
27
|
-
if current_page > first_page
|
28
|
-
li = list.add_content El::Li.new
|
29
|
-
li.add_content make_link(current_page - 1)
|
30
|
-
end
|
31
|
-
|
32
|
-
li = list.add_content El::Li.new
|
33
|
-
li.add_content make_link(current_page)
|
34
|
-
|
35
|
-
if current_page < last_page
|
36
|
-
li = list.add_content El::Li.new
|
37
|
-
li.add_content make_link(current_page + 1)
|
38
|
-
end
|
39
|
-
|
40
|
-
# adds separator
|
41
|
-
list.add_content El::Li.new(contents: [separator])
|
42
|
-
|
43
|
-
# adds last link to list
|
44
|
-
li = El::Li.new
|
45
|
-
li.add_content make_link(last_page)
|
46
|
-
list.add_content li.build
|
47
|
-
|
48
|
-
add_content list
|
49
|
-
end
|
50
|
-
|
51
|
-
private
|
52
|
-
|
53
|
-
def make_link(page_number)
|
54
|
-
link = El::A.new
|
55
|
-
|
56
|
-
link.add_attribute 'arial-label', "Go to page #{page_number}"
|
57
|
-
link.add_attribute :href, "#{url}?page=#{page_number}"
|
58
|
-
link.add_attribute :class, 'pagination-link'
|
59
|
-
link.add_attribute :class, 'is-current' if page_number == current_page
|
60
|
-
link.add_content page_number
|
61
|
-
|
62
|
-
link
|
63
|
-
end
|
64
|
-
|
65
|
-
def list
|
66
|
-
@list ||= El::Ul.new attributes: { class: 'pagination-list' }
|
67
|
-
end
|
68
|
-
|
69
|
-
def separator
|
70
|
-
@separator ||= El::Span.new attributes: { class: 'pagination-ellipsis' }, contents: ['…']
|
71
|
-
end
|
72
|
-
|
73
|
-
def previous_link
|
74
|
-
link = El::A.new
|
75
|
-
link.add_attribute :class, 'pagination-previous'
|
76
|
-
link.add_content 'Previous'
|
77
|
-
|
78
|
-
if current_page > first_page
|
79
|
-
link.add_attribute :href, "#{url}?page=#{current_page - 1}"
|
80
|
-
else
|
81
|
-
link.add_attribute :class, 'is-disabled'
|
82
|
-
end
|
83
|
-
|
84
|
-
link
|
85
|
-
end
|
86
|
-
|
87
|
-
def next_link
|
88
|
-
link = El::A.new
|
89
|
-
link.add_attribute :class, 'pagination-next'
|
90
|
-
link.add_content 'Next'
|
91
|
-
|
92
|
-
if current_page < last_page
|
93
|
-
link.add_attribute :href, "#{url}?page=#{current_page + 1}"
|
94
|
-
else
|
95
|
-
link.add_attribute :class, 'is-disabled'
|
96
|
-
end
|
97
|
-
|
98
|
-
link
|
99
|
-
end
|
100
|
-
end
|
101
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module El
|
4
|
-
# represent the form tag
|
5
|
-
class Form < Element
|
6
|
-
def initialize(method: 'POST', action: '/')
|
7
|
-
super('form', closing_tag: true)
|
8
|
-
|
9
|
-
add_attribute(:method, method)
|
10
|
-
add_attribute(:action, action)
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|