optics_view_components 0.1.5 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/components/optics/sidebar/component.rb +94 -0
- data/lib/optics/view_components/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5194f25da267f185510137dd9cb5cda150d6da2ea4bea6dcdbe2353360b460ba
|
4
|
+
data.tar.gz: c856c408ca950243a0b00bf080c93c8a1d182f7a1bcb87df35084522c82c78d4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 87d76b46feb1fed4772bd7e6ca8efd36e1c3bb38cae8fb94325f676dfef1e38bb8b6ec9a897010d72dd7d154dd6638ce961e2a6245c45be0a170a8c036276fb9
|
7
|
+
data.tar.gz: fafd24dd4f8738e53b012a0a82ce10b4a2c6e35c7ccbaa872316055641260d2c62c09cfbc8ce8e87c63578ea37566c23544fd4d06d57cf54c561e866958fa148
|
@@ -0,0 +1,94 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Optics
|
4
|
+
module Sidebar
|
5
|
+
class Component < ApplicationViewComponent
|
6
|
+
VARIANTS = %w[drawer compact rail]
|
7
|
+
|
8
|
+
renders_one :brand, 'Brand'
|
9
|
+
renders_many :sidebar_contents, 'SidebarContent'
|
10
|
+
|
11
|
+
accepts :responsive, default: false
|
12
|
+
accepts :variant, default: 'drawer'
|
13
|
+
|
14
|
+
def call
|
15
|
+
content_tag(
|
16
|
+
:nav,
|
17
|
+
class: classes
|
18
|
+
) do
|
19
|
+
capture do
|
20
|
+
concat brand
|
21
|
+
sidebar_contents.each do |content|
|
22
|
+
concat content
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def classes
|
29
|
+
class_names(
|
30
|
+
'sidebar',
|
31
|
+
variant_class,
|
32
|
+
@attributes[:class],
|
33
|
+
'sidebar--responsive': responsive
|
34
|
+
).join(' ')
|
35
|
+
end
|
36
|
+
|
37
|
+
def variant_class
|
38
|
+
"sidebar--#{variant}"
|
39
|
+
end
|
40
|
+
|
41
|
+
class Brand < ApplicationViewComponent
|
42
|
+
accepts :url
|
43
|
+
accepts :image_source
|
44
|
+
|
45
|
+
def call
|
46
|
+
link_to(url, class: 'sidebar__brand') do
|
47
|
+
image_tag(image_source)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
class SidebarContent < ApplicationViewComponent
|
53
|
+
renders_many :buttons, Optics::Button::Component
|
54
|
+
|
55
|
+
accepts :position, default: 'center'
|
56
|
+
|
57
|
+
def call
|
58
|
+
concat(
|
59
|
+
content_tag(
|
60
|
+
:div,
|
61
|
+
class: classes
|
62
|
+
) do
|
63
|
+
buttons.each do |button|
|
64
|
+
concat button
|
65
|
+
end
|
66
|
+
end
|
67
|
+
)
|
68
|
+
end
|
69
|
+
|
70
|
+
def classes
|
71
|
+
class_names(
|
72
|
+
'sidebar__content',
|
73
|
+
position_class,
|
74
|
+
).join(' ')
|
75
|
+
end
|
76
|
+
|
77
|
+
def position_class
|
78
|
+
"sidebar__content--#{position}"
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
class LinksComponent < ApplicationViewComponent
|
83
|
+
accepts :image_source
|
84
|
+
accepts :url
|
85
|
+
|
86
|
+
def call
|
87
|
+
link_to(url, class: 'sidebar__brand') do
|
88
|
+
image_tag(image_source)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: optics_view_components
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Reed Law
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-07-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: view_component
|
@@ -119,6 +119,7 @@ files:
|
|
119
119
|
- app/components/optics/application_view_component_preview.rb
|
120
120
|
- app/components/optics/button/component.rb
|
121
121
|
- app/components/optics/icon/component.rb
|
122
|
+
- app/components/optics/sidebar/component.rb
|
122
123
|
- demo/.ruby-version
|
123
124
|
- demo/Gemfile
|
124
125
|
- demo/Gemfile.lock
|