31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
# File 'app/components/primer/alpha/toggle_switch.rb', line 31
def initialize(src: nil, csrf_token: nil, checked: false, enabled: true, size: SIZE_DEFAULT, status_label_position: STATUS_LABEL_POSITION_DEFAULT, turbo: false, **system_arguments)
@src = src
@csrf_token = csrf_token
@checked = checked
@enabled = enabled
@turbo = turbo
@system_arguments = system_arguments
@size = fetch_or_fallback(SIZE_OPTIONS, size, SIZE_DEFAULT)
@status_label_position = fetch_or_fallback(
STATUS_LABEL_POSITION_OPTIONS, status_label_position, STATUS_LABEL_POSITION_DEFAULT
)
@system_arguments[:classes] = class_names(
@system_arguments.delete(:classes),
"ToggleSwitch",
on? ? "ToggleSwitch--checked" : nil,
enabled? ? nil : "ToggleSwitch--disabled",
STATUS_LABEL_POSITION_MAPPINGS[@status_label_position],
SIZE_MAPPINGS[@size]
)
@aria_arguments = {
aria: merge_aria(
@system_arguments,
aria: { pressed: on? }
)
}
@system_arguments[:src] = @src if @src
end
|