Panel: Break types into separate props for simplicity and greater control
Currently, there are 7 types of panel:
- small
- smallFixedFar
- smallFixedNear
- medium
- large
- largeFixed
- extraLarge
As you can see from the names, these mix sizes (small, medium, and large) with behaviors (fixed, fluid) and positions (near, far). It's more complex than necessary and prevents us from making additional panel types that should be valid. For example, a medium panel on the left of the screen.
Proposed props
I propose we instead have the following props: width, minimumWidth, maximumWidth, and attachedEdge. These should cover most scenarios and would be more predictable, as they clearly define the behavior of the Panel without being tied to specific breakpoints.
width
What percentage of the screen's total width should this Panel ideally cover? The remaining space is a "peek" of the content behind and has an overlay. Setting this to 0 would make the Panel shrink to its minimumWidth, while 100 would result in a full-screen Panel until the maximumWidth is reached.
minimumWidth
The minimum width of the Panel. This should be no larger than 320px, as a Panel should display well at full-width on our smallest supported screen size. A smaller value can be provided in cases where even on small devices you want to give context by showing a peek of the content behind.
maximumWidth
How large should a Panel get before it stops growing? As the screen size increases, Panels will expand to fill the available space based on the percent width they have been set to. This can prevent a Panel from getting overly wide.
attachedEdge
Should the Panel be attached to the left/near side of the screen, or the right/far side? This would have no effect on the Panel's other behaviors, so I've left it out from the examples below.
These props make it much simpler to understand and control how a Panel will behave. Developers can consider how well the content of a Panel scales to determine the minimumWidth and maximumWidth. The percentage width provides a single value to tweak to determine whether the Panel grows quickly to optimize for its contents, or slowly to optimize for showing the context of the page behind. Whether it appears on the left or right of the screen is a simple choice available for all Panels, rather than being tied up with other behaviors.
Examples
Typical Panel
| Prop | Value |
|---|---|
width |
50% |
minimumWidth |
270px |
maximumWidth |
400px |
On a 320px screen, we attempt to make the Panel 160px wide. This is less than the specified minimumWidth, so the result is a 270px Panel with a 50px peek area.
On a 640px screen, we attempt to make the Panel 320px wide. This is within the acceptable range, resulting in a 320px Panel with a 320px peek area.
On a 900px screen, we attempt to make the Panel 450px wide. This exceeds its maximumWidth, so the result is a 400px Panel with a 500px peek area.
Show more Panel
| Prop | Value |
|---|---|
width |
100% |
minimumWidth |
320px |
maximumWidth |
900px |
On a 320px screen, it takes up the full width.
On a 640px screen, it still takes up the full width.
On a 1000px screen, it reaches it's maximum width of 900px and leaves a 100px peek area.
Show more peek area
| Prop | Value |
|---|---|
width |
30% |
minimumWidth |
320px |
maximumWidth |
900px |
On a 320px screen, we attempt to make the Panel 96px wide. This is less than the minimumWidth so the Panel takes up the full screen.
On a 640px screen, we attempt to make the Panel 192px wide. This is less than the minimumWidth so the Panel remains a 320px Panel with a 320px peek area.
On a 1200px screen, we attempt to make the Panel 360px wide. This is within the limits, so the result is a 360px Panel with a 840px peek area.
This was reviewed in a Fabric Design Council meeting today. There were no major concerns, I just need to demonstrate how all of the existing panel behaviors can be accomplished using this system.
When the attachedEdge edge props will be available?
@jonathanhotono Work on this feature hasn't started yet. For now, you'll need to pass in a custom className and then use CSS to modify the Panel. You can start with a panel type of smallFixedNear to attach it to the left, and then use CSS to adjust the size if needed.
This is something we can revisit in the future but for now we are going to close this.
I think this is a great proposal and would make the component more useful in different situations.