2022-08-27 11:52:29 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
module Pajamas
|
|
|
|
class SpinnerComponentPreview < ViewComponent::Preview
|
|
|
|
# Spinner
|
|
|
|
# ----
|
|
|
|
# See its design reference [here](https://design.gitlab.com/components/spinner).
|
|
|
|
#
|
|
|
|
# @param inline toggle
|
|
|
|
# @param label text
|
2023-01-13 00:05:48 +05:30
|
|
|
# @param size select {{ Pajamas::SpinnerComponent::SIZE_OPTIONS }}
|
2022-08-27 11:52:29 +05:30
|
|
|
def default(inline: false, label: "Loading", size: :md)
|
2023-01-13 00:05:48 +05:30
|
|
|
render Pajamas::SpinnerComponent.new(
|
|
|
|
inline: inline,
|
|
|
|
label: label,
|
|
|
|
size: size
|
|
|
|
)
|
2022-08-27 11:52:29 +05:30
|
|
|
end
|
|
|
|
|
2023-01-13 00:05:48 +05:30
|
|
|
# Use a light spinner on dark backgrounds.
|
2022-08-27 11:52:29 +05:30
|
|
|
#
|
2023-01-13 00:05:48 +05:30
|
|
|
# @display bg_dark true
|
2022-08-27 11:52:29 +05:30
|
|
|
def light
|
|
|
|
render(Pajamas::SpinnerComponent.new(color: :light))
|
|
|
|
end
|
2023-01-13 00:05:48 +05:30
|
|
|
|
|
|
|
# Any extra HTML attributes like `class`, `data` or `id` get automatically applied to the spinner container element.
|
|
|
|
#
|
|
|
|
def extra_attributes
|
|
|
|
render Pajamas::SpinnerComponent.new(
|
|
|
|
class: "js-do-something",
|
|
|
|
data: { foo: "bar" },
|
|
|
|
id: "my-special-spinner"
|
|
|
|
)
|
|
|
|
end
|
2022-08-27 11:52:29 +05:30
|
|
|
end
|
|
|
|
end
|