Skip to content

Commit

Permalink
Add new defaultExpanded prop to Drawer.jsx:
Browse files Browse the repository at this point in the history
- allows for the drawer to open in an expanded size by default
  • Loading branch information
eric2523 committed Nov 7, 2023
1 parent 870615c commit 607461b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/Drawer/Drawer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,15 @@ const Drawer = ({
behindNav,
children,
className,
defaultExpanded,
expandable,
hasBackgroundOverlay,
visible,
orientation,
size,
onRequestClose,
}) => {
const [expanded, setExpanded] = useState(false);
const [expanded, setExpanded] = useState(defaultExpanded);

const handleExpand = () => setExpanded(!expanded);

Expand Down Expand Up @@ -86,6 +87,7 @@ Drawer.propTypes = {
behindNav: propTypes.bool,
children: propTypes.node,
className: propTypes.string,
defaultExpanded: propTypes.bool,
expandable: propTypes.bool,
hasBackgroundOverlay: propTypes.bool,
orientation: propTypes.oneOf([ORIENTATION_LEFT, ORIENTATION_RIGHT]),
Expand All @@ -98,6 +100,7 @@ Drawer.defaultProps = {
behindNav: true,
children: undefined,
className: null,
defaultExpanded: false,
expandable: false,
hasBackgroundOverlay: true,
orientation: ORIENTATION_RIGHT,
Expand Down
8 changes: 6 additions & 2 deletions src/Drawer/Drawer.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import * as ComponentStories from './Drawer.stories';

<Canvas of={ComponentStories.Default} />

### When to use
### When to use
When we want to focus the user’s attention on an interactive interface or a large amount of information

### When to not use
Expand Down Expand Up @@ -50,7 +50,11 @@ Pass `orientation="left"` to override the default behavior of sliding in from th

### Expandable

Setting `expandable` allows the drawer to expand to the full size of the viewport
Setting `expandable` allows the drawer to expand to the full size of the viewport when the expand button is clicked.

### Default Expanded

Setting `defaultExpanded` allows the drawer to expand the full size of the viewport by default.

### Additional Actions

Expand Down

0 comments on commit 607461b

Please sign in to comment.