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

Commit

Permalink
Merge pull request #184 from strapi/fix/input-icon
Browse files Browse the repository at this point in the history
Add title to labelIcon
  • Loading branch information
soupette authored Mar 4, 2021
2 parents 25becb0 + 2012a45 commit f02ba84
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
17 changes: 12 additions & 5 deletions docs/stories/customComponents/Inputs.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ const form = {
styleName: 'col-6',
description: 'You should enter your name',
label: 'Name',
labelIcon: <GlobeCrossed />,
labelIcon: {
title: 'Not localized',
icon: <GlobeCrossed />,
},
placeholder: 'Paul Bocuse',
type: 'text',
validations: {
Expand All @@ -35,7 +38,10 @@ const form = {
styleName: 'col-6',
label: 'Time',
description: 'Select a slot',
labelIcon: <Globe />,
labelIcon: {
title: 'Localized',
icon: <Globe />,
},
type: 'time',
validations: {
required: true,
Expand Down Expand Up @@ -213,9 +219,10 @@ const form = {
label: 'First Name',
placeholder: 'Viky',
type: 'text',
labelIcon: (
<Globe />
),
labelIcon: {
icon: <Globe />,
title: 'Localized',
},
validations: {
required: true,
uppercase: true,
Expand Down
1 change: 1 addition & 0 deletions packages/buffetjs-custom/src/components/Inputs/Wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const Wrapper = styled.div`

const IconWrapper = styled.span`
margin-left: 5px;
cursor: pointer;
`;

export default Wrapper;
Expand Down
8 changes: 6 additions & 2 deletions packages/buffetjs-custom/src/components/Inputs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,11 @@ function Inputs({
{label}
{isEmpty(label) && <>&nbsp;</>}
</span>
{rest.labelIcon && <IconWrapper>{rest.labelIcon}</IconWrapper>}
{rest.labelIcon && (
<IconWrapper title={rest.labelIcon.title}>
{rest.labelIcon.icon}
</IconWrapper>
)}
</Label>
)}
<InputComponent
Expand Down Expand Up @@ -191,7 +195,7 @@ Inputs.propTypes = {
error: PropTypes.string,
id: PropTypes.string,
label: PropTypes.string,
labelIcon: PropTypes.any,
labelIcon: PropTypes.shape({ icon: PropTypes.any, title: PropTypes.string }),
name: PropTypes.string.isRequired,
onBlur: PropTypes.func,
onChange: () => {},
Expand Down

0 comments on commit f02ba84

Please sign in to comment.