Class: Mxrb::Dsl::DesignSystemBuilder
- Inherits:
-
Object
- Object
- Mxrb::Dsl::DesignSystemBuilder
- Defined in:
- lib/mxrb/dsl/builder.rb
Constant Summary collapse
- TOKEN_KINDS =
%i[color spacing radius typography breakpoint].freeze
Instance Method Summary collapse
- #accessibility(rule) ⇒ Object
- #component(name) ⇒ Object
- #contrast(foreground:, background:, level: :aa) ⇒ Object
- #forbid_literal_colors(value = true) ⇒ Object
-
#initialize ⇒ DesignSystemBuilder
constructor
A new instance of DesignSystemBuilder.
- #layout(name) ⇒ Object
- #theme(name, inherits: nil, &block) ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize ⇒ DesignSystemBuilder
Returns a new instance of DesignSystemBuilder.
568 569 570 571 572 573 574 575 576 |
# File 'lib/mxrb/dsl/builder.rb', line 568 def initialize @tokens = [] @themes = [] @layouts = [] @components = [] @accessibility = [] @contrast_pairs = [] @forbid_literal_colors = false end |
Instance Method Details
#accessibility(rule) ⇒ Object
592 593 594 |
# File 'lib/mxrb/dsl/builder.rb', line 592 def accessibility(rule) @accessibility << rule.to_s end |
#component(name) ⇒ Object
588 589 590 |
# File 'lib/mxrb/dsl/builder.rb', line 588 def component(name) @components << name.to_s end |
#contrast(foreground:, background:, level: :aa) ⇒ Object
602 603 604 605 606 |
# File 'lib/mxrb/dsl/builder.rb', line 602 def contrast(foreground:, background:, level: :aa) @contrast_pairs << { foreground: foreground.to_s, background: background.to_s, level: level.to_s } end |
#forbid_literal_colors(value = true) ⇒ Object
608 609 610 |
# File 'lib/mxrb/dsl/builder.rb', line 608 def forbid_literal_colors(value = true) @forbid_literal_colors = value == true end |
#layout(name) ⇒ Object
584 585 586 |
# File 'lib/mxrb/dsl/builder.rb', line 584 def layout(name) @layouts << name.to_s end |
#theme(name, inherits: nil, &block) ⇒ Object
596 597 598 599 600 |
# File 'lib/mxrb/dsl/builder.rb', line 596 def theme(name, inherits: nil, &block) builder = DesignThemeBuilder.new(name, inherits:) builder.instance_eval(&block) if block @themes << builder.to_h end |
#to_h ⇒ Object
612 613 614 615 616 617 618 619 |
# File 'lib/mxrb/dsl/builder.rb', line 612 def to_h { tokens: @tokens, layouts: @layouts, components: @components, accessibility: @accessibility, themes: @themes, contrast_pairs: @contrast_pairs, forbid_literal_colors: @forbid_literal_colors } end |