-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
389983d
commit 920477b
Showing
3 changed files
with
72 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Documentation generation | ||
You are an expert React documentation writer. You will be given a react component file. Your job is to generate documentation for the component. The documentation should be in markdown format. | ||
|
||
## Format | ||
1. The documentation should be in markdown format. | ||
2. The documentation should be generated from the component file. | ||
3. When importing a component, use `@dhis2/analytics` as the path. | ||
|
||
## Suggested headers | ||
1. Component name | ||
2. Props | ||
3. Usage |
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,31 @@ | ||
# Filter Component | ||
|
||
The Filter component is a reusable input field component from the DHIS2 UI library. It is used to filter data based on the user's input. | ||
|
||
## Props | ||
|
||
- `text`: The current value of the input field. It is a string. | ||
- `onChange`: A function that is called when the value of the input field changes. It is required. | ||
- `onClear`: A function that is called when the input field is cleared. It is required. | ||
- `placeholder`: The placeholder text for the input field. It is a required string. | ||
- `type`: The type of the input field. It defaults to 'text'. | ||
- `dataTest`: A string used for testing purposes. | ||
|
||
## Usage | ||
Here is an example of how to use the Filter component: | ||
|
||
```jsx | ||
import { Filter } from '@dhis2/analytics' | ||
|
||
<Filter | ||
text="Search text" | ||
onChange={(value) => console.log(`New value: ${value}`)} | ||
onClear={() => console.log('Input cleared')} | ||
placeholder="Search..." | ||
type="text" | ||
dataTest="dhis2-uicore-filter" | ||
/> | ||
``` | ||
|
||
In this example, the `Filter` component is imported from the `@dhis2/analytics` package. The `text` prop is set to "Search text", the `onChange` prop is set to a function that returns 'True' if the value is truthy and 'False' otherwise, the `onClear` prop is set to a function that logs a message when the input is cleared, the `placeholder` prop is set to "Search...", the `type` prop is set to "text", and the `dataTest` prop is set to "dhis2-uicore-filter". | ||
|
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,29 @@ | ||
# OrgUnitDimension Component | ||
|
||
The OrgUnitDimension component is a part of the DHIS2 analytics package. It is used to select organisation units, levels, and groups. | ||
|
||
## Props | ||
|
||
- `roots`: An array of strings representing the roots of the organisation units. | ||
- `selected`: An array of objects representing the selected organisation units. Each object should have an `id` and `name` property, and may optionally have a `path` property. | ||
- `onSelect`: A function that is called when an organisation unit is selected. | ||
- `hideGroupSelect`: A boolean that determines whether the group select should be hidden. Defaults to `false`. | ||
- `hideLevelSelect`: A boolean that determines whether the level select should be hidden. Defaults to `false`. | ||
- `hideUserOrgUnits`: A boolean that determines whether the user organisation units should be hidden. Defaults to `false`. | ||
- `warning`: A string that represents a warning message. | ||
|
||
## Usage | ||
```javascript | ||
import { OrgUnitDimension } from '@dhis2/analytics' | ||
|
||
<OrgUnitDimension | ||
roots={['A0000001234']} | ||
selected={[{ id: 'B0000001234', name: 'Unit B' }]} | ||
onSelect={(selected) => console.log('Selected:', selected)} | ||
hideGroupSelect={false} | ||
hideLevelSelect={false} | ||
hideUserOrgUnits={false} | ||
warning="This is a warning message" | ||
/> | ||
``` | ||
|