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

feat(searchbar)!: remove top level subcomponents #1687

Merged
merged 2 commits into from
Jul 14, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/components/SearchBar/SearchBar.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,14 @@
display: flex;
gap: var(--eds-size-1);
}

/**
* Button to trigger search in a Search Bar.
*/
.search-button {
padding-top: 1px;
padding-bottom: 1px;
height: var(--eds-size-5);
box-sizing: content-box;
border: 0;
}
2 changes: 1 addition & 1 deletion src/components/SearchBar/SearchBar.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default {
title: 'Components/SearchBar',
component: SearchBar,
parameters: {
badges: ['1.1', BADGE.BETA],
badges: ['1.1', BADGE.NEEDS_REVISION],
},
decorators: [
(Story) => (
Expand Down
71 changes: 65 additions & 6 deletions src/components/SearchBar/SearchBar.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import clsx from 'clsx';
import type { ReactNode } from 'react';
import type { MouseEventHandler, ReactNode } from 'react';
import React from 'react';
import SearchButton from '../SearchButton';
import SearchField from '../SearchField';
import Button from '../Button';
import Icon from '../Icon';
import Input, { type InputProps } from '../Input';
import styles from './SearchBar.module.css';

export type Props = {
type SearchBarProps = {
/**
* SearchBar subcomponents to be wrapped.
*/
Expand All @@ -16,14 +17,72 @@ export type Props = {
className?: string;
};

type SearchButtonProps = {
/**
* CSS class names that can be appended to the component.
*/
className?: string;
/**
* Disables the button and prevents button use.
*/
disabled?: boolean;
/**
* On click handler for component
*/
onClick?: MouseEventHandler;
};

/**
* A search Input component styled for use with the SearchBar.
*/
const SearchField = ({ className, disabled, ...other }: InputProps) => {
const inputClassName = clsx(styles['search-field__input'], className);
const iconClassName = clsx(
styles['search-field__icon'],
disabled && styles['search-field__icon--disabled'],
);

return (
<div className={styles['search-field']}>
<Input
className={inputClassName}
disabled={disabled}
placeholder="Search"
type="search"
{...other}
/>
<Icon
className={iconClassName}
name="search"
purpose="informative"
size="1.25rem"
title="search"
/>
</div>
);
};

/**
* A button styled for use with the SearchBar.
*/
const SearchButton = ({ className, ...other }: SearchButtonProps) => {
const componentClassName = clsx(styles['search-button'], className);

return (
<Button className={componentClassName} variant="primary" {...other}>
Search
</Button>
);
};

/**
* BETA: This component is still a work in progress and is subject to change.
* In Review: This component is in design review and is subject to change.
*
* `import {SearchBar} from "@chanzuckerberg/eds";`
*
* Input field and button used for searching through various data fields.
*/
export const SearchBar = ({ children, className }: Props) => {
export const SearchBar = ({ children, className }: SearchBarProps) => {
const componentClassName = clsx(styles['search-bar'], className);

return <div className={componentClassName}>{children}</div>;
Expand Down
14 changes: 0 additions & 14 deletions src/components/SearchButton/SearchButton.module.css

This file was deleted.

37 changes: 0 additions & 37 deletions src/components/SearchButton/SearchButton.tsx

This file was deleted.

1 change: 0 additions & 1 deletion src/components/SearchButton/index.ts

This file was deleted.

45 changes: 0 additions & 45 deletions src/components/SearchField/SearchField.module.css

This file was deleted.

40 changes: 0 additions & 40 deletions src/components/SearchField/SearchField.tsx

This file was deleted.

1 change: 0 additions & 1 deletion src/components/SearchField/index.ts

This file was deleted.

2 changes: 0 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,6 @@ export { default as RadioInput } from './components/RadioInput';
export { default as RadioLabel } from './components/RadioLabel';
export { default as Score } from './components/Score';
export { default as SearchBar } from './components/SearchBar';
export { default as SearchButton } from './components/SearchButton';
export { default as SearchField } from './components/SearchField';
export { default as Section } from './components/Section';
export { default as Select } from './components/Select';
export { default as Skeleton } from './components/Skeleton';
Expand Down