Skip to content

Commit

Permalink
feat(TextInput): Replace deprecated implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
m7kvqbe1 committed Feb 21, 2022
1 parent 67897e4 commit 2592488
Show file tree
Hide file tree
Showing 43 changed files with 252 additions and 859 deletions.
4 changes: 2 additions & 2 deletions packages/react-component-library/cypress/selectors/form.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export default {
input: {
email: '[data-testid="form-example-TextInputE-email"]',
password: '[data-testid="form-example-TextInputE-password"]',
email: '[data-testid="form-example-TextInput-email"]',
password: '[data-testid="form-example-TextInput-password"]',
description: '[data-testid="form-example-TextArea-description"]',
checkbox: '[data-testid="checkbox"]',
radio: '[data-testid="radio"]',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import styled from 'styled-components'
import { selectors } from '@defencedigital/design-tokens'

import { COMPONENT_SIZE } from '../../Forms'
import { TEXT_INPUT_INPUT_HEIGHT } from '../../TextInputE/partials/StyledInput'
import { TEXT_INPUT_INPUT_HEIGHT } from '../../TextInput/partials/StyledInput'

const { color, fontSize } = selectors

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ import { hasClass } from '../../helpers'
import { InlineButton } from '../InlineButtons/InlineButton'
import { InputValidationProps } from '../../common/InputValidationProps'
import { isDateValid } from './utils'
import { StyledLabel } from '../TextInputE/partials/StyledLabel'
import { StyledLabel } from '../TextInput/partials/StyledLabel'
import { StyledDatePickerInput } from './partials/StyledDatePickerInput'
import { StyledDayPicker } from './partials/StyledDayPicker'
import { StyledFloatingBox } from './partials/StyledFloatingBox'
import { StyledInlineButtons } from '../InlineButtons/partials/StyledInlineButtons'
import { StyledInput } from '../TextInputE/partials/StyledInput'
import { StyledInput } from '../TextInput/partials/StyledInput'
import { StyledInputWrapper } from './partials/StyledInputWrapper'
import { StyledOuterWrapper } from './partials/StyledOuterWrapper'
import { useExternalId } from '../../hooks/useExternalId'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import styled, { css } from 'styled-components'

import { StyledInput } from '../../TextInputE/partials/StyledInput'
import { StyledInput } from '../../TextInput/partials/StyledInput'

interface StyledDatePickerInputProps {
$isDisabled?: boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react'
import { ComponentStory, ComponentMeta } from '@storybook/react'

import { Field } from './index'
import { TextInputE } from '../TextInputE'
import { TextInput } from '../TextInput'

export default {
component: Field,
Expand All @@ -12,7 +12,7 @@ export default {

const Template: ComponentStory<typeof Field> = (args) => (
<Field {...args}>
<TextInputE label="Example text input" name="example" />
<TextInput label="Example text input" name="example" />
</Field>
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import '@testing-library/jest-dom/extend-expect'
import { render, RenderResult } from '@testing-library/react'

import { Field } from '.'
import { TextInputE } from '../TextInputE'
import { TextInput } from '../TextInput'

describe('Field', () => {
let wrapper: RenderResult
Expand All @@ -12,7 +12,7 @@ describe('Field', () => {
beforeEach(() => {
wrapper = render(
<Field hintText="Example hint text." errors={[{ error: 'Required' }]}>
<TextInputE
<TextInput
label="Example text input"
name="example"
data-testid="example-component"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ComponentStory, ComponentMeta } from '@storybook/react'

import { Fieldset } from './index'
import { Field } from '../Field'
import { TextInputE } from '../TextInputE'
import { TextInput } from '../TextInput'

export default {
component: Fieldset,
Expand All @@ -14,13 +14,13 @@ export default {
const Template: ComponentStory<typeof Fieldset> = (args) => (
<Fieldset {...args}>
<Field>
<TextInputE label="Address line 1" name="address1" />
<TextInput label="Address line 1" name="address1" />
</Field>
<Field>
<TextInputE label="Address line 2" name="address2" />
<TextInput label="Address line 2" name="address2" />
</Field>
<Field>
<TextInputE label="City" name="city" />
<TextInput label="City" name="city" />
</Field>
</Fieldset>
)
Expand All @@ -34,24 +34,24 @@ const TemplateHorizontal: ComponentStory<typeof Fieldset> = (_) => (
<>
<Fieldset legend="Home address">
<Field>
<TextInputE label="Address line 1" name="address1" />
<TextInput label="Address line 1" name="address1" />
</Field>
<Field>
<TextInputE label="Address line 2" name="address2" />
<TextInput label="Address line 2" name="address2" />
</Field>
<Field>
<TextInputE label="City" name="city" />
<TextInput label="City" name="city" />
</Field>
</Fieldset>
<Fieldset legend="Work address">
<Field>
<TextInputE label="Address line 1" name="address1" />
<TextInput label="Address line 1" name="address1" />
</Field>
<Field>
<TextInputE label="Address line 2" name="address2" />
<TextInput label="Address line 2" name="address2" />
</Field>
<Field>
<TextInputE label="City" name="city" />
<TextInput label="City" name="city" />
</Field>
</Fieldset>
</>
Expand All @@ -63,24 +63,24 @@ const TemplateVertical: ComponentStory<typeof Fieldset> = (_) => (
<>
<Fieldset type="block" legend="Home address">
<Field>
<TextInputE label="Address line 1" name="address1" />
<TextInput label="Address line 1" name="address1" />
</Field>
<Field>
<TextInputE label="Address line 2" name="address2" />
<TextInput label="Address line 2" name="address2" />
</Field>
<Field>
<TextInputE label="City" name="city" />
<TextInput label="City" name="city" />
</Field>
</Fieldset>
<Fieldset type="block" legend="Work address">
<Field>
<TextInputE label="Address line 1" name="address1" />
<TextInput label="Address line 1" name="address1" />
</Field>
<Field>
<TextInputE label="Address line 2" name="address2" />
<TextInput label="Address line 2" name="address2" />
</Field>
<Field>
<TextInputE label="City" name="city" />
<TextInput label="City" name="city" />
</Field>
</Fieldset>
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import React from 'react'
import { isNil } from 'lodash'

import { ComponentSizeType } from '../Forms'
import { StyledInput } from '../TextInputE/partials/StyledInput'
import { StyledInput } from '../TextInput/partials/StyledInput'
import { StyledInputWrapper } from './partials/StyledInputWrapper'
import { StyledLabel } from '../TextInputE/partials/StyledLabel'
import { StyledLabel } from '../TextInput/partials/StyledLabel'

export interface InputProps {
hasFocus: boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export const Pagination: React.FC<PaginationProps> = ({
<StyledListItem>
{hasError && <PaginationErrorMessage />}
<StyledTextInput
label=""
aria-label="Enter page number"
onKeyDown={onKeyDown}
name={name}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
import styled from 'styled-components'
import { selectors } from '@defencedigital/design-tokens'

import { TextInput } from '../../TextInput'
import { StyledInput } from '../../TextInput/partials/StyledInput'

const { spacing } = selectors

export const StyledTextInput = styled(TextInput)`
width: 51px;
margin: 0;
${StyledInput} {
height: 31px;
padding: 0 0 0 ${spacing('6')};
}
`
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { SelectChildWithStringType } from './types'
import { StyledInlineButtons } from './partials/StyledInlineButtons'
import { StyledInput } from './partials/StyledInput'
import { StyledInputWrapper } from './partials/StyledInputWrapper'
import { StyledLabel } from '../TextInputE/partials/StyledLabel'
import { StyledLabel } from '../TextInput/partials/StyledLabel'
import { StyledOptions } from './partials/StyledOptions'
import { StyledOptionsWrapper } from './partials/StyledOptionsWrapper'
import { StyledOuterWrapper } from './partials/StyledOuterWrapper'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import styled from 'styled-components'
import {
StyledInput as StyledTextInputInput,
StyledInputProps,
} from '../../TextInputE/partials/StyledInput'
} from '../../TextInput/partials/StyledInput'

export const StyledInput = styled(StyledTextInputInput)<StyledInputProps>`
overflow: hidden;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import styled, { css } from 'styled-components'
import { selectors } from '@defencedigital/design-tokens'

import { COMPONENT_SIZE } from '../../Forms'
import { TEXT_INPUT_INPUT_HEIGHT } from '../../TextInputE/partials/StyledInput'
import { TEXT_INPUT_INPUT_HEIGHT } from '../../TextInput/partials/StyledInput'

const { color, fontSize, spacing } = selectors

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { selectors } from '@defencedigital/design-tokens'

import { BORDER_RADIUS } from '../../../styled-components'
import { COMPONENT_SIZE } from '../../Forms'
import { TEXT_INPUT_INPUT_HEIGHT } from '../../TextInputE/partials/StyledInput'
import { TEXT_INPUT_INPUT_HEIGHT } from '../../TextInput/partials/StyledInput'

const { color, zIndex } = selectors

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import styled from 'styled-components'

import { StyledTextInput as StyledTextInputBase } from '../../TextInputE/partials/StyledTextInput'
import { StyledTextInput as StyledTextInputBase } from '../../TextInput/partials/StyledTextInput'

export const StyledTextInput = styled(StyledTextInputBase)`
margin-bottom: 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import { TextInput } from '.'
export default {
component: TextInput,
title: 'Text Input',
argTypes: { onBlur: { action: 'onBlur' } },
parameters: {
argTypes: { onBlur: { action: 'onBlur' } },
},
} as ComponentMeta<typeof TextInput>

export const Default: ComponentStory<typeof TextInput> = (props) => (
Expand All @@ -19,12 +21,6 @@ Default.args = {
label: 'Example label',
}

export const WithLabel: ComponentStory<typeof TextInput> = (props) => (
<TextInput {...props} name="text-input-label" label="Example label" />
)

WithLabel.storyName = 'With label'

export const Disabled: ComponentStory<typeof TextInput> = (props) => (
<TextInput
{...props}
Expand Down Expand Up @@ -57,3 +53,14 @@ export const WithEndAdornment: ComponentStory<typeof TextInput> = (props) => (
)

WithEndAdornment.storyName = 'With end adornment'

export const WithError: ComponentStory<typeof TextInput> = (props) => (
<TextInput
{...props}
isInvalid
label="Example label"
name="text-input-end-adornment"
/>
)

WithError.storyName = 'With error'
Loading

0 comments on commit 2592488

Please sign in to comment.