Sha256: 95c74770874d457932d59d3d90f080fc587af50b958181b81b053fbf6a7b250e

Contents?: true

Size: 1.79 KB

Versions: 62

Compression:

Stored size: 1.79 KB

Contents

# frozen_string_literal: true

require_relative "../url_helpers"

module Primer
  module Alpha
    # @label Toggle Switch
    class ToggleSwitchPreview < ViewComponent::Preview
      include ActionView::Helpers::FormTagHelper

      def playground
        render(Primer::Alpha::ToggleSwitch.new(src: UrlHelpers.toggle_switch_index_path))
      end

      # @snapshot
      def default
        render(Primer::Alpha::ToggleSwitch.new(src: UrlHelpers.toggle_switch_index_path))
      end

      # @snapshot
      def checked
        render(Primer::Alpha::ToggleSwitch.new(src: UrlHelpers.toggle_switch_index_path, checked: true))
      end

      # @snapshot
      def disabled
        render(Primer::Alpha::ToggleSwitch.new(src: UrlHelpers.toggle_switch_index_path, enabled: false))
      end

      # @snapshot
      def checked_disabled
        render(Primer::Alpha::ToggleSwitch.new(src: UrlHelpers.toggle_switch_index_path, checked: true, enabled: false))
      end

      # @snapshot
      def small
        render(Primer::Alpha::ToggleSwitch.new(src: UrlHelpers.toggle_switch_index_path, size: :small))
      end

      # @snapshot
      def with_status_label_position_end
        render(Primer::Alpha::ToggleSwitch.new(src: UrlHelpers.toggle_switch_index_path, status_label_position: :end))
      end

      # @snapshot
      def with_a_bad_src
        render(Primer::Alpha::ToggleSwitch.new(src: "/foo"))
      end

      def with_no_src
        render(Primer::Alpha::ToggleSwitch.new)
      end

      def with_csrf_token
        render(Primer::Alpha::ToggleSwitch.new(src: UrlHelpers.toggle_switch_index_path, csrf_token: "let_me_in"))
      end

      def with_bad_csrf_token
        render(Primer::Alpha::ToggleSwitch.new(src: UrlHelpers.toggle_switch_index_path, csrf_token: "i_am_a_criminal"))
      end
    end
  end
end

Version data entries

62 entries across 62 versions & 2 rubygems

Version Path
openproject-primer_view_components-0.32.1 previews/primer/alpha/toggle_switch_preview.rb
openproject-primer_view_components-0.32.0 previews/primer/alpha/toggle_switch_preview.rb
openproject-primer_view_components-0.29.1 previews/primer/alpha/toggle_switch_preview.rb
openproject-primer_view_components-0.29.0 previews/primer/alpha/toggle_switch_preview.rb
primer_view_components-0.23.0 previews/primer/alpha/toggle_switch_preview.rb
openproject-primer_view_components-0.28.1 previews/primer/alpha/toggle_switch_preview.rb
openproject-primer_view_components-0.28.0 previews/primer/alpha/toggle_switch_preview.rb
openproject-primer_view_components-0.27.0 previews/primer/alpha/toggle_switch_preview.rb
openproject-primer_view_components-0.26.0 previews/primer/alpha/toggle_switch_preview.rb
openproject-primer_view_components-0.25.1 previews/primer/alpha/toggle_switch_preview.rb
primer_view_components-0.22.0 previews/primer/alpha/toggle_switch_preview.rb
primer_view_components-0.21.1 previews/primer/alpha/toggle_switch_preview.rb
openproject-primer_view_components-0.25.0 previews/primer/alpha/toggle_switch_preview.rb
openproject-primer_view_components-0.24.0 previews/primer/alpha/toggle_switch_preview.rb
primer_view_components-0.21.0 previews/primer/alpha/toggle_switch_preview.rb
primer_view_components-0.20.1 previews/primer/alpha/toggle_switch_preview.rb
primer_view_components-0.20.0 previews/primer/alpha/toggle_switch_preview.rb
openproject-primer_view_components-0.23.0 previews/primer/alpha/toggle_switch_preview.rb
primer_view_components-0.19.0 previews/primer/alpha/toggle_switch_preview.rb
openproject-primer_view_components-0.22.2 previews/primer/alpha/toggle_switch_preview.rb