Skip to content

Commit

Permalink
standards tooltip added onedrive shortcut standard
Browse files Browse the repository at this point in the history
  • Loading branch information
redanthrax committed Jul 25, 2023
1 parent 6dccfc7 commit 281767c
Show file tree
Hide file tree
Showing 4 changed files with 124 additions and 71 deletions.
42 changes: 29 additions & 13 deletions src/components/forms/RFFComponents.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
CFormSwitch,
CFormTextarea,
CSpinner,
CTooltip,
} from '@coreui/react'
import Select from 'react-select'
import AsyncSelect from 'react-select/async'
Expand Down Expand Up @@ -75,9 +76,14 @@ RFFCFormCheck.propTypes = {
...sharedPropTypes,
}

function ConditionWrapper({ condition, wrapper, children }) {
return condition ? wrapper(children) : children
}

export const RFFCFormSwitch = ({
name,
label,
helpText,
sublabel,
className = 'mb-3',
validate,
Expand All @@ -86,26 +92,36 @@ export const RFFCFormSwitch = ({
return (
<Field name={name} type="checkbox" validate={validate}>
{({ meta, input }) => (
<div className={className}>
<CFormSwitch
{...input}
// @todo revisit this, only shows green when checked
valid={!meta.error && meta.touched && validate}
invalid={meta.error && meta.touched && validate}
disabled={disabled}
id={name}
label={label}
/>
{input.value && <RFFCFormFeedback meta={meta} />}
<sub>{sublabel}</sub>
</div>
<ConditionWrapper
condition={helpText}
wrapper={(children) => (
<CTooltip placement="left" content={helpText}>
{children}
</CTooltip>
)}
>
<div className={className}>
<CFormSwitch
{...input}
// @todo revisit this, only shows green when checked
valid={!meta.error && meta.touched && validate}
invalid={meta.error && meta.touched && validate}
disabled={disabled}
id={name}
label={label}
/>
{input.value && <RFFCFormFeedback meta={meta} />}
<sub>{sublabel}</sub>
</div>
</ConditionWrapper>
)}
</Field>
)
}

RFFCFormSwitch.propTypes = {
...sharedPropTypes,
helpText: PropTypes.string,
}

export const RFFCFormInput = ({
Expand Down
Loading

0 comments on commit 281767c

Please sign in to comment.