material_design 0.8.0 → 0.9.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/app/assets/config/material_design_manifest.js +3 -0
- data/app/assets/stylesheets/material_design/chips.css +107 -10
- 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: 501465343ada2fe0bb7395ee4c3b4a5c9b7445900652ce708f4c3624624824b1
|
4
|
+
data.tar.gz: 1521b11bdda2eed12d22b25b4bfaf7c596967b90c0c0fe48301eadbdb2cfc63c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ef3296019b0cb8baf3c0f6555901e82c7e13d7438a137987bc792407dd80f3cb3022a0b8cd5bd785119320b533001f5e0f3ad375eea61da5082398e7afeb5a2e
|
7
|
+
data.tar.gz: dd14b3ed25d14787d566dcff0a304e250f1d37ad111925d434de21e9ee56b47113323aa16a1525ca48a35ae6d555a76389253e32255dab18aa05a81c906f5a15
|
@@ -1,21 +1,118 @@
|
|
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
|
-
display: inline-flex;
|
3
35
|
align-items: center;
|
4
|
-
height: 32px;
|
5
|
-
padding: 8px 12px;
|
6
36
|
border-radius: 8px;
|
7
|
-
|
8
|
-
|
9
|
-
|
37
|
+
cursor: pointer;
|
38
|
+
display: inline-flex;
|
39
|
+
height: 32px;
|
40
|
+
padding: 0px 8px;
|
10
41
|
white-space: nowrap;
|
42
|
+
@media (prefers-color-scheme: light) {
|
43
|
+
border: 1px solid rgb(var(--md-sys-light-outline-variant));
|
44
|
+
color: rgb(var(--md-sys-light-on-surface-variant));
|
45
|
+
}
|
11
46
|
|
47
|
+
@media (prefers-color-scheme: dark) {
|
48
|
+
border: 1px solid rgb(var(--md-sys-dark-outline-variant));
|
49
|
+
color: rgb(var(--md-sys-dark-on-surface-variant));
|
50
|
+
}
|
51
|
+
}
|
52
|
+
|
53
|
+
.chip:hover {
|
54
|
+
background: var(--md-sys-hover-layer-state)
|
55
|
+
radial-gradient(circle, transparent 1%, var(--md-sys-hover-layer-state) 1%)
|
56
|
+
center/15000%;
|
57
|
+
}
|
58
|
+
|
59
|
+
.chip.selected {
|
60
|
+
border-color: transparent;
|
12
61
|
@media (prefers-color-scheme: light) {
|
13
|
-
background: rgb(var(--md-sys-light-secondary-
|
14
|
-
color: rgb(var(--md-sys-
|
62
|
+
background: rgb(var(--md-sys-light-secondary-container));
|
63
|
+
color: rgb(var(--md-sys-light-on-secondary-container));
|
15
64
|
}
|
16
65
|
|
17
66
|
@media (prefers-color-scheme: dark) {
|
18
|
-
background: rgb(var(--md-sys-dark-secondary-
|
19
|
-
color: rgb(var(--md-sys-dark-on-secondary-
|
67
|
+
background: rgb(var(--md-sys-dark-secondary-container));
|
68
|
+
color: rgb(var(--md-sys-dark-on-secondary-container));
|
69
|
+
}
|
70
|
+
}
|
71
|
+
|
72
|
+
.chip.selected:hover {
|
73
|
+
background: var(--md-sys-hover-selected-state)
|
74
|
+
radial-gradient(
|
75
|
+
circle,
|
76
|
+
transparent 1%,
|
77
|
+
var(--md-sys-hover-selected-state) 1%
|
78
|
+
)
|
79
|
+
center/15000%;
|
80
|
+
}
|
81
|
+
|
82
|
+
.chip__container {
|
83
|
+
box-sizing: border-box;
|
84
|
+
display: inline-block;
|
85
|
+
margin: 0;
|
86
|
+
position: relative;
|
87
|
+
vertical-align: middle;
|
88
|
+
}
|
89
|
+
|
90
|
+
.chip__dropdown {
|
91
|
+
box-sizing: border-box;
|
92
|
+
display: block;
|
93
|
+
max-width: calc(100vw - 60px);
|
94
|
+
min-width: 100%;
|
95
|
+
position: absolute;
|
96
|
+
width: fit-content;
|
97
|
+
z-index: 1051;
|
98
|
+
}
|
99
|
+
|
100
|
+
@media (min-width: 768px) {
|
101
|
+
.chip__dropdown {
|
102
|
+
max-width: calc(100vw - 140px);
|
20
103
|
}
|
21
104
|
}
|
105
|
+
|
106
|
+
.chip__label {
|
107
|
+
font-size: 14px;
|
108
|
+
font-weight: 500;
|
109
|
+
padding: 0px 8px;
|
110
|
+
}
|
111
|
+
|
112
|
+
.dropdown--hidden {
|
113
|
+
display: none;
|
114
|
+
}
|
115
|
+
|
116
|
+
.rotate-180 {
|
117
|
+
transform: rotate(180deg);
|
118
|
+
}
|
@@ -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: "chip__container", data: merged_data) do
|
7
|
+
concat(content_tag(:div, class: class_names("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: "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 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.0
|
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
|