This repository has been archived by the owner on Apr 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add help tips to labels to explain what their icon means [#85]
- Loading branch information
Showing
6 changed files
with
120 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/** | ||
* 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'; | ||
|
||
export type BaseProps = { | ||
children: string, | ||
position?: string, | ||
}; | ||
|
||
type Props = BaseProps & { | ||
icon?: string, | ||
tooltip?: string, | ||
}; | ||
|
||
const LabelIcon = ({ | ||
children, | ||
icon, | ||
tooltip, | ||
position = 'bottom left', | ||
}: Props) => ( | ||
<label> | ||
<span data-tooltip={tooltip} data-position={position}> | ||
{icon} | ||
</span> | ||
{` ${children}`} | ||
</label> | ||
); | ||
|
||
module.exports = LabelIcon; |
21 changes: 21 additions & 0 deletions
21
src/js/components/common/LabelIcon/LabelIconOptional.react.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/** | ||
* 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 = require('./LabelIcon.react.js'); | ||
import type { BaseProps as Props } from './LabelIcon.react.js'; | ||
|
||
const LabelIconOptional = ({ children, position }: Props) => ( | ||
<LabelIcon icon="•" tooltip="Field is optional" position={position}> | ||
{children} | ||
</LabelIcon> | ||
); | ||
|
||
module.exports = LabelIconOptional; |
21 changes: 21 additions & 0 deletions
21
src/js/components/common/LabelIcon/LabelIconRequired.react.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/** | ||
* 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 = require('./LabelIcon.react.js'); | ||
import type { BaseProps as Props } from './LabelIcon.react.js'; | ||
|
||
const LabelIconRequired = ({ children, position }: Props) => ( | ||
<LabelIcon icon="✘" tooltip="Field is required" position={position}> | ||
{children} | ||
</LabelIcon> | ||
); | ||
|
||
module.exports = LabelIconRequired; |
21 changes: 21 additions & 0 deletions
21
src/js/components/common/LabelIcon/LabelIconValid.react.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/** | ||
* 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 = require('./LabelIcon.react.js'); | ||
import type { BaseProps as Props } from './LabelIcon.react.js'; | ||
|
||
const LabelIconValid = ({ children, position }: Props) => ( | ||
<LabelIcon icon="✔" tooltip="Field is valid" position={position}> | ||
{children} | ||
</LabelIcon> | ||
); | ||
|
||
module.exports = LabelIconValid; |