-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ExpandableBlock props for subcomponents #2460
base: main
Are you sure you want to change the base?
Changes from all commits
df5c1be
20262bd
8681fbf
e0c0463
5484e4f
a07b631
d3df626
f10d223
98e4414
9d122b1
fb5f772
0823e45
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,10 +17,42 @@ The expandable block has a label reflecting its content. On click, it expands to | |
|
||
## Usage | ||
|
||
The expandable block can be used in two ways: | ||
### Legacy API | ||
|
||
You can use `ExpandableBlock` directly, without any subcomponents. | ||
|
||
- Directly using `ExpandableBlock` along with `title`, `caption`, `endIcon` and children. | ||
- Although this pattern can suffice for simple cases, we strongly recommend using composition API for more flexibility. | ||
|
||
```tsx | ||
<ExpandableBlock title='Expandable Block' caption='With caption!'> | ||
Content in block! | ||
</ExpandableBlock> | ||
``` | ||
|
||
### Composition API | ||
|
||
Alternatively, you can build expandable blocks with sub-components that are fully customizable. | ||
|
||
- Directly using `ExpandableBlock` along with `title`, `caption`, `endIcon` and children. This pattern can suffice for simple cases. | ||
- Using subcomponents (`ExpandableBlock.Wrapper`, `ExpandableBlock.Trigger`, `ExpandableBlock.Content`, etc). This pattern is more verbose but allows full customization over all the parts. | ||
- `ExpandableBlock.Wrapper` is a wrapper around the subcomponents. | ||
- The `ExpandableBlock.Trigger` is the `Header` container that contains `ExpandIcon`, `LabelArea` and `EndIcon` subcomponents. | ||
- The `ExpandableBlock.Content` is the content shown when `ExpandableBlock.Trigger` is triggered. | ||
|
||
The following code is equivalent to the [legacy example](#legacy-api) above: | ||
|
||
```tsx | ||
<ExpandableBlock.Wrapper> | ||
<ExpandableBlock.Trigger> | ||
<ExpandableBlock.ExpandIcon /> | ||
<ExpandableBlock.LabelArea> | ||
<ExpandableBlock.Title>Expandable Block</ExpandableBlock.Title> | ||
<ExpandableBlock.Caption>With caption!</ExpandableBlock.Caption> | ||
</ExpandableBlock.LabelArea> | ||
</ExpandableBlock.Trigger> | ||
<ExpandableBlock.Content>Content in block!</ExpandableBlock.Content> | ||
</ExpandableBlock.Wrapper> | ||
``` | ||
|
||
### With caption | ||
|
||
|
@@ -110,4 +142,27 @@ Use a [hierarchy tree](tree) when: | |
|
||
## Props | ||
|
||
### ExpandableBlock | ||
|
||
<PropsTable path='@itwin/itwinui-react/esm/core/ExpandableBlock/ExpandableBlock.d.ts' /> | ||
|
||
### ExpandableBlock.Wrapper | ||
|
||
<PropsTable | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just wondering, is there a reason you're not showing the props of other ExpandableBlock subcomponents? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added the link to the related discussion for this PR in the description. The comments mainly were about these particular subcomponents. However, if it would make sense to do this for all subcomponents, the relevant changes can be made. |
||
componentName='ExpandableBlockWrapper' | ||
path='@itwin/itwinui-react/esm/core/ExpandableBlock/ExpandableBlock.d.ts' | ||
/> | ||
|
||
### ExpandableBlock.Trigger | ||
|
||
<PropsTable | ||
componentName='ExpandableBlockTrigger' | ||
path='@itwin/itwinui-react/esm/core/ExpandableBlock/ExpandableBlock.d.ts' | ||
/> | ||
|
||
### ExpandableBlock.Content | ||
|
||
<PropsTable | ||
componentName='ExpandableBlockContent' | ||
path='@itwin/itwinui-react/esm/core/ExpandableBlock/ExpandableBlock.d.ts' | ||
/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As suggested in #2460 (comment), I have added to the usage section to describe the legacy and composition API. Please let me know if this should be adjusted or changed.