Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate old filter components #3396

Merged
merged 10 commits into from
Jun 19, 2023
5 changes: 5 additions & 0 deletions .changeset/lemon-dancers-marry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@primer/react': major
---

Deprecates FilterList and FilteredSearch components
9 changes: 6 additions & 3 deletions docs/content/FilterList.mdx
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
---
componentId: filter_list
title: FilterList
status: Alpha
status: Deprecated
description: The FilterList component is a menu with filter options that filter the main content of the page.
---

import data from '../../src/FilterList/FilterList.docs.json'
import data from '../../src/deprecated/FilterList/FilterList.docs.json'

The FilterList component is a menu with filter options that filter the main content of the page.
## Deprecation

Use [ActionList](/ActionList) instead.

## Examples

Expand Down
13 changes: 9 additions & 4 deletions docs/content/FilteredSearch.mdx
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
---
componentId: filtered_search
title: FilteredSearch
status: Alpha
status: Deprecated
description: The FilteredSearch component helps style an ActionMenu and a TextInput side-by-side.
---

import data from '../../src/FilteredSearch/FilteredSearch.docs.json'

The FilteredSearch component helps style an ActionMenu and a TextInput side-by-side.
import data from '../../src/deprecated/FilteredSearch/FilteredSearch.docs.json'

**Note:** You _must_ use a `TextInput` and `ActionMenu` (or native `<details>` and `<summary>`) in order for this component to work properly.

## Deprecation

A new filter component is in progress.

Until the new filter component is ready, you can use Button + TextInput + ActionList to reproduce this pattern.

## Examples

```jsx live
Expand Down
8 changes: 4 additions & 4 deletions docs/src/@primer/gatsby-theme-doctocat/nav.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,6 @@
url: /Details
- title: Dialog
url: /Dialog
- title: FilteredSearch
url: /FilteredSearch
- title: FilterList
url: /FilterList
- title: Flash
url: /Flash
- title: FormControl
Expand Down Expand Up @@ -190,6 +186,10 @@
url: /deprecated/Dropdown
- title: DropdownMenu
url: /deprecated/DropdownMenu
- title: FilteredSearch
url: /deprecated/FilteredSearch
- title: FilterList
url: /deprecated/FilterList
- title: Flex
url: /deprecated/Flex
- title: FormGroup
Expand Down
148 changes: 74 additions & 74 deletions generated/components.json
Original file line number Diff line number Diff line change
Expand Up @@ -1641,80 +1641,6 @@
],
"subcomponents": []
},
"filter_list": {
"id": "filter_list",
"name": "FilterList",
"status": "alpha",
"a11yReviewed": false,
"stories": [
{
"id": "components-filterlist--default",
"code": "() => {\n const [selectedIndex, setSelectedIndex] = useState(0)\n return (\n <FilterList>\n <FilterList.Item\n selected={selectedIndex === 0}\n onClick={() => setSelectedIndex(0)}\n count={32}\n >\n First Filter\n </FilterList.Item>\n <FilterList.Item\n selected={selectedIndex === 1}\n onClick={() => setSelectedIndex(1)}\n count={16}\n >\n Second Filter\n </FilterList.Item>\n <FilterList.Item\n selected={selectedIndex === 2}\n onClick={() => setSelectedIndex(2)}\n >\n Third Filter\n </FilterList.Item>\n </FilterList>\n )\n}"
}
],
"props": [
{
"name": "sx",
"type": "SystemStyleObject"
}
],
"subcomponents": [
{
"name": "FilterList.Item",
"props": [
{
"name": "count",
"type": "number",
"description": "Number to be displayed in the list item"
},
{
"name": "selected",
"type": "boolean",
"description": "Whether the list item is selected or not"
},
{
"name": "small",
"type": "boolean",
"defaultValue": "false",
"description": "Whether the list item is small or not"
},
{
"name": "as",
"type": "React.ElementType",
"defaultValue": "'a'"
},
{
"name": "sx",
"type": "SystemStyleObject"
}
]
}
]
},
"filtered_search": {
"id": "filtered_search",
"name": "FilteredSearch",
"status": "alpha",
"a11yReviewed": false,
"stories": [
{
"id": "components-filteredsearch--default",
"code": "() => (\n <FilteredSearch>\n <ActionMenu>\n <ActionMenu.Button as=\"summary\">Filter</ActionMenu.Button>\n <ActionMenu.Overlay>\n <ActionList>\n <ActionList.Item>Item 1</ActionList.Item>\n <ActionList.Item>Item 2</ActionList.Item>\n <ActionList.Item>Item 3</ActionList.Item>\n </ActionList>\n </ActionMenu.Overlay>\n </ActionMenu>\n <TextInput aria-label=\"filtered-search\" leadingVisual={SearchIcon} />\n </FilteredSearch>\n)"
}
],
"props": [
{
"name": "children",
"type": "React.ReactNode",
"description": "FilteredSearch is expected to contain an `ActionMenu` followed by a `TextInput`."
},
{
"name": "sx",
"type": "SystemStyleObject"
}
],
"subcomponents": []
},
"flash": {
"id": "flash",
"name": "Flash",
Expand Down Expand Up @@ -5040,6 +4966,80 @@
}
]
},
"filter_list": {
"id": "filter_list",
"name": "FilterList",
"status": "deprecated",
"a11yReviewed": false,
"stories": [
{
"id": "components-filterlist--default",
"code": "() => {\n const [selectedIndex, setSelectedIndex] = useState(0)\n return (\n <FilterList>\n <FilterList.Item\n selected={selectedIndex === 0}\n onClick={() => setSelectedIndex(0)}\n count={32}\n >\n First Filter\n </FilterList.Item>\n <FilterList.Item\n selected={selectedIndex === 1}\n onClick={() => setSelectedIndex(1)}\n count={16}\n >\n Second Filter\n </FilterList.Item>\n <FilterList.Item\n selected={selectedIndex === 2}\n onClick={() => setSelectedIndex(2)}\n >\n Third Filter\n </FilterList.Item>\n </FilterList>\n )\n}"
}
],
"props": [
{
"name": "sx",
"type": "SystemStyleObject"
}
],
"subcomponents": [
{
"name": "FilterList.Item",
"props": [
{
"name": "count",
"type": "number",
"description": "Number to be displayed in the list item"
},
{
"name": "selected",
"type": "boolean",
"description": "Whether the list item is selected or not"
},
{
"name": "small",
"type": "boolean",
"defaultValue": "false",
"description": "Whether the list item is small or not"
},
{
"name": "as",
"type": "React.ElementType",
"defaultValue": "'a'"
},
{
"name": "sx",
"type": "SystemStyleObject"
}
]
}
]
},
"filtered_search": {
"id": "filtered_search",
"name": "FilteredSearch",
"status": "deprecated",
"a11yReviewed": false,
"stories": [
{
"id": "components-filteredsearch--default",
"code": "() => (\n <FilteredSearch>\n <ActionMenu>\n <ActionMenu.Button as=\"summary\">Filter</ActionMenu.Button>\n <ActionMenu.Overlay>\n <ActionList>\n <ActionList.Item>Item 1</ActionList.Item>\n <ActionList.Item>Item 2</ActionList.Item>\n <ActionList.Item>Item 3</ActionList.Item>\n </ActionList>\n </ActionMenu.Overlay>\n </ActionMenu>\n <TextInput aria-label=\"filtered-search\" leadingVisual={SearchIcon} />\n </FilteredSearch>\n)"
}
],
"props": [
{
"name": "children",
"type": "React.ReactNode",
"description": "FilteredSearch is expected to contain an `ActionMenu` followed by a `TextInput`."
},
{
"name": "sx",
"type": "SystemStyleObject"
}
],
"subcomponents": []
},
"drafts_button": {
"id": "drafts_button",
"name": "Button2",
Expand Down
2 changes: 1 addition & 1 deletion src/TextInput/TextInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, {MouseEventHandler, useCallback, useState} from 'react'
import {ForwardRefComponent as PolymorphicForwardRefComponent} from '../utils/polymorphic'
import classnames from 'classnames'

import TextInputInnerVisualSlot from '../_TextInputInnerVisualSlot'
import TextInputInnerVisualSlot from '../internal/components/TextInputInnerVisualSlot'
import {useProvidedRefOrCreate} from '../hooks'
import {Merge} from '../utils/types'
import TextInputWrapper, {StyledWrapperProps} from '../internal/components/TextInputWrapper'
Expand Down
3 changes: 2 additions & 1 deletion src/TextInputWithTokens/TextInputWithTokens.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ import Text from '../Text'
import {TextInputProps} from '../TextInput'
import Token from '../Token/Token'
import {TokenSizeKeys} from '../Token/TokenBase'
import TextInputInnerVisualSlot from '../_TextInputInnerVisualSlot'

import TextInputWrapper, {textInputHorizPadding, TextInputSizes} from '../internal/components/TextInputWrapper'
import UnstyledTextInput from '../internal/components/UnstyledTextInput'
import TextInputInnerVisualSlot from '../internal/components/TextInputInnerVisualSlot'

// eslint-disable-next-line @typescript-eslint/no-explicit-any
type AnyReactComponent = React.ComponentType<React.PropsWithChildren<any>>
Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/__snapshots__/exports.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ exports[`@primer/react should not update exports without a semver change 1`] = `
"CounterLabel",
"Details",
"Dialog",
"FilterList",
"FilteredSearch",
"Flash",
"FormControl",
"Header",
Expand Down Expand Up @@ -117,6 +115,8 @@ exports[`@primer/react/decprecated should not update exports without a semver ch
"Dropdown",
"DropdownButton",
"DropdownMenu",
"FilterList",
"FilteredSearch",
"Fixed",
"Flex",
"FormGroup",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react'
import {FilterList} from '..'
import {render, behavesAsComponent, checkExports} from '../utils/testing'
import {FilterList} from '../../deprecated'
import {render, behavesAsComponent, checkExports} from '../../utils/testing'
import {render as HTMLRender} from '@testing-library/react'
import {axe, toHaveNoViolations} from 'jest-axe'

Expand All @@ -9,7 +9,7 @@ expect.extend(toHaveNoViolations)
describe('FilterList', () => {
behavesAsComponent({Component: FilterList})

checkExports('FilterList', {
checkExports('deprecated/FilterList', {
default: FilterList,
})

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react'
import FilterList from '../FilterList'
import FilterList from '../../deprecated/FilterList'

export function shouldAcceptCallWithNoProps() {
return <FilterList />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react'
import {FilterList} from '..'
import {render, behavesAsComponent} from '../utils/testing'
import {FilterList} from '../../deprecated'
import {render, behavesAsComponent} from '../../utils/testing'
import {render as HTMLRender} from '@testing-library/react'
import {axe, toHaveNoViolations} from 'jest-axe'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react'
import {FilteredSearch} from '..'
import {render, behavesAsComponent, checkExports} from '../utils/testing'
import {FilteredSearch} from '../../deprecated'
import {render, behavesAsComponent, checkExports} from '../../utils/testing'
import {render as HTMLRender} from '@testing-library/react'
import {axe, toHaveNoViolations} from 'jest-axe'

Expand All @@ -9,7 +9,7 @@ expect.extend(toHaveNoViolations)
describe('FilteredSearch', () => {
behavesAsComponent({Component: FilteredSearch})

checkExports('FilteredSearch', {
checkExports('deprecated/FilteredSearch', {
default: FilteredSearch,
})

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react'
import FilteredSearch from '../FilteredSearch'
import FilteredSearch from '../../deprecated/FilteredSearch'

export function shouldAcceptCallWithNoProps() {
return <FilteredSearch />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "filter_list",
"name": "FilterList",
"status": "alpha",
"status": "deprecated",
"a11yReviewed": false,
"stories": [],
"props": [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from 'react'
import styled from 'styled-components'
import {get} from '../constants'
import sx, {SxProp} from '../sx'
import {ComponentProps} from '../utils/types'
import {get} from '../../constants'
import sx, {SxProp} from '../../sx'
import {ComponentProps} from '../../utils/types'

const FilterListBase = styled.ul<SxProp>`
list-style-type: none;
Expand All @@ -13,6 +13,9 @@ const FilterListBase = styled.ul<SxProp>`

export type FilterListProps = ComponentProps<typeof FilterListBase>

/**
* @deprecated Use the ActionList component instead.
*/
const FilterList = ({children, ...rest}: React.PropsWithChildren<FilterListProps>) => {
const items = React.Children.map(children, child => {
return <li>{child}</li>
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "filtered_search",
"name": "FilteredSearch",
"status": "alpha",
"status": "deprecated",
"a11yReviewed": false,
"stories": [],
"props": [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from 'react'
import {Meta, ComponentStory} from '@storybook/react'
import FilteredSearch from './FilteredSearch'
import {ActionList} from '../ActionList'
import {ActionMenu} from '../ActionMenu'
import TextInput from '../TextInput'
import {ActionList} from '../../ActionList'
import {ActionMenu} from '../../ActionMenu'
import TextInput from '../../TextInput'
import {SearchIcon} from '@primer/octicons-react'

export default {
Expand Down
Loading