Skip to content

Commit

Permalink
refactor: rename OptionallyVisuallyHiddenContainer to OptionalVisuall…
Browse files Browse the repository at this point in the history
…yHiddenWrapper to match naming to CSSWrapper and make more grammatical sense
  • Loading branch information
LimeWub committed Jul 28, 2023
1 parent 0c85d10 commit 71aa5ed
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 33 deletions.
6 changes: 3 additions & 3 deletions lib/src/components/data-table/DataTableGlobalFilter.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react'
import { debounce } from 'throttle-debounce'

import { OptionallyVisuallyHiddenContainer } from '../../utilities/optionally-visually-hidden-container'
import { OptionalVisuallyHiddenWrapper } from '../../utilities/optional-visually-hidden-wrapper'
import { Label } from '../label'
import { SearchInput } from '../search-input'
import { AsyncDataState } from './DataTable.types'
Expand Down Expand Up @@ -43,11 +43,11 @@ export const DataTableGlobalFilter: React.FC<DataTableSearchProps> = ({

return (
<>
<OptionallyVisuallyHiddenContainer hidden={hideLabel}>
<OptionalVisuallyHiddenWrapper hidden={hideLabel}>
<Label css={{ mb: '$3' }} htmlFor={label}>
{label}
</Label>
</OptionallyVisuallyHiddenContainer>
</OptionalVisuallyHiddenWrapper>
<SearchInput
{...props}
defaultValue={globalFilter}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { render } from '@testing-library/react'
import * as React from 'react'

import { OptionalVisuallyHiddenWrapper } from '.'

const OptionalVisuallyHiddenWrapperImplementation = (props) => {
return (
<OptionalVisuallyHiddenWrapper {...props}>
<p>hello</p>
</OptionalVisuallyHiddenWrapper>
)
}

describe('OptionalVisuallyHidden component', () => {
it('renders hidden content', async () => {
const { container } = render(
<OptionalVisuallyHiddenWrapperImplementation hidden />
)

expect(container).toMatchSnapshot()
})

it('renders visible content', async () => {
const { container } = render(
<OptionalVisuallyHiddenWrapperImplementation />
)

expect(container).toMatchSnapshot()
})
})
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as VisuallyHidden from '@radix-ui/react-visually-hidden'
import * as React from 'react'

export const OptionallyVisuallyHiddenContainer: React.FC<{
export const OptionalVisuallyHiddenWrapper: React.FC<{
hidden?: boolean
}> = ({ children, hidden = false }) => {
if (hidden) return <VisuallyHidden.Root>{children}</VisuallyHidden.Root>
Expand All @@ -13,3 +13,5 @@ export const OptionallyVisuallyHiddenContainer: React.FC<{
<>{children}</>
) : null
}

OptionalVisuallyHiddenWrapper.displayName = 'OptionalVisuallyHiddenWrapper'
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`TopBar component renders hidden content 1`] = `
exports[`OptionalVisuallyHidden component renders hidden content 1`] = `
<div>
<span
style="position: absolute; border: 0px; width: 1px; height: 1px; padding: 0px; margin: -1px; overflow: hidden; clip: rect(0px, 0px, 0px, 0px); white-space: nowrap; word-wrap: normal;"
Expand All @@ -12,7 +12,7 @@ exports[`TopBar component renders hidden content 1`] = `
</div>
`;

exports[`TopBar component renders visible content 1`] = `
exports[`OptionalVisuallyHidden component renders visible content 1`] = `
<div>
<p>
hello
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { OptionalVisuallyHiddenWrapper } from './OptionalVisuallyHiddenWrapper'

This file was deleted.

This file was deleted.

0 comments on commit 71aa5ed

Please sign in to comment.