Previews

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<%= render(Primer::Alpha::Dialog.new(id: "my-dialog", title: "Confirm focus")) do |d| %>
<%= render(Primer::Alpha::Dialog::Body.new()) do %>
Are you sure you want to focus the input?
<% end %>
<%= render(Primer::Alpha::Dialog::Footer.new()) do %>
<%= render(Primer::Beta::Button.new(id: "yes-button", data: { "close-dialog-id": "my-dialog" })) { "Yes" } %>
<%= render(Primer::Beta::Button.new(scheme: :primary, data: { "close-dialog-id": "my-dialog" })) { "Yes but in green" } %>
<% end %>
<% d.with_show_button do |b| %>
Focus input
<% b.with_tooltip(text: "This is a tooltip in an Overlay") %>
<% end %>
<% end %>
<label>
An input
<input type="text" id="input" autocomplete="off">
</label>
<script>
document.querySelector('#my-dialog').addEventListener('close', function () {
document.querySelector('#input').focus();
});
</script>