-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature was in the original designs.
- Loading branch information
Showing
5 changed files
with
86 additions
and
9 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
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
34 changes: 34 additions & 0 deletions
34
packages/react-component-library/src/components/Dropdown/DropdownPlaceholder.tsx
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,34 @@ | ||
import React from 'react' | ||
import { components } from 'react-select' | ||
import styled from 'styled-components' | ||
import { selectors } from '@royalnavy/design-tokens' | ||
|
||
const { spacing } = selectors | ||
|
||
const StyledIcon = styled.span` | ||
position: relative; | ||
top: ${spacing('px')}; | ||
` | ||
|
||
const StyledLabel = styled.span` | ||
${StyledIcon} + & { | ||
margin-left: ${spacing('3')}; | ||
} | ||
` | ||
|
||
export const DropdownPlaceholder: React.FC<any> = (props) => { | ||
const { | ||
selectProps: { labelIcon: icon }, | ||
} = props | ||
|
||
return ( | ||
<components.Placeholder {...props}> | ||
{icon && <StyledIcon data-testid="placeholder-icon">{icon}</StyledIcon>} | ||
<StyledLabel data-testid="placeholder-label"> | ||
{props.children} | ||
</StyledLabel> | ||
</components.Placeholder> | ||
) | ||
} | ||
|
||
DropdownPlaceholder.displayName = 'DropdownPlaceholder' |