Skip to content

Commit

Permalink
chore: Update uikit package.json (#7819)
Browse files Browse the repository at this point in the history
<!--
Before opening a pull request, please read the [contributing
guidelines](https://github.com/pancakeswap/pancake-frontend/blob/develop/CONTRIBUTING.md)
first
-->

<!--
copilot:all
-->
### <samp>🤖 Generated by Copilot at ae57c60</samp>

### Summary
📦🛠️🌟

<!--
1. 📦 for updating the package version and fixing the repository field,
which are both related to the package metadata and distribution.
2. 🛠️ for simplifying the prepublish script and removing some
unnecessary dependencies, which are both related to the package
maintenance and development.
3. 🌟 for improving the uikit components, which is related to the package
functionality and user experience.
-->
Update uikit package and fix repository field. This pull request
enhances the uikit package by upgrading its version, removing unused
dependencies, and fixing the repository field to point to the correct
GitHub URL. It also simplifies the prepublish script to use yarn instead
of pnpm.

> _`uikit` updated_
> _fixes and simplifications_
> _autumn of cleaning_

### Walkthrough
* Increment uikit package version to 0.63.3
([link](https://github.com/pancakeswap/pancake-frontend/pull/7819/files?diff=unified&w=0#diff-cb0a1990ba52670ab2c56f831e950ca6447a9ca43ab7028565a66d0defd034d6L3-R3))
* Update repository field to point to pancake-frontend
([link](https://github.com/pancakeswap/pancake-frontend/pull/7819/files?diff=unified&w=0#diff-cb0a1990ba52670ab2c56f831e950ca6447a9ca43ab7028565a66d0defd034d6L33-R33))
* Replace prepublishOnly script with build:uikit command
([link](https://github.com/pancakeswap/pancake-frontend/pull/7819/files?diff=unified&w=0#diff-cb0a1990ba52670ab2c56f831e950ca6447a9ca43ab7028565a66d0defd034d6L47-R47))
* Remove unused @pancakeswap/farms package from peerDependencies and
dependencies
([link](https://github.com/pancakeswap/pancake-frontend/pull/7819/files?diff=unified&w=0#diff-cb0a1990ba52670ab2c56f831e950ca6447a9ca43ab7028565a66d0defd034d6L54),
[link](https://github.com/pancakeswap/pancake-frontend/pull/7819/files?diff=unified&w=0#diff-cb0a1990ba52670ab2c56f831e950ca6447a9ca43ab7028565a66d0defd034d6L133-R134))
* Remove unused viem package from devDependencies
([link](https://github.com/pancakeswap/pancake-frontend/pull/7819/files?diff=unified&w=0#diff-cb0a1990ba52670ab2c56f831e950ca6447a9ca43ab7028565a66d0defd034d6L133-R134))

---------

Co-authored-by: chefilip <[email protected]>
  • Loading branch information
chefilip and chefilip authored Oct 5, 2023
1 parent 9871a18 commit d9d3159
Show file tree
Hide file tree
Showing 171 changed files with 3,536 additions and 3,628 deletions.
3 changes: 2 additions & 1 deletion apps/web/src/components/SearchModal/CommonBases.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Currency, Token } from '@pancakeswap/sdk'
import { ChainId } from '@pancakeswap/chains'
import { Text, QuestionHelper, AutoColumn, CurrencyLogo } from '@pancakeswap/uikit'
import { Text, QuestionHelper, AutoColumn } from '@pancakeswap/uikit'
import { CurrencyLogo } from '@pancakeswap/widgets-internal'
import { styled } from 'styled-components'
import useNativeCurrency from 'hooks/useNativeCurrency'
import { useTranslation } from '@pancakeswap/localization'
Expand Down
3 changes: 2 additions & 1 deletion apps/web/src/components/SearchModal/CurrencyList.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useTranslation } from '@pancakeswap/localization'
import { Currency, CurrencyAmount, Token } from '@pancakeswap/sdk'
import { ArrowForwardIcon, Column, QuestionHelper, Text, CurrencyLogo } from '@pancakeswap/uikit'
import { ArrowForwardIcon, Column, QuestionHelper, Text } from '@pancakeswap/uikit'
import { CurrencyLogo } from '@pancakeswap/widgets-internal'
import { formatAmount } from '@pancakeswap/utils/formatFractions'
import { LightGreyCard } from 'components/Card'
import { useActiveChainId } from 'hooks/useActiveChainId'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
import { useTranslation } from '@pancakeswap/localization'
import { Currency } from '@pancakeswap/sdk'
import {
ArrowDropDownIcon,
Box,
BoxProps,
Button,
CurrencyLogo,
Flex,
Skeleton,
Text,
useModal,
} from '@pancakeswap/uikit'
import { NumericalInput } from '@pancakeswap/widgets-internal'
import { ArrowDropDownIcon, Box, BoxProps, Button, Flex, Skeleton, Text, useModal } from '@pancakeswap/uikit'
import { NumericalInput, CurrencyLogo } from '@pancakeswap/widgets-internal'
import { FiatLogo } from 'components/Logo/CurrencyLogo'
import CurrencySearchModal, { CurrencySearchModalProps } from 'components/SearchModal/CurrencySearchModal'
import { useAllOnRampTokens } from 'hooks/Tokens'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {
CurrencyLogo,
Text,
Flex,
Box,
Expand All @@ -10,7 +9,7 @@ import {
UnlockIcon,
LockIcon,
} from '@pancakeswap/uikit'
import { Pool } from '@pancakeswap/widgets-internal'
import { Pool, CurrencyLogo } from '@pancakeswap/widgets-internal'
import { StyledCell } from 'views/Pools/components/PoolsTable/Cells/NameCell'
import { useTranslation } from '@pancakeswap/localization'
import React from 'react'
Expand Down
3 changes: 2 additions & 1 deletion apps/web/src/views/FixedStaking/components/ModalTitle.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { CurrencyLogo, Flex, Heading } from '@pancakeswap/uikit'
import { Flex, Heading } from '@pancakeswap/uikit'
import { CurrencyLogo } from '@pancakeswap/widgets-internal'
import { Token } from '@pancakeswap/sdk'
import { useTranslation } from '@pancakeswap/localization'
import { UnlockedFixedTag } from './UnlockedFixedTag'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import {
useTooltip,
AutoColumn,
UseModalV2Props,
CurrencyLogo,
AtomBox,
} from '@pancakeswap/uikit'
import { CurrencyLogo } from '@pancakeswap/widgets-internal'
import { Currency } from '@pancakeswap/sdk'
import { useMemo, memo } from 'react'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
ArrowForwardIcon,
Box,
Button,
CurrencyLogo,
Flex,
MoreIcon,
NextLinkFromReactRouter,
Expand All @@ -14,6 +13,7 @@ import {
Text,
useMatchBreakpoints,
} from '@pancakeswap/uikit'
import { CurrencyLogo } from '@pancakeswap/widgets-internal'
import { useActiveChainId } from 'hooks/useActiveChainId'
import useTheme from 'hooks/useTheme'
import orderBy from 'lodash/orderBy'
Expand Down
17 changes: 3 additions & 14 deletions packages/uikit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"types": "./dist/css/responsiveStyle.d.ts"
}
},
"repository": "https://github.com/pancakeswap/pancake-toolkit/tree/master/packages/pancake-uikit",
"repository": "https://github.com/pancakeswap/pancake-frontend/tree/develop/packages/uikit",
"license": "MIT",
"private": true,
"scripts": {
Expand All @@ -44,23 +44,19 @@
"build:storybook": "storybook build",
"test": "vitest --run",
"update:snapshot": "vitest -u",
"prepublishOnly": "pnpm run pkg:build",
"prepublishOnly": "pnpm run build:uikit",
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist"
},
"devDependencies": {
"@babel/core": "^7.20.12",
"@babel/preset-env": "^7.20.2",
"@babel/preset-react": "^7.18.6",
"@pancakeswap/hooks": "workspace:*",
"@pancakeswap/sdk": "workspace:*",
"@pancakeswap/swap-sdk-core": "workspace:*",
"@pancakeswap/utils": "workspace:*",
"@pancakeswap/v3-sdk": "workspace:*",
"@pancakeswap/chains": "workspace:*",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-typescript": "^8.2.1",
"@rollup/plugin-url": "^6.0.0",
"@sentry/nextjs": "^7.0.0",
"@storybook/addon-a11y": "^7.0.7",
"@storybook/addon-actions": "^7.0.7",
"@storybook/addon-essentials": "^7.0.7",
Expand Down Expand Up @@ -108,15 +104,13 @@
"styled-components": "^6.0.7",
"themeprovider-storybook": "^1.7.2",
"ts-jest": "^27.1.3",
"viem": "^1.10.9",
"vite": "^4.3.1",
"vite-plugin-dts": "^3.5.3",
"vite-tsconfig-paths": "^4.0.3",
"vitest": "^0.27.2",
"wagmi": "^1.3.10"
},
"peerDependencies": {
"@sentry/nextjs": "^7.0.0",
"js-cookie": "*",
"next": "*",
"next-seo": "*",
Expand All @@ -127,16 +121,11 @@
"react-redux": "^8.0.5",
"react-transition-group": "*",
"remark-gfm": "*",
"styled-components": "^6.0.7",
"viem": "^1.2.9"
"styled-components": "^6.0.7"
},
"dependencies": {
"@pancakeswap/farms": "workspace:*",
"@pancakeswap/hooks": "workspace:*",
"@pancakeswap/localization": "workspace:*",
"@pancakeswap/sdk": "workspace:*",
"@pancakeswap/swap-sdk-core": "workspace:*",
"@pancakeswap/v3-sdk": "workspace:*",
"@popperjs/core": "^2.9.2",
"@radix-ui/react-dismissable-layer": "^1.0.3",
"@radix-ui/react-slot": "^1.0.0",
Expand Down
32 changes: 0 additions & 32 deletions packages/uikit/src/components/CurrencyInput/index.stories.tsx

This file was deleted.

64 changes: 0 additions & 64 deletions packages/uikit/src/components/CurrencyInput/index.tsx

This file was deleted.

2 changes: 0 additions & 2 deletions packages/uikit/src/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ export * from "./SeverityErrorText";
export * from "./ReleasedChart";
export * from "./BunnyKnownPlaceholder";
export * from "./DropdownMenu";
export * from "./CurrencyInput";
export * from "./CurrencyLogo";
export * from "./DynamicSection";
export * from "./Chart";

Expand Down
21 changes: 0 additions & 21 deletions packages/uikit/src/shared.ts

This file was deleted.

22 changes: 10 additions & 12 deletions packages/uikit/src/widgets/Modal/ModalInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import BigNumber from "bignumber.js";
import { useMemo } from "react";
import { styled } from "styled-components";
import { useTranslation } from "@pancakeswap/localization";
import { parseUnits } from "viem";
import { formatBigInt } from "@pancakeswap/utils/formatBalance";
import { displayBalance } from "@pancakeswap/utils/displayBalance";
import { trimTrailZero } from "@pancakeswap/utils/trimTrailZero";
import { Flex } from "../../components/Box";
import { Text } from "../../components/Text";
Expand Down Expand Up @@ -80,15 +79,6 @@ const ModalInput: React.FC<React.PropsWithChildren<ModalInputProps>> = ({
const { t } = useTranslation();
const isBalanceZero = max === "0" || !max;

const displayBalance = (balance: `${number}`) => {
if (isBalanceZero) {
return "0";
}

const balanceUnits = parseUnits(balance, decimals);
return formatBigInt(balanceUnits, decimals, decimals);
};

const percentAmount = useMemo(
() => ({
25: maxAmount ? trimTrailZero(maxAmount.dividedBy(100).multipliedBy(25).toNumber().toFixed(decimals)) : undefined,
Expand All @@ -105,7 +95,15 @@ const ModalInput: React.FC<React.PropsWithChildren<ModalInputProps>> = ({
<StyledTokenInput isWarning={isBalanceZero}>
<Flex justifyContent="space-between" pl="16px">
<Text fontSize="14px">{inputTitle}</Text>
<Text fontSize="14px">{t("Balance: %balance%", { balance: displayBalance(max as `${number}`) })}</Text>
<Text fontSize="14px">
{t("Balance: %balance%", {
balance: displayBalance({
balance: max as `${number}`,
decimals,
isBalanceZero,
}),
})}
</Text>
</Flex>
<Flex alignItems="flex-end" justifyContent="space-between">
<StyledInput
Expand Down
19 changes: 19 additions & 0 deletions packages/utils/displayBalance.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { formatBigInt } from './formatBalance'
import { parseUnits } from './viem/parseUnits'

export const displayBalance = ({
balance,
decimals,
isBalanceZero,
}: {
balance: `${number}`
decimals: number
isBalanceZero: boolean
}) => {
if (isBalanceZero) {
return '0'
}

const balanceUnits = parseUnits(balance, decimals)
return formatBigInt(balanceUnits, decimals, decimals)
}
2 changes: 1 addition & 1 deletion packages/utils/formatBalance.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import BigNumber from 'bignumber.js'
import { formatUnits } from 'viem'
import { getLanguageCodeFromLS } from '@pancakeswap/localization'
import _trimEnd from 'lodash/trimEnd'
import { getFullDecimalMultiplier } from './getFullDecimalMultiplier'
import { formatUnits } from './viem/formatUnits'

/**
* Take a formatted amount, e.g. 15 BNB and convert it to full decimal value, e.g. 15000000000000000
Expand Down
4 changes: 1 addition & 3 deletions packages/utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
"@pancakeswap/localization": "workspace:*",
"date-fns": "^2.29.3",
"lodash": "^4.17.21",
"styled-components": "^6.0.7",
"viem": "^1.10.9"
"styled-components": "^6.0.7"
},
"devDependencies": {
"@pancakeswap/swap-sdk-core": "workspace:*",
Expand All @@ -19,7 +18,6 @@
"jotai": "^2.2.2",
"styled-components": "^6.0.7",
"swr": "^2.1.3",
"viem": "^1.10.9",
"vitest": "^0.30.1"
},
"peerDependenciesMeta": {
Expand Down
2 changes: 1 addition & 1 deletion packages/utils/tryParseAmount.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { parseUnits } from 'viem'
import { Currency, CurrencyAmount } from '@pancakeswap/swap-sdk-core'
import { parseUnits } from './viem/parseUnits'

// try to parse a user entered amount for a given token
function tryParseAmount<T extends Currency>(value?: string, currency?: T): CurrencyAmount<T> | undefined {
Expand Down
15 changes: 15 additions & 0 deletions packages/utils/viem/formatUnits.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copy from viem package to avoid unneessary dependency
export function formatUnits(value: bigint, decimals: number) {
let display = value.toString()

const negative = display.startsWith('-')
if (negative) display = display.slice(1)

display = display.padStart(decimals, '0')

let [integer, fraction] = [display.slice(0, display.length - decimals), display.slice(display.length - decimals)]
fraction = fraction.replace(/(0+)$/, '')
integer = integer || '0'

return `${negative ? '-' : ''}${integer}${fraction ? `.${fraction}` : ''}`
}
Loading

1 comment on commit d9d3159

@vercel
Copy link

@vercel vercel bot commented on d9d3159 Oct 5, 2023

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

uikit – ./packages/uikit

uikit-git-develop.pancake.run
uikit.pancake.run

Please sign in to comment.