@dhis2-ui/help 10.16.2 → 10.16.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhis2-ui/help",
3
- "version": "10.16.2",
3
+ "version": "10.16.3",
4
4
  "description": "UI Help",
5
5
  "repository": {
6
6
  "type": "git",
@@ -33,13 +33,14 @@
33
33
  },
34
34
  "dependencies": {
35
35
  "@dhis2/prop-types": "^3.1.2",
36
- "@dhis2/ui-constants": "10.16.2",
36
+ "@dhis2/ui-constants": "10.16.3",
37
37
  "classnames": "^2.3.1",
38
38
  "prop-types": "^15.7.2"
39
39
  },
40
40
  "files": [
41
41
  "build",
42
- "types"
42
+ "types",
43
+ "src"
43
44
  ],
44
45
  "devDependencies": {
45
46
  "react": "^18.3.1",
@@ -0,0 +1,10 @@
1
+ import { Given, Then } from '@badeball/cypress-cucumber-preprocessor'
2
+
3
+ Given('a Help component with children is rendered', () => {
4
+ cy.visitStory('Help', 'With children')
5
+ cy.get('[data-test="dhis2-uicore-help"]').should('be.visible')
6
+ })
7
+
8
+ Then('the children are visible', () => {
9
+ cy.contains('I am a child').should('be.visible')
10
+ })
@@ -0,0 +1,5 @@
1
+ Feature: The Help component renders children
2
+
3
+ Scenario: A Help component with children
4
+ Given a Help component with children is rendered
5
+ Then the children are visible
@@ -0,0 +1,5 @@
1
+ import React from 'react'
2
+ import { Help } from './help.js'
3
+
4
+ export default { title: 'Help' }
5
+ export const WithChildren = () => <Help>I am a child</Help>
package/src/help.js ADDED
@@ -0,0 +1,59 @@
1
+ import { spacers, theme, colors, sharedPropTypes } from '@dhis2/ui-constants'
2
+ import cx from 'classnames'
3
+ import PropTypes from 'prop-types'
4
+ import React from 'react'
5
+
6
+ const Help = ({
7
+ children,
8
+ valid,
9
+ error,
10
+ warning,
11
+ className,
12
+ dataTest = 'dhis2-uicore-help',
13
+ }) => (
14
+ <p
15
+ className={cx(className, {
16
+ valid,
17
+ error,
18
+ warning,
19
+ })}
20
+ data-test={dataTest}
21
+ >
22
+ {children}
23
+
24
+ <style jsx>{`
25
+ p {
26
+ margin-top: ${spacers.dp4};
27
+ margin-right: 0;
28
+ margin-bottom: 0;
29
+ margin-left: 0;
30
+ font-size: 12px;
31
+ line-height: 14px;
32
+ color: ${theme.default};
33
+ }
34
+
35
+ .valid {
36
+ color: ${colors.blue700};
37
+ }
38
+
39
+ .error {
40
+ color: ${theme.error};
41
+ }
42
+
43
+ .warning {
44
+ color: ${colors.yellow800};
45
+ }
46
+ `}</style>
47
+ </p>
48
+ )
49
+
50
+ Help.propTypes = {
51
+ children: PropTypes.string,
52
+ className: PropTypes.string,
53
+ dataTest: PropTypes.string,
54
+ error: sharedPropTypes.statusPropType,
55
+ valid: sharedPropTypes.statusPropType,
56
+ warning: sharedPropTypes.statusPropType,
57
+ }
58
+
59
+ export { Help }
@@ -0,0 +1,45 @@
1
+ import { sharedPropTypes } from '@dhis2/ui-constants'
2
+ import React from 'react'
3
+ import { Help } from './help.js'
4
+
5
+ const description = `
6
+ Small text for giving guiding information or feedback, especially for data entry instructions or form validation feedback.
7
+
8
+ \`\`\`js
9
+ import { Help } from '@dhis2/ui'
10
+ \`\`\`
11
+ `
12
+
13
+ export default {
14
+ title: 'Help',
15
+ component: Help,
16
+ parameters: { docs: { description: { component: description } } },
17
+ argTypes: {
18
+ valid: { ...sharedPropTypes.statusArgType },
19
+ warning: { ...sharedPropTypes.statusArgType },
20
+ error: { ...sharedPropTypes.statusArgType },
21
+ },
22
+ args: { children: 'Allow me to be of assistance' },
23
+ }
24
+
25
+ const Template = (args) => <Help {...args} />
26
+
27
+ export const Default = Template.bind({})
28
+
29
+ export const StatusWarning = Template.bind({})
30
+ StatusWarning.args = { warning: true }
31
+ StatusWarning.storyName = 'Status: Warning'
32
+
33
+ export const StatusValid = Template.bind({})
34
+ StatusValid.args = { valid: true }
35
+ StatusValid.storyName = 'Status: Valid'
36
+
37
+ export const StatusError = Template.bind({})
38
+ StatusError.args = { error: true }
39
+ StatusError.storyName = 'Status: Error'
40
+
41
+ export const TextOverflow = (args) => (
42
+ <div style={{ width: 200 }}>
43
+ <Help {...args}>I take up more space than my container</Help>
44
+ </div>
45
+ )
package/src/index.js ADDED
@@ -0,0 +1 @@
1
+ export { Help } from './help.js'