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.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +20 -43
  3. data/Rakefile +8 -5
  4. data/lib/cubit_components/base_component.rb +48 -19
  5. data/lib/cubit_components/box_component.rb +1 -3
  6. data/lib/cubit_components/configuration.rb +16 -8
  7. data/lib/cubit_components/container_component.rb +11 -0
  8. data/lib/cubit_components/flex_component.rb +17 -0
  9. data/lib/cubit_components/grid_component.rb +16 -0
  10. data/lib/cubit_components/hstack_component.rb +12 -0
  11. data/lib/cubit_components/page_component.rb +11 -27
  12. data/lib/cubit_components/page_container_component.rb +27 -0
  13. data/lib/cubit_components/placeholder_component.rb +36 -0
  14. data/lib/cubit_components/spread_component.rb +9 -54
  15. data/lib/cubit_components/stack_component.rb +7 -25
  16. data/lib/cubit_components/style_dsl.rb +53 -0
  17. data/lib/cubit_components/version.rb +3 -1
  18. data/lib/cubit_components/vstack_component.rb +12 -0
  19. data/lib/cubit_components.rb +11 -24
  20. data/sig/cubit_components.rbs +4 -0
  21. metadata +23 -156
  22. data/MIT-LICENSE +0 -20
  23. data/app/assets/stylesheets/cubit_components/application.css +0 -6
  24. data/app/assets/tailwind/cubit_components/engine.css +0 -4
  25. data/config/routes.rb +0 -2
  26. data/lib/cubit_components/bleed_component.rb +0 -26
  27. data/lib/cubit_components/columns_component.rb +0 -48
  28. data/lib/cubit_components/content_block_component.rb +0 -21
  29. data/lib/cubit_components/engine.rb +0 -14
  30. data/lib/cubit_components/inline_component.rb +0 -19
  31. data/lib/cubit_components/page_block_component.rb +0 -37
  32. data/lib/cubit_components/previews/bleed_component_preview.rb +0 -13
  33. data/lib/cubit_components/previews/box_component_preview.rb +0 -12
  34. data/lib/cubit_components/previews/columns_component_preview.rb +0 -20
  35. data/lib/cubit_components/previews/components_index.rb +0 -28
  36. data/lib/cubit_components/previews/content_block_component_preview.rb +0 -13
  37. data/lib/cubit_components/previews/inline_component_preview.rb +0 -25
  38. data/lib/cubit_components/previews/page_block_component_preview.rb +0 -13
  39. data/lib/cubit_components/previews/page_component_preview.rb +0 -17
  40. data/lib/cubit_components/previews/preview_helper.rb +0 -15
  41. data/lib/cubit_components/previews/spread_component_preview.rb +0 -46
  42. data/lib/cubit_components/previews/stack_component_preview.rb +0 -22
  43. data/lib/cubit_components/previews/tiles_component_preview.rb +0 -20
  44. data/lib/cubit_components/tailwind_generated_classes_chat.txt +0 -127
  45. data/lib/cubit_components/tiles_component.rb +0 -43
  46. data/lib/cubit_components/vattr_validator.rb +0 -53
  47. data/lib/generators/cubit/install/install_generator.rb +0 -63
  48. data/lib/tasks/cubit_components_tasks.rake +0 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cb5dec0910e548ed2c02c397e6d86114e03ce01bec318de5226908b947a5d83b
4
- data.tar.gz: 197294b2c0f689acd25e06bf41bbc4ca932336992768b45e594ff43d54043418
3
+ metadata.gz: '079a9a086defbad7b5c7c8f44d67becc3aa6ba3b8788e67c01a9e5d76e38b82d'
4
+ data.tar.gz: 65f689f428627c804f4dc52be2ca3acddd32309c50cbccac8fe801a149b63c4e
5
5
  SHA512:
6
- metadata.gz: 29a419c390f2df73fd6e6783370e68aac8b028620ec9073d49d5f17bc6051a98f0ef49b676dcc1bc3019729b8f6bf4668c257d453d71ce5819544455148a6e00
7
- data.tar.gz: 1f9502b054915d5071ee4f660d6cab32184ce1761e79eab82f5f0884f62a312da2771dd1af4e111a14100d36e1a78a7591f4b1a80207a37ad6fe6c863bfb8983
6
+ metadata.gz: 1313573894c48833cab1e4eb11b6c29a46bca1aa6b221f9b8b230a9f5beee848c43f75f7e7269bb5d28305944279c88212ac365769902017642cf4b9ff785986
7
+ data.tar.gz: 25afe4f9296084e993fc51b6adc60072dd278eac6e598d914cb4b56d2efb6c23f6c5a138e2be459e7d887e766ba0b159bd57a84d9f9ff9de42845298991d3e57
data/README.md CHANGED
@@ -1,58 +1,35 @@
1
1
  # CubitComponents
2
2
 
3
- A collection of reusable ViewComponents with standardized styling and utility class validation.
3
+ TODO: Delete this and the text below, and describe your gem
4
+
5
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/cubit_components`. To experiment with that code, run `bin/console` for an interactive prompt.
4
6
 
5
7
  ## Installation
6
8
 
7
- Add to your Gemfile:
8
- ```ruby
9
- gem 'cubit_components'
10
- ```
11
- Then run:
9
+ TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
10
+
11
+ Install the gem and add to the application's Gemfile by executing:
12
+
12
13
  ```bash
13
- bundle install
14
+ bundle add UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
14
15
  ```
15
16
 
16
- ## Usage
17
+ If bundler is not being used to manage dependencies, install the gem by executing:
17
18
 
18
- ### Basic Component
19
- ```erb
20
- <%= render CubitComponents::BoxComponent.new do %>
21
- Box content
22
- <% end %>
19
+ ```bash
20
+ gem install UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
23
21
  ```
24
22
 
25
- ### With Custom Classes
26
- ```erb
27
- <%= render CubitComponents::StackComponent.new(classes: "bg-gray-100") do %>
28
- <div>Item 1</div>
29
- <div>Item 2</div>
30
- <% end %>
31
- ```
23
+ ## Usage
32
24
 
33
- ### Available Components
34
- - BoxComponent - Basic container
35
- - StackComponent - Vertical layout
36
- - ColumnsComponent - Horizontal layout
37
- - BleedComponent - Negative margins
38
- - ContentBlockComponent - Width-constrained container
39
-
40
- ## Configuration
41
-
42
- Create an initializer to customize validation behavior:
43
- ```ruby
44
- # config/initializers/cubit_components.rb
45
- CubitComponents.configure do |config|
46
- config.invalid_vattr_behavior = :raise # :warn, :silent
47
- end
48
- ```
25
+ TODO: Write usage instructions here
49
26
 
50
27
  ## Development
51
- After checking out the repo:
52
- ```bash
53
- bin/setup
54
- bundle exec rspec
55
- ```
56
28
 
57
- ## License
58
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/fapapa/cubit_components.
data/Rakefile CHANGED
@@ -1,8 +1,11 @@
1
- require "bundler/setup"
1
+ # frozen_string_literal: true
2
2
 
3
- APP_RAKEFILE = File.expand_path("test/dummy/Rakefile", __dir__)
4
- load "rails/tasks/engine.rake"
3
+ require "bundler/gem_tasks"
4
+ Bundler::GemHelper.tag_prefix = "cubit_components-"
5
+ require "minitest/test_task"
5
6
 
6
- load "rails/tasks/statistics.rake"
7
+ Minitest::TestTask.create
7
8
 
8
- require "bundler/gem_tasks"
9
+ require "standard/rake"
10
+
11
+ task default: %i[test standard]
@@ -1,39 +1,68 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "view_component"
4
- require_relative "vattr_validator"
4
+ require_relative "style_dsl"
5
5
 
6
6
  module CubitComponents
7
7
  class BaseComponent < ViewComponent::Base
8
- include ::CubitComponents::VattrValidator
8
+ STYLE_CONFIG = StyleConfig.new
9
9
 
10
- # Valid “utility” / “variant” classes
11
- VALID_VATTRS = Set.new(
12
- %w[gap-small gap-medium text-left text-center text-right]
13
- ).freeze
10
+ def self.style(&block)
11
+ dsl = StyleDSL.new
12
+ dsl.instance_eval(&block)
13
+ config = dsl.config
14
+ const_set(:STYLE_CONFIG, config)
15
+ config.presences.each do |token|
16
+ define_method("#{token.to_s.tr("-", "_")}?") { @tokens.include?(token) }
17
+ end
18
+ end
14
19
 
15
- # @param vattrs [Array<String>] extra utility / variant classes
16
- def initialize(element: "div", classes: "", vattrs: [])
17
- @element = element
18
- @classes = classes
19
- @vattrs = vattrs
20
+ def self.inline_template(source)
21
+ compiled = ActionView::Template::Handlers::ERB::Erubi.new(source, bufvar: "@output_buffer").src
22
+ class_eval <<~RUBY, __FILE__, __LINE__ + 1
23
+ def call
24
+ @output_buffer = ActionView::OutputBuffer.new
25
+ begin
26
+ #{compiled}
27
+ end.to_s
28
+ end
29
+ RUBY
30
+ end
20
31
 
21
- validate_vattrs(vattrs, self.class::VALID_VATTRS) if validate_vattrs?
32
+ def initialize(tokens: [], as: "div")
33
+ @tokens = Array(tokens).flat_map { |t|
34
+ t.is_a?(String) ? t.split.map(&:to_sym) : t
35
+ }
36
+ @tag_name = as
22
37
  end
23
38
 
39
+ attr_reader :tag_name
40
+
24
41
  def call
25
- content_tag @element, content, class: all_classes
42
+ content_tag(tag_name, content, class: html_classes.map(&:to_s).join(" "))
26
43
  end
27
44
 
28
- private
45
+ def html_classes
46
+ config = self.class.const_get(:STYLE_CONFIG)
47
+ expanded = @tokens.flat_map { |t| expand_token(config, t) }
48
+ kept_defaults = config.defaults
49
+ .reject { |d| d.replaced_by && expanded.any? { |t| match?(d.replaced_by, t) } }
50
+ .map(&:token)
51
+ visible = expanded.reject { |t| config.presences.include?(t) }
52
+ (kept_defaults + visible).uniq
53
+ end
29
54
 
30
- def all_classes
31
- (Array(@vattrs) + Array(@classes.to_s.split)).join(" ").strip
55
+ private def expand_token(config, token)
56
+ return config.expansions[token] if config.expansions.key?(token)
57
+ str = token.to_s
58
+ config.pattern_expansions.each do |pattern, replacement|
59
+ return [str.sub(pattern, replacement).to_sym] if pattern.match?(str)
60
+ end
61
+ [token]
32
62
  end
33
63
 
34
- # Sub-classes may disable validation
35
- def validate_vattrs?
36
- true
64
+ private def match?(pattern, token)
65
+ pattern.is_a?(Regexp) ? pattern.match?(token) : pattern.include?(token)
37
66
  end
38
67
  end
39
68
  end
@@ -1,8 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CubitComponents
4
- class BoxComponent < BaseComponent
5
- # Accept every vattr ⇒ disable validation
6
- private def validate_vattrs? = false
4
+ class BoxComponent < CubitComponents::BaseComponent
7
5
  end
8
6
  end
@@ -1,18 +1,26 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module CubitComponents
2
4
  class Configuration
3
- attr_reader :invalid_vattr_behavior
5
+ attr_accessor :token_validation, :placeholder_allowed
4
6
 
5
7
  def initialize
6
- # Set default values
7
- @invalid_vattr_behavior = :warn
8
+ @token_validation = :warn
9
+ @placeholder_allowed = true
8
10
  end
11
+ end
9
12
 
10
- def invalid_vattr_behavior=(value)
11
- unless [:warn, :raise, :silent].include?(value)
12
- raise ArgumentError, "invalid_class_behavior must be :warn, :raise, or :silent"
13
- end
13
+ class << self
14
+ def configuration
15
+ @configuration ||= Configuration.new
16
+ end
17
+
18
+ def configure
19
+ yield(configuration)
20
+ end
14
21
 
15
- @invalid_vattr_behavior = value
22
+ def reset_configuration!
23
+ @configuration = nil
16
24
  end
17
25
  end
18
26
  end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CubitComponents
4
+ class ContainerComponent < CubitComponents::BaseComponent
5
+ style do
6
+ default :"max-w-7xl", replaced_by: /\Amax-w-/
7
+ default :"w-full"
8
+ default :"mx-auto"
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CubitComponents
4
+ class FlexComponent < CubitComponents::BaseComponent
5
+ style do
6
+ default :flex, replaced_by: %i[flex inline-flex]
7
+ expand(
8
+ inline: %i[inline-flex],
9
+ row: %i[flex-row],
10
+ col: %i[flex-col],
11
+ "row-reverse": %i[flex-row-reverse],
12
+ "col-reverse": %i[flex-col-reverse],
13
+ wrap: %i[flex-wrap]
14
+ )
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CubitComponents
4
+ class GridComponent < CubitComponents::BaseComponent
5
+ style do
6
+ default :grid, replaced_by: %i[grid inline-grid]
7
+ expand inline: %i[inline-grid]
8
+ expand(
9
+ /\Acols-(.+)\z/ => 'grid-cols-\1',
10
+ /\Arows-(.+)\z/ => 'grid-rows-\1',
11
+ /\Aflow-(.+)\z/ => 'grid-flow-\1',
12
+ /\Amin-col-w-(\d+)\z/ => 'grid-cols-[repeat(auto-fit,_minmax(\1px,_1fr))]'
13
+ )
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CubitComponents
4
+ class HStackComponent < CubitComponents::BaseComponent
5
+ style do
6
+ default :flex
7
+ default :"flex-row"
8
+ default :"items-center-safe"
9
+ default :"gap-16", replaced_by: /\Agap-/
10
+ end
11
+ end
12
+ end
@@ -1,34 +1,18 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module CubitComponents
2
- class PageComponent < BaseComponent
3
- VALID_VATTRS = %w[
4
- min-h-screen flex
5
- ]
4
+ class PageComponent < CubitComponents::BaseComponent
5
+ style do
6
+ default :flex
7
+ default :"flex-col"
8
+ default :"min-h-screen"
9
+ presence :"footer-below-fold"
10
+ end
6
11
 
7
- # Use ViewComponent slot for footer.
8
12
  renders_one :footer
9
13
 
10
- erb_template <<~ERB
11
- <<%= @element %> class="<%= classes %>">
12
- <div class="grow pb-30<%= ' min-h-screen' if below_fold? %>">
13
- <%= content %>
14
- </div>
15
- <%= footer %>
16
- </<%= @element %>>
14
+ inline_template <<~ERB
15
+ <%= content_tag(tag_name, class: html_classes.map(&:to_s).join(" ")) do %><div class="<%= footer_below_fold? ? "min-h-screen" : "grow pb-24" %>"><%= content %></div><%= footer %><% end %>
17
16
  ERB
18
-
19
- # @param footer_position: nil (default) or "below_fold"
20
- def initialize(footer_position: nil, classes: "")
21
- @footer_position = footer_position
22
- @classes = ["flex", "flex-col", "min-h-screen", classes].join(" ")
23
- super(element: "div", classes: @classes)
24
- end
25
-
26
- private
27
-
28
- attr_reader :classes
29
-
30
- def below_fold?
31
- @footer_position.to_s == "below_fold"
32
- end
33
17
  end
34
18
  end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CubitComponents
4
+ class PageContainerComponent < CubitComponents::BaseComponent
5
+ style do
6
+ default :"px-4"
7
+ default :"md:px-6"
8
+ default :"lg:px-8"
9
+ end
10
+
11
+ # Two-element wrapper: an outer gutter element wraps an inner Container.
12
+ # Caller tokens (notably max-w-*) route to the inner Container per FR-17;
13
+ # the outer element carries only the fixed responsive gutters.
14
+ def call
15
+ inner = content_tag(
16
+ "div",
17
+ content,
18
+ class: ContainerComponent.new(tokens: @tokens).html_classes.map(&:to_s).join(" ")
19
+ )
20
+ content_tag(tag_name, inner, class: gutter_classes)
21
+ end
22
+
23
+ private def gutter_classes
24
+ self.class.const_get(:STYLE_CONFIG).defaults.map { |d| d.token.to_s }.join(" ")
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CubitComponents
4
+ class PlaceholderComponent < CubitComponents::BaseComponent
5
+ style do
6
+ default :flex
7
+ default :"items-center"
8
+ default :"justify-center"
9
+ default :"text-sm"
10
+ default :"text-gray-500"
11
+ end
12
+
13
+ DOTTED_GRID_STYLE =
14
+ "background-image:radial-gradient(currentColor 1px,transparent 1px);" \
15
+ "background-size:16px 16px"
16
+
17
+ def initialize(label: nil, tokens: [], as: "div")
18
+ unless CubitComponents.configuration.placeholder_allowed
19
+ raise PlaceholderNotAllowedError,
20
+ "PlaceholderComponent is only available when placeholder_allowed is enabled " \
21
+ "(dev/test); it is disabled in this environment."
22
+ end
23
+ @label = label
24
+ super(tokens:, as:)
25
+ end
26
+
27
+ def call
28
+ content_tag(
29
+ tag_name,
30
+ @label,
31
+ class: html_classes.map(&:to_s).join(" "),
32
+ style: DOTTED_GRID_STYLE
33
+ )
34
+ end
35
+ end
36
+ end
@@ -1,59 +1,14 @@
1
- require "debug"
1
+ # frozen_string_literal: true
2
2
 
3
3
  module CubitComponents
4
- class SpreadComponent < BaseComponent
5
- VALID_VATTRS = Set.new(
6
- %w[
7
- items-start items-center items-end
8
- text-left text-center text-right
9
- flex-col flex-row
10
- justify-between
11
- ]
12
- ).freeze
13
-
14
- DEFAULT_VATTRS = %w[flex justify-between w-full items-start text-left].freeze
15
-
16
- # @param element [String] HTML element to use
17
- # @param classes [String] additional CSS classes
18
- # @param vattrs [Array<String>] utility/variant attributes
19
- def initialize(element: "div", classes: "", vattrs: [])
20
- vattrs = merge_default_vattrs(Array(vattrs))
21
-
22
- extra_classes = []
23
- # Add vertical class if specified, otherwise it's horizontal by default
24
- if vattrs.include?("vertical")
25
- extra_classes << "flex-col"
26
- extra_classes << "h-full"
27
- vattrs.delete("vertical")
28
- else
29
- extra_classes << "flex-row"
30
- end
31
-
32
- super(
33
- element: element,
34
- classes: [classes, extra_classes].join(" ").strip,
35
- vattrs: vattrs
36
- )
37
- end
38
-
39
- private
40
-
41
- def merge_default_vattrs(custom)
42
- result = DEFAULT_VATTRS.dup
43
-
44
- # Override defaults with custom values
45
- custom.each do |attr|
46
- # For each attribute type (items-*, text-*), remove the default if a custom is provided
47
- if attr.start_with?("items-")
48
- result.delete_if { |v| v.start_with?("items-") }
49
- elsif attr.start_with?("text-")
50
- result.delete_if { |v| v.start_with?("text-") }
51
- end
52
-
53
- result << attr
54
- end
55
-
56
- result
4
+ class SpreadComponent < CubitComponents::BaseComponent
5
+ style do
6
+ default :flex
7
+ default :"justify-between"
8
+ default :"gap-8", replaced_by: /\Agap-/
9
+ default :"w-full"
10
+ default :"items-center", replaced_by: /\Aitems-/
11
+ expand col: %i[flex-col], row: %i[flex-row]
57
12
  end
58
13
  end
59
14
  end
@@ -1,32 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CubitComponents
4
- class StackComponent < BaseComponent
5
- VALID_VATTRS = Set.new(
6
- %w[
7
- gap-0 gap-small gap-medium gap-large
8
- text-left text-center text-right
9
- ]
10
- ).freeze
11
-
12
- DEFAULT_VATTRS = %w[flex flex-col gap-0 text-left].freeze
13
-
14
- # Forward element / classes, but merge-override vattrs
15
- def initialize(element: "div", classes: "", vattrs: [])
16
- vattrs = merge_default_vattrs(Array(vattrs))
17
- super
4
+ class StackComponent < CubitComponents::BaseComponent
5
+ style do
6
+ default :flex
7
+ default :"flex-col", replaced_by: %i[flex-col flex-row flex-col-reverse flex-row-reverse]
8
+ default :"gap-16", replaced_by: /\Agap-/
9
+ expand col: %i[flex-col], row: %i[flex-row], wrap: %i[flex-wrap]
18
10
  end
19
11
 
20
- private
21
-
22
- # Replace default gap- or text- related vattrs when caller supplies one
23
- def merge_default_vattrs(custom)
24
- merged = DEFAULT_VATTRS.dup
25
- custom.each do |v|
26
- merged.reject! { |d| d.start_with?("gap-") } if v.start_with?("gap-")
27
- merged.reject! { |d| d.start_with?("text-") } if v.start_with?("text-")
28
- end
29
- (merged + custom).uniq
30
- end
12
+ renders_one :separator
31
13
  end
32
14
  end
@@ -0,0 +1,53 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CubitComponents
4
+ class StyleConfig
5
+ Default = Data.define(:token, :replaced_by)
6
+
7
+ attr_reader :defaults, :expansions, :pattern_expansions, :presences
8
+
9
+ def initialize(defaults: [], expansions: {}, pattern_expansions: {}, presences: [])
10
+ @defaults = defaults.freeze
11
+ @expansions = expansions.freeze
12
+ @pattern_expansions = pattern_expansions.freeze
13
+ @presences = presences.freeze
14
+ freeze
15
+ end
16
+ end
17
+
18
+ class StyleDSL
19
+ def initialize
20
+ @defaults = []
21
+ @expansions = {}
22
+ @pattern_expansions = {}
23
+ @presences = []
24
+ end
25
+
26
+ def default(token, replaced_by: nil)
27
+ @defaults << StyleConfig::Default.new(token: token, replaced_by: replaced_by.freeze)
28
+ end
29
+
30
+ def expand(**pairs)
31
+ pairs.each do |key, value|
32
+ if key.is_a?(Regexp)
33
+ @pattern_expansions[key] = value.freeze
34
+ else
35
+ @expansions[key] = value.freeze
36
+ end
37
+ end
38
+ end
39
+
40
+ def presence(token)
41
+ @presences << token
42
+ end
43
+
44
+ def config
45
+ StyleConfig.new(
46
+ defaults: @defaults,
47
+ expansions: @expansions,
48
+ pattern_expansions: @pattern_expansions,
49
+ presences: @presences
50
+ )
51
+ end
52
+ end
53
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module CubitComponents
2
- VERSION = "0.1.0"
4
+ VERSION = "0.2.1"
3
5
  end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CubitComponents
4
+ class VStackComponent < CubitComponents::BaseComponent
5
+ style do
6
+ default :flex
7
+ default :"flex-col"
8
+ default :"items-center-safe"
9
+ default :"gap-16", replaced_by: /\Agap-/
10
+ end
11
+ end
12
+ end
@@ -1,34 +1,21 @@
1
- require "cubit_components/version"
2
- require "cubit_components/engine"
1
+ # frozen_string_literal: true
3
2
 
4
- # components
3
+ require_relative "cubit_components/version"
5
4
  require_relative "cubit_components/base_component"
6
5
  require_relative "cubit_components/box_component"
6
+ require_relative "cubit_components/flex_component"
7
7
  require_relative "cubit_components/stack_component"
8
- require_relative "cubit_components/inline_component"
9
- require_relative "cubit_components/columns_component"
8
+ require_relative "cubit_components/hstack_component"
9
+ require_relative "cubit_components/vstack_component"
10
+ require_relative "cubit_components/grid_component"
11
+ require_relative "cubit_components/container_component"
12
+ require_relative "cubit_components/page_container_component"
10
13
  require_relative "cubit_components/spread_component"
11
- require_relative "cubit_components/tiles_component"
12
- require_relative "cubit_components/content_block_component"
13
- require_relative "cubit_components/page_block_component"
14
+ require_relative "cubit_components/placeholder_component"
14
15
  require_relative "cubit_components/page_component"
15
- require_relative "cubit_components/bleed_component"
16
16
  require_relative "cubit_components/configuration"
17
17
 
18
18
  module CubitComponents
19
- class << self
20
- attr_writer :configuration
21
- end
22
-
23
- def self.configuration
24
- @configuration ||= Configuration.new
25
- end
26
-
27
- def self.configure
28
- yield(configuration)
29
- end
30
-
31
- def self.reset_configuration!
32
- @configuration = Configuration.new
33
- end
19
+ class Error < StandardError; end
20
+ class PlaceholderNotAllowedError < Error; end
34
21
  end
@@ -0,0 +1,4 @@
1
+ module CubitComponents
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end