-
Notifications
You must be signed in to change notification settings - Fork 750
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
2,827 additions
and
2,284 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Pancake Toolkit | ||
|
||
This repository is a monorepo manage with [yarn workspaces](https://classic.yarnpkg.com/en/docs/workspaces/) and [Lerna](https://lerna.js.org/). | ||
|
||
## Packages | ||
|
||
- [pancake-uikit](https://github.com/pancakeswap/pancake-toolkit/tree/master/packages/pancake-uikit) : React components used to build the Pancake UI | ||
- [eslint-config-pancake](https://github.com/pancakeswap/pancake-toolkit/tree/master/packages/eslint-config-pancake) : An ESLint config for pancake, with Typescript and Prettier support | ||
|
||
## How to use | ||
|
||
Clone the repository | ||
|
||
``` | ||
git clone [email protected]:pancakeswap/pancake-toolkit.git | ||
``` | ||
|
||
Run yarn at the root of the workspace | ||
|
||
``` | ||
cd pancake-toolkit | ||
yarn | ||
``` | ||
|
||
Then, refer to the readme of each project. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,13 @@ | ||
{ | ||
"packages": [ | ||
"packages/*" | ||
], | ||
"version": "0.0.0" | ||
"packages": ["packages/*"], | ||
"version": "independent", | ||
"npmClient": "yarn", | ||
"workspaces": true, | ||
"ignoreChanges": ["**/__tests__/**", "**/*.md"], | ||
"command": { | ||
"version": { | ||
"conventionalCommits": true, | ||
"message": "chore(release): Publish %s" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# eslint-config-pancake | ||
|
||
Pancake Eslint config with: | ||
|
||
- Airbnb config | ||
- Typescript | ||
- Prettier | ||
|
||
## Usage | ||
|
||
``` | ||
npx install-peerdeps --dev @pancakeswap-libs/eslint-config-pancake | ||
``` | ||
|
||
Add `"extends": "@pancakeswap-libs/eslint-config-pancake"` to your eslint config file. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
module.exports = { | ||
root: true, | ||
parser: "@typescript-eslint/parser", | ||
parserOptions: { | ||
ecmaVersion: 2017, | ||
ecmaFeatures: { | ||
jsx: true, | ||
}, | ||
}, | ||
env: { | ||
es6: true, | ||
browser: true, | ||
}, | ||
settings: { | ||
"import/resolver": { | ||
node: { | ||
extensions: [".js", ".ts", ".jsx", ".tsx"], | ||
}, | ||
}, | ||
"import/extensions": [".js", ".ts", ".jsx", ".tsx"], | ||
}, | ||
extends: [ | ||
"airbnb", | ||
"airbnb/hooks", | ||
"prettier", | ||
"prettier/react", | ||
"prettier/@typescript-eslint", | ||
"plugin:@typescript-eslint/recommended", | ||
], | ||
rules: { | ||
// Typescript | ||
"@typescript-eslint/no-unused-vars": "warn", | ||
"no-use-before-define": "off", | ||
"@typescript-eslint/no-use-before-define": ["warn"], | ||
"no-shadow": "off", | ||
"@typescript-eslint/no-shadow": ["error"], | ||
// React | ||
"react/jsx-filename-extension": ["error", { extensions: [".tsx"] }], | ||
"react/prop-types": 0, | ||
"react/jsx-props-no-spreading": 0, | ||
"react/no-multi-comp": 0, | ||
"import/extensions": [ | ||
"error", | ||
"ignorePackages", | ||
{ | ||
js: "never", | ||
mjs: "never", | ||
jsx: "never", | ||
ts: "never", | ||
tsx: "never", | ||
}, | ||
], | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"name": "@pancakeswap-libs/eslint-config-pancake", | ||
"version": "1.0.1", | ||
"description": "Eslint config for PancakeSwap", | ||
"main": "lib/index.js", | ||
"files": [ | ||
"lib" | ||
], | ||
"repository": "https://github.com/pancakeswap/pancake-toolkit/tree/master/packages/eslint-config-pancake", | ||
"license": "MIT", | ||
"author": "RabbitDoge", | ||
"private": false, | ||
"dependencies": { | ||
"@typescript-eslint/eslint-plugin": "^4.7.0", | ||
"@typescript-eslint/parser": "^4.7.0", | ||
"eslint-config-airbnb": "^18.2.1", | ||
"eslint-config-prettier": "^6.15.0", | ||
"eslint-plugin-import": "^2.22.1", | ||
"eslint-plugin-jsx-a11y": "^6.4.1", | ||
"eslint-plugin-react": "^7.21.5", | ||
"eslint-plugin-react-hooks": "^4.0.0" | ||
}, | ||
"peerDependencies": { | ||
"eslint": "^7.2.0", | ||
"prettier": "^2.1.2" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
packages/pancake-uikit/src/__tests__/components/balanceinput.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import React from "react"; | ||
import { renderWithTheme } from "../../testHelpers"; | ||
import BalanceInput from "../../components/BalanceInput/BalanceInput"; | ||
|
||
const handleChange = jest.fn(); | ||
|
||
it("renders correctly", () => { | ||
const { asFragment } = renderWithTheme(<BalanceInput value="14" currencyValue="15 USD" onChange={handleChange} />); | ||
expect(asFragment()).toMatchInlineSnapshot(` | ||
<DocumentFragment> | ||
<div | ||
class="sc-gsTCUz sc-hKgILt jLyPtw bSJkHm" | ||
> | ||
<input | ||
class="sc-dlfnbm sc-eCssSg iIlYpN jebGQw" | ||
placeholder="0.0" | ||
scale="md" | ||
type="text" | ||
value="14" | ||
/> | ||
<div | ||
class="sc-bdfBwQ hRRNWZ" | ||
color="textSubtle" | ||
font-size="12px" | ||
> | ||
15 USD | ||
</div> | ||
</div> | ||
</DocumentFragment> | ||
`); | ||
}); |
26 changes: 26 additions & 0 deletions
26
packages/pancake-uikit/src/components/BalanceInput/BalanceInput.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import React from "react"; | ||
import Text from "../Text/Text"; | ||
import { StyledBalanceInput, StyledInput } from "./styles"; | ||
import { BalanceInputProps } from "./types"; | ||
|
||
const BalanceInput: React.FC<BalanceInputProps> = ({ | ||
value, | ||
placeholder = "0.0", | ||
onChange, | ||
currencyValue, | ||
inputProps, | ||
...props | ||
}) => { | ||
return ( | ||
<StyledBalanceInput {...props}> | ||
<StyledInput type="text" value={value} onChange={onChange} placeholder={placeholder} {...inputProps} /> | ||
{currencyValue && ( | ||
<Text fontSize="12px" textAlign="right" color="textSubtle"> | ||
{currencyValue} | ||
</Text> | ||
)} | ||
</StyledBalanceInput> | ||
); | ||
}; | ||
|
||
export default BalanceInput; |
27 changes: 27 additions & 0 deletions
27
packages/pancake-uikit/src/components/BalanceInput/index.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import React, { useState } from "react"; | ||
import Box from "../Box/Box"; | ||
import BalanceInput from "./BalanceInput"; | ||
|
||
export default { | ||
title: "Components/BalanceInput", | ||
component: BalanceInput, | ||
argTypes: {}, | ||
}; | ||
|
||
export const Default: React.FC = () => { | ||
const [value, setValue] = useState(1.43333); | ||
const currencyValue = `~${(value * 1.3).toLocaleString(undefined, { | ||
minimumFractionDigits: 2, | ||
maximumFractionDigits: 2, | ||
})} USD`; | ||
|
||
const handleChange = (evt) => { | ||
setValue(evt.target.value); | ||
}; | ||
|
||
return ( | ||
<Box width="300px"> | ||
<BalanceInput value={value} currencyValue={currencyValue} onChange={handleChange} placeholder="0.0" /> | ||
</Box> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export { default as BalanceInput } from "./BalanceInput"; | ||
export type { BalanceInputProps } from "./types"; |
27 changes: 27 additions & 0 deletions
27
packages/pancake-uikit/src/components/BalanceInput/styles.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import styled from "styled-components"; | ||
import Box from "../Box/Box"; | ||
import Input from "../Input/Input"; | ||
|
||
export const StyledBalanceInput = styled(Box)` | ||
background-color: ${({ theme }) => theme.colors.input}; | ||
border-radius: 16px; | ||
box-shadow: ${({ theme }) => theme.shadows.inset}; | ||
padding: 8px 16px; | ||
`; | ||
|
||
export const StyledInput = styled(Input)` | ||
background: transparent; | ||
border-radius: 0; | ||
box-shadow: none; | ||
padding-left: 0; | ||
padding-right: 0; | ||
text-align: right; | ||
::placeholder { | ||
color: ${({ theme }) => theme.colors.textSubtle}; | ||
} | ||
&:focus:not(:disabled) { | ||
box-shadow: none; | ||
} | ||
`; |
10 changes: 10 additions & 0 deletions
10
packages/pancake-uikit/src/components/BalanceInput/types.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { InputHTMLAttributes, ReactNode, ReactText } from "react"; | ||
import { BoxProps } from "../Box"; | ||
|
||
export interface BalanceInputProps extends BoxProps { | ||
value: ReactText; | ||
onChange?: InputHTMLAttributes<HTMLInputElement>["onChange"]; | ||
currencyValue?: ReactNode; | ||
placeholder?: string; | ||
inputProps?: Omit<InputHTMLAttributes<HTMLInputElement>, "value" | "placeholder" | "onChange">; | ||
} |
Oops, something went wrong.