Skip to content

Commit

Permalink
fix: updated InputSearch sub component types
Browse files Browse the repository at this point in the history
  • Loading branch information
wp-aberg committed Jun 30, 2023
1 parent 361e1d8 commit 18e9bc1
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 54 deletions.
11 changes: 2 additions & 9 deletions ui/input-search/src/InputSearchInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,14 @@ import { InputSearchContext } from "./InputSearchRoot";
type InputSearchLabelVariants = WPDS.VariantProps<typeof InputLabel>;

export type InputSearchInputProps = InputSearchLabelVariants & {
/** Any React node may be used as a child to allow for formatting */
children?: React.ReactNode;
/** Override CSS */
css?: WPDS.CSS;
/**The input's label text, required for accessibility
* @default Search
*/
label?: string;
/** The id for the underlying input element. Required for accessibility */
id: string;
/** The name for the underlying input element */
name: string;
disabled?: boolean;
onChange?: (event) => void;
};
} & React.ComponentPropsWithRef<typeof ComboboxInput> &
Omit<React.ComponentPropsWithRef<typeof InputText>, "label">;

//TODO: when you press the search button things should search

Expand Down
16 changes: 5 additions & 11 deletions ui/input-search/src/InputSearchList.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
import * as React from "react";

import { styled } from "@washingtonpost/wpds-theme";
import type * as WPDS from "@washingtonpost/wpds-theme";

import { ComboboxList, useComboboxContext } from "@reach/combobox";

export type InputSearchListProps = {
/** Any React node may be used as a child to allow for formatting */
children?: React.ReactNode;
/** Override CSS */
css?: WPDS.CSS;
};
import { styled } from "@washingtonpost/wpds-theme";

const StyledList = styled(ComboboxList, {
marginBlock: 0,
Expand All @@ -19,6 +9,10 @@ const StyledList = styled(ComboboxList, {
listStyleType: "none",
});

export type InputSearchListProps = React.ComponentPropsWithRef<
typeof StyledList
>;

export const InputSearchList = ({
children,
css,
Expand Down
17 changes: 5 additions & 12 deletions ui/input-search/src/InputSearchListItem.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,6 @@
import * as React from "react";

import type * as WPDS from "@washingtonpost/wpds-theme";
import { styled, theme } from "@washingtonpost/wpds-theme";

import { ComboboxOption } from "@reach/combobox";

export type InputSearchListItemProps = {
/** Any React node may be used as a child to allow for formatting */
children?: React.ReactNode;
/** Override CSS */
css?: WPDS.CSS;
value: string;
};
import { styled, theme } from "@washingtonpost/wpds-theme";

const StyledListItem = styled(ComboboxOption, {
color: theme.colors.primary,
Expand All @@ -30,6 +19,10 @@ const StyledListItem = styled(ComboboxOption, {
},
});

export type InputSearchListItemProps = React.ComponentPropsWithRef<
typeof StyledListItem
>;

export const InputSearchListItem = ({
children,
value,
Expand Down
12 changes: 3 additions & 9 deletions ui/input-search/src/InputSearchPopover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import { ComboboxPopover } from "@reach/combobox";
import { styled, theme } from "@washingtonpost/wpds-theme";
import { InputSearchContext } from "./InputSearchRoot";

import type * as WPDS from "@washingtonpost/wpds-theme";

const StyledPopover = styled(ComboboxPopover, {
backgroundColor: theme.colors.secondary,
maxHeight: "300px",
Expand All @@ -20,13 +18,9 @@ const StyledPopover = styled(ComboboxPopover, {
},
});

export type InputSearchPopoverProps = {
/** Any React node may be used as a child to allow for formatting */
children?: React.ReactNode;
portal?: boolean;
/** Override CSS */
css?: WPDS.CSS;
};
export type InputSearchPopoverProps = React.ComponentPropsWithRef<
typeof StyledPopover
>;

export const InputSearchPopover = ({
children,
Expand Down
18 changes: 5 additions & 13 deletions ui/input-search/src/InputSearchRoot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import * as React from "react";
import { Combobox } from "@reach/combobox";
import { styled, theme } from "@washingtonpost/wpds-theme";

import type * as WPDS from "@washingtonpost/wpds-theme";

type InputSearchContextProps = {
term: string;
setTerm: (string: string) => void;
Expand All @@ -17,17 +15,6 @@ export const InputSearchContext = React.createContext(
{} as InputSearchContextProps
);

export type InputSearchRootProps = {
/** Any React node may be used as a child to allow for formatting */
children?: React.ReactNode;
"aria-label": string;
/** Override CSS */
css?: WPDS.CSS;
/** Whether the input field should be disabled or not */
disabled?: boolean;
openOnFocus?: boolean;
};

const StyledComboBox = styled(Combobox, {
width: "100%",
position: "relative",
Expand All @@ -48,6 +35,11 @@ const StyledComboBox = styled(Combobox, {
},
});

export type InputSearchRootProps = {
/** Whether the input field should be disabled or not */
disabled?: boolean;
} & React.ComponentPropsWithRef<typeof StyledComboBox>;

export const InputSearchRoot = ({
children,
css,
Expand Down
1 change: 1 addition & 0 deletions ui/input-search/src/play.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export default {
Popover: InputSearch.Popover,
List: InputSearch.List,
ListItem: InputSearch.ListItem,
ListHeading: InputSearch.ListHeading,
EmptyState: InputSearch.EmptyState,
LoadingState: InputSearch.LoadingState,
},
Expand Down

4 comments on commit 18e9bc1

@vercel
Copy link

@vercel vercel bot commented on 18e9bc1 Jun 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 18e9bc1 Jun 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

wpds-ui-kit-storybook – ./

wpds-ui-kit-storybook.preview.now.washingtonpost.com
wpds-ui-kit-storybook-git-main.preview.now.washingtonpost.com

@vercel
Copy link

@vercel vercel bot commented on 18e9bc1 Jun 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

wpds-ui-kit-vitejs-example – ./apps/vite-project

wpds-ui-kit-vitejs-example.preview.now.washingtonpost.com
wpds-ui-kit-vitejs-example-git-main.preview.now.washingtonpost.com

@vercel
Copy link

@vercel vercel bot commented on 18e9bc1 Jun 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

wpds-ui-kit – ./build.washingtonpost.com

wpds-ui-kit-git-main.preview.now.washingtonpost.com
wpds-ui-kit.preview.now.washingtonpost.com
build.washingtonpost.com

Please sign in to comment.