Skip to content

Commit 1f0d42e

Browse files
authored
Merge pull request KelvinTegelaar#29 from KelvinTegelaar/dev
[pull] dev from KelvinTegelaar:dev
2 parents df9dbfb + 45ef541 commit 1f0d42e

File tree

7 files changed

+159
-82
lines changed

7 files changed

+159
-82
lines changed

.vscode/launch.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"cwd": "${file}"
1010
},
1111
{
12-
"command": "npm run start-api",
12+
"command": "npm run start-swa",
1313
"name": "Run emulator",
1414
"request": "launch",
1515
"type": "node-terminal"

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717
"changelog": "auto-changelog --starting-version 3.0.0 --commit-limit false --hide-credit",
1818
"eject": "react-scripts eject",
1919
"lint": "eslint \"src/**/*.js\"",
20-
"start": "react-scripts start",
20+
"start": "set HTTPS=true&&set SSL_CRT_FILE=./.vscode/cert.crt&&set SSL_KEY_FILE=./.vscode/key.key&&react-scripts start",
2121
"test": "react-scripts test",
2222
"test:cov": "npm test -- --coverage --watchAll=false",
2323
"test:debug": "react-scripts --inspect-brk test --runInBand",
24-
"start-api": "swa start --ssl --ssl-cert ./.vscode/cert.crt --ssl-key ./.vscode/key.key --swa-config-location .vscode http://localhost:3000 --api-location http://localhost:7071",
24+
"start-swa": "swa start --ssl --ssl-cert ./.vscode/cert.crt --ssl-key ./.vscode/key.key --swa-config-location .vscode https://localhost:3000 --api-location http://localhost:7071",
2525
"prepare": "husky install"
2626
},
2727
"config": {
@@ -98,7 +98,7 @@
9898
"stylelint-order": "^5.0.0"
9999
},
100100
"engines": {
101-
"node": "16",
101+
"node": "18",
102102
"npm": ">=7"
103103
}
104104
}

src/components/forms/RFFComponents.js

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
CFormSwitch,
88
CFormTextarea,
99
CSpinner,
10+
CTooltip,
1011
} from '@coreui/react'
1112
import Select from 'react-select'
1213
import AsyncSelect from 'react-select/async'
@@ -75,9 +76,14 @@ RFFCFormCheck.propTypes = {
7576
...sharedPropTypes,
7677
}
7778

79+
function ConditionWrapper({ condition, wrapper, children }) {
80+
return condition ? wrapper(children) : children
81+
}
82+
7883
export const RFFCFormSwitch = ({
7984
name,
8085
label,
86+
helpText,
8187
sublabel,
8288
className = 'mb-3',
8389
validate,
@@ -86,26 +92,36 @@ export const RFFCFormSwitch = ({
8692
return (
8793
<Field name={name} type="checkbox" validate={validate}>
8894
{({ meta, input }) => (
89-
<div className={className}>
90-
<CFormSwitch
91-
{...input}
92-
// @todo revisit this, only shows green when checked
93-
valid={!meta.error && meta.touched && validate}
94-
invalid={meta.error && meta.touched && validate}
95-
disabled={disabled}
96-
id={name}
97-
label={label}
98-
/>
99-
{input.value && <RFFCFormFeedback meta={meta} />}
100-
<sub>{sublabel}</sub>
101-
</div>
95+
<ConditionWrapper
96+
condition={helpText}
97+
wrapper={(children) => (
98+
<CTooltip placement="left" content={helpText}>
99+
{children}
100+
</CTooltip>
101+
)}
102+
>
103+
<div className={className}>
104+
<CFormSwitch
105+
{...input}
106+
// @todo revisit this, only shows green when checked
107+
valid={!meta.error && meta.touched && validate}
108+
invalid={meta.error && meta.touched && validate}
109+
disabled={disabled}
110+
id={name}
111+
label={label}
112+
/>
113+
{input.value && <RFFCFormFeedback meta={meta} />}
114+
<sub>{sublabel}</sub>
115+
</div>
116+
</ConditionWrapper>
102117
)}
103118
</Field>
104119
)
105120
}
106121

107122
RFFCFormSwitch.propTypes = {
108123
...sharedPropTypes,
124+
helpText: PropTypes.string,
109125
}
110126

111127
export const RFFCFormInput = ({

0 commit comments

Comments
 (0)