Skip to content

Polish some static core components #63

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 35 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
8f333e6
update contribute readme, fix some typo
pascalwengerter Jun 19, 2019
9fd1c78
save some LOC in the views
pascalwengerter Jun 19, 2019
69dc261
save another LOC each!
pascalwengerter Jun 19, 2019
cd3a7b1
Add caption with doc and specs
michaelrevans Jun 26, 2019
f8c519b
add documented, untested video component
pascalwengerter Jun 27, 2019
b79eb32
Refactor caption haml if/else logic
michaelrevans Jun 28, 2019
942e8fe
Update caption.md
pascalwengerter Jun 29, 2019
f75a9f2
Merge pull request #68 from basemate/caption-core-component
pascalwengerter Jun 29, 2019
02d68bf
update span component in 0.7.0
pascalwengerter Jun 30, 2019
7b7a52d
update matestack-ui-core version in gem-specs
pascalwengerter Jun 30, 2019
4dad570
detail summary spec outlined test
bdlb77 Jul 6, 2019
e15c49a
Details and Summary
bdlb77 Jul 6, 2019
fc916d3
Merge branch 'develop' into summary_details_components
pascalwengerter Jul 6, 2019
2231de3
Fix indentation in summary/details documentation
pascalwengerter Jul 7, 2019
06bb80e
Rename pg to paragraph in text (deprecated name)
pascalwengerter Jul 7, 2019
58dd08f
Merge pull request #76 from basemate/summary_details_components
pascalwengerter Jul 7, 2019
6d406f9
Merge pull request #70 from basemate/introduce_video_component
jonasjabari Jul 16, 2019
b811cb3
Merge pull request #74 from basemate/update_span_component
jonasjabari Jul 16, 2019
0bfe250
fixed and documented link component #83
jonasjabari Jul 17, 2019
f55007c
readded require path
jonasjabari Jul 17, 2019
e0e02be
added information to docs and raise specific error in order to inform…
jonasjabari Jul 17, 2019
d341770
Adds small tags to the base components
cameronnorman Jul 18, 2019
6763cb2
spec fix
cameronnorman Jul 18, 2019
2c359fe
Small spec fix. Ignore coverage folder
cameronnorman Jul 18, 2019
c95ebeb
Adds blockquote tag to main component
cameronnorman Jul 18, 2019
c84ace8
dont ignore coverage
cameronnorman Jul 22, 2019
54b1f71
Fixed blockquote issue
cameronnorman Jul 22, 2019
340f35c
Merge pull request #85 from basemate/implementing_issue_75
jonasjabari Jul 22, 2019
b401d7b
adds strong to main components
cameronnorman Jul 23, 2019
07c16fd
rename span to strong
cameronnorman Jul 23, 2019
716c548
Merge pull request #84 from basemate/implementing_issue_83
jonasjabari Jul 23, 2019
c54c38d
Merge pull request #93 from basemate/add-strong-tag-3
pascalwengerter Jul 23, 2019
649901e
Merge pull request #87 from basemate/add-small-tags
pascalwengerter Jul 23, 2019
43e7324
Merge pull request #88 from basemate/add-block-quotes
pascalwengerter Jul 23, 2019
451d85a
merge develop into branch
pascalwengerter Jul 23, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
matestack-ui-core (0.6.0)
matestack-ui-core (0.7.0)
cells-haml
cells-rails
haml
Expand Down
5 changes: 5 additions & 0 deletions app/concepts/matestack/ui/core/blockquote/blockquote.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
%blockquote{@tag_attributes}
- if options[:text].nil? && block_given?
= yield
- else
= options[:text]
9 changes: 9 additions & 0 deletions app/concepts/matestack/ui/core/blockquote/blockquote.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module Matestack::Ui::Core::Blockquote
class Blockquote < Matestack::Ui::Core::Component::Static
def setup
@tag_attributes.merge!({
"cite": options[:cite]
})
end
end
end
10 changes: 4 additions & 6 deletions app/concepts/matestack/ui/core/button/button.haml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
- if options[:text].nil?
%button{@tag_attributes}
- if block_given?
= yield
- else
%button{@tag_attributes}
%button{@tag_attributes}
- if options[:text].nil? && block_given?
= yield
- else
= options[:text]
6 changes: 6 additions & 0 deletions app/concepts/matestack/ui/core/caption/caption.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
%caption{@tag_attributes}
- if options[:text].nil?
- if block_given?
= yield
- else
= options[:text]
5 changes: 5 additions & 0 deletions app/concepts/matestack/ui/core/caption/caption.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module Matestack::Ui::Core::Caption
class Caption < Matestack::Ui::Core::Component::Static

end
end
3 changes: 3 additions & 0 deletions app/concepts/matestack/ui/core/details/details.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
%details{@tag_attributes}
- if block_given?
= yield
4 changes: 4 additions & 0 deletions app/concepts/matestack/ui/core/details/details.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module Matestack::Ui::Core::Details
class Details < Matestack::Ui::Core::Component::Static
end
end
10 changes: 4 additions & 6 deletions app/concepts/matestack/ui/core/label/label.haml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
- if options[:text].blank?
%label{@tag_attributes}
- if block_given?
= yield
- else
%label{@tag_attributes}
%label{@tag_attributes}
- if options[:text].nil? && block_given?
= yield
- else
= options[:text]
11 changes: 5 additions & 6 deletions app/concepts/matestack/ui/core/link/link.haml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
- if options[:text].nil?
= link_to link_path, @tag_attributes do
- if block_given?
= yield
- else
= link_to options[:text], link_path, @tag_attributes
%a{@tag_attributes}
- if options[:text].nil? && block_given?
= yield
- else
= options[:text]
6 changes: 4 additions & 2 deletions app/concepts/matestack/ui/core/link/link.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ class Link < Matestack::Ui::Core::Component::Static
REQUIRED_KEYS = [:path]

def setup
@tag_attributes.merge!({ "class": options[:class],
@tag_attributes.merge!({
"class": options[:class],
"id": component_id,
"method": options[:method],
"target": options[:target] ||= nil
"target": options[:target] ||= nil,
"href": link_path
})
end

Expand Down
31 changes: 17 additions & 14 deletions app/concepts/matestack/ui/core/page/page.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,25 +82,28 @@ def show(component_key=nil, only_page=false)

when :only_page
nodes_to_cell
# keys_array = ["div_2","components", "partial_1", "components", "form_1"]
# puts @nodes.dig(*keys_array)
render :page
when :render_page_with_app
concept(@app_class).call(:show, @page_id, @nodes)
when :render_component
if component_key.include?("__")
keys_array = component_key.gsub("__", "__components__").split("__").map {|k| k.to_s}
page_content_keys = keys_array.select{|key| key.match(/^page_content_/)}
if page_content_keys.any?
keys_array = keys_array.drop(keys_array.find_index(page_content_keys[0])+2)
begin
if component_key.include?("__")
keys_array = component_key.gsub("__", "__components__").split("__").map {|k| k.to_s}
page_content_keys = keys_array.select{|key| key.match(/^page_content_/)}
if page_content_keys.any?
keys_array = keys_array.drop(keys_array.find_index(page_content_keys[0])+2)
end
node = @nodes.dig(*keys_array)
cell = to_cell(component_key, node["component_name"], node["config"], node["argument"], node["components"], node["included_config"])
return cell.render_content
else
node = @nodes[component_key]
cell = to_cell(component_key, node["component_name"], node["config"], node["argument"], node["components"], node["included_config"])
return cell.render_content
end
node = @nodes.dig(*keys_array)
cell = to_cell(component_key, node["component_name"], node["config"], node["argument"], node["components"], node["included_config"])
return cell.render_content
else
node = @nodes[component_key]
cell = to_cell(component_key, node["component_name"], node["config"], node["argument"], node["components"], node["included_config"])
return cell.render_content
rescue
raise "Component '#{component_key}' could not be resolved. Notice: Rerendering currently works only on page-level. \
You are therefore currently not able to use 'async' within a component for example!"
end
end
end
Expand Down
11 changes: 4 additions & 7 deletions app/concepts/matestack/ui/core/paragraph/paragraph.haml
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
- if options[:text].nil?
%p{@tag_attributes}
- if block_given?
= yield

- else
%p{@tag_attributes}
%p{@tag_attributes}
- if options[:text].nil? && block_given?
= yield
- else
= options[:text]
11 changes: 4 additions & 7 deletions app/concepts/matestack/ui/core/pg/pg.haml
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
- if options[:text].nil?
%p{@tag_attributes}
- if block_given?
= yield

- else
%p{@tag_attributes}
%p{@tag_attributes}
- if options[:text].nil? && block_given?
= yield
- else
= options[:text]
5 changes: 5 additions & 0 deletions app/concepts/matestack/ui/core/small/small.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
%small{@tag_attributes}
- if options[:text].nil? && block_given?
= yield
- else
= options[:text]
5 changes: 5 additions & 0 deletions app/concepts/matestack/ui/core/small/small.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module Matestack::Ui::Core::Small
class Small < Matestack::Ui::Core::Component::Static

end
end
4 changes: 3 additions & 1 deletion app/concepts/matestack/ui/core/span/span.haml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
%span{@tag_attributes}
- if block_given?
- if options[:text].nil? && block_given?
= yield
- else
= options[:text]
5 changes: 5 additions & 0 deletions app/concepts/matestack/ui/core/strong/strong.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
%strong{@tag_attributes}
- if options[:text].nil? && block_given?
= yield
- else
= options[:text]
5 changes: 5 additions & 0 deletions app/concepts/matestack/ui/core/strong/strong.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module Matestack::Ui::Core::Strong
class Strong < Matestack::Ui::Core::Component::Static

end
end
6 changes: 6 additions & 0 deletions app/concepts/matestack/ui/core/summary/summary.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
%summary{@tag_attributes}
- if options[:text].blank?
- if block_given?
= yield
- else
= options[:text]
4 changes: 4 additions & 0 deletions app/concepts/matestack/ui/core/summary/summary.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module Matestack::Ui::Core::Summary
class Summary < Matestack::Ui::Core::Component::Static
end
end
11 changes: 4 additions & 7 deletions app/concepts/matestack/ui/core/td/td.haml
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
- if options[:text].nil?
%td{@tag_attributes}
- if block_given?
= yield

- else
%td{@tag_attributes}
%td{@tag_attributes}
- if options[:text].nil? && block_given?
= yield
- else
= options[:text]
11 changes: 4 additions & 7 deletions app/concepts/matestack/ui/core/th/th.haml
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
- if options[:text].nil?
%th{@tag_attributes}
- if block_given?
= yield

- else
%th{@tag_attributes}
%th{@tag_attributes}
- if options[:text].nil? && block_given?
= yield
- else
= options[:text]
10 changes: 4 additions & 6 deletions app/concepts/matestack/ui/core/transition/transition.haml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
- if options[:text].nil?
%a{@tag_attributes}
- if block_given?
= yield
- else
%a{@tag_attributes}
%a{@tag_attributes}
- if options[:text].nil? && block_given?
= yield
- else
= options[:text]
1 change: 1 addition & 0 deletions app/concepts/matestack/ui/core/video/video.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
= video_tag(ActionController::Base.helpers.asset_path(options[:path]), height: options[:height], width: options[:width], preload: options[:preload], autoplay: options[:autoplay], muted: options[:muted], playsinline: options[:playsinline], loop: options[:loop], class: options[:class], id: options[:id], controls: options[:controls])
7 changes: 7 additions & 0 deletions app/concepts/matestack/ui/core/video/video.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module Matestack::Ui::Core::Video
class Video < Matestack::Ui::Core::Component::Static

REQUIRED_KEYS = [:path]

end
end
9 changes: 9 additions & 0 deletions app/concepts/plain/cell/plain.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module Plain::Cell
class Plain < Component::Cell::Static

def show
@argument
end

end
end
2 changes: 2 additions & 0 deletions docs/components/async.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ As the name suggests, the async component allows us to let our components behave

Please be aware that, if not configured otherwise, the async core component does get loaded and displayed on initial pageload!

**the async component currently only works on page-level --> we're working on it in order support the usage of async within a component [#75](https://github.com/basemate/matestack-ui-core/issues/75)**

## Parameters

The async core component accepts the following parameters:
Expand Down
48 changes: 48 additions & 0 deletions docs/components/blockquote.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# matestack core component: Blockquote

Show [specs](../../spec/usage/components/blockquote_spec.rb)

The HTML blockquote tag implemented in ruby.

## Parameters

This component can take 3 optional configuration params and either yield content or display what gets passed to the `text` configuration param.

#### # id (optional)
Expects a string with all ids the span should have.

#### # class (optional)
Expects a string with all classes the span should have.

#### # cite (optional)
Expects a string referencing a cite for the blockquote.

## Example 1: Yield a given block

```ruby
blockquote id: "foo", class: "bar", cite: "this is a cite" do
plain 'Hello World' # optional content
end
```

returns

```html
<blockquote cite="this is a cite" id="foo" class="bar">
Hello World
</blockquote>
```

## Example 2: Render options[:text] param

```ruby
blockquote id: "foo", class: "bar", cite: "this is a cite", text: 'Hello World'
```

returns

```html
<blockquote cite="this is a cite" id="foo" class="bar">
Hello World
</blockquote>
```
Loading