From 2ddf0a4d3fa92281f7d6f76c09d6b75eb4fd1313 Mon Sep 17 00:00:00 2001 From: matassp Date: Tue, 27 Feb 2024 17:51:48 +0200 Subject: [PATCH] refactor: convert ToolbarButton to typescript (#4440) * refactor: convert ToolbarButton to typescript * docs: update url * chore: format --- .github/CONTRIBUTING.md | 2 +- .../{ToolbarButton.js => ToolbarButton.tsx} | 22 +++++++++++++++++-- 2 files changed, 21 insertions(+), 3 deletions(-) rename packages/ibm-products/src/components/Toolbar/{ToolbarButton.js => ToolbarButton.tsx} (73%) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index dcdcd2c950..549c01af0c 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -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 diff --git a/packages/ibm-products/src/components/Toolbar/ToolbarButton.js b/packages/ibm-products/src/components/Toolbar/ToolbarButton.tsx similarity index 73% rename from packages/ibm-products/src/components/Toolbar/ToolbarButton.js rename to packages/ibm-products/src/components/Toolbar/ToolbarButton.tsx index ca4fb7037d..413de2e8bb 100644 --- a/packages/ibm-products/src/components/Toolbar/ToolbarButton.js +++ b/packages/ibm-products/src/components/Toolbar/ToolbarButton.tsx @@ -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. @@ -16,10 +16,28 @@ import { blockClass as toolbarClass, ToolbarContext } from './Toolbar'; export const blockClass = `${toolbarClass}__button`; +interface ToolbarButtonProps extends React.ComponentProps { + /** 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, ref ) => { const Icon = renderIcon;