Sha256: efe97a83cf2c4f963d1fab29a068528dbc0f71678981fb389e9710672a4240fa

Contents?: true

Size: 1.74 KB

Versions: 12

Compression:

Stored size: 1.74 KB

Contents

module Accordion
  def open_page stack
    active = app.slot.contents.map { |x| x.contents[1] }.
      detect { |x| x.height > 0 }
    return if active == stack
    a = animate 60 do
      stack.height += 20
      active.height = 240 - stack.height if active
      a.stop if stack.height == 240
    end
  end
  def page title, text
    @pages ||= []
    @pages <<
      stack do
        page_text = nil
        stack :width => "100%" do
          background "#fff".."#eed"
          hi = background "#ddd".."#ba9", :hidden => true
          para link(title) {}, :size => 26
          hover { hi.show }
          leave { hi.hide }
          click { open_page page_text }
        end
        page_text =
          stack :width => "100%", :height => (@pages.empty? ? 240 : 0) do
            stack :margin => 10 do
              text.split(/\n{2,}/).each do |pg|
                para pg
              end
            end
          end
      end
  end
end

Shoes.app do
  extend Accordion
  style(Link, :stroke => black, :underline => nil, :weight => "strong")
  style(LinkHover, :stroke => black, :fill => nil, :underline => nil)

  page "0.0", <<-'END'
There is a thought
I have just had
Which I don’t care to pass to
Anyone at all at this time.

I have even forgotten it now,
But kept only the pleasures
Of my property
And of my controlled mental slippage.
END
  page "0.1", <<-'END'
My eyes have blinked again
And I have just realized
This upright world
I have been in.

My eyelids wipe
My eyes hundreds of times
Reseting and renovating
The scenery.
END
  page "0.2", <<-'END'
Sister, without you,
The universe would
Have such a hole through it,
Where infinity has been shot.

This cannot be, though.
There will always be room
For you—all of us are
Holding the way open.
END
end

Version data entries

12 entries across 9 versions & 4 rubygems

Version Path
scarpe-0.4.0 examples/legacy/not_checked/shoes-contrib/simple/simple-accordion.rb
scarpe-0.3.0 examples/legacy/not_checked/shoes-contrib/simple/simple-accordion.rb
scarpe-0.2.2 examples/legacy/not_checked/shoes-contrib/simple/simple-accordion.rb
lacci-0.2.1 examples/legacy/not_checked/shoes-dep-samples/simple-accordion.rb
lacci-0.2.1 examples/legacy/not_checked/shoes-contrib/simple/simple-accordion.rb
scarpe-0.2.1 examples/legacy/not_checked/shoes-dep-samples/simple-accordion.rb
scarpe-0.2.1 examples/legacy/not_checked/shoes-contrib/simple/simple-accordion.rb
scarpe-0.2.0 examples/legacy/not_checked/shoes-dep-samples/simple-accordion.rb
scarpe-0.2.0 examples/legacy/not_checked/shoes-contrib/simple/simple-accordion.rb
shoes-3.0.1 samples/simple-accordion.rb
shoesgem-0.1514.0 shoes/samples/simple-accordion.rb
shoesgem-0.1424.0 shoes/samples/simple-accordion.rb