6.24.0 • Published 3 years ago

@dhis2/ui-core v6.24.0

Weekly downloads
2,143
License
BSD-3-Clause
Repository
github
Last release
3 years ago

ui-core

semantic-release

Online docs and demos (latest master build)

Requires polyfills

These are included with apps generated with Create React App, but if you want to use this library with the environments in .browserslistrc you need to polyfill the following:

  • web.dom.iterable
  • es6.array.fill
  • es6.array.iterator
  • es6.function.name
  • es6.object.assign
  • es6.object.keys
  • es6.object.set-prototype-of
  • es6.promise
  • es6.regexp.match
  • es6.regexp.split
  • es6.string.starts-with
  • es6.string.iterator
  • es6.symbol
  • es7.symbol.async-iterator

Review

Make a PR from the component branch. Add a team member who can review the code and example for both LTR and RTL modes.

Development

We use Storybook that is excellent for testing components while developing them.

yarn install
yarn start

The Storybook runs on localhost:5000.

Apply the code style

This library follows the dhis2 code-style. There is a commit hook that will apply the code style to staged files, but if you want to do this manually during development, run:

yarn format

Commit messages

This library follows the commit message style defined in @commitlint/config-conventional. There is a pre-commit hook that will stop commits that don't follow the convention.

Releasing

When a PR is merged to the master branch, the release process automatically starts.

It is very important that the commit that lands on master follows the conventional commit format, since that is what is used to automatically determine the next version.

Never push straight to master, always go through a PR!

Testing

Testing is done with cypress & cucumber.

  • Run yarn cypress:run This will run cypress and exit with either 0 or 1

  • Run yarn cypress:open This will open the cypress gui, which is useful for writing tests

Recording videos and taking screenshots

When running yarn cypress:run, by default no video is recorded and no screenshot will be taken.

  • Recording videos can be enabled by supplying the CYPRESS_VIDEO=true env var.
  • Taking screenshots can be enabled by supplying the CYPRESS_SCREENSHOT=true env var.

Storybook stories for testing

Sometimes it's required to add stateful stories to test certain behavior. That's why you can add files with the following file name format: *.stories.testing.js These stories will not be used when generating the docs storybook and can contain more sophisticated scenarios for testing.

FAQ

How to avoid a global style rule from affecting a ui-core component?

The best practice is that each component has styles that are scoped to that component to avoid style rules that leak out from one component and bleeds into another component.

Generally all the CSS-in-JS solutions grant this out of the box, and this is only a problem when using global stylesheets, e.g. by importing index.css in an application and adding global rules to it.

There are two ways to work around the problem.

Example CSS

Given the following CSS:

index.css:

div {
    padding: 20px;
}

.disabled {
    opacity: 0.5;    
}

These styles will bleed into all components that use div or .disabled and doesn't itself set those rules and win by specificity.

If a rule is not set by the component, the technique that overrides through the use of className still applies, it's just "softer" and does not require !important to counter the rules.

If the rules do something !important, the only course of action is to counter it with another !important rule. Given the following CSS:

index.css:

div {
    padding: 20px !important;
}

.disabled {
    opacity: 0.5 !important;    
}

Now there is no way for specificity to win, and all components that use those classes or elements will inherit those rules.

Cascading override

By using a cascading override, the style bleed can be stopped by utilizing a wrapper element for the component, and this will cascade down to the children of the component as well. The technique allows for a workaround which does not affect the component itself, and is easily removed when the App no longer uses leaky styles.

Before:

<div>
    {...}
    <Component disabled />
</div>

After:

<div>
    {...}
    <div className="fix-container">
        <Component disabled />
    </div>
</div>
.fix-container .disabled {
    /* will undo the overriding of global styles for this component */
    opacity: 1 !important;
}

Class name override

If you cannot control the CSS that bleeds into ui components, then you need to define a class that counters the effects of the rule, and use the className prop to override the global rule.

index.css:

.fix {
    opacity: 1 !important;
    padding: 10px !important;
}

Pass that to the component through className='fix', and it should negate the troublesome CSS. Once the global rules in the App has been removed, it is possible to remove the className='fix' as well. This should be considered a temporary measure.

6.25.3

3 years ago

6.25.2

3 years ago

6.25.1

3 years ago

6.25.0

3 years ago

6.24.2

3 years ago

6.24.0

3 years ago

6.24.1

3 years ago

6.23.5

3 years ago

6.23.3

3 years ago

6.23.4

3 years ago

6.23.0

3 years ago

6.23.1

3 years ago

6.23.2

3 years ago

6.22.0

3 years ago

6.22.1

3 years ago

6.21.0

3 years ago

6.20.0

3 years ago

6.20.0-alpha.2

3 years ago

6.20.0-alpha.1

3 years ago

6.20.0-alpha.3

3 years ago

6.19.1

3 years ago

6.19.0

3 years ago

6.18.1

3 years ago

6.19.0-alpha.1

3 years ago

6.18.0

3 years ago

6.17.0

3 years ago

6.16.0

3 years ago

6.15.2

3 years ago

6.15.1

3 years ago

6.15.0

3 years ago

6.14.0

3 years ago

6.13.0

3 years ago

6.12.0

3 years ago

6.11.0

3 years ago

6.10.6

3 years ago

6.10.5

3 years ago

6.10.4

3 years ago

6.10.3

3 years ago

6.10.2

3 years ago

6.10.1

3 years ago

6.10.0

3 years ago

6.10.0-alpha.5

3 years ago

6.10.0-alpha.4

3 years ago

6.9.2

3 years ago

6.9.1

3 years ago

6.10.0-alpha.3

3 years ago

6.10.0-alpha.2

3 years ago

6.10.0-alpha.1

3 years ago

6.8.1

3 years ago

6.8.0

3 years ago

6.9.0

3 years ago

6.8.0-alpha.1

3 years ago

6.6.3

3 years ago

6.6.2

3 years ago

6.7.0

3 years ago

6.6.1

3 years ago

6.6.0-alpha.1

3 years ago

6.6.0

3 years ago

6.5.0-alpha.3

3 years ago

6.5.6

3 years ago

6.5.7

3 years ago

6.5.4

3 years ago

6.5.5

3 years ago

6.5.3

3 years ago

6.5.2

3 years ago

6.5.1

3 years ago

6.5.0

3 years ago

6.5.0-alpha.2

3 years ago

6.5.0-alpha.1

3 years ago

6.3.0

3 years ago

6.4.1

3 years ago

6.4.0

3 years ago

6.2.3

3 years ago

6.2.2

3 years ago

6.2.1

3 years ago

6.2.0

3 years ago

6.1.7

3 years ago

6.1.6

3 years ago

6.1.5

3 years ago

6.1.4

3 years ago

6.1.3

3 years ago

6.1.2

3 years ago

6.1.1

3 years ago

6.1.0

3 years ago

6.0.2

3 years ago

6.0.1

3 years ago

6.0.0

3 years ago

5.7.8

3 years ago

5.7.7

3 years ago

5.7.6

3 years ago

5.7.5

3 years ago

5.7.4

3 years ago

5.7.3

4 years ago

5.7.2

4 years ago

5.7.1

4 years ago

5.7.0

4 years ago

5.6.2

4 years ago

5.6.1

4 years ago

5.5.11

4 years ago

5.6.0

4 years ago

5.5.10

4 years ago

5.5.9

4 years ago

5.5.8

4 years ago

5.5.7

4 years ago

5.5.6

4 years ago

5.5.5

4 years ago

5.5.4

4 years ago

5.5.3

4 years ago

5.5.2

4 years ago

5.5.1

4 years ago

5.5.0

4 years ago

5.4.2

4 years ago

5.4.1

4 years ago

5.4.0

4 years ago

5.3.3

4 years ago

5.3.2

4 years ago

5.3.1

4 years ago

5.3.0

4 years ago

5.2.0

4 years ago

5.1.3

4 years ago

5.1.2

4 years ago

5.1.1

4 years ago

5.1.0

4 years ago

5.0.7

4 years ago

5.0.6

4 years ago

5.0.5

4 years ago

5.0.4

4 years ago

5.0.3

4 years ago

5.0.2

4 years ago

5.0.1

4 years ago

5.0.0

4 years ago

5.0.0-alpha.20

4 years ago

5.0.0-alpha.21

4 years ago

5.0.0-alpha.19

4 years ago

5.0.0-alpha.18

4 years ago

5.0.0-alpha.17

4 years ago

5.0.0-alpha.16

4 years ago

4.21.1

4 years ago

4.21.0

4 years ago

5.0.0-alpha.15

4 years ago

4.20.0

4 years ago

5.0.0-alpha.13

4 years ago

5.0.0-alpha.14

4 years ago

5.0.0-alpha.12

4 years ago

4.19.1

4 years ago

5.0.0-alpha.11

4 years ago

4.19.0

4 years ago

5.0.0-alpha.9

4 years ago

5.0.0-alpha.10

4 years ago

5.0.0-alpha.8

4 years ago

5.0.0-alpha.7

4 years ago

4.18.0

4 years ago

5.0.0-alpha.6

4 years ago

5.0.0-alpha.5

4 years ago

4.17.1

4 years ago

4.17.0

4 years ago

5.0.0-alpha.4

4 years ago

5.0.0-alpha.3

4 years ago

4.16.0

4 years ago

5.0.0-alpha.2

4 years ago

4.15.0

4 years ago

5.0.0-alpha.1

4 years ago

4.14.0

4 years ago

4.13.0

4 years ago

4.12.0

4 years ago

4.11.1

4 years ago

4.10.0

4 years ago

4.11.0

4 years ago

4.9.1

4 years ago

4.9.0

4 years ago

4.8.0

4 years ago

4.7.2

4 years ago

4.7.1

4 years ago

4.7.0

4 years ago

4.6.1

4 years ago

4.6.0

4 years ago

4.5.0

4 years ago

4.4.1

4 years ago

4.4.0

4 years ago

4.3.1

4 years ago

4.3.0

4 years ago

4.2.0

4 years ago

4.1.3

4 years ago

4.1.2

4 years ago

4.1.1

4 years ago

4.1.0

4 years ago

4.0.3

4 years ago

4.0.2

4 years ago

4.0.1

4 years ago

4.0.0

4 years ago

4.0.0-beta.2

4 years ago

4.0.0-beta.1

4 years ago

3.12.0

5 years ago

3.11.2

5 years ago

3.11.1

5 years ago

3.11.0

5 years ago

3.10.0

5 years ago

3.9.1

5 years ago

3.9.0

5 years ago

3.8.0

5 years ago

3.7.3

5 years ago

3.7.2

5 years ago

3.7.1

5 years ago

3.7.0

5 years ago

3.6.3

5 years ago

3.6.2

5 years ago

3.6.1

5 years ago

3.6.0

5 years ago

3.5.0

5 years ago

3.4.0

5 years ago

3.3.0

5 years ago

3.2.1

5 years ago

3.2.0

5 years ago

3.1.1

5 years ago

3.1.0

5 years ago

3.0.0

5 years ago

2.5.2

5 years ago

2.5.1

5 years ago

2.5.0

5 years ago

2.4.4

5 years ago

2.4.3

5 years ago

2.4.2

5 years ago

2.4.1

5 years ago

2.4.0

5 years ago

2.3.0

5 years ago

2.2.3

5 years ago

2.2.2

5 years ago

2.2.1

5 years ago

2.2.0

5 years ago

2.1.2

5 years ago

2.1.1

5 years ago

2.1.0

5 years ago

2.0.2

5 years ago

2.0.1

5 years ago

2.0.0

5 years ago

1.1.3

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.0

5 years ago