Skip to content

Commit

Permalink
Use normal select for preview sizes
Browse files Browse the repository at this point in the history
More accessible and one less select2 instance.
  • Loading branch information
tvdeyen committed Jun 6, 2024
1 parent ddd07db commit 57a7dd2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
5 changes: 3 additions & 2 deletions app/assets/stylesheets/alchemy/selects.scss
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,9 @@ select {
align-items: center;
margin: 0 3 * $default-margin;

label {
margin-right: 2 * $default-margin;
label,
alchemy-icon {
margin-right: var(--spacing-2);
}
}

Expand Down
3 changes: 1 addition & 2 deletions app/javascript/alchemy_admin/components/preview_window.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ class PreviewWindow extends HTMLIFrameElement {

key("alt+r", () => this.refresh())

// Need to listen with jQuery here because select2 does not emit native events.
$(this.sizeSelect).on("change", (evt) => {
this.sizeSelect.addEventListener("change", (evt) => {
const select = evt.target
const width = select.value

Expand Down
10 changes: 6 additions & 4 deletions app/views/alchemy/admin/pages/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,12 @@
<% end %>
<div class="toolbar_spacer"></div>
<div class="select_with_label">
<label><%= Alchemy.t(:preview_size) %></label>
<%= select_tag 'preview_size',
preview_sizes_for_select,
class: 'medium', is: 'alchemy-select' %>
<sl-tooltip content="<%= Alchemy.t(:preview_size) %>" placement="top-start">
<%= render_icon(:computer) %>
<%= select_tag "preview_size",
preview_sizes_for_select,
include_blank: Alchemy.t("auto", scope: "preview_sizes") %>
</sl-tooltip>
</div>
<div class="toolbar_spacer"></div>
<% if @preview_urls.many? %>
Expand Down

0 comments on commit 57a7dd2

Please sign in to comment.