-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(PhoneInput): add tkv3 phone input
Completes #111
- Loading branch information
1 parent
89685b1
commit 584be3a
Showing
3 changed files
with
77 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { Story, Meta } from '@storybook/react'; | ||
|
||
import { classlessSelector, classySelector, PhoneInput } from './PhoneInput'; | ||
|
||
const contentVariants = [ | ||
{}, | ||
{ 'data-disabled': true }, | ||
{ 'data-stretch': true }, | ||
{ 'data-error': true } | ||
]; | ||
|
||
export default { | ||
title: 'TableKit/PhoneInput', | ||
component: PhoneInput, | ||
parameters: { | ||
variants: contentVariants, | ||
classlessSelector, | ||
classySelector | ||
} | ||
} as Meta; | ||
|
||
export const Variants: Story = () => ( | ||
<> | ||
{contentVariants.map((props) => ( | ||
<PhoneInput {...props} /> | ||
))} | ||
</> | ||
); |
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,47 @@ | ||
import { Close } from '@carbon/icons-react'; | ||
import { css} from '@emotion/react'; | ||
import styled from '@emotion/styled'; | ||
import * as React from 'react'; | ||
|
||
import { Input, InputWithIcons } from './Input'; | ||
|
||
export const classlessSelector = 'input[type="tel"]'; | ||
export const classySelector = '.phone-input'; | ||
|
||
export const baseStyles = css``; | ||
|
||
// export const Flag = styled.span<{ country: string }>` | ||
// display: inline-block; | ||
// width: 20px; | ||
// height: 15px; | ||
// box-shadow: 0px 0px 1px 0px #888; | ||
// background-image: url(${getSrcPath(flagImage)}); | ||
// background-repeat: no-repeat; | ||
|
||
// ${getStyle}; | ||
|
||
// @media only screen and (-webkit-min-device-pixel-ratio: 2), | ||
// only screen and (min--moz-device-pixel-ratio: 2), | ||
// only screen and (-o-min-device-pixel-ratio: 2 / 1), | ||
// only screen and (min-device-pixel-ratio: 2), | ||
// only screen and (min-resolution: 192dpi), | ||
// only screen and (min-resolution: 2dppx) { | ||
// background-image: url(${getSrcPath(flagImage2x)}); | ||
// background-size: 5630px 15px; | ||
// } | ||
// `; | ||
|
||
export interface Props { | ||
displayFlag?: boolean; | ||
} | ||
|
||
export const PhoneInput = React.forwardRef< | ||
HTMLDivElement, | ||
Omit<React.HTMLAttributes<HTMLDivElement>, 'children'> & Props | ||
>(({displayFlag, ...props}, ref) => ( | ||
<InputWithIcons {...props} ref={ref}> | ||
{displayFlag && } | ||
<Input placeholder="09000789" type="tel" /> | ||
<Close size={16} /> | ||
</InputWithIcons> | ||
)); |
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