sdr_view_components 0.4.0 → 0.4.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/README.md +21 -0
- data/app/components/sdr_view_components/elements/toast_component.html.erb +1 -1
- data/app/components/sdr_view_components/elements/toast_component.rb +6 -0
- data/app/javascript/sdr_view_components/toast_controller.js +7 -0
- data/lib/sdr_view_components/engine.rb +1 -0
- data/lib/sdr_view_components/version.rb +1 -1
- data/spec/components/previews/sdr_view_components/elements/toast_component_preview.rb +2 -0
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4925b643ff3bbb773d0583382c635d876b270fe449561a106b0766fc85865938
|
|
4
|
+
data.tar.gz: d226b6b48db3c1ca228633f9e6c3c78a53beb4ea6336e9c41c980bc425871a3e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d2ed8d3c294e718797978c170bbf247d9721122f0b8811da747b0ab1d71d6b724b074562e872adbf090d4b5f049400da88f922dfff4ec5f0d81d9524e961915a
|
|
7
|
+
data.tar.gz: 1c8464a8b72bb93c65068cb3b3ab5f47f10e691c5c286757368ac1f87c116adb34ef1f21dcebfe0d3905b304e1f5b021af0169bad069ca47e1fac95893755754
|
data/README.md
CHANGED
|
@@ -25,6 +25,27 @@ This set of components relies on the component library stylesheets, add:
|
|
|
25
25
|
|
|
26
26
|
with the most recent date tagged release to your `application.html.erb` layout file.
|
|
27
27
|
|
|
28
|
+
## JavaScript
|
|
29
|
+
|
|
30
|
+
Some components require JavaScript. The gem ships Stimulus controllers under `app/javascript/sdr_view_components/` and registers that path with the asset pipeline automatically.
|
|
31
|
+
|
|
32
|
+
Here is an example of how to add a Stimulus controller:
|
|
33
|
+
|
|
34
|
+
The disappearing toast uses `sdr_view_components/toast_controller` to remove itself from the DOM after its fade-out animation completes.
|
|
35
|
+
|
|
36
|
+
Add to `config/importmap.rb`:
|
|
37
|
+
```ruby
|
|
38
|
+
pin "sdr_view_components/toast_controller", to: "sdr_view_components/toast_controller.js"
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Register the controller in `app/javascript/controllers/index.js`:
|
|
42
|
+
```javascript
|
|
43
|
+
import { application } from "controllers/application"
|
|
44
|
+
import ToastController from "sdr_view_components/toast_controller"
|
|
45
|
+
|
|
46
|
+
application.register("sdr-toast", ToastController)
|
|
47
|
+
```
|
|
48
|
+
|
|
28
49
|
## Usage
|
|
29
50
|
|
|
30
51
|
### Form components
|
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
module SdrViewComponents
|
|
4
4
|
module Elements
|
|
5
5
|
# Component for rendering a toast element.
|
|
6
|
+
# The disappearing toast uses `sdr_view_components/toast_controller` to remove itself from the DOM after its
|
|
7
|
+
# fade-out animation completes.
|
|
6
8
|
class ToastComponent < BaseComponent
|
|
7
9
|
def initialize(title:, text: nil, close_text: nil, variant: :black, disappearing: false)
|
|
8
10
|
@title = title
|
|
@@ -23,6 +25,10 @@ module SdrViewComponents
|
|
|
23
25
|
merge_classes([background_color], %w[toast-body text-white])
|
|
24
26
|
end
|
|
25
27
|
|
|
28
|
+
def data
|
|
29
|
+
{ controller: 'sdr-toast' } if disappearing
|
|
30
|
+
end
|
|
31
|
+
|
|
26
32
|
def background_color
|
|
27
33
|
case variant
|
|
28
34
|
when :red
|
|
@@ -26,6 +26,7 @@ module SdrViewComponents
|
|
|
26
26
|
initializer 'sdr_view_components.assets' do |app|
|
|
27
27
|
app.config.assets.paths << Engine.root.join('app', 'assets').to_s
|
|
28
28
|
app.config.assets.paths << Engine.root.join('app', 'assets', 'stylesheets').to_s
|
|
29
|
+
app.config.assets.paths << Engine.root.join('app', 'javascript').to_s
|
|
29
30
|
end
|
|
30
31
|
|
|
31
32
|
initializer 'sdr_view_components.helpers' do
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: sdr_view_components
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.4.
|
|
4
|
+
version: 0.4.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Aaron Collier
|
|
@@ -158,6 +158,7 @@ files:
|
|
|
158
158
|
- app/components/sdr_view_components/tables/row_component.html.erb
|
|
159
159
|
- app/components/sdr_view_components/tables/row_component.rb
|
|
160
160
|
- app/components/sdr_view_components/tables/table_component.rb
|
|
161
|
+
- app/javascript/sdr_view_components/toast_controller.js
|
|
161
162
|
- app/views/layouts/lookbook.html.erb
|
|
162
163
|
- config/routes.rb
|
|
163
164
|
- lib/sdr_view_components.rb
|