Sha256: 961b3c8e2b746d80b863cc205b2b21882ad5536c7ca70d8826e9bfbe93e93349

Contents?: true

Size: 1.11 KB

Versions: 150

Compression:

Stored size: 1.11 KB

Contents

# frozen_string_literal: true

module Playbook
  module Classnames
    def self.included(base)
      base.prop :classname
      base.prop :dark, type: Playbook::Props::Boolean, default: false
    end

    def generate_classname(*name_parts, separator: "_")
      [
        name_parts.compact.join(separator),
        prop(:classname),
        spacing_props,
        dark_props,
        max_width_props,
        z_index_props,
        number_spacing_props,
        shadow_props,
        line_height_props,
        display_props,
        cursor_props,
        flex_direction_props,
        flex_wrap_props,
        justify_content_props,
        justify_self_props,
        align_items_props,
        align_content_props,
        align_self_props,
        flex_props,
        flex_grow_props,
        flex_shrink_props,
        order_props,
      ].compact.join(" ")
    end

    def generate_classname_without_spacing(*name_parts, separator: "_")
      [
        name_parts.compact.join(separator),
        prop(:classname),
      ].compact.join(" ")
    end

  private

    def dark_props
      dark ? "dark" : nil
    end
  end
end

Version data entries

150 entries across 150 versions & 1 rubygems

Version Path
playbook_ui-12.13.0.pre.alpha.addingProductTokens439 lib/playbook/classnames.rb
playbook_ui-12.13.0.pre.alpha.PLAY705phonenumberkit438 lib/playbook/classnames.rb
playbook_ui-12.13.0 lib/playbook/classnames.rb
playbook_ui-12.12.0.pre.alpha.PLAY697sandpacklayoutstyles413 lib/playbook/classnames.rb
playbook_ui-12.12.0 lib/playbook/classnames.rb
playbook_ui-12.11.0 lib/playbook/classnames.rb
playbook_ui-12.10.0.pre.alpha.PLAY705phonenumberreturn372 lib/playbook/classnames.rb
playbook_ui-12.10.0.pre.alpha.PLAY677richtexteditorts370 lib/playbook/classnames.rb
playbook_ui-12.10.0 lib/playbook/classnames.rb
playbook_ui-12.9.1.pre.alpha.play664tiptapinvestigation353 lib/playbook/classnames.rb
playbook_ui-12.9.1.pre.alpha.PLAY689bugtxtinputlabel346 lib/playbook/classnames.rb
playbook_ui-12.9.1.pre.alpha.menucleanup345 lib/playbook/classnames.rb
playbook_ui-12.9.1.pre.alpha.menucleanup342 lib/playbook/classnames.rb
playbook_ui-12.9.1 lib/playbook/classnames.rb
playbook_ui-12.9.0 lib/playbook/classnames.rb
playbook_ui-12.8.0.pre.alpha.PLAY625phonenumberdark301 lib/playbook/classnames.rb
playbook_ui-12.8.0.pre.alpha.PLAY625phonenumberdark300 lib/playbook/classnames.rb
playbook_ui-12.8.0.pre.alpha.PLAY649mapkitstyles299 lib/playbook/classnames.rb
playbook_ui-12.8.0.pre.alpha.PLAY645typescriptprogresstep298 lib/playbook/classnames.rb
playbook_ui-12.8.0.pre.alpha.PLAY645typescriptprogresstep297 lib/playbook/classnames.rb