Skip to content

Commit

Permalink
chore: rename ButtonWithIcon to IconButton
Browse files Browse the repository at this point in the history
Signed-off-by: Nguyen, Tom CITZ:EX <[email protected]>
  • Loading branch information
Nguyen, Tom CITZ:EX authored and tom11-nguyen committed Oct 10, 2024
1 parent 65c9b11 commit 4727947
Show file tree
Hide file tree
Showing 15 changed files with 39 additions and 39 deletions.
4 changes: 2 additions & 2 deletions packages/legacy/core/App/components/buttons/HeaderHome.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import { useTranslation } from 'react-i18next'
import { Screens, TabStacks } from '../../types/navigators'
import { testIdWithKey } from '../../utils/testable'

import ButtonWithIcon, { ButtonLocation } from './ButtonWithIcon'
import IconButton, { ButtonLocation } from './IconButton'

const HeaderRightHome: React.FC = () => {
const { t } = useTranslation()
const navigation = useNavigation()

return (
<ButtonWithIcon
<IconButton
buttonLocation={ButtonLocation.Right}
accessibilityLabel={t('Global.Home')}
testID={testIdWithKey('HomeButton')}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export enum ButtonLocation {
Right,
}

interface ButtonWithIconProps {
interface IconButtonProps {
buttonLocation: ButtonLocation
accessibilityLabel: string
testID: string
Expand All @@ -22,7 +22,7 @@ interface ButtonWithIconProps {
iconTintColor?: string
}

const ButtonWithIcon: React.FC<ButtonWithIconProps> = ({
const IconButton: React.FC<IconButtonProps> = ({
buttonLocation,
icon,
text,
Expand Down Expand Up @@ -83,4 +83,4 @@ const ButtonWithIcon: React.FC<ButtonWithIconProps> = ({
)
}

export default ButtonWithIcon
export default IconButton
4 changes: 2 additions & 2 deletions packages/legacy/core/App/components/buttons/InfoIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { useTranslation } from 'react-i18next'
import { RootStackParams, Screens, Stacks } from '../../types/navigators'
import { testIdWithKey } from '../../utils/testable'

import ButtonWithIcon, { ButtonLocation } from './ButtonWithIcon'
import IconButton, { ButtonLocation } from './IconButton'

interface InfoIconProps {
connectionId: string
Expand All @@ -17,7 +17,7 @@ const InfoIcon: React.FC<InfoIconProps> = ({ connectionId }) => {
const { t } = useTranslation()

return (
<ButtonWithIcon
<IconButton
buttonLocation={ButtonLocation.Right}
accessibilityLabel={t('Screens.Settings')}
testID={testIdWithKey('Settings')}
Expand Down
4 changes: 2 additions & 2 deletions packages/legacy/core/App/components/buttons/SettingsMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import { useTranslation } from 'react-i18next'
import { RootStackParams, Screens, Stacks } from '../../types/navigators'
import { testIdWithKey } from '../../utils/testable'

import ButtonWithIcon, { ButtonLocation } from './ButtonWithIcon'
import IconButton, { ButtonLocation } from './IconButton'

const SettingsMenu: React.FC = () => {
const navigation = useNavigation<StackNavigationProp<RootStackParams>>()
const { t } = useTranslation()

return (
<ButtonWithIcon
<IconButton
buttonLocation={ButtonLocation.Left}
accessibilityLabel={t('Screens.Settings')}
testID={testIdWithKey('Settings')}
Expand Down
8 changes: 4 additions & 4 deletions packages/legacy/core/App/components/misc/NewQRView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { ConnectStackParams, Screens, Stacks } from '../../types/navigators'
import { createConnectionInvitation } from '../../utils/helpers'
import { testIdWithKey } from '../../utils/testable'
import LoadingIndicator from '../animated/LoadingIndicator'
import ButtonWithIcon, { ButtonLocation } from '../buttons/ButtonWithIcon'
import IconButton, { ButtonLocation } from '../buttons/IconButton'
import InfoBox, { InfoBoxType } from '../misc/InfoBox'
import DismissiblePopupModal from '../modals/DismissiblePopupModal'

Expand Down Expand Up @@ -138,7 +138,7 @@ const NewQRView: React.FC<Props> = ({ defaultToConnect, handleCodeScan, error, e

useEffect(() => {
let headerRight = invitation ? (
<ButtonWithIcon
<IconButton
buttonLocation={ButtonLocation.Right}
accessibilityLabel={t('Global.Share')}
testID={testIdWithKey('ShareButton')}
Expand All @@ -152,7 +152,7 @@ const NewQRView: React.FC<Props> = ({ defaultToConnect, handleCodeScan, error, e

if (firstTabActive) {
headerRight = (
<ButtonWithIcon
<IconButton
buttonLocation={ButtonLocation.Right}
accessibilityLabel={t('Global.Share')}
testID={testIdWithKey('ShareButton')}
Expand Down Expand Up @@ -312,7 +312,7 @@ const NewQRView: React.FC<Props> = ({ defaultToConnect, handleCodeScan, error, e
<Text testID={testIdWithKey('WalletName')} style={[styles.walletName, { paddingHorizontal: 20 }]}>
{store.preferences.walletName}
</Text>
<ButtonWithIcon
<IconButton
buttonLocation={ButtonLocation.Right}
accessibilityLabel={t('NameWallet.EditWalletName')}
testID={testIdWithKey('EditWalletName')}
Expand Down
4 changes: 2 additions & 2 deletions packages/legacy/core/App/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import AgentProvider from '@credo-ts/react-hooks'
import App from './App'
import * as components from './components'
import { Button as IButton, ButtonImpl as Button, ButtonType } from './components/buttons/Button'
import ButtonWithIcon, { ButtonLocation } from './components/buttons/ButtonWithIcon'
import IconButton, { ButtonLocation } from './components/buttons/IconButton'
import BulletPoint from './components/inputs/BulletPoint'
import CheckBoxRow from './components/inputs/CheckBoxRow'
import ContentGradient from './components/misc/ContentGradient'
Expand Down Expand Up @@ -125,7 +125,7 @@ export {
credentialOfferTourSteps,
proofRequestTourSteps,
ButtonType,
ButtonWithIcon,
IconButton,
ButtonLocation,
CheckBoxRow,
CredentialCard,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { StackNavigationProp } from '@react-navigation/stack'
import React from 'react'
import { useTranslation } from 'react-i18next'

import ButtonWithIcon, { ButtonLocation } from '../../../../components/buttons/ButtonWithIcon'
import IconButton, { ButtonLocation } from '../../../../components/buttons/IconButton'
import { RootStackParams, Screens, Stacks } from '../../../../types/navigators'
import { testIdWithKey } from '../../../../utils/testable'

Expand All @@ -12,7 +12,7 @@ const HistoryMenu: React.FC = () => {
const { t } = useTranslation()

return (
<ButtonWithIcon
<IconButton
buttonLocation={ButtonLocation.Right}
accessibilityLabel={t('Screens.Settings')}
testID={testIdWithKey('Settings')}
Expand Down
6 changes: 3 additions & 3 deletions packages/legacy/core/App/navigators/ProofRequestStack.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { createStackNavigator } from '@react-navigation/stack'
import React from 'react'
import { useTranslation } from 'react-i18next'

import ButtonWithIcon, { ButtonLocation } from '../components/buttons/ButtonWithIcon'
import IconButton, { ButtonLocation } from '../components/buttons/IconButton'
import HeaderRightHome from '../components/buttons/HeaderHome'
import { useTheme } from '../contexts/theme'
import ListProofRequests from '../screens/ListProofRequests'
Expand Down Expand Up @@ -53,7 +53,7 @@ const ProofRequestStack: React.FC = () => {
options={({ navigation }) => ({
title: t('ProofRequest.RequestForProof'),
headerLeft: () => (
<ButtonWithIcon
<IconButton
buttonLocation={ButtonLocation.Left}
accessibilityLabel={t('Global.Back')}
testID={testIdWithKey('BackButton')}
Expand All @@ -69,7 +69,7 @@ const ProofRequestStack: React.FC = () => {
options={({ navigation, route }) => ({
title: '',
headerLeft: () => (
<ButtonWithIcon
<IconButton
buttonLocation={ButtonLocation.Left}
accessibilityLabel={t('Global.Back')}
testID={testIdWithKey('BackButton')}
Expand Down
4 changes: 2 additions & 2 deletions packages/legacy/core/App/navigators/RootStack.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import React, { useCallback, useEffect, useRef, useState } from 'react'
import { useTranslation } from 'react-i18next'
import { AppState, DeviceEventEmitter } from 'react-native'

import ButtonWithIcon, { ButtonLocation } from '../components/buttons/ButtonWithIcon'
import IconButton, { ButtonLocation } from '../components/buttons/IconButton'
import { EventTypes, walletTimeout } from '../constants'
import { TOKENS, useServices } from '../container-api'
import { useAuth } from '../contexts/auth'
Expand Down Expand Up @@ -272,7 +272,7 @@ const RootStack: React.FC = () => {
headerShown: true,
title: t('Screens.CredentialOffer'),
headerLeft: () => (
<ButtonWithIcon
<IconButton
buttonLocation={ButtonLocation.Left}
accessibilityLabel={t('Global.Back')}
testID={testIdWithKey('BackButton')}
Expand Down
4 changes: 2 additions & 2 deletions packages/legacy/core/App/screens/ListContacts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import React, { useCallback, useEffect, useState } from 'react'
import { useTranslation } from 'react-i18next'
import { DeviceEventEmitter, FlatList, StyleSheet, View } from 'react-native'

import ButtonWithIcon, { ButtonLocation } from '../components/buttons/ButtonWithIcon'
import IconButton, { ButtonLocation } from '../components/buttons/IconButton'
import ContactListItem from '../components/listItems/ContactListItem'
import EmptyListContacts from '../components/misc/EmptyListContacts'
import { EventTypes } from '../constants'
Expand Down Expand Up @@ -74,7 +74,7 @@ const ListContacts: React.FC<ListContactsProps> = ({ navigation }) => {
if (store.preferences.useConnectionInviterCapability) {
navigation.setOptions({
headerRight: () => (
<ButtonWithIcon
<IconButton
buttonLocation={ButtonLocation.Right}
accessibilityLabel={t('Contacts.AddContact')}
testID={testIdWithKey('AddContact')}
Expand Down
4 changes: 2 additions & 2 deletions packages/legacy/core/App/screens/Onboarding.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { useTranslation } from 'react-i18next'
import { Animated, BackHandler, FlatList, View, useWindowDimensions } from 'react-native'
import { SafeAreaView } from 'react-native-safe-area-context'

import ButtonWithIcon, { ButtonLocation } from '../components/buttons/ButtonWithIcon'
import IconButton, { ButtonLocation } from '../components/buttons/IconButton'
import { Pagination } from '../components/misc/Pagination'
import { DispatchAction } from '../contexts/reducers/store'
import { useStore } from '../contexts/store'
Expand Down Expand Up @@ -101,7 +101,7 @@ const Onboarding: React.FC<OnboardingProps> = ({
!disableSkip &&
navigation.setOptions({
headerRight: () => (
<ButtonWithIcon
<IconButton
buttonLocation={ButtonLocation.Right}
accessibilityLabel={t('Onboarding.SkipA11y')}
testID={testIdWithKey('Skip')}
Expand Down
4 changes: 2 additions & 2 deletions packages/legacy/core/App/screens/ProofRequesting.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { SafeAreaView } from 'react-native-safe-area-context'

import LoadingIndicator from '../components/animated/LoadingIndicator'
import Button, { ButtonType } from '../components/buttons/Button'
import ButtonWithIcon, { ButtonLocation } from '../components/buttons/ButtonWithIcon'
import IconButton, { ButtonLocation } from '../components/buttons/IconButton'
import QRRenderer from '../components/misc/QRRenderer'
import { EventTypes } from '../constants'
import { useStore } from '../contexts/store'
Expand Down Expand Up @@ -154,7 +154,7 @@ const ProofRequesting: React.FC<ProofRequestingProps> = ({ route, navigation })
useEffect(() => {
if (message && store.preferences.enableShareableLink) {
const scanShareUrl = () => (
<ButtonWithIcon
<IconButton
buttonLocation={ButtonLocation.Right}
accessibilityLabel={t('Global.Share')}
testID={testIdWithKey('ShareButton')}
Expand Down
4 changes: 2 additions & 2 deletions packages/legacy/core/App/screens/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { getVersion, getBuildNumber } from 'react-native-device-info'
import { SafeAreaView } from 'react-native-safe-area-context'
import Icon from 'react-native-vector-icons/MaterialIcons'

import ButtonWithIcon, { ButtonLocation } from '../components/buttons/ButtonWithIcon'
import IconButton, { ButtonLocation } from '../components/buttons/IconButton'
import { DispatchAction } from '../contexts/reducers/store'
import { useStore } from '../contexts/store'
import { useTheme } from '../contexts/theme'
Expand Down Expand Up @@ -291,7 +291,7 @@ const Settings: React.FC<SettingsProps> = ({ navigation }) => {
</Text>
</View>
{iconRight && (
<ButtonWithIcon
<IconButton
buttonLocation={ButtonLocation.Right}
accessibilityLabel={iconRight.accessibilityLabel!}
testID={iconRight.testID!}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { render, fireEvent } from '@testing-library/react-native'
import React from 'react'

import ButtonWithIcon, { ButtonLocation } from '../../App/components/buttons/ButtonWithIcon'
import IconButton, { ButtonLocation } from '../../App/components/buttons/IconButton'
import { testIdWithKey } from '../../App/utils/testable'

describe('ButtonWithIcon Component', () => {
describe('IconButton Component', () => {
test('Left alignment renders correctly', () => {
const tree = render(
<ButtonWithIcon
<IconButton
buttonLocation={ButtonLocation.Left}
accessibilityLabel={'LeftButton'}
testID={testIdWithKey('LeftButton')}
Expand All @@ -21,7 +21,7 @@ describe('ButtonWithIcon Component', () => {

test('Right alignment renders correctly', () => {
const tree = render(
<ButtonWithIcon
<IconButton
buttonLocation={ButtonLocation.Right}
accessibilityLabel={'RightButton'}
testID={testIdWithKey('RightButton')}
Expand All @@ -35,7 +35,7 @@ describe('ButtonWithIcon Component', () => {

test('Right alignment with text renders correctly', () => {
const tree = render(
<ButtonWithIcon
<IconButton
buttonLocation={ButtonLocation.Right}
accessibilityLabel={'RightButton'}
testID={testIdWithKey('RightButton')}
Expand All @@ -51,7 +51,7 @@ describe('ButtonWithIcon Component', () => {
test('Button onPress triggers on press', () => {
const callback = jest.fn()
const { getByTestId } = render(
<ButtonWithIcon
<IconButton
buttonLocation={ButtonLocation.Left}
accessibilityLabel={'LeftButton'}
testID={testIdWithKey('LeftButton')}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`ButtonWithIcon Component Left alignment renders correctly 1`] = `
exports[`IconButton Component Left alignment renders correctly 1`] = `
<View
accessibilityLabel="LeftButton"
accessibilityRole="button"
Expand Down Expand Up @@ -80,7 +80,7 @@ exports[`ButtonWithIcon Component Left alignment renders correctly 1`] = `
</View>
`;

exports[`ButtonWithIcon Component Right alignment renders correctly 1`] = `
exports[`IconButton Component Right alignment renders correctly 1`] = `
<View
accessibilityLabel="RightButton"
accessibilityRole="button"
Expand Down Expand Up @@ -160,7 +160,7 @@ exports[`ButtonWithIcon Component Right alignment renders correctly 1`] = `
</View>
`;

exports[`ButtonWithIcon Component Right alignment with text renders correctly 1`] = `
exports[`IconButton Component Right alignment with text renders correctly 1`] = `
<View
accessibilityLabel="RightButton"
accessibilityRole="button"
Expand Down

0 comments on commit 4727947

Please sign in to comment.