Skip to content

Commit

Permalink
feat(PhoneInput): add tkv3 phone input
Browse files Browse the repository at this point in the history
Completes #111
  • Loading branch information
wahidfarid committed Nov 1, 2022
1 parent 89685b1 commit 25ab57a
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 0 deletions.
28 changes: 28 additions & 0 deletions system/react/src/components/PhoneInput.stories.tsx
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} />
))}
</>
);
24 changes: 24 additions & 0 deletions system/react/src/components/PhoneInput.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { Close } from '@carbon/icons-react';
import { css } from '@emotion/react';
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 interface Props {
// phone specific props
}

export const PhoneInput = React.forwardRef<
HTMLDivElement,
Omit<React.HTMLAttributes<HTMLDivElement>, 'children'> & Props
>((props, ref) => (
<InputWithIcons {...props} ref={ref}>
<Input placeholder="09000789" type="tel" />
<Close size={16} />
</InputWithIcons>
));
2 changes: 2 additions & 0 deletions system/react/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ export {
baseStylesObject as menuListStylesObject,
MenuList
} from './components/MenuList';
export { PhoneInput } from './components/PhoneInput';
export type { Props as PhoneInputProps } from './components/PhoneInput';
export { Radio } from './components/Radio';
export { ScrollShadow } from './components/ScrollShadow';
export { globalThemeVars, Select } from './components/Select';
Expand Down

0 comments on commit 25ab57a

Please sign in to comment.