lib/atome/genesis/generators/spatial.rb in atome-0.5.5.9.1 vs lib/atome/genesis/generators/spatial.rb in atome-0.5.6.0.2

- old
+ new

@@ -1,40 +1,22 @@ # frozen_string_literal: true -# new ({particle: :left}) do |params| -# {value: params, unit: :px} unless params.instance_of? Hash -# end -# new({ particle: :right, type: :integer })do |params| -# {value: params, unit: :px} unless params.instance_of? Hash -# end -# new({ particle: :top, type: :integer })do |params| -# {value: params, unit: :px} unless params.instance_of? Hash -# -# end -# new({ particle: :bottom, type: :integer })do |params| -# {value: params, unit: :px} unless params.instance_of? Hash -# end - -new ({particle: :left}) -new ({particle: :right}) -new ({particle: :top}) -new ({particle: :bottom}) - - +new({ particle: :left }) +new({ particle: :right }) +new({ particle: :top }) +new({ particle: :bottom }) new({ particle: :rotate, type: :integer }) new({ particle: :direction, type: :string }) -new({ particle: :center, type: :string}) -new({particle: :depth, type: :integer}) +new({ particle: :depth, type: :integer }) new({ particle: :position }) new({ particle: :organise }) new({ particle: :spacing }) new({ particle: :display }) do |params| params = { mode: params } unless params.instance_of? Hash params end new({ particle: :layout }) do |params| - mode_found = params.delete(:mode) || :list elements_style = params.delete(:element) || {} # now we get the list of the atome to layout atomes_to_organise = [] atomes_to_organise = collect if type == :group @@ -43,18 +25,17 @@ if mode_found == :default # the user want to revert the layout to the default atomes_to_organise.each do |atome_id_to_organise| atome_found = grab(atome_id_to_organise) # now restoring - if atome_found.backup - atome_found.backup.each do |particle, value| - atome_found.send(:delete, particle) - atome_found.send(particle, value) - end - atome_found.remove_layout - end + next unless atome_found.backup + atome_found.backup.each do |particle, value| + atome_found.send(:delete, particle) + atome_found.send(particle, value) + end + atome_found.remove_layout end else if params[:id] container_name = params[:id] @@ -74,16 +55,14 @@ end # now we add user wanted particles atomes_to_organise.each do |atome_id_to_organise| atome_found = grab(atome_id_to_organise) # now restoring - if atome_found.backup - atome_found.backup.each do |particle, value| - atome_found.send(:delete, particle) - atome_found.send(particle, value) - end - # atome_found.remove_layout + # atome_found.remove_layout + atome_found.backup&.each do |particle, value| + atome_found.send(:delete, particle) + atome_found.send(particle, value) end # we remove previous display mode atome_found.remove_layout atome_found.display[:mode] = mode_found atome_found.display[:layout] = id_found @@ -105,9 +84,9 @@ end end end params end -new({particle: :center}) - - - +new({ particle: :center, type: :hash }) do |params| + params = { x: 0, y: 0, dynamic: true } if params == true + params +end