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

refactor: convert ToolbarButton to typescript #4440

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Contributing

IBMers should complete steps documented on
[W3 Developer](https://w3.ibm.com/developer/docs/open-source/contributing/)
[W3 Developer](https://w3.ibm.com/developer/docs/open-source/oss-contributing/)
before contributing to open source projects.

Also refer to
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright IBM Corp. 2021, 2021
* Copyright IBM Corp. 2021, 2024
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
Expand All @@ -16,10 +16,28 @@ import { blockClass as toolbarClass, ToolbarContext } from './Toolbar';

export const blockClass = `${toolbarClass}__button`;

interface ToolbarButtonProps extends React.ComponentProps<typeof IconButton> {
/** Determines whether the caret is rendered */
caret?: boolean;
/** Provide an optional class to be applied to the containing node */
className?: string;
/** Specifies the label for the icon button */
iconDescription: string;
/** Specifies the icon to be used by the ToolbarButton component */
renderIcon: React.ElementType;
}

/** Toolbar buttons are common functions performed as part of a products interface or an open window. */
export let ToolbarButton = forwardRef(
(
{ caret, children, className, renderIcon, iconDescription = '', ...rest },
{
caret = false,
children,
className,
renderIcon,
iconDescription = '',
...rest
}: React.PropsWithChildren<ToolbarButtonProps>,
ref
) => {
const Icon = renderIcon;
Expand Down
Loading