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.
680 681 682 683 684 685 686 687 688 |
# File 'lib/mxrb/dsl/builder.rb', line 680 def initialize @tokens = [] @themes = [] @layouts = [] @components = [] @accessibility = [] @contrast_pairs = [] @forbid_literal_colors = false end |
Instance Method Details
#accessibility(rule) ⇒ Object
704 705 706 |
# File 'lib/mxrb/dsl/builder.rb', line 704 def accessibility(rule) @accessibility << rule.to_s end |
#component(name) ⇒ Object
700 701 702 |
# File 'lib/mxrb/dsl/builder.rb', line 700 def component(name) @components << name.to_s end |
#contrast(foreground:, background:, level: :aa) ⇒ Object
714 715 716 717 718 |
# File 'lib/mxrb/dsl/builder.rb', line 714 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
720 721 722 |
# File 'lib/mxrb/dsl/builder.rb', line 720 def forbid_literal_colors(value = true) @forbid_literal_colors = value == true end |
#layout(name) ⇒ Object
696 697 698 |
# File 'lib/mxrb/dsl/builder.rb', line 696 def layout(name) @layouts << name.to_s end |
#theme(name, inherits: nil, &block) ⇒ Object
708 709 710 711 712 |
# File 'lib/mxrb/dsl/builder.rb', line 708 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
724 725 726 727 728 729 730 731 |
# File 'lib/mxrb/dsl/builder.rb', line 724 def to_h { tokens: @tokens, layouts: @layouts, components: @components, accessibility: @accessibility, themes: @themes, contrast_pairs: @contrast_pairs, forbid_literal_colors: @forbid_literal_colors } end |