From 6c9c73edb8fe29155a0541e13fa8bbb9e9fec77d Mon Sep 17 00:00:00 2001 From: Alex Ruzenhack Date: Thu, 23 May 2024 17:18:12 +0100 Subject: [PATCH] refactor: move icons to /Icons and add typed properties --- src/components/Icon/ActionDot.icon.js | 32 --------------- src/components/Icon/CircleCheck.icon.js | 39 ------------------- src/components/Icon/CircleClock.icon.js | 25 ------------ src/components/Icon/CircleError.icon.js | 25 ------------ src/components/Icons/ActionDot.icon.js | 5 +++ .../{Icon => Icons}/ArrowDown.icon.js | 16 +++++--- .../{Icon => Icons}/ArrowUp.icon.js | 16 +++++--- src/components/{Icon => Icons}/Base.icon.js | 12 +++--- src/components/Icons/CircleCheck.icon.js | 8 ++++ src/components/Icons/CircleClock.icon.js | 8 ++++ src/components/Icons/CircleError.icon.js | 8 ++++ .../{Icon => Icons}/CircleInfo.icon.js | 13 ++++++- .../{Icon => Icons}/NanoContract.icon.js | 20 ++++++---- src/components/{Icon => Icons}/Oracle.icon.js | 22 +++++++---- src/components/{Icon => Icons}/Pen.icon.js | 18 +++++---- .../{Icon => Icons}/RandomTx.icon.js | 20 ++++++---- .../{Icon => Icons}/Registered.icon.js | 22 +++++++---- src/components/{Icon => Icons}/Wallet.icon.js | 20 ++++++---- .../NanoContract/NanoContractIcon.icon.js | 29 -------------- .../NanoContract/NanoContractsListItem.js | 2 +- 20 files changed, 144 insertions(+), 216 deletions(-) delete mode 100644 src/components/Icon/ActionDot.icon.js delete mode 100644 src/components/Icon/CircleCheck.icon.js delete mode 100644 src/components/Icon/CircleClock.icon.js delete mode 100644 src/components/Icon/CircleError.icon.js rename src/components/{Icon => Icons}/ArrowDown.icon.js (66%) rename src/components/{Icon => Icons}/ArrowUp.icon.js (66%) rename src/components/{Icon => Icons}/Base.icon.js (73%) rename src/components/{Icon => Icons}/CircleInfo.icon.js (70%) rename src/components/{Icon => Icons}/NanoContract.icon.js (76%) rename src/components/{Icon => Icons}/Oracle.icon.js (78%) rename src/components/{Icon => Icons}/Pen.icon.js (68%) rename src/components/{Icon => Icons}/RandomTx.icon.js (83%) rename src/components/{Icon => Icons}/Registered.icon.js (73%) rename src/components/{Icon => Icons}/Wallet.icon.js (76%) delete mode 100644 src/components/NanoContract/NanoContractIcon.icon.js diff --git a/src/components/Icon/ActionDot.icon.js b/src/components/Icon/ActionDot.icon.js deleted file mode 100644 index d245a076d..000000000 --- a/src/components/Icon/ActionDot.icon.js +++ /dev/null @@ -1,32 +0,0 @@ -/** - * Copyright (c) Hathor Labs and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -import * as React from 'react' -import Svg, { G, Path, Defs, ClipPath } from 'react-native-svg' - -export const ActionDotIcon = () => ( - - - - - - - - - - -) diff --git a/src/components/Icon/CircleCheck.icon.js b/src/components/Icon/CircleCheck.icon.js deleted file mode 100644 index 7304e1735..000000000 --- a/src/components/Icon/CircleCheck.icon.js +++ /dev/null @@ -1,39 +0,0 @@ -/** - * Copyright (c) Hathor Labs and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -import * as React from 'react' -import Svg, { Mask, Path } from 'react-native-svg' - -export const CircleCheckIcon = ({ size = 24, color = '#000' }) => ( - - - - - - - -) diff --git a/src/components/Icon/CircleClock.icon.js b/src/components/Icon/CircleClock.icon.js deleted file mode 100644 index b20b33146..000000000 --- a/src/components/Icon/CircleClock.icon.js +++ /dev/null @@ -1,25 +0,0 @@ -/** - * Copyright (c) Hathor Labs and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -import * as React from 'react' -import Svg, { Path } from 'react-native-svg' - -export const CircleClockIcon = ({ size = 24, color = '#000' }) => ( - - - -) diff --git a/src/components/Icon/CircleError.icon.js b/src/components/Icon/CircleError.icon.js deleted file mode 100644 index 2e441b317..000000000 --- a/src/components/Icon/CircleError.icon.js +++ /dev/null @@ -1,25 +0,0 @@ -/** - * Copyright (c) Hathor Labs and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -import * as React from 'react' -import Svg, { Path } from 'react-native-svg' - -export const CircleErrorIcon = ({ size = 24, color = '#000' }) => ( - - - -) diff --git a/src/components/Icons/ActionDot.icon.js b/src/components/Icons/ActionDot.icon.js index a27bd4fee..5680cbb8f 100644 --- a/src/components/Icons/ActionDot.icon.js +++ b/src/components/Icons/ActionDot.icon.js @@ -11,6 +11,11 @@ import { COLORS } from '../../styles/themes' import { DEFAULT_ICON_SIZE } from './constants' import { getScale, getViewBox } from './helper' +/** + * @param {object} props + * @property {number} props.size + * @property {StyleSheet} props.color + */ export const ActionDot = ({ size = DEFAULT_ICON_SIZE, color = COLORS.black }) => ( ( +export const ArrowDownIcon = ({ size = DEFAULT_ICON_SIZE, style }) => ( - + ); diff --git a/src/components/Icon/ArrowUp.icon.js b/src/components/Icons/ArrowUp.icon.js similarity index 66% rename from src/components/Icon/ArrowUp.icon.js rename to src/components/Icons/ArrowUp.icon.js index 61f079105..1be5fcd89 100644 --- a/src/components/Icon/ArrowUp.icon.js +++ b/src/components/Icons/ArrowUp.icon.js @@ -8,16 +8,20 @@ import * as React from 'react' import { View, Image, StyleSheet } from 'react-native'; import chevronUp from '../../assets/icons/chevron-up.png'; +import { DEFAULT_ICON_SIZE } from './constants'; /** - * @typedef {Object} Properties prop - * @property {StyleSheet} prop.style - * - * @param {Properties} properties + * @param {object} props + * @property {number} props.size + * @property {StyleSheet} props.style */ -export const ArrowUpIcon = ({ style }) => ( +export const ArrowUpIcon = ({ size = DEFAULT_ICON_SIZE, style }) => ( - + ); diff --git a/src/components/Icon/Base.icon.js b/src/components/Icons/Base.icon.js similarity index 73% rename from src/components/Icon/Base.icon.js rename to src/components/Icons/Base.icon.js index 6166e3321..c505a5c5c 100644 --- a/src/components/Icon/Base.icon.js +++ b/src/components/Icons/Base.icon.js @@ -9,14 +9,12 @@ import { StyleSheet, View } from 'react-native'; import { COLORS } from '../../styles/themes'; /** - * @typedef {Object} Base base - * @property {'default'|'outline'|'fill'} base.type - * @property {StyleSheet} base.style - * @property {ReactNode} base.children - * - * @param {Base} + * @param {object} props + * @property {'default'|'outline'|'fill'} props.type + * @property {StyleSheet} props.style + * @property {ReactNode} props.children */ -export const BaseIcon = ({ type, style, children }) => ( +export const BaseIcon = ({ type = 'default', style, children }) => ( ( ( ( ( +/** + * @param {object} props + * @property {number} props.size + * @property {StyleSheet} props.color + * + * @description + * Svg converted from Figma using transaformer at https://react-svgr.com/playground/?native=true + */ +export const CircleInfoIcon = ({ size = 20, color = COLORS.white }) => ( ( - + diff --git a/src/components/Icon/NanoContract.icon.js b/src/components/Icons/NanoContract.icon.js similarity index 76% rename from src/components/Icon/NanoContract.icon.js rename to src/components/Icons/NanoContract.icon.js index a29e67372..7f68f545d 100644 --- a/src/components/Icon/NanoContract.icon.js +++ b/src/components/Icons/NanoContract.icon.js @@ -7,25 +7,31 @@ import * as React from 'react' import Svg, { Path } from 'react-native-svg' +import { COLORS } from '../../styles/themes'; import { BaseIcon } from './Base.icon'; +import { DEFAULT_ICON_SIZE } from './constants'; /** - * @param {SvgProps|{type: 'default'|'outline'|'fill'}} props + * @param {object} props + * @property {SvgProps|{type: 'default'|'outline'|'fill'}} props.type + * @property {number} props.size + * @property {StyleSheet} props.color * * @description * Svg converted from Figma using transaformer at https://react-svgr.com/playground/?native=true */ -export const NanoContractIcon = (props) => ( - +export const NanoContractIcon = ({ type = 'default', size = DEFAULT_ICON_SIZE, color = COLORS.black }) => ( + diff --git a/src/components/Icon/Oracle.icon.js b/src/components/Icons/Oracle.icon.js similarity index 78% rename from src/components/Icon/Oracle.icon.js rename to src/components/Icons/Oracle.icon.js index 841b0fd62..892df1348 100644 --- a/src/components/Icon/Oracle.icon.js +++ b/src/components/Icons/Oracle.icon.js @@ -7,29 +7,35 @@ import * as React from 'react' import Svg, { Path } from 'react-native-svg' +import { COLORS } from '../../styles/themes'; import { BaseIcon } from './Base.icon'; +import { DEFAULT_ICON_SIZE } from './constants'; /** - * @param {SvgProps|{type: 'default'|'outline'|'fill'}} props + * @param {object} props + * @property {SvgProps|{type: 'default'|'outline'|'fill'}} props.type + * @property {number} props.size + * @property {StyleSheet} props.color * * @description * Svg converted from Figma using transaformer at https://react-svgr.com/playground/?native=true */ -export const OracleIcon = (props) => ( - +export const OracleIcon = ({ type = 'default', size = DEFAULT_ICON_SIZE, color = COLORS.black }) => ( + diff --git a/src/components/Icon/Pen.icon.js b/src/components/Icons/Pen.icon.js similarity index 68% rename from src/components/Icon/Pen.icon.js rename to src/components/Icons/Pen.icon.js index 69c454e3b..03d4204c8 100644 --- a/src/components/Icon/Pen.icon.js +++ b/src/components/Icons/Pen.icon.js @@ -7,25 +7,29 @@ import * as React from 'react' import Svg, { Path } from 'react-native-svg' +import { COLORS } from '../../styles/themes'; import { BaseIcon } from './Base.icon'; +import { DEFAULT_ICON_SIZE } from './constants'; /** - * @param {SvgProps|{type: 'default'|'outline'|'fill'}} props + * @param {object} props + * @property {SvgProps|{type: 'default'|'outline'|'fill'}} props.type + * @property {number} props.size + * @property {StyleSheet} props.color * * @description * Svg converted from Figma using transaformer at https://react-svgr.com/playground/?native=true */ -export const PenIcon = (props) => ( - +export const PenIcon = ({ type = 'default', size = DEFAULT_ICON_SIZE, color = COLORS.black }) => ( + diff --git a/src/components/Icon/RandomTx.icon.js b/src/components/Icons/RandomTx.icon.js similarity index 83% rename from src/components/Icon/RandomTx.icon.js rename to src/components/Icons/RandomTx.icon.js index 2e7e2af2f..9233dd723 100644 --- a/src/components/Icon/RandomTx.icon.js +++ b/src/components/Icons/RandomTx.icon.js @@ -7,25 +7,31 @@ import * as React from 'react' import Svg, { Path } from 'react-native-svg' +import { COLORS } from '../../styles/themes'; import { BaseIcon } from './Base.icon'; +import { DEFAULT_ICON_SIZE } from './constants'; /** - * @param {SvgProps|{type: 'default'|'outline'|'fill'}} props + * @param {object} props + * @property {SvgProps|{type: 'default'|'outline'|'fill'}} props.type + * @property {number} props.size + * @property {StyleSheet} props.color * * @description * Svg converted from Figma using transaformer at https://react-svgr.com/playground/?native=true */ -export const RandomTxIcon = (props) => ( - +export const RandomTxIcon = ({ type = 'default', size = DEFAULT_ICON_SIZE, color = COLORS.black }) => ( + diff --git a/src/components/Icon/Registered.icon.js b/src/components/Icons/Registered.icon.js similarity index 73% rename from src/components/Icon/Registered.icon.js rename to src/components/Icons/Registered.icon.js index 1692a383a..53ff1d202 100644 --- a/src/components/Icon/Registered.icon.js +++ b/src/components/Icons/Registered.icon.js @@ -7,29 +7,35 @@ import * as React from 'react' import Svg, { Path } from 'react-native-svg' +import { COLORS } from '../../styles/themes'; import { BaseIcon } from './Base.icon'; +import { DEFAULT_ICON_SIZE } from './constants'; /** - * @param {SvgProps|{type: 'default'|'outline'|'fill'}} props + * @param {object} props + * @property {SvgProps|{type: 'default'|'outline'|'fill'}} props.type + * @property {number} props.size + * @property {StyleSheet} props.color * * @description * Svg converted from Figma using transaformer at https://react-svgr.com/playground/?native=true */ -export const RegisteredIcon = (props) => ( - +export const RegisteredIcon = ({ type = 'default', size = DEFAULT_ICON_SIZE, color = COLORS.black }) => ( + diff --git a/src/components/Icon/Wallet.icon.js b/src/components/Icons/Wallet.icon.js similarity index 76% rename from src/components/Icon/Wallet.icon.js rename to src/components/Icons/Wallet.icon.js index 42e9ab28a..c2f1df00b 100644 --- a/src/components/Icon/Wallet.icon.js +++ b/src/components/Icons/Wallet.icon.js @@ -7,25 +7,31 @@ import * as React from 'react' import Svg, { Path } from 'react-native-svg' +import { COLORS } from '../../styles/themes'; import { BaseIcon } from './Base.icon'; +import { DEFAULT_ICON_SIZE } from './constants'; /** - * @param {SvgProps|{type: 'default'|'outline'|'fill'}} props + * @param {object} props + * @property {SvgProps|{type: 'default'|'outline'|'fill'}} props.type + * @property {number} props.size + * @property {StyleSheet} props.color * * @description * Svg converted from Figma using transaformer at https://react-svgr.com/playground/?native=true */ -export const WalletIcon = (props) => ( - +export const WalletIcon = ({ type = 'default', size = DEFAULT_ICON_SIZE, color = COLORS.black }) => ( + diff --git a/src/components/NanoContract/NanoContractIcon.icon.js b/src/components/NanoContract/NanoContractIcon.icon.js deleted file mode 100644 index 4a3737bd4..000000000 --- a/src/components/NanoContract/NanoContractIcon.icon.js +++ /dev/null @@ -1,29 +0,0 @@ -/** - * Copyright (c) Hathor Labs and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -import * as React from 'react' -import Svg, { Path } from 'react-native-svg' - -/** - * @param {SvgProps} props - * - * @description - * Svg converted from Figma using transaformer at https://react-svgr.com/playground/?native=true - */ -export const NanoContractIcon = (props) => ( - - - -); diff --git a/src/components/NanoContract/NanoContractsListItem.js b/src/components/NanoContract/NanoContractsListItem.js index dde25bac4..06b5150be 100644 --- a/src/components/NanoContract/NanoContractsListItem.js +++ b/src/components/NanoContract/NanoContractsListItem.js @@ -11,7 +11,7 @@ import { TouchableHighlight, StyleSheet, View, Text, Image } from 'react-native' import chevronRight from '../../assets/icons/chevron-right.png'; import { COLORS } from '../../styles/themes'; import { getShortHash } from '../../utils'; -import { NanoContractIcon } from './NanoContractIcon.icon'; +import { NanoContractIcon } from '../Icons/NanoContract.icon'; /** * Renders each item of Nano Contract List.