Skip to content

Commit

Permalink
Element hidden style
Browse files Browse the repository at this point in the history
Make it visually more obvious if an element is hidden
  • Loading branch information
tvdeyen committed Dec 15, 2020
1 parent ef259c2 commit b3a2763
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 1 deletion.
26 changes: 26 additions & 0 deletions app/assets/stylesheets/alchemy/elements.scss
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,32 @@
margin-bottom: 2*$default-margin;
transition: box-shadow $transition-duration;

&.hidden {
display: block;
border-style: dashed;
opacity: 0.5;
transition: opacity $transition-duration;

> .element-header {
background-color: transparent;
background-image: linear-gradient(
45deg,
$light-gray 25%,
$medium-gray 25%,
$medium-gray 50%,
$light-gray 50%,
$light-gray 75%,
$medium-gray 75%,
$medium-gray 100%
);
background-size: 28.28px 28.28px;
}

&:hover {
opacity: 1;
}
}

&.is-fixed {
border-width: 0;
border-radius: 0;
Expand Down
1 change: 1 addition & 0 deletions app/decorators/alchemy/element_editor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ def css_classes
folded ? "folded" : "expanded",
compact? ? "compact" : nil,
fixed? ? "is-fixed" : "not-fixed",
public? ? "visible" : "hidden",
].join(" ")
end

Expand Down
2 changes: 1 addition & 1 deletion app/views/alchemy/admin/elements/_element_footer.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</p>
<% end %>

<button type="submit" form="element_<%= element.id %>_form" class="button" data-alchemy-button>
<button type="submit" <%= "disabled" unless element.public? %> form="element_<%= element.id %>_form" class="button" data-alchemy-button>
<%= Alchemy.t(:save) %>
</button>
</div>
1 change: 1 addition & 0 deletions app/views/alchemy/admin/elements/publish.js.erb
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ var eye = el.find('> .element-toolbar .publish-element-button .icon');
eye.addClass('fa-eye');
label.text('<%= Alchemy.t(:show_element) %>');
<%- end -%>
el.toggleClass('visible hidden');

Alchemy.reloadPreview();
12 changes: 12 additions & 0 deletions spec/decorators/alchemy/element_editor_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,18 @@
is_expected.to include("element-editor")
end

context "with element is public" do
let(:element) { build_stubbed(:alchemy_element, public: true) }

it { is_expected.to include("visible") }
end

context "with element is not public" do
let(:element) { build_stubbed(:alchemy_element, public: false) }

it { is_expected.to include("hidden") }
end

context "with element is folded" do
let(:element) { build_stubbed(:alchemy_element, folded: true) }

Expand Down

0 comments on commit b3a2763

Please sign in to comment.