Continuing from this Slack thread.
As O3 has developed, we have run into some use-cases that need reusable components that can be shared. So far, our solution has been to stick such components into the styleguide or other shared library. However, this doesn’t completely solve the issue for a few reasons:
- The styleguide components often don’t have access to the same configuration machinery extensions do, meaning that they need to take more of their configuration as props.
- It doesn’t give implementers really clear guidance about how to build re-usable components.
As a result of this, we have a proliferation of various ways of doing this from relatively complicated setup proposals to a proliferation of various “generic” components.
The goal of this proposal is to give us a way of providing shared components that:
- Doesn’t privilege esm-core over approaches easily implementable by code using the framework.
- Doesn’t require adding complexity to the configuration system or the rather simple needs that the configuration system is designed for (e.g., choosing a specific concept to use for a widget, etc.)
The heart of this proposal is to allow an app to define an “extension” using an export from a different app and perform some configuration of it via the extension’s meta
property. So, say I have two apps: @openmrs/esm-ward-app
and @digi-uw/esm-digi-app
and @openmrs/esm-ward-app
has an export called wardView
defined in it’s index.ts
that defines a “view” of a patient in the ward app. Then, in @digi-uw/esm-digi-app
, I can create a new extension in that app’s routes.json
that looks like this:
{
"name": "digi-default-ward-view",
"component": "@openmrs/esm-ward-app#wardView",
"meta": {
"elements": ["obs-text-admission-reason"]
}
},
{
"name": "obs-text-admission-reason",
"component": "@openmrs/esm-core-components#obsText",
"meta": {
"concept": "DIGI:Admission Reason"
}
}
So we have here two custom extensions added that expand on two existing exports, the wardView
export from @openmrs/esm-ward-app
and the obsText
export from the (purely speculative) @openmrs/esm-core-components
, with the Ward View configured to display the customized obsText
element.
@dkigen @chibongho1 @samuel34 @mseaton @mogoodrich @vasharma05