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

feat: add new Asset component #314

Merged
merged 5 commits into from
Aug 31, 2023
Merged

feat: add new Asset component #314

merged 5 commits into from
Aug 31, 2023

Conversation

pedronauck
Copy link
Contributor

@pedronauck pedronauck commented Aug 30, 2023

This pull request intends to add a new component called Asset to handle different scenarios using visual information related to assets across all applications.

Usage

Works as a namespace component, using context to set data, and just using the child component to manage UI.

import { Asset } from '@fuel-ui/react'

function App() {
  return (
    <Asset asset={Asset.get('eth')} amount="1000000000">
      <Asset.Icon />
      <Asset.Name />
      <Box.HStack>
        <Asset.Amount />
        <Asset.Symbol />
      </Box.HStack>
    </Asset>
  );
}

This code will render a component like this:
CleanShot 2023-08-30 at 17 05 13@2x

You can see other variations that are possible to create inside the Asset story.

Comment on lines 3 to 9
export const assets: AssetList = {
eth: {
symbol: 'ETH',
name: 'Ethereum',
imageUrl: '/assets/eth.svg',
},
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should not include this here, but instead, we can receive a JSON with these configs on the application level. This is because we will need an asset package with only asset information and images, that will contain more information.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@github-actions
Copy link
Contributor

github-actions bot commented Aug 30, 2023

Coverage report

St.
Category Percentage Covered / Total
🟢 Statements 84.95% 2388/2811
🟡 Branches 75.49% 425/563
🟢 Functions 83.55% 254/304
🟢 Lines 90.41% 2121/2346

Test suite run success

197 tests passing in 49 suites.

Report generated by 🧪jest coverage report action from b1ede38

import type { ReactNode } from 'react';
import { Children } from 'react';

export function useStrictedChildren(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like something that could affect the performance of the application. As if create arrays on every execution, and not caches anything. What do you think?

Copy link
Contributor Author

@pedronauck pedronauck Aug 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm, I guess isn't a big thing, but I just added two useMemo to prevent head and last from being on every render and added the check inside an useEffect. We already have other children map operations inside components, which isn't something so unusual in fact.

@pedronauck pedronauck merged commit 1dcecb3 into master Aug 31, 2023
@pedronauck pedronauck deleted the pn/feat/asset-amount branch August 31, 2023 20:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants