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

chore(js-ts): Convert app/components/Views/PickComponent/index.js to TypeScript #11357

Merged
merged 4 commits into from
Sep 23, 2024
Merged
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
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import { StyleSheet, View } from 'react-native';
import { baseStyles } from '../../../styles/common';
import { ThemeContext, mockTheme } from '../../../util/theme';
import RadioButton from '../../../component-library/components/RadioButton/RadioButton';
import { Theme } from '@metamask/design-tokens';

const createStyles = (colors) =>
const createStyles = (_colors: Theme['colors']) =>
smilingkylan marked this conversation as resolved.
Show resolved Hide resolved
StyleSheet.create({
root: {
...baseStyles.flexGrow,
Expand All @@ -16,36 +16,38 @@ const createStyles = (colors) =>
},
});

interface PickComponentProps {
/**
* Callback to pick an option
*/
pick?: (value: string) => void;
/**
* Text to first option
*/
textFirst: string;
/**
* Value of first option
*/
valueFirst: string;
/**
* Text to second option
*/
textSecond: string;
/**
* Value of second option
*/
valueSecond: string;
/**
* Current selected value
*/
selectedValue: string;
}

/**
* Componets that allows to select clicking two options
* Component that allows to select clicking two options
*/
export default class PickComponent extends PureComponent {
static propTypes = {
/**
* Callback to pick an option
*/
pick: PropTypes.func,
/**
* Text to first option
*/
textFirst: PropTypes.string,
/**
* Value of first option
*/
valueFirst: PropTypes.string,
/**
* Text to second option
*/
textSecond: PropTypes.string,
/**
* Value of second option
*/
valueSecond: PropTypes.string,
/**
* Current selected value
*/
selectedValue: PropTypes.string,
};
export default class PickComponent extends PureComponent<PickComponentProps> {
static contextType = ThemeContext;

pickFirst = () => {
const { pick, valueFirst } = this.props;
Expand Down Expand Up @@ -83,5 +85,3 @@ export default class PickComponent extends PureComponent {
);
};
}

PickComponent.contextType = ThemeContext;
Loading