Skip to content

Commit

Permalink
docs(architecture): update component structure
Browse files Browse the repository at this point in the history
  • Loading branch information
varl committed Jun 21, 2021
1 parent 2dec7d3 commit 5144ed1
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
22 changes: 22 additions & 0 deletions ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,28 @@ This means that:
> and may have breaking changes without us bumping the major version on
> `@dhis2/ui-*` components.
Each component package has a logical and semantic scope, that may group
related components.

If needed, components can be extracted to distinct component packages to
break e.g. circular dependencies or to provide a tighter scope.

If UI is fully decomposed, every single component would be its own
package, and this would not be a problem. We may end up there in the
future, but for now we are striking a pragmatic balance between packages
and components.

To make extraction easier, each component package has a
`{component}/src/index.js` file that defines the exported components for that
package.

If a package contains multiple components, then each subcomponent should have a
`index.js` file that defines its module boundary. This makes it easier to
extract it in the future: {component}/src/{subcomponent}/index.js`.

Components should import from the `index.js` files and avoid reaching into
non-exported parts of a component.

#### Collections

In UI terms a collection is a set of components, and is considered the
Expand Down
4 changes: 1 addition & 3 deletions components/modal/src/modal/modal.stories.e2e.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { Button, ButtonStrip } from '@dhis2-ui/button'
import { storiesOf } from '@storybook/react'
import React, { useState } from 'react'
import { ModalActions } from '../index.js'
import { ModalContent } from '../index.js'
import { ModalTitle } from '../index.js'
import { ModalActions, ModalContent, ModalTitle } from '../index.js'
import { Modal } from './modal.js'

window.onClose = window.Cypress && window.Cypress.cy.stub()
Expand Down
4 changes: 1 addition & 3 deletions components/modal/src/modal/modal.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ import { Button, ButtonStrip } from '@dhis2-ui/button'
import { SingleSelect, SingleSelectOption } from '@dhis2-ui/select'
import { sharedPropTypes } from '@dhis2/ui-constants'
import React, { useState } from 'react'
import { ModalActions } from '../index.js'
import { ModalContent } from '../index.js'
import { ModalTitle } from '../index.js'
import { ModalActions, ModalContent, ModalTitle } from '../index.js'
import { Modal } from './modal.js'

const description = `
Expand Down

0 comments on commit 5144ed1

Please sign in to comment.