Skip to content
This repository has been archived by the owner on Apr 20, 2023. It is now read-only.

Commit

Permalink
Add help tips to labels to explain what their icon means [#85]
Browse files Browse the repository at this point in the history
  • Loading branch information
nataliemt committed Feb 23, 2021
1 parent d8250f7 commit f35ff4f
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 4 deletions.
7 changes: 4 additions & 3 deletions src/js/components/PropertyPicker.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const React = require('react');
const classNames = require('classnames');
const DateTimeFormatPicker = require('./DateTimeFormatPicker.react.js');
const SelectorPicker = require('./SelectorPicker.react.js');
const LabelIcon = require('./common/LabelIcon.react.js');
import type { RuleProperty } from '../models/RuleProperty';
import RulePropertyTypes from '../models/RulePropertyTypes';
import RuleActions from '../data/RuleActions';
Expand Down Expand Up @@ -124,11 +125,11 @@ class PropertyPicker extends React.Component<Props> {
>
<label>
{RulePropertyUtils.isValid(this.props.property) ? (
<span></span>
<LabelIcon valid />
) : this.props.property.definition.required ? (
<span></span>
<LabelIcon required />
) : (
<span></span>
<LabelIcon />
)}{' '}
{this.props.property.definition.displayName}
</label>
Expand Down
3 changes: 2 additions & 1 deletion src/js/components/RulePicker.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
const React = require('react');
const PropertyPicker = require('./PropertyPicker.react.js');
const SelectorPicker = require('./SelectorPicker.react');
const LabelIcon = require('./common/LabelIcon.react.js');
const classNames = require('classnames');
const RuleActions = require('../data/RuleActions');

Expand Down Expand Up @@ -88,7 +89,7 @@ class RulePicker extends React.Component<Props, State> {
})}
>
<label>
{this.props.rule.selector != '' ? <span></span> : <span></span>}{' '}
{this.props.rule.selector != '' ? <LabelIcon valid /> : <LabelIcon required />}{' '}
Selector
</label>
<SelectorPicker {...this.props} field={this.props.rule} />
Expand Down
29 changes: 29 additions & 0 deletions src/js/components/common/LabelIcon.react.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/**
* Copyright 2017-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/

import React from 'react';

const LabelIcon = ({ required, valid }) => {
let icon = '•';
let tooltip = 'Field is optional';
if (required) {
icon = '✘';
tooltip = 'Field is required';
}
if (valid) {
icon = '✔';
tooltip = 'Field is valid';
}
return (
<span data-tooltip={tooltip} data-position="bottom left">{icon}</span>
);
}

module.exports = LabelIcon;

0 comments on commit f35ff4f

Please sign in to comment.