-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
establishing using of children property in reusable components. connected to #125
- Loading branch information
1 parent
8fe3a8d
commit 721b3ee
Showing
5 changed files
with
56 additions
and
12 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
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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
UI component library | ||
==================== | ||
|
||
To ensure a consistent look and feel across the application, developers should reuse standard components, and avoid applying specific styling on pages. | ||
|
||
# Implementing components | ||
|
||
An example of a reusable component is the [Modal](../../instances/treasury-devdao.near/widget/lib/modal.jsx). | ||
|
||
To implement a reusable component, we can create a function that takes `children` as a parameter. Here's an example: | ||
|
||
```jsx | ||
const ModalFooter = ({ children }) => | ||
<div className="modalfooter d-flex gap-2 align-items-center justify-content-end mt-2"> | ||
{children} | ||
</div> | ||
; | ||
``` | ||
|
||
We can then use it in another widget like this: | ||
|
||
```jsx | ||
const { Modal, ModalBackdrop, ModalContent, ModalDialog, ModalHeader, ModalFooter } = | ||
VM.require("${REPL_BASE_DEPLOYMENT_ACCOUNT}/widget/lib.modal"); | ||
|
||
return <ModalFooter> | ||
<button>Dismiss</button> | ||
</ModalFooter> | ||
; | ||
``` | ||
|
||
This way, we can have custom jsx inside the resuable component. The styles and classes of the reusable component will be applied to the custom jsx content. |
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
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
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