material_design 0.8.0 → 0.9.1
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/app/assets/config/material_design_manifest.js +3 -0
- data/app/assets/stylesheets/material_design/chips.css +119 -1
- data/app/helpers/material_design/chip_helper.rb +32 -0
- data/app/javascript/material_design/application.js +1 -0
- data/app/javascript/material_design/controllers/application.js +9 -0
- data/app/javascript/material_design/controllers/filter_chip_controller.js +73 -0
- data/app/javascript/material_design/controllers/index.js +11 -0
- data/config/importmap.rb +5 -0
- data/lib/material_design/engine.rb +13 -0
- data/lib/material_design/railtie.rb +4 -3
- data/lib/material_design/version.rb +1 -1
- metadata +38 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5cd4edaa73836367a47688dc4c71958243d528a4dc98d3c72d8994d62d51394d
|
4
|
+
data.tar.gz: 37caf5262a8ab7f6b362355153e8a2f366f1f2eb8cbd3e104eb53ae11e3d7bf8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9b27f10fd39f2c79654ff56002e52979171647272140f9764494bf42b2af5539c18b11860f5d9505eb23435c895b8f364d33d7b7d3bd47bb135d4f0d4648eb07
|
7
|
+
data.tar.gz: 2f9f0bb2e39c1956a1a3517bea036fe68c31211578ca1f20258e40ebfdbee1583b5fd0586b7984c659c3dda1279d43d33d2b9746e76edd99986d6eaa232a1f93
|
@@ -1,3 +1,36 @@
|
|
1
|
+
@media (prefers-color-scheme: light) {
|
2
|
+
:root {
|
3
|
+
--md-sys-hover-layer-state: rgb(
|
4
|
+
var(--md-sys-light-on-surface-variant) /
|
5
|
+
var(--md-sys-light-state-hover-state-layer-opacity)
|
6
|
+
);
|
7
|
+
--md-sys-hover-selected-state: rgb(
|
8
|
+
var(--md-sys-light-on-secondary-container) /
|
9
|
+
var(--md-sys-light-state-hover-state-layer-opacity)
|
10
|
+
);
|
11
|
+
--md-sys-pressed-layer-state: rgb(
|
12
|
+
var(--md-sys-light-on-secondary-container) / 0.1
|
13
|
+
);
|
14
|
+
}
|
15
|
+
}
|
16
|
+
|
17
|
+
@media (prefers-color-scheme: dark) {
|
18
|
+
:root {
|
19
|
+
--md-sys-hover-layer-state: rgb(
|
20
|
+
var(--md-sys-dark-on-surface-variant) /
|
21
|
+
var(--md-sys-dark-state-hover-state-layer-opacity)
|
22
|
+
);
|
23
|
+
--md-sys-hover-selected-state: rgb(
|
24
|
+
var(--md-sys-dark-on-secondary-container) /
|
25
|
+
var(--md-sys-dark-state-hover-state-layer-opacity)
|
26
|
+
);
|
27
|
+
--md-sys-pressed-layer-state: rgb(
|
28
|
+
var(--md-sys-dark-on-secondary-container) /
|
29
|
+
var(--md-sys-dark-state-pressed-state-layer-opacity)
|
30
|
+
);
|
31
|
+
}
|
32
|
+
}
|
33
|
+
|
1
34
|
.chip {
|
2
35
|
display: inline-flex;
|
3
36
|
align-items: center;
|
@@ -6,7 +39,6 @@
|
|
6
39
|
border-radius: 8px;
|
7
40
|
font-size: 14px;
|
8
41
|
font-weight: 500;
|
9
|
-
margin-right: 8px;
|
10
42
|
white-space: nowrap;
|
11
43
|
|
12
44
|
@media (prefers-color-scheme: light) {
|
@@ -19,3 +51,89 @@
|
|
19
51
|
color: rgb(var(--md-sys-dark-on-secondary-fixed));
|
20
52
|
}
|
21
53
|
}
|
54
|
+
|
55
|
+
.filter-chip {
|
56
|
+
align-items: center;
|
57
|
+
border-radius: 8px;
|
58
|
+
cursor: pointer;
|
59
|
+
display: inline-flex;
|
60
|
+
height: 32px;
|
61
|
+
padding: 0px 8px;
|
62
|
+
white-space: nowrap;
|
63
|
+
@media (prefers-color-scheme: light) {
|
64
|
+
border: 1px solid rgb(var(--md-sys-light-outline-variant));
|
65
|
+
color: rgb(var(--md-sys-light-on-surface-variant));
|
66
|
+
}
|
67
|
+
|
68
|
+
@media (prefers-color-scheme: dark) {
|
69
|
+
border: 1px solid rgb(var(--md-sys-dark-outline-variant));
|
70
|
+
color: rgb(var(--md-sys-dark-on-surface-variant));
|
71
|
+
}
|
72
|
+
}
|
73
|
+
|
74
|
+
.filter-chip:hover {
|
75
|
+
background: var(--md-sys-hover-layer-state)
|
76
|
+
radial-gradient(circle, transparent 1%, var(--md-sys-hover-layer-state) 1%)
|
77
|
+
center/15000%;
|
78
|
+
}
|
79
|
+
|
80
|
+
.filter-chip.selected {
|
81
|
+
border-color: transparent;
|
82
|
+
@media (prefers-color-scheme: light) {
|
83
|
+
background: rgb(var(--md-sys-light-secondary-container));
|
84
|
+
color: rgb(var(--md-sys-light-on-secondary-container));
|
85
|
+
}
|
86
|
+
|
87
|
+
@media (prefers-color-scheme: dark) {
|
88
|
+
background: rgb(var(--md-sys-dark-secondary-container));
|
89
|
+
color: rgb(var(--md-sys-dark-on-secondary-container));
|
90
|
+
}
|
91
|
+
}
|
92
|
+
|
93
|
+
.filter-chip.selected:hover {
|
94
|
+
background: var(--md-sys-hover-selected-state)
|
95
|
+
radial-gradient(
|
96
|
+
circle,
|
97
|
+
transparent 1%,
|
98
|
+
var(--md-sys-hover-selected-state) 1%
|
99
|
+
)
|
100
|
+
center/15000%;
|
101
|
+
}
|
102
|
+
|
103
|
+
.filter-chip__container {
|
104
|
+
box-sizing: border-box;
|
105
|
+
display: inline-block;
|
106
|
+
margin: 0;
|
107
|
+
position: relative;
|
108
|
+
vertical-align: middle;
|
109
|
+
}
|
110
|
+
|
111
|
+
.filter-chip__dropdown {
|
112
|
+
box-sizing: border-box;
|
113
|
+
display: block;
|
114
|
+
max-width: calc(100vw - 60px);
|
115
|
+
min-width: 100%;
|
116
|
+
position: absolute;
|
117
|
+
width: fit-content;
|
118
|
+
z-index: 1051;
|
119
|
+
}
|
120
|
+
|
121
|
+
@media (min-width: 768px) {
|
122
|
+
.filter-chip__dropdown {
|
123
|
+
max-width: calc(100vw - 140px);
|
124
|
+
}
|
125
|
+
}
|
126
|
+
|
127
|
+
.filter-chip__label {
|
128
|
+
font-size: 14px;
|
129
|
+
font-weight: 500;
|
130
|
+
padding: 0px 8px;
|
131
|
+
}
|
132
|
+
|
133
|
+
.dropdown--hidden {
|
134
|
+
display: none;
|
135
|
+
}
|
136
|
+
|
137
|
+
.rotate-180 {
|
138
|
+
transform: rotate(180deg);
|
139
|
+
}
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module MaterialDesign
|
2
|
+
module ChipHelper
|
3
|
+
def md_filter_chip(label=nil, leading_icon: nil, trailing_icon: nil, selected: false, data: {}, style: nil, &block)
|
4
|
+
merged_data = data.merge(controller: "filter-chip", filter_chip_selected_value: selected, action: "#{block_given? ? "click->filter-chip#toggleDropdown" : "click->filter-chip#toggleSelect"}")
|
5
|
+
|
6
|
+
chip_content = content_tag(:div, class: "filter-chip__container", data: merged_data) do
|
7
|
+
concat(content_tag(:div, class: class_names("filter-chip", selected: selected), data: { filter_chip_target: "chip"}, style: style) do
|
8
|
+
concat(content_tag(:span, class: "dropdown--hidden", data: {filter_chip_target: "selectedIcon"}) do
|
9
|
+
render("material_design/icons/icon", locals: { icon: "check", size: 18 })
|
10
|
+
end)
|
11
|
+
concat(content_tag(:span, data: {filter_chip_target: "leadingIcon"}) do
|
12
|
+
render("material_design/icons/icon", locals: { icon: leading_icon, size: 18 }) if leading_icon
|
13
|
+
end)
|
14
|
+
concat(content_tag(:p, label, class: "filter-chip__label", data: {filter_chip_target: "label"}))
|
15
|
+
concat(content_tag(:span, data: {filter_chip_target: "chevronIcon"}) do
|
16
|
+
render("material_design/icons/icon", locals: { icon: "arrow_drop_down", size: 18 })
|
17
|
+
end) if block_given?
|
18
|
+
concat(content_tag(:span, data: {filter_chip_target: "trailingIcon"}) do
|
19
|
+
render("material_design/icons/icon", locals: { icon: trailing_icon, size: 18 }) if trailing_icon && !block_given?
|
20
|
+
end)
|
21
|
+
end)
|
22
|
+
if block_given?
|
23
|
+
concat(content_tag(:div, class: "dropdown--hidden filter-chip__dropdown", data: {filter_chip_target: "dropdown"}) do
|
24
|
+
capture(&block)
|
25
|
+
end)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
chip_content
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
import "controllers";
|
@@ -0,0 +1,73 @@
|
|
1
|
+
import { Controller } from "@hotwired/stimulus";
|
2
|
+
import { useClickOutside, useTransition } from "stimulus-use";
|
3
|
+
|
4
|
+
export default class extends Controller {
|
5
|
+
static targets = [
|
6
|
+
"chevronIcon",
|
7
|
+
"chip",
|
8
|
+
"dropdown",
|
9
|
+
"label",
|
10
|
+
"leadingIcon",
|
11
|
+
"selectedIcon",
|
12
|
+
"trailingIcon",
|
13
|
+
];
|
14
|
+
static values = { open: Boolean, selected: Boolean };
|
15
|
+
|
16
|
+
connect() {
|
17
|
+
this.setSelected();
|
18
|
+
|
19
|
+
useTransition(this, {
|
20
|
+
element: this.dropdownTarget,
|
21
|
+
enterActive: "transition ease-out duration-100",
|
22
|
+
enterFrom: "transform opacity-0 scale-95",
|
23
|
+
enterTo: "transform opacity-100 scale-100",
|
24
|
+
leaveActive: "transition ease-in duration-75",
|
25
|
+
leaveFrom: "transform opacity-100 scale-100",
|
26
|
+
leaveTo: "transform opacity-0 scale-95",
|
27
|
+
hiddenClass: "dropdown--hidden",
|
28
|
+
transitioned: false,
|
29
|
+
});
|
30
|
+
|
31
|
+
useClickOutside(this);
|
32
|
+
|
33
|
+
if (this.openValue) {
|
34
|
+
this.openDropdown();
|
35
|
+
} else {
|
36
|
+
this.closeDropdown();
|
37
|
+
}
|
38
|
+
}
|
39
|
+
|
40
|
+
clickOutside() {
|
41
|
+
this.closeDropdown();
|
42
|
+
}
|
43
|
+
|
44
|
+
toggleDropdown() {
|
45
|
+
if (this.dropdownTarget.classList.contains("dropdown--hidden")) {
|
46
|
+
this.openDropdown();
|
47
|
+
} else {
|
48
|
+
this.closeDropdown();
|
49
|
+
}
|
50
|
+
}
|
51
|
+
|
52
|
+
openDropdown() {
|
53
|
+
this.enter();
|
54
|
+
this.chevronIconTarget.classList.add("rotate-180");
|
55
|
+
}
|
56
|
+
|
57
|
+
closeDropdown() {
|
58
|
+
this.leave();
|
59
|
+
this.chevronIconTarget.classList.remove("rotate-180");
|
60
|
+
}
|
61
|
+
|
62
|
+
setSelected() {
|
63
|
+
if (this.selectedValue) {
|
64
|
+
this.selectedIconTarget.classList.remove("dropdown--hidden");
|
65
|
+
this.leadingIconTarget.classList.add("dropdown--hidden");
|
66
|
+
}
|
67
|
+
}
|
68
|
+
|
69
|
+
toggleSelected() {
|
70
|
+
this.selectedIconTarget.classList.toggle("dropdown--hidden");
|
71
|
+
this.leadingIconTarget.classList.toggle("dropdown--hidden");
|
72
|
+
}
|
73
|
+
}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
// Import and register all your controllers from the importmap under controllers/*
|
2
|
+
|
3
|
+
import { application } from "./application";
|
4
|
+
|
5
|
+
// Eager load all controllers defined in the import map under controllers/**/*_controller
|
6
|
+
import { eagerLoadControllersFrom } from "@hotwired/stimulus-loading";
|
7
|
+
eagerLoadControllersFrom("controllers", application);
|
8
|
+
|
9
|
+
// Lazy load controllers as they appear in the DOM (remember not to preload controllers in import map!)
|
10
|
+
// import { lazyLoadControllersFrom } from "@hotwired/stimulus-loading"
|
11
|
+
// lazyLoadControllersFrom("controllers", application)
|
data/config/importmap.rb
ADDED
@@ -0,0 +1,5 @@
|
|
1
|
+
pin "application-md", to: "material_design/application.js"
|
2
|
+
pin "@hotwired/stimulus", to: "stimulus.min.js", preload: true
|
3
|
+
pin "@hotwired/stimulus-loading", to: "stimulus-loading.js", preload: true
|
4
|
+
pin_all_from MaterialDesign::Engine.root.join("app/javascript/material_design/controllers"), under: "controllers", to: "material_design/controllers"
|
5
|
+
|
@@ -1,5 +1,18 @@
|
|
1
|
+
require "importmap-rails"
|
2
|
+
require "stimulus-rails"
|
3
|
+
|
1
4
|
module MaterialDesign
|
2
5
|
class Engine < ::Rails::Engine
|
3
6
|
isolate_namespace MaterialDesign
|
7
|
+
|
8
|
+
initializer "material_design.assets" do |app|
|
9
|
+
app.config.assets.paths << root.join("app/javascript")
|
10
|
+
app.config.assets.precompile += %w[ material_design_manifest ]
|
11
|
+
end
|
12
|
+
|
13
|
+
initializer "material_design.importmap", before: "importmap" do |app|
|
14
|
+
app.config.importmap.paths << root.join("config/importmap.rb")
|
15
|
+
app.config.importmap.cache_sweepers << root.join("app/javascript")
|
16
|
+
end
|
4
17
|
end
|
5
18
|
end
|
@@ -1,10 +1,11 @@
|
|
1
1
|
require "rails/railtie"
|
2
2
|
|
3
3
|
module MyGem
|
4
|
-
class Railtie < Rails::Railtie
|
4
|
+
class Railtie < Rails::Railtie
|
5
5
|
initializer "material_design.action_controller" do
|
6
|
-
ActiveSupport.on_load(:action_controller_base) do
|
7
|
-
helper MaterialDesign::ButtonHelper
|
6
|
+
ActiveSupport.on_load(:action_controller_base) do
|
7
|
+
helper MaterialDesign::ButtonHelper
|
8
|
+
helper MaterialDesign::ChipHelper
|
8
9
|
end
|
9
10
|
end
|
10
11
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: material_design
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eduardo Yutaka Nakanishi
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2024-10-
|
15
|
+
date: 2024-10-28 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: rails
|
@@ -28,6 +28,34 @@ dependencies:
|
|
28
28
|
- - ">="
|
29
29
|
- !ruby/object:Gem::Version
|
30
30
|
version: 7.1.3
|
31
|
+
- !ruby/object:Gem::Dependency
|
32
|
+
name: importmap-rails
|
33
|
+
requirement: !ruby/object:Gem::Requirement
|
34
|
+
requirements:
|
35
|
+
- - ">="
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
requirements:
|
42
|
+
- - ">="
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: '0'
|
45
|
+
- !ruby/object:Gem::Dependency
|
46
|
+
name: stimulus-rails
|
47
|
+
requirement: !ruby/object:Gem::Requirement
|
48
|
+
requirements:
|
49
|
+
- - ">="
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: '0'
|
52
|
+
type: :runtime
|
53
|
+
prerelease: false
|
54
|
+
version_requirements: !ruby/object:Gem::Requirement
|
55
|
+
requirements:
|
56
|
+
- - ">="
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: '0'
|
31
59
|
description: Material is Google’s open-source design system. Design and build beautiful,
|
32
60
|
usable products with Material.
|
33
61
|
email:
|
@@ -39,6 +67,7 @@ files:
|
|
39
67
|
- MIT-LICENSE
|
40
68
|
- README.md
|
41
69
|
- Rakefile
|
70
|
+
- app/assets/config/material_design_manifest.js
|
42
71
|
- app/assets/stylesheets/material_design/app_bars.css
|
43
72
|
- app/assets/stylesheets/material_design/application.css
|
44
73
|
- app/assets/stylesheets/material_design/buttons.css
|
@@ -54,6 +83,11 @@ files:
|
|
54
83
|
- app/controllers/material_design/application_controller.rb
|
55
84
|
- app/helpers/material_design/application_helper.rb
|
56
85
|
- app/helpers/material_design/button_helper.rb
|
86
|
+
- app/helpers/material_design/chip_helper.rb
|
87
|
+
- app/javascript/material_design/application.js
|
88
|
+
- app/javascript/material_design/controllers/application.js
|
89
|
+
- app/javascript/material_design/controllers/filter_chip_controller.js
|
90
|
+
- app/javascript/material_design/controllers/index.js
|
57
91
|
- app/jobs/material_design/application_job.rb
|
58
92
|
- app/mailers/material_design/application_mailer.rb
|
59
93
|
- app/models/material_design/application_record.rb
|
@@ -2206,6 +2240,7 @@ files:
|
|
2206
2240
|
- app/views/material_design/typography/_label_large.html.erb
|
2207
2241
|
- app/views/material_design/typography/_title_large.html.erb
|
2208
2242
|
- app/views/material_design/typography/_title_small.html.erb
|
2243
|
+
- config/importmap.rb
|
2209
2244
|
- config/routes.rb
|
2210
2245
|
- lib/material_design.rb
|
2211
2246
|
- lib/material_design/engine.rb
|
@@ -2232,7 +2267,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
2232
2267
|
- !ruby/object:Gem::Version
|
2233
2268
|
version: '0'
|
2234
2269
|
requirements: []
|
2235
|
-
rubygems_version: 3.5.
|
2270
|
+
rubygems_version: 3.5.21
|
2236
2271
|
signing_key:
|
2237
2272
|
specification_version: 4
|
2238
2273
|
summary: Material Design
|