Skip to content

Commit

Permalink
Merge branch 'release/v0.2.5'
Browse files Browse the repository at this point in the history
  • Loading branch information
bopm committed Apr 12, 2024
2 parents 8665edd + dd56262 commit cb5814e
Show file tree
Hide file tree
Showing 18 changed files with 116 additions and 6 deletions.
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:
turbo_material (0.2.4)
turbo_material (0.2.5)
importmap-rails (~> 2.0.1)
rails (~> 7.1, >= 7.1.2)
stimulus-rails (~> 1.3)
Expand Down
2 changes: 1 addition & 1 deletion app/assets/dist/turbo_material/tailwind.css

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ export default class extends Controller {
static outlets = [ "material-drawer" ]

connect() {
mdc.ripple.MDCRipple.attachTo(this.element);
if(!document.querySelector('.mdc-drawer--dismissible.mdc-drawer--right')) {
this.element.style.display = 'none';
} else {
mdc.ripple.MDCRipple.attachTo(this.element);
}
}

click() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ export default class extends Controller {

connect() {
this.dialog = mdc.dialog.MDCDialog.attachTo(this.element);
this.dialog.listen('MDCDialog:opened', () => {
this.element.querySelectorAll('.mdc-icon-button').forEach((button) => {
mdc.ripple.MDCRipple.attachTo(button);
});
});
if (this.openedValue) {
this.dialog.open();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { Controller } from "@hotwired/stimulus";

export default class extends Controller {
ripple = undefined;
connect() {
mdc.ripple.MDCRipple.attachTo(this.element);
this.ripple = mdc.ripple.MDCRipple.attachTo(this.element);
}

disconnect() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Controller } from "@hotwired/stimulus";

export default class extends Controller {
connect() {
mdc.tooltip.MDCTooltip.attachTo(this.element);
}

disconnect() {
}
}
11 changes: 11 additions & 0 deletions app/helpers/turbo_material/chip_set_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module TurboMaterial
module ChipSetHelper
def material_chip_set(kwargs = {})
render "components/chip_set", **kwargs
end

def material_chip(kwargs = {})
render "components/chip", **kwargs
end
end
end
14 changes: 13 additions & 1 deletion app/helpers/turbo_material/data_table_helper.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
module TurboMaterial
module DataTableHelper
def material_data_table(kwargs = {})
render "components/material_data_table", **kwargs
render 'components/data_table', **kwargs
end

def material_data_table_row_checkbox(kwargs = {})
render 'components/data_table/row_checkbox', **kwargs
end

def material_data_table_sortable_header(kwargs = {})
render 'components/data_table/sortable_header', **kwargs
end

def material_data_table_header(kwargs = {})
render 'components/data_table/header', **kwargs
end

def aria_sort(key, default: false)
Expand Down
8 changes: 8 additions & 0 deletions app/helpers/turbo_material/tooltip_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module TurboMaterial
module TooltipHelper
def material_tooltip(kwargs = {}, &block)
content = block_given? ? capture(&block) : nil
render "components/tooltip", **kwargs, content: content
end
end
end
9 changes: 9 additions & 0 deletions app/views/components/_chip.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<%# locals: (label:) %>
<span class="mdc-chip" role="row">
<span class="mdc-chip__cell mdc-evolution-chip__cell--primary" role="gridcell">
<button class="mdc-chip__action mdc-evolution-chip__action--primary" type="button">
<span class="mdc-chip__ripple mdc-evolution-chip__ripple--primary"></span>
<span class="mdc-chip__text-label"><%= label %></span>
</button>
</span>
</span>
8 changes: 8 additions & 0 deletions app/views/components/_chip_set.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<%# locals: (chips: []) %>
<span class="mdc-chip-set" role="grid" data-controller="material-chipset">
<span class="mdc-chip-set__chips" role="presentation">
<%- chips.each do |chip| -%>
<%= material_chip label: chip[:label] %>
<%- end -%>
</span>
</span>
File renamed without changes.
8 changes: 8 additions & 0 deletions app/views/components/_tooltip.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<%# locals: (id:, content: nil) %>
<%- if content.present? -%>
<div id="<%= id %>" class="mdc-tooltip" role="tooltip" aria-hidden="true" data-controller="material-tooltip">
<div class="mdc-tooltip__surface mdc-tooltip__surface-animation">
<span class="mdc-tooltip__label flex flex-col items-start"><%= content %></span>
</div>
</div>
<%- end -%>
4 changes: 4 additions & 0 deletions app/views/components/data_table/_header.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<%# locals: (label:, column_id:) %>
<th class="mdc-data-table__header-cell" role="columnheader" scope="col" data-column-id="<%= column_id %>">
<%= label %>
</th>
13 changes: 13 additions & 0 deletions app/views/components/data_table/_row_checkbox.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<%# locals: (id:) %>
<td class="mdc-data-table__cell mdc-data-table__cell--checkbox">
<div class="mdc-checkbox mdc-data-table__row-checkbox">
<input type="checkbox" class="mdc-checkbox__native-control" aria-labelledby="<%= id %>"/>
<div class="mdc-checkbox__background">
<svg class="mdc-checkbox__checkmark" viewBox="0 0 24 24">
<path class="mdc-checkbox__checkmark-path" fill="none" d="M1.73,12.91 8.1,19.28 22.79,4.59"/>
</svg>
<div class="mdc-checkbox__mixedmark"></div>
</div>
<div class="mdc-checkbox__ripple"></div>
</div>
</td>
15 changes: 15 additions & 0 deletions app/views/components/data_table/_sortable_header.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<%# locals: (label:, sort_value:, column_id:) %>
<th
class="mdc-data-table__header-cell mdc-data-table__header-cell--with-sort<%= sort_class(sort_value) %>"
role="columnheader"
scope="col"
aria-sort="<%= sort_value %>"
data-column-id="<%= column_id %>"
>
<div class="mdc-data-table__header-cell-wrapper">
<div class="mdc-data-table__header-cell-label"><%= label %></div>
<button class="mdc-icon-button material-icons mdc-data-table__sort-icon-button"
aria-label="Sort by <%= label %>" aria-describedby="<%= column_id %>-label"><%= sort_arrow(sort_value) %></button>
<div class="mdc-data-table__sort-status-label" aria-hidden="true" id="<%= column_id %>-label"></div>
</div>
</th>
2 changes: 2 additions & 0 deletions lib/turbo_material/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class Engine < ::Rails::Engine
helper TurboMaterial::ApplicationHelper
helper TurboMaterial::InputHelper
helper TurboMaterial::CheckboxHelper
helper TurboMaterial::ChipSetHelper
helper TurboMaterial::ChipsInputHelper
helper TurboMaterial::ChipsSelectHelper
helper TurboMaterial::DataTableHelper
Expand All @@ -18,6 +19,7 @@ class Engine < ::Rails::Engine
helper TurboMaterial::SelectHelper
helper TurboMaterial::SwitchHelper
helper TurboMaterial::TextareaHelper
helper TurboMaterial::TooltipHelper
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/turbo_material/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module TurboMaterial
VERSION = "0.2.4"
VERSION = "0.2.5"
end

0 comments on commit cb5814e

Please sign in to comment.