Sha256: 52d0009e22a0cf22b76fd208acc66367a90a1f4649a6b58ef6ba0bc51b549031

Contents?: true

Size: 1.77 KB

Versions: 21

Compression:

Stored size: 1.77 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))
      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

21 entries across 21 versions & 2 rubygems

Version Path
openproject-primer_view_components-0.39.1 previews/primer/alpha/toggle_switch_preview.rb
openproject-primer_view_components-0.39.0 previews/primer/alpha/toggle_switch_preview.rb
openproject-primer_view_components-0.38.0 previews/primer/alpha/toggle_switch_preview.rb
primer_view_components-0.29.0 previews/primer/alpha/toggle_switch_preview.rb
primer_view_components-0.28.0 previews/primer/alpha/toggle_switch_preview.rb
openproject-primer_view_components-0.37.1 previews/primer/alpha/toggle_switch_preview.rb
openproject-primer_view_components-0.37.0 previews/primer/alpha/toggle_switch_preview.rb
openproject-primer_view_components-0.36.2 previews/primer/alpha/toggle_switch_preview.rb
openproject-primer_view_components-0.36.1 previews/primer/alpha/toggle_switch_preview.rb
openproject-primer_view_components-0.36.0 previews/primer/alpha/toggle_switch_preview.rb
primer_view_components-0.27.0 previews/primer/alpha/toggle_switch_preview.rb
openproject-primer_view_components-0.35.2 previews/primer/alpha/toggle_switch_preview.rb
openproject-primer_view_components-0.35.1 previews/primer/alpha/toggle_switch_preview.rb
primer_view_components-0.26.1 previews/primer/alpha/toggle_switch_preview.rb
openproject-primer_view_components-0.35.0 previews/primer/alpha/toggle_switch_preview.rb
primer_view_components-0.26.0 previews/primer/alpha/toggle_switch_preview.rb
openproject-primer_view_components-0.34.0 previews/primer/alpha/toggle_switch_preview.rb
openproject-primer_view_components-0.33.2 previews/primer/alpha/toggle_switch_preview.rb
openproject-primer_view_components-0.33.1 previews/primer/alpha/toggle_switch_preview.rb
openproject-primer_view_components-0.33.0 previews/primer/alpha/toggle_switch_preview.rb