-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(expandcollapse): Adjust panel content height when inner cont…
…ent changes
- Loading branch information
1 parent
3c5f4c8
commit 5b2c369
Showing
2 changed files
with
61 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,53 @@ | ||
``` | ||
<ExpandCollapse open={["panel-1"]}> | ||
<ExpandCollapse> | ||
<ExpandCollapse.Panel id="panel-1" header="First panel title"> | ||
First panel | ||
</ExpandCollapse.Panel> | ||
<ExpandCollapse.Panel id="panel-2" header="Second panel title"> | ||
<ExpandCollapse.Panel id="panel-2" header="Second panel title" subtext="Some subtext"> | ||
Second panel | ||
</ExpandCollapse.Panel> | ||
</ExpandCollapse> | ||
``` | ||
|
||
### Arbitrary header component | ||
|
||
``` | ||
<ExpandCollapse> | ||
<ExpandCollapse.Panel id="panel-10" header={<Text size="large">I'm large and misligned</Text>}> | ||
First panel | ||
</ExpandCollapse.Panel> | ||
</ExpandCollapse> | ||
``` | ||
|
||
|
||
### Adjusting height | ||
|
||
``` | ||
initialState = { | ||
error: '', | ||
}; | ||
const trigger = () => { | ||
if( state.error === '' ) { | ||
setState({error: 'Oh no there was an error'}); | ||
} | ||
else { | ||
setState({error: ''}); | ||
} | ||
}; | ||
<ExpandCollapse open={['panel-21']}> | ||
<ExpandCollapse.Panel id="panel-20" header="First panel title"> | ||
First panel | ||
</ExpandCollapse.Panel> | ||
<ExpandCollapse.Panel id="panel-21" header="Second panel title"> | ||
<div> | ||
<Paragraph>Second panel blah blah blah</Paragraph> | ||
<Button onClick={trigger}>Trigger</Button> | ||
<Input label="Testing" error={state.error} /> | ||
</div> | ||
</ExpandCollapse.Panel> | ||
</ExpandCollapse> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters