From 336dc41e2817083e7859ddb326cf00f26dd4db68 Mon Sep 17 00:00:00 2001 From: anuradha9712 Date: Thu, 7 Sep 2023 19:48:15 +0530 Subject: [PATCH] fix(input): update action button to icon component --- .../atoms/input/actionButton/ActionButton.tsx | 52 +++++-------- .../__tests__/ActionButton.test.tsx | 2 +- .../__snapshots__/ActionButton.test.tsx.snap | 74 +++---------------- 3 files changed, 31 insertions(+), 97 deletions(-) diff --git a/core/components/atoms/input/actionButton/ActionButton.tsx b/core/components/atoms/input/actionButton/ActionButton.tsx index 1d266aa238..9e8520e62d 100644 --- a/core/components/atoms/input/actionButton/ActionButton.tsx +++ b/core/components/atoms/input/actionButton/ActionButton.tsx @@ -1,9 +1,10 @@ import * as React from 'react'; import classNames from 'classnames'; -import { BaseProps, extractBaseProps } from '@/utils/types'; -import { useAccessibilityProps } from '@/accessibility/utils'; +import { BaseProps } from '@/utils/types'; +import { FontVariationType } from '@/common.type'; +import { Icon } from '@/index'; -export type ActionButtonType = 'filled' | 'outlined' | 'round' | 'two-tone' | 'sharp'; +export type ActionButtonType = 'outlined' | 'rounded'; export interface ActionButtonProps extends BaseProps { /** @@ -18,6 +19,19 @@ export interface ActionButtonProps extends BaseProps { * Type of material `ActionButton` */ type?: ActionButtonType; + /** + * Set font-variation-settings CSS Property + * + *
+   *  FontVariationType: {
+   *    fill?: number;
+   *    weight?: number; Range: [100, 700]
+   *    grade?: number; Range: [-25, 200]
+   *    opticalSize?: number; Range: [20px, 48px]
+   *  }
+   * 
+ */ + iconVariations?: FontVariationType; /** * Handler to be called when icon is clicked */ @@ -38,48 +52,22 @@ export interface ActionButtonProps extends BaseProps { } export const ActionButton = (props: ActionButtonProps) => { - const { className, name, size, children, type } = props; - const accessibilityProps = useAccessibilityProps(props); - - const baseProps = extractBaseProps(props); + const { className, iconVariations, ...rest } = props; const iconClass = classNames({ - ['material-icons']: true, - [`material-icons-${type}`]: type && type !== 'filled', ['ActionButton']: true, [`${className}`]: className, }); - const styles = { - fontSize: `${size}px`, - width: `${size}px`, - }; - - // change `children` to {name} after migration - if (children && React.isValidElement(children)) { - return ( - - {children} - - ); - } return ( - - {`${name}_${type}`} - + ); }; ActionButton.displayName = 'ActionButton'; ActionButton.defaultProps = { size: 16, - type: 'round', + type: 'rounded', }; export default ActionButton; diff --git a/core/components/atoms/input/actionButton/__tests__/ActionButton.test.tsx b/core/components/atoms/input/actionButton/__tests__/ActionButton.test.tsx index 77531dad51..c83c65293c 100644 --- a/core/components/atoms/input/actionButton/__tests__/ActionButton.test.tsx +++ b/core/components/atoms/input/actionButton/__tests__/ActionButton.test.tsx @@ -5,7 +5,7 @@ import { testHelper, filterUndefined, valueHelper, testMessageHelper } from '@/u const size = 16; -const type: ActionButtonType[] = ['filled', 'outlined', 'round', 'two-tone', 'sharp']; +const type: ActionButtonType[] = ['outlined', 'rounded']; const FunctionValue = jest.fn(); const StringValue = 'events'; diff --git a/core/components/atoms/input/actionButton/__tests__/__snapshots__/ActionButton.test.tsx.snap b/core/components/atoms/input/actionButton/__tests__/__snapshots__/ActionButton.test.tsx.snap index f86680ab08..2a4443af0e 100644 --- a/core/components/atoms/input/actionButton/__tests__/__snapshots__/ActionButton.test.tsx.snap +++ b/core/components/atoms/input/actionButton/__tests__/__snapshots__/ActionButton.test.tsx.snap @@ -6,31 +6,13 @@ exports[`ActionButton component
- events_round - -
- -`; - -exports[`ActionButton component - name: "events", size: 16, type: "filled", onClick: "[Function]" - 1`] = ` - -
- - events_filled + events
@@ -42,67 +24,31 @@ exports[`ActionButton component
- events_outlined - -
- -`; - -exports[`ActionButton component - name: "events", size: 16, type: "round", onClick: "[Function]" - 1`] = ` - -
- - events_round - -
- -`; - -exports[`ActionButton component - name: "events", size: 16, type: "sharp", onClick: "[Function]" - 1`] = ` - -
- - events_sharp + events
`; exports[`ActionButton component - name: "events", size: 16, type: "two-tone", onClick: "[Function]" + name: "events", size: 16, type: "rounded", onClick: "[Function]" 1`] = `
- events_two-tone + events