From 920477b4d180d28f94aa0c850e69418b3bc133b3 Mon Sep 17 00:00:00 2001 From: eirikhaugstulen Date: Tue, 24 Oct 2023 13:48:34 +0200 Subject: [PATCH] feat: initial commit --- Prompts/generate-documentation.md | 12 ++++++++++++ docs/Filter.md | 31 +++++++++++++++++++++++++++++++ docs/OrgUnitDimension.md | 29 +++++++++++++++++++++++++++++ 3 files changed, 72 insertions(+) create mode 100644 Prompts/generate-documentation.md create mode 100644 docs/Filter.md create mode 100644 docs/OrgUnitDimension.md diff --git a/Prompts/generate-documentation.md b/Prompts/generate-documentation.md new file mode 100644 index 000000000..7a9fe9d31 --- /dev/null +++ b/Prompts/generate-documentation.md @@ -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 diff --git a/docs/Filter.md b/docs/Filter.md new file mode 100644 index 000000000..6924aa413 --- /dev/null +++ b/docs/Filter.md @@ -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' + + 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". + diff --git a/docs/OrgUnitDimension.md b/docs/OrgUnitDimension.md new file mode 100644 index 000000000..4e657db12 --- /dev/null +++ b/docs/OrgUnitDimension.md @@ -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' + + console.log('Selected:', selected)} + hideGroupSelect={false} + hideLevelSelect={false} + hideUserOrgUnits={false} + warning="This is a warning message" +/> +``` +