Sha256: 32e2a6f05de7098da41dfb0d7feef234f812c46b8e7cd53acc64fd43a4859d5a

Contents?: true

Size: 1.33 KB

Versions: 46

Compression:

Stored size: 1.33 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,
        position_props,
        hover_props,
        border_radius_props,
        text_align_props,
        overflow_props,
        truncate_props,
        left_props,
        top_props,
        right_props,
        bottom_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

46 entries across 46 versions & 1 rubygems

Version Path
playbook_ui-13.28.0.pre.alpha.PLAY1338alpha3001 lib/playbook/classnames.rb
playbook_ui-13.28.0.pre.alpha.PLAY1343fixTooltiprunwayissue2987 lib/playbook/classnames.rb
playbook_ui-13.28.0.pre.alpha.PLAY1343fixTooltiprunwayissue2986 lib/playbook/classnames.rb
playbook_ui-13.28.0.pre.alpha.PLAY1343fixTooltiprunwayissue2984 lib/playbook/classnames.rb
playbook_ui-13.27.0 lib/playbook/classnames.rb
playbook_ui-13.26.0.pre.alpha.PBNTR291Dropdownrailsv22840 lib/playbook/classnames.rb
playbook_ui-13.26.0.pre.alpha.jasoncypretpatch12820 lib/playbook/classnames.rb
playbook_ui-13.26.0.pre.alpha.jasoncypretpatch12816 lib/playbook/classnames.rb
playbook_ui-13.25.0.pre.alpha.PBNTR291Dropdownrailsv22812 lib/playbook/classnames.rb
playbook_ui-13.26.0 lib/playbook/classnames.rb
playbook_ui-13.25.0.pre.alpha.PLAY1249fixTooltipswrappingformelementscausingmisalignment2785 lib/playbook/classnames.rb
playbook_ui-13.25.0.pre.alpha.PLAY1249fixTooltipswrappingformelementscausingmisalignment2783 lib/playbook/classnames.rb
playbook_ui-13.25.0.pre.alpha.PBNTR272Dropdownkitv42769 lib/playbook/classnames.rb
playbook_ui-13.25.0.pre.alpha.barchartfix2766 lib/playbook/classnames.rb
playbook_ui-13.25.0.pre.alpha.PLAY761globalpaddingpropsbuttons2713 lib/playbook/classnames.rb
playbook_ui-13.25.0 lib/playbook/classnames.rb
playbook_ui-13.24.0.pre.alpha.play1305drycontenttag2689 lib/playbook/classnames.rb
playbook_ui-13.24.0.pre.alpha.PBNTR261NewKitDropdown2681 lib/playbook/classnames.rb
playbook_ui-13.24.0.pre.alpha.PLAY1181circleiconkitfixsizingerrorglobalspacingprops2675 lib/playbook/classnames.rb
playbook_ui-13.24.0.pre.alpha.PLAY998backgroundkitremoveemptyinlinline2666 lib/playbook/classnames.rb