On 18/01/13 19:45 , Dave Townsend wrote:
> The API that would make sense to me looks something like this:
>
> var panel = require("panel").Panel({
> width: 300,
> height: 200,
> x: 200,
> y: 400,
> arrow: "top left"
> });
I can see a couple of major issues with this approach:
1. It doesn't cover the scenario of the bug we're fixing (bug 732294);
basically you can't align the panel, just position it (what if I want to
position the panel at the top right corner?).
2. The position of the arrow has specific guidelines how should be
displayed, in according to UX; also depends by the panel's size,
position of the browser and the screen space available, keep a specific
arrow's position could be not possible (see also comments in bug
669523); because the panel will be flipped or moved.
For the first point, I will suggest to use one of the alternative API I
already suggested in the previous post:
var panel = require("panel").Panel({
width: 300,
height: 200,
top: 200,
left: 400 // and right and bottom too
});
In that case, if I want to align on the top right, I have just to write:
var panel = require("panel").Panel({
width: 300,
height: 200,
top: 0,
right: 0
});
This is also mimic the CSS syntax for position an absolute element, so
it's good for web developers.
To center a panel, we could set a string with percent:
var panel = require("panel").Panel({
width: 300,
height: 200,
top: "50%",
right: 0
});
Or either implement floating values:
var panel = require("panel").Panel({
width: 300,
height: 200,
top: 0.5,
right: 0
});
But it will be more confusing IMVHO.
For the second point, even if the UX will be fine with that, we still
can't assure that the arrow will be placed where specified.
So or we either don't do that, leaving the panel's arrow displayed in
accordance with Firefox's UI, or we explicitly say that the values set
for the `arrow` property are more "suggested values" rather than "actual
values", and there is no guarantee the arrow will be placed there.
As far as I remember, the UX guidelines says about arrowed panels:
- The arrow should be always placed in the center of the anchor element
(we can't assure that, of course, if we just pass coordinates instead of
anchor element)
- The panel should be always "tend" to the center of the content area.
Not sure if it's the right way to say, but basically if we open an
arrowed panel in top right corner of the browser, the arrow should be
displayed in the top right, with the panel's body that "point" to the
center of the content area. If we open an arrowed panel on the bottom
right, the arrow should be on the bottom right, with the panel's body
that point to the center of the content area, etc.
Personally, I would like for high level API be consistent with Firefox's
UI guidelines and behaviors: one of the big issue so far before Jetpack,
was that the user experience across add-ons was inconsistent; and I can
see Add-on SDK as a good way to mitigate that.