forked from ontoportal/ontoportal_web_ui
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #305 from ontoportal-lirmm/feature/add-table-compo…
…nent Feature: Add table component & Migrate the views to use it
- Loading branch information
Showing
22 changed files
with
339 additions
and
222 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
|
||
.concept_details_component .raw-table .dropdown-title-bar p { | ||
padding: 10px 0px; | ||
color: rgb(136, 136, 136); | ||
font-weight: 400; | ||
} | ||
|
||
|
||
.concept_details_component table th { | ||
width: 220px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
.table-content{ | ||
border-collapse: collapse; | ||
width: 100%; | ||
border-spacing: 0; | ||
} | ||
|
||
.table-content thead th{ | ||
background-color: hsl(0, 0%, 100%); | ||
border-bottom: 1px solid hsl(240, 4%, 85%); | ||
font-weight: 700; | ||
color: hsl(230, 13%, 9%); | ||
} | ||
|
||
|
||
.table-content td, .table-content th{ | ||
padding: 12px 24px; | ||
vertical-align: top; | ||
} | ||
|
||
|
||
.table-content-stripped tbody tr:nth-child(odd) { | ||
background-color: #FAFAFA; | ||
} | ||
|
||
.table-content tbody th:first-child { | ||
color: #888888; | ||
font-weight: 400; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 21 additions & 18 deletions
39
app/components/concept_details_component/concept_details_component.html.haml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,23 @@ | ||
- require 'cgi' | ||
%div.hide-if-loading | ||
%div.hide-if-loading.concept_details_component | ||
%div.card | ||
%table.concepts-content | ||
= header | ||
= header | ||
%div.my-3 | ||
.accordion.concepts-raw-data{id: "accordion-#{@id}"} | ||
%div{id: "heading-#{@id}"} | ||
%h2.mb-0.text-right | ||
.concepts-raw-title{"data-target" => "#collapse-#{@id}", "data-toggle" => "collapse"} | ||
%div Raw data | ||
%img{src: asset_path("arrow-down.svg")} | ||
.collapse{id: "collapse-#{@id}", "data-parent" => "#accordion-#{@id}"} | ||
%table#concepts-content.concepts-content | ||
- top_set, leftover_set, bottom_set = filter_properties(@top_keys, @bottom_keys, @exclude_keys, @concept_properties) | ||
= render_properties(top_set, @acronym) | ||
= render_properties(leftover_set, @acronym) | ||
- sections&.each do |section| | ||
= section | ||
= render_properties(bottom_set, @acronym) | ||
%div.raw-table | ||
= render DropdownContainerComponent.new(title: 'Raw data', id: "accordion-#{@id}") do | ||
- top_set, leftover_set, bottom_set = filter_properties(@top_keys, @bottom_keys, @exclude_keys, @concept_properties) | ||
= render TableComponent.new(stripped: true) do |t| | ||
|
||
- row_hash_properties(top_set, @acronym).each do |row| | ||
- t.add_row(*row) | ||
|
||
- row_hash_properties(leftover_set, @acronym).each do |row| | ||
- t.add_row(*row) | ||
|
||
|
||
- sections.each do |section| | ||
- t.row do | ||
= section | ||
|
||
|
||
- row_hash_properties(bottom_set, @acronym).each do |row| | ||
- t.add_row(*row) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# frozen_string_literal: true | ||
|
||
class TableCellComponent < ViewComponent::Base | ||
|
||
def initialize(width: nil, colspan: nil,type: 'td') | ||
super | ||
@width = width | ||
@type = type | ||
@colspan = colspan | ||
end | ||
|
||
def call | ||
options = {} | ||
options[:width] = @width if @width | ||
options[:colspan] = @colspan if @colspan | ||
content_tag(@type, content&.html_safe, options) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# frozen_string_literal: true | ||
|
||
class TableComponent < ViewComponent::Base | ||
|
||
renders_one :header, TableRowComponent | ||
renders_many :rows, TableRowComponent | ||
|
||
def initialize(id: '', stripped: true) | ||
super | ||
@id = id | ||
@stripped = stripped | ||
end | ||
|
||
def stripped_class | ||
@stripped ? 'table-content-stripped' : '' | ||
end | ||
|
||
def add_row(*array, &block) | ||
self.row.create(*array, &block) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
%table.table-content{id: @id, class: stripped_class} | ||
%thead | ||
= header | ||
%tbody{id: "#{@id}_table_body"} | ||
- rows.each do |row| | ||
= row | ||
= content |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# frozen_string_literal: true | ||
|
||
class TableRowComponent < ViewComponent::Base | ||
|
||
renders_many :cells, TableCellComponent | ||
|
||
def initialize(id: '') | ||
super | ||
@id = id | ||
end | ||
|
||
def create(*array, &block) | ||
array.each do |key_value| | ||
key, value = key_value.to_a.first | ||
self.cell(type: key) { value&.to_s } | ||
end | ||
block.call(self) if block_given? | ||
end | ||
|
||
def th(width: nil, colspan: nil, &block) | ||
self.cell(type: 'th', width: width, colspan: colspan, &block) | ||
end | ||
|
||
def td(width: nil, colspan: nil, &block) | ||
self.cell(type: 'td', width: width, colspan: colspan, &block) | ||
end | ||
end |
4 changes: 4 additions & 0 deletions
4
app/components/table_row_component/table_row_component.html.haml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
%tr{id: @id} | ||
- cells.each do |cell| | ||
= cell | ||
= content |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.