Skip to content

Commit

Permalink
Remove outdated STYLEGUIDE point (#2244)
Browse files Browse the repository at this point in the history
  • Loading branch information
r100-stack authored Sep 23, 2024
1 parent f800d53 commit e2f953a
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 81 deletions.
33 changes: 0 additions & 33 deletions STYLEGUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,39 +80,6 @@ export const Alert = (props: AlertProps) => {
...
```

### Destruct props and set default values

```jsx
// Good
export const Alert = (props: AlertProps) => {
const {
children,
className,
type = 'informational',
clickableText,
onClick,
onClose,
style,
isSticky = false,
} = props;
...
```

```jsx
// Bad
export const Alert = ({
children,
className,
type = 'informational',
clickableText,
onClick,
onClose,
style,
isSticky = false,
}: AlertProps) => {
...
```
### Use classnames object syntax for conditional classes

```jsx
Expand Down
81 changes: 33 additions & 48 deletions packages/itwinui-react/src/core/SearchBox/SearchBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,54 +23,6 @@ import type {
import type { IconButtonProps } from '../Buttons/IconButton.js';
import type { IconProps } from '../Icon/Icon.js';

const SearchBoxContext = React.createContext<
| {
/**
* Context prop for sizing subcomponents
*/
size?: 'small' | 'large';
/**
* Context prop for disabling subcomponents
*/
isDisabled?: boolean;
/**
* Id to pass to input
*/
inputId: string;
/**
* Callback to set inputID
*/
setInputId: (inputId: string) => void;
/**
* Ref for input subcomponent
*/
inputRef: React.RefObject<HTMLInputElement>;
/**
* Ref for open button subcomponent
*/
openButtonRef: React.RefObject<HTMLButtonElement>;
/**
* Callback for closing expandable searchbox
*/
onCollapse?: () => void;
/**
* Callback for expanding searchbox
*/
onExpand?: () => void;
/**
* SearchBox state
*/
isExpanded?: boolean;
/**
* Is SearchBox expandable
*/
expandable?: boolean;
}
| undefined
>(undefined);

// ----------------------------------------------------------------------------

type SearchBoxOwnProps = {
/**
* Whether the searchbox is expandable.
Expand Down Expand Up @@ -99,6 +51,39 @@ type SearchBoxOwnProps = {
size?: 'small' | 'large';
};

// ----------------------------------------------------------------------------

const SearchBoxContext = React.createContext<
| ({
/**
* Context prop for disabling subcomponents
*/
isDisabled?: boolean;
/**
* Id to pass to input
*/
inputId: string;
/**
* Callback to set inputID
*/
setInputId: (inputId: string) => void;
/**
* Ref for input subcomponent
*/
inputRef: React.RefObject<HTMLInputElement>;
/**
* Ref for open button subcomponent
*/
openButtonRef: React.RefObject<HTMLButtonElement>;
} & Pick<
SearchBoxOwnProps,
'size' | 'onCollapse' | 'expandable' | 'isExpanded' | 'onExpand'
>)
| undefined
>(undefined);

// ----------------------------------------------------------------------------

const SearchBoxComponent = React.forwardRef((props, ref) => {
const {
size,
Expand Down

0 comments on commit e2f953a

Please sign in to comment.