cubit_components 0.1.0 → 0.2.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 +20 -43
- data/Rakefile +8 -5
- data/lib/cubit_components/base_component.rb +48 -19
- data/lib/cubit_components/box_component.rb +1 -3
- data/lib/cubit_components/configuration.rb +16 -8
- data/lib/cubit_components/container_component.rb +11 -0
- data/lib/cubit_components/flex_component.rb +17 -0
- data/lib/cubit_components/grid_component.rb +16 -0
- data/lib/cubit_components/hstack_component.rb +12 -0
- data/lib/cubit_components/page_component.rb +11 -27
- data/lib/cubit_components/page_container_component.rb +27 -0
- data/lib/cubit_components/placeholder_component.rb +36 -0
- data/lib/cubit_components/spread_component.rb +9 -54
- data/lib/cubit_components/stack_component.rb +7 -25
- data/lib/cubit_components/style_dsl.rb +53 -0
- data/lib/cubit_components/version.rb +3 -1
- data/lib/cubit_components/vstack_component.rb +12 -0
- data/lib/cubit_components.rb +11 -24
- data/sig/cubit_components.rbs +4 -0
- metadata +23 -156
- data/MIT-LICENSE +0 -20
- data/app/assets/stylesheets/cubit_components/application.css +0 -6
- data/app/assets/tailwind/cubit_components/engine.css +0 -4
- data/config/routes.rb +0 -2
- data/lib/cubit_components/bleed_component.rb +0 -26
- data/lib/cubit_components/columns_component.rb +0 -48
- data/lib/cubit_components/content_block_component.rb +0 -21
- data/lib/cubit_components/engine.rb +0 -14
- data/lib/cubit_components/inline_component.rb +0 -19
- data/lib/cubit_components/page_block_component.rb +0 -37
- data/lib/cubit_components/previews/bleed_component_preview.rb +0 -13
- data/lib/cubit_components/previews/box_component_preview.rb +0 -12
- data/lib/cubit_components/previews/columns_component_preview.rb +0 -20
- data/lib/cubit_components/previews/components_index.rb +0 -28
- data/lib/cubit_components/previews/content_block_component_preview.rb +0 -13
- data/lib/cubit_components/previews/inline_component_preview.rb +0 -25
- data/lib/cubit_components/previews/page_block_component_preview.rb +0 -13
- data/lib/cubit_components/previews/page_component_preview.rb +0 -17
- data/lib/cubit_components/previews/preview_helper.rb +0 -15
- data/lib/cubit_components/previews/spread_component_preview.rb +0 -46
- data/lib/cubit_components/previews/stack_component_preview.rb +0 -22
- data/lib/cubit_components/previews/tiles_component_preview.rb +0 -20
- data/lib/cubit_components/tailwind_generated_classes_chat.txt +0 -127
- data/lib/cubit_components/tiles_component.rb +0 -43
- data/lib/cubit_components/vattr_validator.rb +0 -53
- data/lib/generators/cubit/install/install_generator.rb +0 -63
- data/lib/tasks/cubit_components_tasks.rake +0 -4
metadata
CHANGED
|
@@ -1,192 +1,60 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: cubit_components
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1
|
|
4
|
+
version: 0.2.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Fabio Papa
|
|
8
|
-
bindir:
|
|
8
|
+
bindir: exe
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date:
|
|
10
|
+
date: 2026-07-18 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
|
-
- !ruby/object:Gem::Dependency
|
|
13
|
-
name: propshaft
|
|
14
|
-
requirement: !ruby/object:Gem::Requirement
|
|
15
|
-
requirements:
|
|
16
|
-
- - "~>"
|
|
17
|
-
- !ruby/object:Gem::Version
|
|
18
|
-
version: '1.0'
|
|
19
|
-
type: :runtime
|
|
20
|
-
prerelease: false
|
|
21
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
22
|
-
requirements:
|
|
23
|
-
- - "~>"
|
|
24
|
-
- !ruby/object:Gem::Version
|
|
25
|
-
version: '1.0'
|
|
26
|
-
- !ruby/object:Gem::Dependency
|
|
27
|
-
name: rails
|
|
28
|
-
requirement: !ruby/object:Gem::Requirement
|
|
29
|
-
requirements:
|
|
30
|
-
- - "~>"
|
|
31
|
-
- !ruby/object:Gem::Version
|
|
32
|
-
version: '8.0'
|
|
33
|
-
type: :runtime
|
|
34
|
-
prerelease: false
|
|
35
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
36
|
-
requirements:
|
|
37
|
-
- - "~>"
|
|
38
|
-
- !ruby/object:Gem::Version
|
|
39
|
-
version: '8.0'
|
|
40
|
-
- !ruby/object:Gem::Dependency
|
|
41
|
-
name: tailwindcss-rails
|
|
42
|
-
requirement: !ruby/object:Gem::Requirement
|
|
43
|
-
requirements:
|
|
44
|
-
- - "~>"
|
|
45
|
-
- !ruby/object:Gem::Version
|
|
46
|
-
version: '4.0'
|
|
47
|
-
type: :runtime
|
|
48
|
-
prerelease: false
|
|
49
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
50
|
-
requirements:
|
|
51
|
-
- - "~>"
|
|
52
|
-
- !ruby/object:Gem::Version
|
|
53
|
-
version: '4.0'
|
|
54
12
|
- !ruby/object:Gem::Dependency
|
|
55
13
|
name: view_component
|
|
56
14
|
requirement: !ruby/object:Gem::Requirement
|
|
57
15
|
requirements:
|
|
58
|
-
- - "
|
|
16
|
+
- - ">="
|
|
59
17
|
- !ruby/object:Gem::Version
|
|
60
18
|
version: '3.0'
|
|
61
19
|
type: :runtime
|
|
62
20
|
prerelease: false
|
|
63
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
64
22
|
requirements:
|
|
65
|
-
- - "
|
|
23
|
+
- - ">="
|
|
66
24
|
- !ruby/object:Gem::Version
|
|
67
25
|
version: '3.0'
|
|
68
|
-
-
|
|
69
|
-
name: capybara
|
|
70
|
-
requirement: !ruby/object:Gem::Requirement
|
|
71
|
-
requirements:
|
|
72
|
-
- - "~>"
|
|
73
|
-
- !ruby/object:Gem::Version
|
|
74
|
-
version: '3.38'
|
|
75
|
-
type: :development
|
|
76
|
-
prerelease: false
|
|
77
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
78
|
-
requirements:
|
|
79
|
-
- - "~>"
|
|
80
|
-
- !ruby/object:Gem::Version
|
|
81
|
-
version: '3.38'
|
|
82
|
-
- !ruby/object:Gem::Dependency
|
|
83
|
-
name: rspec-its
|
|
84
|
-
requirement: !ruby/object:Gem::Requirement
|
|
85
|
-
requirements:
|
|
86
|
-
- - "~>"
|
|
87
|
-
- !ruby/object:Gem::Version
|
|
88
|
-
version: '2.0'
|
|
89
|
-
type: :development
|
|
90
|
-
prerelease: false
|
|
91
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
92
|
-
requirements:
|
|
93
|
-
- - "~>"
|
|
94
|
-
- !ruby/object:Gem::Version
|
|
95
|
-
version: '2.0'
|
|
96
|
-
- !ruby/object:Gem::Dependency
|
|
97
|
-
name: rspec-rails
|
|
98
|
-
requirement: !ruby/object:Gem::Requirement
|
|
99
|
-
requirements:
|
|
100
|
-
- - "~>"
|
|
101
|
-
- !ruby/object:Gem::Version
|
|
102
|
-
version: '6.0'
|
|
103
|
-
type: :development
|
|
104
|
-
prerelease: false
|
|
105
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
106
|
-
requirements:
|
|
107
|
-
- - "~>"
|
|
108
|
-
- !ruby/object:Gem::Version
|
|
109
|
-
version: '6.0'
|
|
110
|
-
- !ruby/object:Gem::Dependency
|
|
111
|
-
name: standardrb
|
|
112
|
-
requirement: !ruby/object:Gem::Requirement
|
|
113
|
-
requirements:
|
|
114
|
-
- - "~>"
|
|
115
|
-
- !ruby/object:Gem::Version
|
|
116
|
-
version: '1.0'
|
|
117
|
-
type: :development
|
|
118
|
-
prerelease: false
|
|
119
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
120
|
-
requirements:
|
|
121
|
-
- - "~>"
|
|
122
|
-
- !ruby/object:Gem::Version
|
|
123
|
-
version: '1.0'
|
|
124
|
-
- !ruby/object:Gem::Dependency
|
|
125
|
-
name: standard-rails
|
|
126
|
-
requirement: !ruby/object:Gem::Requirement
|
|
127
|
-
requirements:
|
|
128
|
-
- - "~>"
|
|
129
|
-
- !ruby/object:Gem::Version
|
|
130
|
-
version: '1.4'
|
|
131
|
-
type: :development
|
|
132
|
-
prerelease: false
|
|
133
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
134
|
-
requirements:
|
|
135
|
-
- - "~>"
|
|
136
|
-
- !ruby/object:Gem::Version
|
|
137
|
-
version: '1.4'
|
|
138
|
-
description: CubitComponents provides a set of layout-focused ViewComponents with
|
|
139
|
-
built-in Tailwind CSS support and utility class validation.
|
|
26
|
+
description: ViewComponent-based layout primitives and token system for Sugar Cube.
|
|
140
27
|
email:
|
|
141
28
|
- me@fabiopapa.dev
|
|
142
29
|
executables: []
|
|
143
30
|
extensions: []
|
|
144
31
|
extra_rdoc_files: []
|
|
145
32
|
files:
|
|
146
|
-
- MIT-LICENSE
|
|
147
33
|
- README.md
|
|
148
34
|
- Rakefile
|
|
149
|
-
- app/assets/stylesheets/cubit_components/application.css
|
|
150
|
-
- app/assets/tailwind/cubit_components/engine.css
|
|
151
|
-
- config/routes.rb
|
|
152
35
|
- lib/cubit_components.rb
|
|
153
36
|
- lib/cubit_components/base_component.rb
|
|
154
|
-
- lib/cubit_components/bleed_component.rb
|
|
155
37
|
- lib/cubit_components/box_component.rb
|
|
156
|
-
- lib/cubit_components/columns_component.rb
|
|
157
38
|
- lib/cubit_components/configuration.rb
|
|
158
|
-
- lib/cubit_components/
|
|
159
|
-
- lib/cubit_components/
|
|
160
|
-
- lib/cubit_components/
|
|
161
|
-
- lib/cubit_components/
|
|
39
|
+
- lib/cubit_components/container_component.rb
|
|
40
|
+
- lib/cubit_components/flex_component.rb
|
|
41
|
+
- lib/cubit_components/grid_component.rb
|
|
42
|
+
- lib/cubit_components/hstack_component.rb
|
|
162
43
|
- lib/cubit_components/page_component.rb
|
|
163
|
-
- lib/cubit_components/
|
|
164
|
-
- lib/cubit_components/
|
|
165
|
-
- lib/cubit_components/previews/columns_component_preview.rb
|
|
166
|
-
- lib/cubit_components/previews/components_index.rb
|
|
167
|
-
- lib/cubit_components/previews/content_block_component_preview.rb
|
|
168
|
-
- lib/cubit_components/previews/inline_component_preview.rb
|
|
169
|
-
- lib/cubit_components/previews/page_block_component_preview.rb
|
|
170
|
-
- lib/cubit_components/previews/page_component_preview.rb
|
|
171
|
-
- lib/cubit_components/previews/preview_helper.rb
|
|
172
|
-
- lib/cubit_components/previews/spread_component_preview.rb
|
|
173
|
-
- lib/cubit_components/previews/stack_component_preview.rb
|
|
174
|
-
- lib/cubit_components/previews/tiles_component_preview.rb
|
|
44
|
+
- lib/cubit_components/page_container_component.rb
|
|
45
|
+
- lib/cubit_components/placeholder_component.rb
|
|
175
46
|
- lib/cubit_components/spread_component.rb
|
|
176
47
|
- lib/cubit_components/stack_component.rb
|
|
177
|
-
- lib/cubit_components/
|
|
178
|
-
- lib/cubit_components/tiles_component.rb
|
|
179
|
-
- lib/cubit_components/vattr_validator.rb
|
|
48
|
+
- lib/cubit_components/style_dsl.rb
|
|
180
49
|
- lib/cubit_components/version.rb
|
|
181
|
-
- lib/
|
|
182
|
-
-
|
|
183
|
-
homepage: https://github.com/fapapa/cubit_components
|
|
184
|
-
licenses:
|
|
185
|
-
- MIT
|
|
50
|
+
- lib/cubit_components/vstack_component.rb
|
|
51
|
+
- sig/cubit_components.rbs
|
|
52
|
+
homepage: https://github.com/fapapa/sugar_cube_system/tree/main/gems/cubit_components
|
|
53
|
+
licenses: []
|
|
186
54
|
metadata:
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
55
|
+
allowed_push_host: https://rubygems.org
|
|
56
|
+
homepage_uri: https://github.com/fapapa/sugar_cube_system/tree/main/gems/cubit_components
|
|
57
|
+
source_code_uri: https://github.com/fapapa/sugar_cube_system/tree/main/gems/cubit_components
|
|
190
58
|
rdoc_options: []
|
|
191
59
|
require_paths:
|
|
192
60
|
- lib
|
|
@@ -194,15 +62,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
194
62
|
requirements:
|
|
195
63
|
- - ">="
|
|
196
64
|
- !ruby/object:Gem::Version
|
|
197
|
-
version:
|
|
65
|
+
version: 3.2.0
|
|
198
66
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
199
67
|
requirements:
|
|
200
68
|
- - ">="
|
|
201
69
|
- !ruby/object:Gem::Version
|
|
202
70
|
version: '0'
|
|
203
71
|
requirements: []
|
|
204
|
-
rubygems_version: 3.6.
|
|
72
|
+
rubygems_version: 3.6.2
|
|
205
73
|
specification_version: 4
|
|
206
|
-
summary:
|
|
207
|
-
class validation.
|
|
74
|
+
summary: ViewComponent-based layout primitives and token system for Sugar Cube.
|
|
208
75
|
test_files: []
|
data/MIT-LICENSE
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
Copyright Fabio Papa
|
|
2
|
-
|
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
-
a copy of this software and associated documentation files (the
|
|
5
|
-
"Software"), to deal in the Software without restriction, including
|
|
6
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
-
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
-
the following conditions:
|
|
10
|
-
|
|
11
|
-
The above copyright notice and this permission notice shall be
|
|
12
|
-
included in all copies or substantial portions of the Software.
|
|
13
|
-
|
|
14
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/config/routes.rb
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
module CubitComponents
|
|
2
|
-
class BleedComponent < BaseComponent
|
|
3
|
-
# Allow negative margin utility classes.
|
|
4
|
-
# They follow Tailwind's pattern, e.g., "-m-3" or "sm:-mx-4"
|
|
5
|
-
VALID_VATTRS = Set.new(
|
|
6
|
-
begin
|
|
7
|
-
breakpoints = ["", "sm:", "md:", "lg:", "xl:"]
|
|
8
|
-
directions = ["", "x", "y", "t", "r", "b", "l"]
|
|
9
|
-
values = %w[1 2 3 4 5]
|
|
10
|
-
breakpoints.flat_map do |bp|
|
|
11
|
-
directions.flat_map do |dir|
|
|
12
|
-
values.map do |val|
|
|
13
|
-
# For no breakpoint, produces e.g. "-m-3"
|
|
14
|
-
# For a breakpoint, produces e.g. "sm:-mx-4"
|
|
15
|
-
"#{bp}-m#{dir}-#{val}"
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
).freeze
|
|
21
|
-
|
|
22
|
-
def initialize(element: "div", classes: "", vattrs: [])
|
|
23
|
-
super
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
end
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module CubitComponents
|
|
4
|
-
# Horizontal flex-layout that can collapse into a vertical stack.
|
|
5
|
-
class ColumnsComponent < BaseComponent
|
|
6
|
-
VALID_VATTRS = Set.new(
|
|
7
|
-
%w[
|
|
8
|
-
gap-small gap-medium gap-large
|
|
9
|
-
items-start items-center items-end
|
|
10
|
-
text-left text-center text-right
|
|
11
|
-
]
|
|
12
|
-
).freeze
|
|
13
|
-
|
|
14
|
-
# :reverse – Boolean, applies `flex-row-reverse`
|
|
15
|
-
# :collapse_below – breakpoint string, ex. "sm" → "sm:flex-col"
|
|
16
|
-
# `reverse` can only be true when `collapse_below` is non-nil
|
|
17
|
-
def initialize(element: "div", classes: "", vattrs: [], reverse: false, collapse_below: nil)
|
|
18
|
-
@reverse = reverse
|
|
19
|
-
@collapse_below = collapse_below
|
|
20
|
-
|
|
21
|
-
super(
|
|
22
|
-
element: element,
|
|
23
|
-
classes: build_layout_classes(classes),
|
|
24
|
-
vattrs: vattrs
|
|
25
|
-
)
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
# Nested column – accepts any utility classes, no validation
|
|
29
|
-
class ColumnComponent < BaseComponent
|
|
30
|
-
private def validate_vattrs? = false
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
private
|
|
34
|
-
|
|
35
|
-
def build_layout_classes(user)
|
|
36
|
-
base = %w[flex]
|
|
37
|
-
base << if @collapse_below && @reverse
|
|
38
|
-
"flex-col-reverse"
|
|
39
|
-
elsif @collapse_below
|
|
40
|
-
"flex-col"
|
|
41
|
-
else
|
|
42
|
-
"flex-row"
|
|
43
|
-
end
|
|
44
|
-
base << "#{@collapse_below}:flex-row" if @collapse_below
|
|
45
|
-
(base + user.to_s.split).join(" ")
|
|
46
|
-
end
|
|
47
|
-
end
|
|
48
|
-
end
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
module CubitComponents
|
|
2
|
-
class ContentBlockComponent < BaseComponent
|
|
3
|
-
DEFAULT_CLASSES = "max-w-screen mx-auto"
|
|
4
|
-
VALID_VATTRS = Set.new(
|
|
5
|
-
%w[
|
|
6
|
-
max-w-3xs max-w-2xs max-w-xs
|
|
7
|
-
max-w-sm max-w-md max-w-lg
|
|
8
|
-
max-w-xl max-w-2xl max-w-3xl max-w-4xl max-w-5xl max-w-6xl max-w-7xl
|
|
9
|
-
max-w-none max-w-full max-w-screen
|
|
10
|
-
]
|
|
11
|
-
)
|
|
12
|
-
|
|
13
|
-
# No extra vattr validation is required, so simply merge with default classes.
|
|
14
|
-
def initialize(element: "div", classes: "", vattrs: [])
|
|
15
|
-
default_classes = DEFAULT_CLASSES.split(" ")
|
|
16
|
-
default_classes.delete("max-w-screen") if vattrs.any? { |v| v.start_with?("max-w-") }
|
|
17
|
-
merged_classes = [*default_classes, classes].join(" ").strip
|
|
18
|
-
super(element: element, classes: merged_classes, vattrs: vattrs)
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
end
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
require "rails"
|
|
2
|
-
require "view_component"
|
|
3
|
-
|
|
4
|
-
module CubitComponents
|
|
5
|
-
class Engine < ::Rails::Engine
|
|
6
|
-
config.view_component.preview_paths << root.join("lib/cubit_components/previews")
|
|
7
|
-
|
|
8
|
-
isolate_namespace CubitComponents
|
|
9
|
-
|
|
10
|
-
initializer "cubit_components.assets" do |app|
|
|
11
|
-
app.config.assets.precompile += %w[cubit_components/application.css]
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
end
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module CubitComponents
|
|
4
|
-
class InlineComponent < BaseComponent
|
|
5
|
-
VALID_VATTRS = Set.new(
|
|
6
|
-
%w[gap-6 gap-small gap-medium gap-large text-left text-center text-right]
|
|
7
|
-
).freeze
|
|
8
|
-
|
|
9
|
-
# collapse_below – e.g. "sm", "md"; adds "#{breakpoint}:flex-col"
|
|
10
|
-
def initialize(element: "div", classes: "", vattrs: [], collapse_below: nil)
|
|
11
|
-
extra_classes = %w[flex flex-wrap]
|
|
12
|
-
extra_classes << "flex-col #{collapse_below}:flex-row" if collapse_below
|
|
13
|
-
|
|
14
|
-
combined_classes = ([classes] + extra_classes).reject(&:empty?).join(" ")
|
|
15
|
-
|
|
16
|
-
super(element: element, classes: combined_classes, vattrs: vattrs)
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
module CubitComponents
|
|
2
|
-
class PageBlockComponent < BaseComponent
|
|
3
|
-
DEFAULT_OUTER_CLASSES = "px-4 sm:px-6".freeze
|
|
4
|
-
VALID_VATTRS = Set.new(
|
|
5
|
-
%w[
|
|
6
|
-
max-w-3xs max-w-2xs max-w-xs
|
|
7
|
-
max-w-sm max-w-md max-w-lg
|
|
8
|
-
max-w-xl max-w-2xl max-w-3xl max-w-4xl max-w-5xl max-w-6xl max-w-7xl
|
|
9
|
-
max-w-none max-w-full max-w-screen
|
|
10
|
-
]
|
|
11
|
-
)
|
|
12
|
-
|
|
13
|
-
# Optionally allow extra classes for the inner content block if needed.
|
|
14
|
-
def initialize(element: "div", classes: "", vattrs: [], content_block_classes: "")
|
|
15
|
-
@outer_classes = [DEFAULT_OUTER_CLASSES, classes].join(" ").strip
|
|
16
|
-
@content_block_classes = content_block_classes
|
|
17
|
-
@content_block_vattrs = vattrs # Pass the vattrs wholesale to the inner content block
|
|
18
|
-
|
|
19
|
-
super(element: element, classes: @outer_classes)
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
def call
|
|
23
|
-
content_tag @element, class: @outer_classes do
|
|
24
|
-
render_content_block { content }
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
private
|
|
29
|
-
|
|
30
|
-
def render_content_block(&block)
|
|
31
|
-
# Create a ContentBlockComponent, passing in any inner classes overrides.
|
|
32
|
-
ContentBlockComponent
|
|
33
|
-
.new(classes: @content_block_classes, vattrs: @content_block_vattrs)
|
|
34
|
-
.render_in(view_context, &block)
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
end
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
class BleedComponentPreview < ViewComponent::Preview
|
|
2
|
-
def default
|
|
3
|
-
render(CubitComponents::BleedComponent.new(vattrs: ["-m-3"])) do
|
|
4
|
-
tag.div("Bleed Content", class: "bg-gray-100 p-4")
|
|
5
|
-
end
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
def responsive
|
|
9
|
-
render(CubitComponents::BleedComponent.new(vattrs: ["sm:-mx-2", "md:-m-4"])) do
|
|
10
|
-
tag.div("Responsive Bleed Content", class: "bg-blue-100 p-4")
|
|
11
|
-
end
|
|
12
|
-
end
|
|
13
|
-
end
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
class BoxComponentPreview < ViewComponent::Preview
|
|
4
|
-
def default
|
|
5
|
-
render(CubitComponents::BoxComponent.new) { "Default Box" }
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
def with_utilities
|
|
9
|
-
render(CubitComponents::BoxComponent.new(classes: "p-4",
|
|
10
|
-
vattrs: %w[gap-small text-center])) { "Preview" }
|
|
11
|
-
end
|
|
12
|
-
end
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
class ColumnsComponentPreview < ViewComponent::Preview
|
|
4
|
-
# Two equal columns, default layout
|
|
5
|
-
def default
|
|
6
|
-
render(CubitComponents::ColumnsComponent.new(vattrs: %w[gap-medium])) do
|
|
7
|
-
tag.div("Col 1", class: "w-1/3") +
|
|
8
|
-
tag.div("Col 2", class: "w-1/6") +
|
|
9
|
-
tag.div("Col 3", class: "w-1/2")
|
|
10
|
-
end
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
# Reversed order & collapses below md
|
|
14
|
-
def reversed_and_collapsing
|
|
15
|
-
render(CubitComponents::ColumnsComponent.new(reverse: true, collapse_below: "md", vattrs: %w[gap-large items-center])) do
|
|
16
|
-
tag.div("First", class: "w-full") +
|
|
17
|
-
tag.div("Second", class: "w-full")
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
end
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
module CubitComponents
|
|
2
|
-
module Previews
|
|
3
|
-
class ComponentsIndex < ViewComponent::Preview
|
|
4
|
-
# A listing of all component previews.
|
|
5
|
-
def index
|
|
6
|
-
previews = [
|
|
7
|
-
{name: "BleedComponentPreview", path: "/cubit_components/bleed_component_preview"},
|
|
8
|
-
{name: "BoxComponentPreview", path: "/cubit_components/box_component_preview"},
|
|
9
|
-
{name: "ColumnsComponentPreview", path: "/cubit_components/columns_component_preview"},
|
|
10
|
-
{name: "ContentBlockComponentPreview", path: "/cubit_components/content_block_component_preview"},
|
|
11
|
-
{name: "InlineComponentPreview", path: "/cubit_components/inline_component_preview"},
|
|
12
|
-
{name: "PageBlockComponentPreview", path: "/cubit_components/page_block_component_preview"},
|
|
13
|
-
{name: "PageComponentPreview", path: "/cubit_components/page_component_preview"},
|
|
14
|
-
{name: "SpreadComponentPreview", path: "/cubit_components/spread_component_preview"},
|
|
15
|
-
{name: "StackComponentPreview", path: "/cubit_components/stack_component_preview"},
|
|
16
|
-
{name: "TilesComponentPreview", path: "/cubit_components/tiles_component_preview"}
|
|
17
|
-
]
|
|
18
|
-
|
|
19
|
-
html = "<h1>Components Preview Index</h1><ul>"
|
|
20
|
-
previews.each do |preview|
|
|
21
|
-
html << "<li><a href='#{preview[:path]}'>#{preview[:name]}</a></li>"
|
|
22
|
-
end
|
|
23
|
-
html << "</ul>"
|
|
24
|
-
html.html_safe
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
end
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
class ContentBlockComponentPreview < ViewComponent::Preview
|
|
2
|
-
def default
|
|
3
|
-
render(CubitComponents::ContentBlockComponent.new(vattrs: %w[max-w-sm])) do
|
|
4
|
-
tag.p("This content is constrained by the max-width and centered.")
|
|
5
|
-
end
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
def with_extra_classes
|
|
9
|
-
render(CubitComponents::ContentBlockComponent.new(classes: "bg-gray-100 p-4")) do
|
|
10
|
-
tag.p("Content block with extra background and padding.")
|
|
11
|
-
end
|
|
12
|
-
end
|
|
13
|
-
end
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
class InlineComponentPreview < ViewComponent::Preview
|
|
4
|
-
def default
|
|
5
|
-
render(CubitComponents::InlineComponent.new(vattrs: ["gap-6"])) do
|
|
6
|
-
tag.div("Block 1") +
|
|
7
|
-
tag.div("Block 2") +
|
|
8
|
-
tag.div("Block 3") +
|
|
9
|
-
tag.div("Block 4") +
|
|
10
|
-
tag.div("Block 5") +
|
|
11
|
-
tag.div("Block 6")
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def collapse_below_md
|
|
16
|
-
render(CubitComponents::InlineComponent.new(collapse_below: "sm", vattrs: ["gap-6"])) do
|
|
17
|
-
tag.div("Block 1") +
|
|
18
|
-
tag.div("Block 2") +
|
|
19
|
-
tag.div("Block 3") +
|
|
20
|
-
tag.div("Block 4") +
|
|
21
|
-
tag.div("Block 5") +
|
|
22
|
-
tag.div("Block 6")
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
end
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
class PageBlockComponentPreview < ViewComponent::Preview
|
|
2
|
-
def default
|
|
3
|
-
render(CubitComponents::PageBlockComponent.new(vattrs: %w[max-w-sm])) do
|
|
4
|
-
tag.p("This is a page block which wraps a content block. Outer padding is applied.")
|
|
5
|
-
end
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
def custom_inner
|
|
9
|
-
render(CubitComponents::PageBlockComponent.new(content_block_classes: "bg-white shadow-lg p-6")) do
|
|
10
|
-
tag.p("Page block with a customized inner content block.")
|
|
11
|
-
end
|
|
12
|
-
end
|
|
13
|
-
end
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
class PageComponentPreview < ViewComponent::Preview
|
|
2
|
-
def default
|
|
3
|
-
render(CubitComponents::PageComponent.new(footer_position: "screen_bottom", classes: "bg-gray-100")) do |component|
|
|
4
|
-
component.with_footer { tag.footer("Footer content", class: "p-4 bg-blue-200") }
|
|
5
|
-
tag.header("Header content", class: "p-4 bg-blue-200") +
|
|
6
|
-
tag.main("Body content", class: "p-4")
|
|
7
|
-
end
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
def below_fold
|
|
11
|
-
render(CubitComponents::PageComponent.new(footer_position: "below_fold", classes: "bg-gray-100")) do |component|
|
|
12
|
-
component.with_footer { tag.footer("Footer content", class: "p-4 bg-blue-200") }
|
|
13
|
-
tag.header("Header content", class: "p-4 bg-blue-200") +
|
|
14
|
-
tag.main("Body content", class: "p-4")
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
end
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
module CubitComponents
|
|
2
|
-
module Previews
|
|
3
|
-
module PreviewHelper
|
|
4
|
-
# Returns a documentation link for the component.
|
|
5
|
-
def documentation_link(component_name)
|
|
6
|
-
"https://your.documentation.url/#{component_name}"
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
# Standard documentation render for previews
|
|
10
|
-
def render_documentation(component_name)
|
|
11
|
-
render plain: "See documentation: #{documentation_link(component_name)}"
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
end
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
class SpreadComponentPreview < ViewComponent::Preview
|
|
2
|
-
# Default horizontal spread with items-start and text-left
|
|
3
|
-
def default
|
|
4
|
-
render(CubitComponents::SpreadComponent.new) do
|
|
5
|
-
tag.div(class: "p-2 border") { "Item 1" } +
|
|
6
|
-
tag.div(class: "p-2 border") { "Item 2" } +
|
|
7
|
-
tag.div(class: "p-2 border") { "Item 3" }
|
|
8
|
-
end
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
# Vertical spread layout
|
|
12
|
-
def vertical
|
|
13
|
-
render(CubitComponents::SpreadComponent.new(vattrs: ["vertical", "items-center"])) do
|
|
14
|
-
tag.div(class: "p-2 border") { "Item 1" } +
|
|
15
|
-
tag.div(class: "p-2 border") { "Item 2" } +
|
|
16
|
-
tag.div(class: "p-2 border") { "Item 3" }
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
# Centered items
|
|
21
|
-
def centered_items
|
|
22
|
-
render(CubitComponents::SpreadComponent.new(vattrs: ["items-center"])) do
|
|
23
|
-
tag.div(class: "p-2 border h-16") { "Tall Item" } +
|
|
24
|
-
tag.div(class: "p-2 border") { "Regular Item" } +
|
|
25
|
-
tag.div(class: "p-2 border h-12") { "Medium Item" }
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
# Text alignment
|
|
30
|
-
def text_alignment
|
|
31
|
-
render(CubitComponents::SpreadComponent.new(vattrs: ["text-center"])) do
|
|
32
|
-
tag.div(class: "p-2 border w-32") { "Centered Text" } +
|
|
33
|
-
tag.div(class: "p-2 border w-32") { "Centered Text" } +
|
|
34
|
-
tag.div(class: "p-2 border w-32") { "Centered Text" }
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
# Custom element
|
|
39
|
-
def custom_element
|
|
40
|
-
render(CubitComponents::SpreadComponent.new(element: "section", classes: "border p-4")) do
|
|
41
|
-
tag.div(class: "p-2 bg-gray-100") { "Section Item 1" } +
|
|
42
|
-
tag.div(class: "p-2 bg-gray-100") { "Section Item 2" } +
|
|
43
|
-
tag.div(class: "p-2 bg-gray-100") { "Section Item 3" }
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
end
|