diff --git a/.babelrc.json b/.babelrc.json index 5776fcb4..816572ae 100644 --- a/.babelrc.json +++ b/.babelrc.json @@ -14,8 +14,5 @@ ], "@babel/preset-typescript", ["@babel/preset-react", { "runtime": "automatic" }] - ], - "plugins": [ - "babel-plugin-styled-components" ] } diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 7fdaa702..6e2c4b7a 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -39,8 +39,8 @@ module.exports = { // Hacky workaround to enforce extensions in ESM imports. See: // https://github.com/import-js/eslint-plugin-import/issues/2170#issuecomment-1149473239 'import/extensions': ['error', 'always', { ts: 'never', tsx: 'never' }], - 'node/file-extension-in-import': ['error', 'always'], 'node/no-missing-import': 'off', + '@typescript-eslint/no-require-imports': 'off', }, overrides: [ { diff --git a/.github/workflows/deploy-lido-ui-v2.yml b/.github/workflows/deploy-lido-ui-v2.yml new file mode 100644 index 00000000..581175da --- /dev/null +++ b/.github/workflows/deploy-lido-ui-v2.yml @@ -0,0 +1,53 @@ +name: Deploy lido-ui-4 + +on: + push: + branches: + - lido-ui-v4 + +permissions: + contents: write + pages: write + +jobs: + deploy: + runs-on: ubuntu-latest + environment: production + env: + NODE_OPTIONS: --max_old_space_size=4096 + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + persist-credentials: false + + - name: Setup Node + uses: actions/setup-node@v3 + with: + node-version: '20' + cache: 'yarn' + + - name: Install Dependencies + run: yarn install --immutable + + - name: Build Components + run: yarn build + + # - name: Publish to NPM + # env: + # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + # NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + # run: | + # echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> ~/.npmrc + # yarn release + + - name: Build Storybook + run: yarn build-storybook + + # - name: Deploy to GitHub Pages + # uses: lidofinance/github-pages-action@v1 + # with: + # branch: gh-pages + # folder: storybook-static diff --git a/.github/workflows/test-lido-ui-v2.yml b/.github/workflows/test-lido-ui-v2.yml new file mode 100644 index 00000000..3ab1aa86 --- /dev/null +++ b/.github/workflows/test-lido-ui-v2.yml @@ -0,0 +1,173 @@ +name: Test lido-ui-v4 + +on: + workflow_dispatch: + pull_request: + branches: + - lido-ui-4 + +permissions: + contents: read + security-events: write + +env: + NODE_OPTIONS: --max_old_space_size=4096 + +jobs: + security: + uses: lidofinance/linters/.github/workflows/security.yml@master + + actions: + uses: lidofinance/linters/.github/workflows/actions.yml@master + + cache-deps: + runs-on: ubuntu-latest + steps: + - name: Checkout repo + uses: actions/checkout@v3 + with: + persist-credentials: false + + - name: Set up node + uses: actions/setup-node@v3 + with: + node-version: '20' + + - name: Restore cache + uses: actions/cache@v3 + with: + path: node_modules + key: ${{ runner.os }}-node_modules-${{ hashFiles('**/yarn.lock') }} + + - name: Install dependencies + run: yarn install --immutable + + check-types: + runs-on: ubuntu-latest + needs: cache-deps + steps: + - name: Checkout repo + uses: actions/checkout@v3 + with: + persist-credentials: false + + - name: Set up node + uses: actions/setup-node@v3 + with: + node-version: '20' + + - name: Restore cache + uses: actions/cache@v3 + with: + path: node_modules + key: ${{ runner.os }}-node_modules-${{ hashFiles('**/yarn.lock') }} + + - name: Install dependencies + run: yarn install --immutable + + - name: Check types + run: yarn types + + lint-js: + runs-on: ubuntu-latest + needs: cache-deps + steps: + - name: Checkout repo + uses: actions/checkout@v3 + with: + persist-credentials: false + + - name: Set up node + uses: actions/setup-node@v3 + with: + node-version: '20' + + - name: Restore cache + uses: actions/cache@v3 + with: + path: node_modules + key: ${{ runner.os }}-node_modules-${{ hashFiles('**/yarn.lock') }} + + - name: Install dependencies + run: yarn install --immutable + + - name: Lint JS/TS + run: yarn lint:js + + lint-css: + runs-on: ubuntu-latest + needs: cache-deps + steps: + - name: Checkout repo + uses: actions/checkout@v3 + with: + persist-credentials: false + + - name: Set up node + uses: actions/setup-node@v3 + with: + node-version: '20' + + - name: Restore cache + uses: actions/cache@v3 + with: + path: node_modules + key: ${{ runner.os }}-node_modules-${{ hashFiles('**/yarn.lock') }} + + - name: Install dependencies + run: yarn install --immutable + + - name: Lint CSS + run: yarn lint:css + + run-tests: + runs-on: ubuntu-latest + needs: cache-deps + steps: + - name: Checkout repo + uses: actions/checkout@v3 + with: + persist-credentials: false + + - name: Set up node + uses: actions/setup-node@v3 + with: + node-version: '20' + + - name: Restore cache + uses: actions/cache@v3 + with: + path: node_modules + key: ${{ runner.os }}-node_modules-${{ hashFiles('**/yarn.lock') }} + + - name: Install dependencies + run: yarn install --immutable + + - name: Run tests + run: yarn test + + demo-build: + runs-on: ubuntu-latest + needs: cache-deps + steps: + - name: Checkout repo + uses: actions/checkout@v3 + with: + persist-credentials: false + + - name: Set up node + uses: actions/setup-node@v3 + with: + node-version: '20' + + - name: Restore cache + uses: actions/cache@v3 + with: + path: node_modules + key: ${{ runner.os }}-node_modules-${{ hashFiles('**/yarn.lock') }} + + - name: Install dependencies + run: yarn install --immutable + + - name: Try to build + run: yarn build \ No newline at end of file diff --git a/.releaserc.cjs b/.releaserc.cjs index a2849ab3..35b49d1c 100644 --- a/.releaserc.cjs +++ b/.releaserc.cjs @@ -1,6 +1,6 @@ module.exports = { branches: [ - { name: 'main' }, + { name: 'lido-ui-v4' }, { name: 'next', channel: 'next', prerelease: true }, ], plugins: [ diff --git a/.storybook/components/WithThemeProvider.tsx b/.storybook/components/WithThemeProvider.tsx index 61e5aa5f..aa86cd60 100644 --- a/.storybook/components/WithThemeProvider.tsx +++ b/.storybook/components/WithThemeProvider.tsx @@ -1,17 +1,6 @@ import { Decorator } from '@storybook/react' -import { createGlobalStyle } from 'styled-components' -import { CookieThemeProvider, ThemeName } from '../../packages/theme/index.js' - -const GlobalStyle = createGlobalStyle` - body { - padding: 0 !important; - display: flex; - } - - html, body, #root { - min-height: 100vh; - } -` +import { ThemeName } from '../../packages/theme-css/constants' +import { CookieThemeProvider } from '../../packages/theme-css/cookie-theme-provider' export const WithThemeProvider: Decorator<{ themeOverride?: ThemeName | 'follow cookie and system' @@ -24,7 +13,6 @@ export const WithThemeProvider: Decorator<{ : args.themeOverride } > -
({ - base, - - colorPrimary: theme.colors.primary, - - // UI - appBg: theme.colors.background, - appContentBg: theme.colors.background, - appBorderRadius: 8, - - // Typography - fontBase: - 'Manrope, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen, Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif', - - // Text - textColor: theme.colors.text, - - // Form - inputBorderRadius: 8, - - // Brand - brandTitle: 'Lido UI', - brandImage: `/images/lido-${base}.svg`, -}) - -export const light = create(constructor('light', themeLight)) -export const dark = create(constructor('dark', themeDark)) - -export default { - darkMode: { - dark, - light, - }, -} diff --git a/.storybook/viewport.ts b/.storybook/viewport.ts deleted file mode 100644 index 013eeca5..00000000 --- a/.storybook/viewport.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { themeDefault } from '../packages/theme/index.js' - -const { breakpointsMap } = themeDefault - -const themeViewports = Object.keys(breakpointsMap).reduce( - (viewports, breakpoint: keyof typeof breakpointsMap) => ({ - ...viewports, - [breakpoint]: { - name: breakpoint, - styles: breakpointsMap[breakpoint], - }, - }), - {}, -) - -export default { - viewport: { viewports: themeViewports }, -} diff --git a/.stylelintrc b/.stylelintrc index b9dc69f4..5e353663 100644 --- a/.stylelintrc +++ b/.stylelintrc @@ -5,10 +5,20 @@ "plugins": [ "stylelint-prettier" ], - "customSyntax": "postcss-styled-syntax", + "ignoreFiles": [ + "dist/**/*" + ], "rules": { "prettier/prettier": true, "custom-property-pattern": null, - "no-empty-source": null + "no-empty-source": null, + "selector-class-pattern": null, + "no-descending-specificity": null, + "property-no-unknown": [ + true, + { + "ignoreProperties": ["composes"] + } + ] } } diff --git a/README.md b/README.md index 522f055b..a3524da3 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -# Lido UI Components +# Lido UI Components v4 -> React components for Lido Finance projects. +> React components (v4) for Lido Finance projects. Check out our Storybook at [https://ui.lido.fi](https://ui.lido.fi) @@ -65,35 +65,8 @@ yarn build yarn dev ``` -### Adding a new package - -#### Add files - -1. Add a new package directory into the `packages` dir. -2. Add `package.json`, check other packages to find out what you can copy from their `package.json` files. -3. Fill in correctly the `name` field in the `package.json`. -4. Add `README.md` and `LICENSE.txt`. You can copy `tsconfig.json` and `.npmignore` from other packages. -5. Add the `src` directory, where the package's code will be placed. - -#### Run commands in the following order - -``` -yarn combine -``` - -It triggers a script, which updates the main `lido-ui` package. The script finds all packages, including the new one, -and adds them to dependencies of `lido-ui` and to exports in its index file. - -``` -yarn install && yarn build -``` - ## Publishing Packages are automatically published to npm when you push to master. The publication is based on [semantic-release](https://github.com/semantic-release/semantic-release) and [@qiwi/multi-semantic-release](https://github.com/qiwi/multi-semantic-release). For correct version detection, please follow the [conventional commit format](https://www.conventionalcommits.org/en/v1.0.0/). - -## Linking - -To include a local version of modified lido in your project, run `yarn link` in `packages/lido` and run `yarn link lido` in project you want to use it in. Make sure to run `yarn unlink lido` after it's no longer needed. diff --git a/RELEASES.md b/RELEASES.md index e5ac2c73..260068d6 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -2,7 +2,7 @@ ## Overview -[Release workflow](https://github.com/lidofinance/ui/blob/main/.github/workflows/deploy.yml) is triggered automatically on pushes to `main`. It will: +[Release workflow](https://github.com/lidofinance/ui/blob/main/.github/workflows/deploy.yml) is triggered automatically on pushes to `lido-ui-v4`. It will: - Build all packages - Run tests diff --git a/global.d.ts b/global.d.ts new file mode 100644 index 00000000..6c344ed3 --- /dev/null +++ b/global.d.ts @@ -0,0 +1 @@ +declare module '*.module.css' diff --git a/package.json b/package.json index 528e55b0..eb9e5857 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@lidofinance/lido-ui", - "version": "3.0.0-next.17", + "version": "4.0.0-canary", "homepage": "https://github.com/lidofinance/ui", "repository": { "type": "git", @@ -34,27 +34,25 @@ "lint:fix": "set +e; yarn lint:js:fix; yarn lint:css:fix; set -e", "lint:js": "eslint .", "lint:js:fix": "eslint --fix .", - "lint:css": "stylelint '**/*Styles.tsx'", - "lint:css:fix": "yarn lint:css --fix", + "lint:css": "stylelint '**/*.css'", + "lint:css:fix": "yarn lint:css --fix", "types": "tsc --noEmit", "prepare": "husky install", "release": "semantic-release", "release:dry": "yarn release --dry-run", - "icons:convert": "node ./packages/icons/converter/index.js" + "icons:convert": "node ./packages/icons/converter/index.cjs" }, "peerDependencies": { "react": "16 || 17 || 18", "react-dom": "16 || 17 || 18", - "react-is": "16 || 17 || 18", - "styled-components": "^5.3.5" + "react-is": "16 || 17 || 18" }, "dependencies": { - "@styled-system/should-forward-prop": "5.1.5", + "classnames": "^2.5.1", "react-collapsed": "3.0.2", "react-jazzicon": "^1.0.4", "react-toastify": "7.0.4", "react-transition-group": "4", - "styled-system": "5.1.5", "ua-parser-js": "^1.0.35", "use-callback-ref": "1.2.5" }, @@ -87,13 +85,10 @@ "@types/react-dom": "18.0.6", "@types/react-is": "17.0.2", "@types/react-transition-group": "^4.4.6", - "@types/styled-components": "^5.1.26", - "@types/styled-system": "^5.1.16", - "@types/styled-system__should-forward-prop": "^5.1.2", "@types/ua-parser-js": "^0.7.36", "@typescript-eslint/eslint-plugin": "^5.36.1", "@typescript-eslint/parser": "^5.36.1", - "babel-plugin-styled-components": "^2.1.4", + "autoprefixer": "^10.4.20", "browserslist": "^4.21.10", "conventional-changelog-conventionalcommits": "4.6.3", "eslint": "8.46.0", @@ -112,27 +107,26 @@ "jest-haste-map": "^29.0.1", "jest-resolve": "^29.0.1", "jest-runner": "^29.0.1", - "jest-styled-components": "^7.1.1", "lint-staged": "11.1.2", "postcss": "^8.4.27", - "postcss-styled-syntax": "^0.4.0", "prettier": "^3.0.1", "react": "18.2.0", "react-dom": "18.2.0", "react-is": "18.2.0", "rimraf": "3.0.2", "rollup": "3.29.1", + "rollup-plugin-postcss": "^4.0.2", "semantic-release": "^19.0.5", "storybook": "^7.2.3", "storybook-addon-swc": "^1.2.0", "storybook-dark-mode": "^3.0.1", - "styled-components": "^5.3.5", "stylelint": "^15.10.2", "stylelint-config-standard": "^34.0.0", "stylelint-prettier": "^4.0.2", "ts-jest": "^29.1.1", "tslib": "2.3.1", - "typescript": "4.8", + "typescript": "4.9", + "typescript-plugin-css-modules": "^5.1.0", "zx": "^7.0.8" } } diff --git a/packages/accordion/Accordion.stories.tsx b/packages/accordion/Accordion.stories.tsx deleted file mode 100644 index 3bbff831..00000000 --- a/packages/accordion/Accordion.stories.tsx +++ /dev/null @@ -1,80 +0,0 @@ -import { StoryFn, Meta } from '@storybook/react' -import { Accordion, AccordionProps } from './index.js' - -export default { - component: Accordion, - title: 'Layout/Accordion', -} as Meta - -export const Basic: StoryFn = (props: AccordionProps) => ( - - Liquid staking protocols allow users to earn staking rewards without locking - assets or maintaining staking infrastructure. Users of these protocols can - deposit staking tokens and receive tradable liquid tokens in return. The DAO - controlled smart contract then stakes tokens with DAO-picked staking - providers. Users' deposited funds are controlled by the DAO, staking - providers never have direct access to the users' assets. - -) - -Basic.args = { - defaultExpanded: false, - summary: 'What is Liquid Staking?', -} - -Basic.argTypes = { - defaultExpanded: { - description: 'Accordion default state', - }, - summary: { - description: 'Summary title', - }, -} - -export const List: StoryFn = () => ( - <> - -

- Liquid staking protocols allow users to earn staking rewards without - locking assets or maintaining staking infrastructure. Users of these - protocols can deposit staking tokens and receive tradable liquid tokens - in return. The DAO controlled smart contract then stakes tokens with - DAO-picked staking providers. Users' deposited funds are controlled - by the DAO, staking providers never have direct access to the users' - assets. -

-
- -

- When staking with Lido, users receive stETH tokens on a 1:1 basis - representing their staked ETH. stETH balances can be used like regular - ETH to earn yields and lending rewards, and are updated on a daily basis - to reflect your ETH staking rewards. Note that there are no lock-ups or - minimum deposits when staking with Lido. -

-

- When using Lido, users receive secure staking rewards in real-time, - allowing for participation in the securing of Ethereum without the - associated risks and downside potential. -

-
- -

Lido is a secure liquid staking solution for a number of reasons:

-
    -
  • Open-sourcing & continuous review of all code.
  • -
  • - Committee of elected, best-in-class validators to minimise staking - risk. -
  • -
  • - Use of non-custodial staking service to eliminate counterparty risk. -
  • -
  • Use of DAO for governance decisions & to manage risk factors.
  • -
-

- Usually when staking ETH you choose only one validator. In the case of - Lido you stake across many validators, minimising your staking risk. -

-
- -) diff --git a/packages/accordion/Accordion.tsx b/packages/accordion/Accordion.tsx deleted file mode 100644 index 3671d042..00000000 --- a/packages/accordion/Accordion.tsx +++ /dev/null @@ -1,43 +0,0 @@ -import { ForwardedRef, forwardRef } from 'react' -import { AccordionProps } from './types.js' -import { - AccordionStyle, - AccordionSummaryStyle, - AccordionTitleStyle, - AccordionArrowStyle, - AccordionContentStyle, -} from './AccordionStyles.js' -import { useExpanded } from './useExpanded.js' - -export const Accordion = forwardRef( - ( - { - defaultExpanded, - summary, - children, - onExpand, - onCollapse, - ...rest - }: AccordionProps, - ref?: ForwardedRef, - ) => { - const { toggleProps, collapseProps, isExpanded } = useExpanded({ - defaultExpanded, - onExpand, - onCollapse, - }) - - return ( - - - {summary} - - -
- {children} -
-
- ) - }, -) -Accordion.displayName = 'Accordion' diff --git a/packages/accordion/AccordionStyles.tsx b/packages/accordion/AccordionStyles.tsx deleted file mode 100644 index 55188aa0..00000000 --- a/packages/accordion/AccordionStyles.tsx +++ /dev/null @@ -1,71 +0,0 @@ -import styled from '../utils/styled-components-wrapper.js' -import { ArrowBottom } from '../icons/index.js' - -export const AccordionStyle = styled.div` - margin: 0 0 ${({ theme }) => theme.spaceMap.sm}px 0; - background: var(--lido-color-foreground); - border-radius: ${({ theme }) => theme.borderRadiusesMap.xl}px; -` - -export const AccordionSummaryStyle = styled.div` - padding: ${({ theme }) => theme.spaceMap.lg}px - ${({ theme }) => theme.spaceMap.xxl}px; - cursor: pointer; - display: flex; - align-items: center; - outline: none; - min-height: 40px; - box-sizing: content-box; - - ${({ theme }) => theme.mediaQueries.md} { - padding: ${({ theme }) => theme.spaceMap.lg}px; - } -` - -export const AccordionTitleStyle = styled.div` - color: var(--lido-color-text); - flex-grow: 1; - font-weight: 800; - font-size: ${({ theme }) => theme.fontSizesMap.xs}px; - line-height: 1.6em; -` - -export const AccordionArrowStyle = styled(ArrowBottom)<{ $expanded: boolean }>` - flex-shrink: 0; - transform: rotate(${(props) => (props.$expanded ? 180 : 0)}deg); - transition: transform ${({ theme }) => theme.duration.norm} ease; - margin: -2px; - margin-left: ${({ theme }) => theme.spaceMap.md}px; - fill: var(--lido-color-textSecondary); -` - -export const AccordionContentStyle = styled.div` - color: var(--lido-color-textSecondary); - padding: ${({ theme }) => theme.spaceMap.xxl}px; - padding-top: 0; - font-weight: 400; - font-size: ${({ theme }) => theme.fontSizesMap.xxs}px; - line-height: 1.6em; - - ${({ theme }) => theme.mediaQueries.md} { - padding: ${({ theme }) => theme.spaceMap.lg}px; - padding-top: 0; - } - - p, - ul, - ol { - margin: 0 0 1.6em; - - &:last-child { - margin-bottom: 0; - } - } - - /* stylelint-disable-next-line no-descending-specificity */ - ul, - /* stylelint-disable-next-line no-descending-specificity */ - ol { - padding: 0 0 0 1.5em; - } -` diff --git a/packages/accordion/index.ts b/packages/accordion/index.ts deleted file mode 100644 index cecd178b..00000000 --- a/packages/accordion/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './Accordion.js' -export * from './types.js' diff --git a/packages/accordion/types.ts b/packages/accordion/types.ts deleted file mode 100644 index 459ec8ff..00000000 --- a/packages/accordion/types.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { LidoComponentProps } from '../utils/index.js' -import { ReactNode } from 'react' -export type { Theme } from '../theme/index.js' - -export type AccordionProps = LidoComponentProps< - 'div', - { - defaultExpanded?: boolean - summary: ReactNode - onExpand?: () => void - onCollapse?: () => void - } -> diff --git a/packages/accordion/useExpanded.ts b/packages/accordion/useExpanded.ts deleted file mode 100644 index af2cba18..00000000 --- a/packages/accordion/useExpanded.ts +++ /dev/null @@ -1,47 +0,0 @@ -import { useCallback, useEffect, useState } from 'react' -import { AccordionProps } from './types.js' -import _useCollapse from 'react-collapsed' -import { - GetCollapsePropsOutput, - GetTogglePropsOutput, -} from 'react-collapsed/dist/types.js' - -//@ts-expect-error Property default doesn't exist on type -const useCollapse: typeof _useCollapse = _useCollapse.default || _useCollapse - -type UseExpanded = ( - props: Pick, -) => { - toggleProps: GetTogglePropsOutput - collapseProps: GetCollapsePropsOutput - isExpanded: boolean -} - -export const useExpanded: UseExpanded = ({ - defaultExpanded = false, - onExpand, - onCollapse, -}) => { - const [isExpanded, setExpanded] = useState(defaultExpanded) - - useEffect(() => { - setExpanded(defaultExpanded) - }, [defaultExpanded]) - - const handleToggle = useCallback( - () => setExpanded((previous) => !previous), - [], - ) - - const { getToggleProps, getCollapseProps } = useCollapse({ - isExpanded, - onExpandEnd: onExpand, - onCollapseEnd: onCollapse, - }) - - return { - toggleProps: getToggleProps({ onClick: handleToggle }), - collapseProps: getCollapseProps(), - isExpanded, - } -} diff --git a/packages/address/Address.stories.tsx b/packages/address/Address.stories.tsx deleted file mode 100644 index f70bc95a..00000000 --- a/packages/address/Address.stories.tsx +++ /dev/null @@ -1,18 +0,0 @@ -import { StoryFn, Meta } from '@storybook/react' -import { Address, AddressProps } from './index.js' - -export default { - component: Address, - title: 'Wallet/Address', - args: { - address: '0x5a98fcbea516cf06857215779fd812ca3bef1b32', - symbols: 3, - }, - argTypes: { - symbols: { - control: { type: 'range', min: 3, max: 21, step: 1 }, - }, - }, -} as Meta - -export const Basic: StoryFn = (props) =>
diff --git a/packages/address/Address.tsx b/packages/address/Address.tsx deleted file mode 100644 index 62e77543..00000000 --- a/packages/address/Address.tsx +++ /dev/null @@ -1,25 +0,0 @@ -import { ForwardedRef, forwardRef } from 'react' -import { AddressProps } from './types.js' -import { - AddressStyle, - AddressFullStyle, - AddressTrimmedStyle, -} from './AddressStyles.js' -import { trimAddress } from './trimAddress.js' - -export const Address = forwardRef( - ( - { symbols = 3, address, ...rest }: AddressProps, - ref?: ForwardedRef, - ) => { - return ( - - {address} - - {trimAddress(address, symbols)} - - - ) - }, -) -Address.displayName = 'Address' diff --git a/packages/address/AddressStyles.tsx b/packages/address/AddressStyles.tsx deleted file mode 100644 index bee86445..00000000 --- a/packages/address/AddressStyles.tsx +++ /dev/null @@ -1,19 +0,0 @@ -import styled from '../utils/styled-components-wrapper.js' - -export const AddressStyle = styled.div` - position: relative; - display: inline-block; - font-weight: 400; -` - -export const AddressFullStyle = styled.span` - position: absolute; - overflow: hidden; - inset: 0; - color: transparent; -` - -export const AddressTrimmedStyle = styled.span` - user-select: none; - pointer-events: none; -` diff --git a/packages/address/index.ts b/packages/address/index.ts deleted file mode 100644 index 46521523..00000000 --- a/packages/address/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './Address.js' -export * from './trimAddress.js' -export * from './types.js' diff --git a/packages/address/trimAddress.ts b/packages/address/trimAddress.ts deleted file mode 100644 index cd316f87..00000000 --- a/packages/address/trimAddress.ts +++ /dev/null @@ -1,9 +0,0 @@ -export const trimAddress = (address: string, symbols: number): string => { - if (symbols <= 0) return '' - if (symbols * 2 >= address.length) return address - - const left = address.slice(0, symbols) - const right = address.slice(-symbols) - - return `${left}...${right}` -} diff --git a/packages/address/types.ts b/packages/address/types.ts deleted file mode 100644 index e682a542..00000000 --- a/packages/address/types.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { LidoComponentProps } from '../utils/index.js' - -export type AddressProps = LidoComponentProps< - 'div', - { - address: string - symbols?: number - } -> diff --git a/packages/addressBadge/AddressBadge.stories.tsx b/packages/addressBadge/AddressBadge.stories.tsx deleted file mode 100644 index 0ddf0aef..00000000 --- a/packages/addressBadge/AddressBadge.stories.tsx +++ /dev/null @@ -1,24 +0,0 @@ -import { StoryFn, Meta } from '@storybook/react' -import { AddressBadge, AddressBadgeProps } from './index.js' - -export default { - component: AddressBadge, - title: 'Wallet/AddressBadge', - args: { - address: '0x5a98fcbea516cf06857215779fd812ca3bef1b32', - symbolsMobile: 3, - symbolsDesktop: 6, - }, - argTypes: { - symbolsMobile: { - control: { type: 'range', min: 3, max: 21, step: 1 }, - }, - symbolsDesktop: { - control: { type: 'range', min: 3, max: 21, step: 1 }, - }, - }, -} as Meta - -export const Basic: StoryFn = (props) => ( - -) diff --git a/packages/addressBadge/AddressBadge.tsx b/packages/addressBadge/AddressBadge.tsx deleted file mode 100644 index d5114fde..00000000 --- a/packages/addressBadge/AddressBadge.tsx +++ /dev/null @@ -1,28 +0,0 @@ -import { ForwardedRef, forwardRef } from 'react' -import { useBreakpoint } from '../hooks/useBreakpoint.js' -import { AddressBadgeStyle } from './AddressBadgeStyles.js' -import { AddressBadgeProps } from './types.js' - -export const AddressBadge = forwardRef( - ( - { - address, - symbolsMobile = 3, - symbolsDesktop = 6, - ...rest - }: AddressBadgeProps, - ref?: ForwardedRef, - ) => { - const isMobile = useBreakpoint('md') - - return ( - - ) - }, -) -AddressBadge.displayName = 'AddressBadge' diff --git a/packages/addressBadge/AddressBadgeStyles.tsx b/packages/addressBadge/AddressBadgeStyles.tsx deleted file mode 100644 index 95f762bc..00000000 --- a/packages/addressBadge/AddressBadgeStyles.tsx +++ /dev/null @@ -1,18 +0,0 @@ -import styled from '../utils/styled-components-wrapper.js' -import { IdenticonBadge } from '../identicon/index.js' - -export const AddressBadgeStyle = styled(IdenticonBadge)` - max-width: 100%; - box-sizing: border-box; - overflow: hidden; - - & > * { - flex-shrink: 0; - } - - & > :first-child { - flex-shrink: 1; - overflow: hidden; - text-overflow: ellipsis; - } -` diff --git a/packages/addressBadge/index.ts b/packages/addressBadge/index.ts deleted file mode 100644 index 07834e0b..00000000 --- a/packages/addressBadge/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './AddressBadge.js' -export * from './types.js' diff --git a/packages/addressBadge/types.ts b/packages/addressBadge/types.ts deleted file mode 100644 index f1b2cbb6..00000000 --- a/packages/addressBadge/types.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { IdenticonBadgeProps } from '../identicon/index.js' - -export type AddressBadgeProps = Omit< - IdenticonBadgeProps, - 'address' | 'symbol' | 'as' | 'forwardedAs' -> & { - address?: string - symbolsMobile?: number - symbolsDesktop?: number -} diff --git a/packages/block/Block.tsx b/packages/block/Block.tsx deleted file mode 100644 index e28dc9c9..00000000 --- a/packages/block/Block.tsx +++ /dev/null @@ -1,26 +0,0 @@ -import { ForwardedRef, forwardRef } from 'react' -import { BlockStyle } from './BlockStyles.js' -import { BlockProps } from './types.js' - -export const Block = forwardRef( - ( - { - color = 'foreground', - variant = 'flat', - paddingLess = false, - ...rest - }: BlockProps, - ref?: ForwardedRef, - ) => { - return ( - - ) - }, -) -Block.displayName = 'Block' diff --git a/packages/block/BlockStyles.tsx b/packages/block/BlockStyles.tsx deleted file mode 100644 index b66630e7..00000000 --- a/packages/block/BlockStyles.tsx +++ /dev/null @@ -1,56 +0,0 @@ -import styled, { css } from '../utils/styled-components-wrapper.js' -import { Theme } from '../theme/index.js' -import { BlockVariants, BlockColors } from './types.js' - -type InjectedProps = { - $variant: BlockVariants - $color: BlockColors - $paddingLess: boolean - theme: Theme -} - -const colors = { - foreground: css` - background: var(--lido-color-foreground); - color: var(--lido-color-textSecondary); - `, - background: css` - background: var(--lido-color-background); - color: var(--lido-color-textSecondary); - `, - accent: css` - background: var(--lido-color-accent); - color: var(--lido-color-accentContrast); - `, -} - -const variants = { - flat: css` - box-shadow: none; - `, - shadow: css` - box-shadow: ${({ theme }) => theme.boxShadows.lg} - var(--lido-colors-shadowLight); - `, -} - -const paddings = css` - padding: ${({ theme }) => theme.spaceMap.xxl}px; - - ${({ theme }) => theme.mediaQueries.md} { - padding: ${({ theme }) => theme.spaceMap.lg}px; - } -` - -export const BlockStyle = styled.div` - font-weight: 400; - font-size: ${({ theme }) => theme.fontSizesMap.xxs}px; - line-height: 1.6em; - border-radius: ${({ theme }) => theme.borderRadiusesMap.xl}px; - margin: 0; - - ${({ $paddingLess }) => !$paddingLess && paddings} - - ${({ $variant }) => variants[$variant]} - ${({ $color }) => colors[$color]} -` diff --git a/packages/block/block.module.css b/packages/block/block.module.css new file mode 100644 index 00000000..b0c2e4bb --- /dev/null +++ b/packages/block/block.module.css @@ -0,0 +1,38 @@ +.foreground { + background: var(--lido-color-foreground); + color: var(--lido-color-text-secondary); +} + +.background { + background: var(--lido-color-background); + color: var(--lido-color-text-secondary); +} + +.accent { + background: var(--lido-color-accent); + color: var(--lido-color-accent-contrast); +} + +.flat { + box-shadow: none; +} + +.shadow { + box-shadow: var(--lido-shadows-lg) var(--lido-color-shadow-light); +} + +.padding { + padding: var(--lido-space-lg); + + @media (--lido-media-breakpoint-up-md) { + padding: var(--lido-space-xxl); + } +} + +.block { + font-weight: 400; + font-size: var(--lido-font-size-xxs); + line-height: 1.6em; + border-radius: var(--lido-border-radius-xl); + margin: 0; +} diff --git a/packages/block/Block.stories.tsx b/packages/block/block.stories.tsx similarity index 88% rename from packages/block/Block.stories.tsx rename to packages/block/block.stories.tsx index 3ef3b93d..f0e296d6 100644 --- a/packages/block/Block.stories.tsx +++ b/packages/block/block.stories.tsx @@ -1,5 +1,5 @@ import { StoryFn, Meta } from '@storybook/react' -import { Block, BlockProps, BlockColor, BlockVariant } from './index.js' +import { Block, BlockProps, BlockColor, BlockVariant } from '.' const getOptions = (enumObject: Record) => Object.values(enumObject).filter((value) => typeof value === 'string') @@ -23,6 +23,6 @@ export default { control: 'inline-radio', }, }, -} as Meta +} satisfies Meta export const Basic: StoryFn = (props) => diff --git a/packages/block/block.tsx b/packages/block/block.tsx new file mode 100644 index 00000000..d2992387 --- /dev/null +++ b/packages/block/block.tsx @@ -0,0 +1,51 @@ +import { ComponentPropsWithoutRef, ForwardedRef, forwardRef } from 'react' +import cn from 'classnames' +import styles from './block.module.css' + +export enum BlockVariant { + flat, + shadow, +} +export type BlockVariants = keyof typeof BlockVariant + +export enum BlockColor { + foreground, + background, + accent, +} +export type BlockColors = keyof typeof BlockColor + +export type BlockProps = ComponentPropsWithoutRef<'div'> & { + color?: BlockColors + variant?: BlockVariants + paddingLess?: boolean +} + +export const Block = forwardRef( + ( + { + color = 'foreground', + variant = 'flat', + paddingLess = false, + className, + ...rest + }: BlockProps, + ref?: ForwardedRef, + ) => { + return ( +
+ ) + }, +) +Block.displayName = 'Block' diff --git a/packages/block/index.ts b/packages/block/index.ts index 1a232cf3..8739b3fb 100644 --- a/packages/block/index.ts +++ b/packages/block/index.ts @@ -1,2 +1 @@ -export * from './Block.js' -export * from './types.js' +export * from './block' diff --git a/packages/block/types.tsx b/packages/block/types.tsx deleted file mode 100644 index e3cf87db..00000000 --- a/packages/block/types.tsx +++ /dev/null @@ -1,24 +0,0 @@ -import { LidoComponentProps } from '../utils/index.js' -export type { Theme } from '../theme/index.js' - -export enum BlockVariant { - flat, - shadow, -} -export type BlockVariants = keyof typeof BlockVariant - -export enum BlockColor { - foreground, - background, - accent, -} -export type BlockColors = keyof typeof BlockColor - -export type BlockProps = LidoComponentProps< - 'div', - { - color?: BlockColors - variant?: BlockVariants - paddingLess?: boolean - } -> diff --git a/packages/box/Box.stories.tsx b/packages/box/Box.stories.tsx deleted file mode 100644 index 619c9ce9..00000000 --- a/packages/box/Box.stories.tsx +++ /dev/null @@ -1,28 +0,0 @@ -import { StoryFn, Meta } from '@storybook/react' -import { Box } from './index.js' - -export default { - component: Box, - title: 'Styled System/Box', -} as Meta - -export const Basic: StoryFn = (props) => ( - -) - -export const Breakpoints: StoryFn = (props) => ( - - Example - -) diff --git a/packages/box/Box.tsx b/packages/box/Box.tsx deleted file mode 100644 index 8c7bd360..00000000 --- a/packages/box/Box.tsx +++ /dev/null @@ -1,4 +0,0 @@ -import styled from '../utils/styled-components-wrapper.js' -import { withStyledSystem } from '../styled-system/index.js' - -export const Box = withStyledSystem(styled.div``) diff --git a/packages/box/index.ts b/packages/box/index.ts deleted file mode 100644 index d7babce6..00000000 --- a/packages/box/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './Box.js' diff --git a/packages/button/Button.stories.tsx b/packages/button/Button.stories.tsx deleted file mode 100644 index 2837d5a8..00000000 --- a/packages/button/Button.stories.tsx +++ /dev/null @@ -1,60 +0,0 @@ -import { StoryFn, Meta } from '@storybook/react' -import { Whitepaper } from '../icons/index.js' -import { - Button, - ButtonIcon, - ButtonProps, - ButtonIconProps, - ButtonColor, - ButtonSize, - ButtonVariant, -} from '.' - -const getOptions = (enumObject: Record) => - Object.values(enumObject).filter((value) => typeof value === 'string') - -export default { - component: Button, - title: 'Controls/Button', - args: { - size: 'md', - variant: 'filled', - color: 'primary', - disabled: false, - fullwidth: false, - loading: false, - children: 'Example', - }, - argTypes: { - size: { - options: getOptions(ButtonSize), - control: 'inline-radio', - }, - variant: { - options: getOptions(ButtonVariant), - control: 'inline-radio', - }, - color: { - options: getOptions(ButtonColor), - control: 'inline-radio', - }, - }, -} as Meta - -export const Basic: StoryFn = (props) => - , - ) - - expect(container.firstChild?.firstChild).toMatchSnapshot() -}) diff --git a/packages/button/Button.tsx b/packages/button/Button.tsx deleted file mode 100644 index e438723c..00000000 --- a/packages/button/Button.tsx +++ /dev/null @@ -1,60 +0,0 @@ -import { ForwardedRef, forwardRef } from 'react' -import { - ButtonStyle, - ButtonContentStyle, - ButtonLoaderStyle, -} from './ButtonStyles.js' -import { ButtonProps } from './types.js' -import { useRipple } from './useRipple.js' - -const loaderSizes = { - xxs: 'small', - xs: 'small', - sm: 'small', - md: 'medium', - lg: 'medium', -} as const - -export const Button = forwardRef( - ( - { - size = 'md', - variant = 'filled', - color = 'primary', - square = false, - fullwidth = false, - loading = false, - active = false, - onClick, - disabled, - children, - ...rest - }: ButtonProps, - ref?: ForwardedRef, - ) => { - const { handleClick, ripple } = useRipple({ onClick }) - const loaderSize = loaderSizes[size] - - return ( - - {children} - {loading && } - {!active && ripple} - - ) - }, -) -Button.displayName = 'Butotn' diff --git a/packages/button/ButtonIcon.tsx b/packages/button/ButtonIcon.tsx deleted file mode 100644 index 8fec43e2..00000000 --- a/packages/button/ButtonIcon.tsx +++ /dev/null @@ -1,27 +0,0 @@ -import { ForwardedRef, forwardRef } from 'react' -import { - ButtonWrapperStyle, - ButtonIconStyle, - ButtonContentStyle, -} from './ButtonIconStyles.js' -import { ButtonIconProps } from './types.js' -import { Button } from './Button.js' - -export const ButtonIcon = forwardRef( - ( - { icon, children, ...rest }: ButtonIconProps, - ref?: ForwardedRef, - ) => { - const hasNoChildren = !children - - return ( - - ) - }, -) -ButtonIcon.displayName = 'ButtonIcon' diff --git a/packages/button/ButtonIconStyles.tsx b/packages/button/ButtonIconStyles.tsx deleted file mode 100644 index 183ad9b3..00000000 --- a/packages/button/ButtonIconStyles.tsx +++ /dev/null @@ -1,27 +0,0 @@ -import styled from '../utils/styled-components-wrapper.js' - -export const ButtonWrapperStyle = styled.span` - display: flex; - align-items: center; - justify-content: center; - min-height: 1em; - min-width: 1em; -` - -export const ButtonIconStyle = styled.span<{ $square: boolean }>` - margin: ${({ $square }) => ($square ? '-12px' : '-12px -6px')}; - line-height: 0; - flex-shrink: 0; - - svg { - fill: currentcolor; - } -` - -export const ButtonContentStyle = styled.span` - margin-left: 10px; - - :empty { - display: none; - } -` diff --git a/packages/button/ButtonStyles.tsx b/packages/button/ButtonStyles.tsx deleted file mode 100644 index 35d7fd4c..00000000 --- a/packages/button/ButtonStyles.tsx +++ /dev/null @@ -1,240 +0,0 @@ -import styled, { css, keyframes } from '../utils/styled-components-wrapper.js' -import { Theme } from '../theme/index.js' -import { Loader } from '../loaders/index.js' -import { ButtonColors, ButtonSizes, ButtonVariants } from './types.js' - -type InjectedProps = { - $color: ButtonColors - $size: ButtonSizes - $variant: ButtonVariants - $fullwidth: boolean - $square: boolean - $loading: boolean - $active: boolean - theme: Theme -} - -const sizes = { - xxs: css` - line-height: 1em; - font-size: ${({ theme }) => theme.fontSizesMap.xxxs}px; - border-radius: ${({ theme }) => theme.borderRadiusesMap.sm}px; - padding: ${({ $square }) => ($square ? '11px' : '11px 16px')}; - min-width: ${({ $square }) => ($square ? '0' : '50px')}; - `, - xs: css` - line-height: 1em; - font-size: ${({ theme }) => theme.fontSizesMap.xxs}px; - border-radius: ${({ theme }) => theme.borderRadiusesMap.sm}px; - padding: ${({ $square }) => ($square ? '10px' : '10px 16px')}; - min-width: ${({ $square }) => ($square ? '0' : '60px')}; - `, - sm: css` - line-height: 1em; - font-size: ${({ theme }) => theme.fontSizesMap.xs}px; - border-radius: ${({ theme }) => theme.borderRadiusesMap.sm}px; - padding: ${({ $square }) => ($square ? '16px' : '16px 24px')}; - min-width: ${({ $square }) => ($square ? '0' : '100px')}; - `, - md: css` - line-height: 1em; - font-size: ${({ theme }) => theme.fontSizesMap.xs}px; - border-radius: ${({ theme }) => theme.borderRadiusesMap.lg}px; - padding: ${({ $square }) => ($square ? '21px' : '21px 44px')}; - min-width: ${({ $square }) => ($square ? '0' : '120px')}; - `, - lg: css` - line-height: 1em; - font-size: ${({ theme }) => theme.fontSizesMap.sm}px; - border-radius: ${({ theme }) => theme.borderRadiusesMap.lg}px; - box-shadow: ${({ theme }) => theme.boxShadows.md} - var(--lido-color-shadowDark); - padding: ${({ $square }) => ($square ? '24px' : '24px 64px')}; - min-width: ${({ $square }) => ($square ? '0' : '160px')}; - `, -} - -const getMainColor = (props: InjectedProps) => { - const colorsMap = { - primary: `var(--lido-color-primary)`, - secondary: `var(--lido-color-secondary)`, - warning: `var(--lido-color-warning)`, - error: `var(--lido-color-error)`, - success: `var(--lido-color-success)`, - } - return colorsMap[props.$color] -} - -const getContrastColor = (props: InjectedProps) => { - const colorsMap = { - primary: `var(--lido-color-primaryContrast)`, - secondary: `var(--lido-color-secondaryContrast)`, - warning: `var(--lido-color-warningContrast)`, - error: `var(--lido-color-errorContrast)`, - success: `var(--lido-color-successContrast)`, - } - return colorsMap[props.$color] -} - -const getHoverColor = (props: InjectedProps) => { - const colorsMap = { - primary: `var(--lido-color-primaryHover)`, - secondary: `var(--lido-color-secondaryHover)`, - warning: `var(--lido-color-warningHover)`, - error: `var(--lido-color-errorHover)`, - success: `var(--lido-color-successHover)`, - } - return colorsMap[props.$color] -} - -const variants = { - filled: css` - color: ${getContrastColor}; - background-color: ${getMainColor}; - transition: background-color ${({ theme }) => theme.duration.fast} ease; - - :not(:disabled):hover, - :focus-visible { - background-color: ${getHoverColor}; - } - `, - outlined: css` - color: ${getMainColor}; - transition: - background-color ${({ theme }) => theme.duration.fast} ease, - color ${({ theme }) => theme.duration.fast} ease; - - ::before { - display: block; - border: 1px solid ${getMainColor}; - } - - :not(:disabled):hover, - :focus-visible { - background-color: ${getHoverColor}; - color: ${getContrastColor}; - } - `, - text: css` - color: ${getMainColor}; - background-color: var(--lido-color-foreground); - - ::before { - display: block; - background-color: ${getMainColor}; - transition: opacity ${({ theme }) => theme.duration.fast} ease; - opacity: 0; - } - - :not(:disabled):hover, - :focus-visible { - /* stylelint-disable-next-line no-descending-specificity */ - ::before { - opacity: 0.1; - } - } - `, - ghost: css` - color: ${getMainColor}; - - ::before { - display: block; - background-color: ${getMainColor}; - transition: opacity ${({ theme }) => theme.duration.fast} ease; - opacity: 0; - } - - :not(:disabled):hover, - :focus-visible { - /* stylelint-disable-next-line no-descending-specificity */ - ::before { - opacity: 0.1; - } - } - `, - translucent: css` - color: ${getMainColor}; - - ::before { - display: block; - background-color: ${getMainColor}; - transition: opacity ${({ theme }) => theme.duration.fast} ease; - opacity: 0.1; - } - - :not(:disabled):hover, - :focus-visible { - /* stylelint-disable-next-line no-descending-specificity */ - ::before { - opacity: 0.2; - } - } - `, -} - -export const ButtonStyle = styled.button` - box-sizing: border-box; - margin: 0; - border: none; - outline: none; - white-space: nowrap; - overflow: hidden; - position: relative; - background: transparent; - font-family: inherit; - font-weight: 700; - width: ${({ $fullwidth }) => ($fullwidth ? ' 100%' : 'auto')}; - -webkit-tap-highlight-color: transparent; - - ::before { - content: ''; - position: absolute; - inset: 0; - pointer-events: none; - border-radius: inherit; - display: none; - } - - :not(:disabled) { - cursor: pointer; - } - - :disabled { - opacity: ${({ $loading }) => ($loading ? 1 : 0.5)}; - } - - ${(props) => sizes[props.$size]} - ${(props) => variants[props.$variant]} -` - -export const ripple = keyframes` - to { - transform: scale(4); - opacity: 0; - } -` - -export const ButtonRippleStyle = styled.span` - position: absolute; - border-radius: 50%; - transform: scale(0); - pointer-events: none; - animation: ${ripple} 0.8s linear; - background-color: currentcolor; - opacity: 0.4; -` - -export const ButtonContentStyle = styled.span<{ $hidden: boolean }>` - position: relative; - pointer-events: none; - visibility: ${({ $hidden }) => ($hidden ? 'hidden' : 'visible')}; -` - -export const ButtonLoaderStyle = styled(Loader)` - position: absolute; - top: 50%; - left: 50%; - transform: translate(-50%, -50%); - color: currentcolor; - pointer-events: none; -` diff --git a/packages/button/__snapshots__/Button.test.tsx.snap b/packages/button/__snapshots__/Button.test.tsx.snap deleted file mode 100644 index 7d4451eb..00000000 --- a/packages/button/__snapshots__/Button.test.tsx.snap +++ /dev/null @@ -1,66 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`renders correctly 1`] = ` -.c0 { - box-sizing: border-box; - margin: 0; - border: none; - outline: none; - white-space: nowrap; - overflow: hidden; - position: relative; - background: transparent; - font-family: inherit; - font-weight: 700; - width: auto; - -webkit-tap-highlight-color: transparent; - line-height: 1em; - font-size: 14px; - border-radius: 10px; - padding: 21px 44px; - min-width: 120px; - color: var(--lido-color-primaryContrast); - background-color: var(--lido-color-primary); - -webkit-transition: background-color 100ms ease; - transition: background-color 100ms ease; -} - -.c0::before { - content: ''; - position: absolute; - inset: 0; - pointer-events: none; - border-radius: inherit; - display: none; -} - -.c0:not(:disabled) { - cursor: pointer; -} - -.c0:disabled { - opacity: 0.5; -} - -.c0:not(:disabled):hover, -.c0:focus-visible { - background-color: var(--lido-color-primaryHover); -} - -.c1 { - position: relative; - pointer-events: none; - visibility: visible; -} - - -`; diff --git a/packages/button/index.ts b/packages/button/index.ts deleted file mode 100644 index 67e42cff..00000000 --- a/packages/button/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './Button.js' -export * from './ButtonIcon.js' -export * from './types.js' diff --git a/packages/button/types.tsx b/packages/button/types.tsx deleted file mode 100644 index 725575e6..00000000 --- a/packages/button/types.tsx +++ /dev/null @@ -1,47 +0,0 @@ -import { LidoComponentProps } from '../utils/index.js' -export type { Theme } from '../theme/index.js' - -export enum ButtonSize { - xxs, - xs, - sm, - md, - lg, -} -export type ButtonSizes = keyof typeof ButtonSize - -export enum ButtonVariant { - filled, - outlined, - text, - ghost, - translucent, -} -export type ButtonVariants = keyof typeof ButtonVariant - -export enum ButtonColor { - primary, - secondary, - warning, - error, - success, -} -export type ButtonColors = keyof typeof ButtonColor - -export type ButtonProps = LidoComponentProps< - 'button', - { - size?: ButtonSizes - variant?: ButtonVariants - color?: ButtonColors - fullwidth?: boolean - square?: boolean - loading?: boolean - active?: boolean - as?: never - } -> - -export type ButtonIconProps = { - icon: JSX.Element -} & ButtonProps diff --git a/packages/button/useRipple.tsx b/packages/button/useRipple.tsx deleted file mode 100644 index c81d7545..00000000 --- a/packages/button/useRipple.tsx +++ /dev/null @@ -1,46 +0,0 @@ -import { MouseEvent, ReactNode, useCallback, useState } from 'react' -import { ButtonProps } from './types.js' -import { ButtonRippleStyle } from './ButtonStyles.js' - -type UseRipple = (props: Pick) => { - ripple: ReactNode - handleClick: (event: MouseEvent) => void -} - -export const useRipple: UseRipple = ({ onClick }) => { - const [ripple, setRipple] = useState(null) - - const handleClick = useCallback( - (event: MouseEvent) => { - const button = event.currentTarget - const rect = button.getBoundingClientRect() - const diameter = Math.max(button.clientWidth, button.clientHeight) - const radius = diameter / 2 - const isMouseClick = event.clientX > 0 && event.clientY > 0 - - const x = isMouseClick - ? event.clientX - rect.left - : button.clientWidth / 2 - - const y = isMouseClick - ? event.clientY - rect.top - : button.clientHeight / 2 - - const style = { - width: diameter, - height: diameter, - left: x - radius, - top: y - radius, - } - - setRipple() - onClick?.(event) - }, - [onClick], - ) - - return { - ripple, - handleClick, - } -} diff --git a/packages/checkbox/Checkbox.stories.tsx b/packages/checkbox/Checkbox.stories.tsx deleted file mode 100644 index a1f80e01..00000000 --- a/packages/checkbox/Checkbox.stories.tsx +++ /dev/null @@ -1,40 +0,0 @@ -import { StoryFn, Meta } from '@storybook/react' -import { Checkbox, CheckboxProps } from './index.js' - -export default { - component: Checkbox, - title: 'Controls/Checkbox', - args: { - disabled: false, - }, - argTypes: { - onChange: { - action: 'change', - table: { disable: true }, - }, - }, -} as Meta - -export const Uncontrolled: StoryFn = (props) => ( - -) - -Uncontrolled.args = { - defaultChecked: false, -} - -export const Controlled: StoryFn = (props) => { - return -} - -Controlled.args = { - checked: true, -} - -export const WithLabel: StoryFn = (props) => { - return -} - -WithLabel.args = { - label: 'Label', -} diff --git a/packages/checkbox/Checkbox.tsx b/packages/checkbox/Checkbox.tsx deleted file mode 100644 index 2995ecad..00000000 --- a/packages/checkbox/Checkbox.tsx +++ /dev/null @@ -1,48 +0,0 @@ -import { ForwardedRef, forwardRef } from 'react' -import { CheckboxProps } from './types.js' -import { - CheckboxWrapperStyle, - CheckboxInputStyle, - CheckboxIconStyle, -} from './CheckboxStyles.js' -import { Text } from '../text/index.js' -import { Box } from '../box/index.js' - -export const Checkbox = forwardRef( - ( - { - className, - style, - wrapperRef, - disabled, - children, - label, - ...rest - }: CheckboxProps, - inputRef?: ForwardedRef, - ) => { - return ( - - - - {label && ( - - - {label} - - - )} - - ) - }, -) -Checkbox.displayName = 'Checkbox' diff --git a/packages/checkbox/CheckboxStyles.tsx b/packages/checkbox/CheckboxStyles.tsx deleted file mode 100644 index 98573ab3..00000000 --- a/packages/checkbox/CheckboxStyles.tsx +++ /dev/null @@ -1,68 +0,0 @@ -import styled from '../utils/styled-components-wrapper.js' -import { Check } from '../icons/index.js' - -export const CheckboxWrapperStyle = styled.label` - flex-shrink: 0; - display: inline-flex; - position: relative; - overflow: hidden; - line-height: 0; - align-items: center; -` - -export const CheckboxIconStyle = styled(Check)` - height: 24px; - width: 24px; - border-radius: 4px; - transition: - box-shadow 0.1s ease, - background-color 0.1s ease; - fill: var(--lido-color-primaryContrast); -` - -export const CheckboxInputStyle = styled.input` - width: 1px; - height: 1px; - position: absolute; - overflow: hidden; - clip: rect(0 0 0 0); - - &:not(:disabled) ~ * { - cursor: pointer; - } - - label:hover &:not(:disabled):not(:checked) + ${CheckboxIconStyle} { - box-shadow: inset 0 0 0 1px var(--lido-color-borderHover); - } - - & + ${CheckboxIconStyle} { - background-color: var(--lido-color-controlBg); - box-shadow: inset 0 0 0 1px var(--lido-color-border); - - path { - opacity: 0; - } - } - - &:checked + ${CheckboxIconStyle} { - background-color: var(--lido-color-primary); - box-shadow: none; - - path { - opacity: 1; - } - } - - &:disabled + ${CheckboxIconStyle} { - opacity: 0.5; - cursor: default; - } - - &:focus-visible + ${CheckboxIconStyle} { - box-shadow: inset 0 0 0 1px var(--lido-color-primary); - } - - &:focus-visible:checked + ${CheckboxIconStyle} { - box-shadow: inset 0 0 0 1px var(--lido-color-borderHover); - } -` diff --git a/packages/checkbox/index.ts b/packages/checkbox/index.ts deleted file mode 100644 index 1fe575b0..00000000 --- a/packages/checkbox/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './Checkbox.js' -export * from './types.js' diff --git a/packages/checkbox/types.ts b/packages/checkbox/types.ts deleted file mode 100644 index 8ff89d19..00000000 --- a/packages/checkbox/types.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { ReactNode, RefObject } from 'react' -import { LidoComponentProps } from '../utils/index.js' -export type { Theme } from '../theme/index.js' - -export type CheckboxProps = LidoComponentProps< - 'input', - { - wrapperRef?: RefObject - children?: never - label?: ReactNode - } -> diff --git a/packages/chip/Chip.stories.tsx b/packages/chip/Chip.stories.tsx deleted file mode 100644 index ad05c806..00000000 --- a/packages/chip/Chip.stories.tsx +++ /dev/null @@ -1,28 +0,0 @@ -import { StoryFn, Meta } from '@storybook/react' -import { Chip, ChipVariant } from './index.js' - -const getOptions = (enumObject: Record) => - Object.values(enumObject).filter((value) => typeof value === 'string') - -export default { - component: Chip, - title: 'Controls/Chip', - args: { - interactive: false, - children: 'Lido', - variant: 'positive', - }, - argTypes: { - variant: { - options: getOptions(ChipVariant), - control: 'inline-radio', - }, - }, -} as Meta - -export const Basic: StoryFn = (props, options) => ( - void 0 : undefined} - /> -) diff --git a/packages/chip/Chip.tsx b/packages/chip/Chip.tsx deleted file mode 100644 index 56a5841c..00000000 --- a/packages/chip/Chip.tsx +++ /dev/null @@ -1,23 +0,0 @@ -import { ForwardedRef, forwardRef } from 'react' -import { ChipProps } from './types.js' -import { ChipWrapperStyle } from './ChipStyles.js' - -export const Chip = forwardRef( - ( - { children, onClick, variant = 'positive', ...rest }: ChipProps, - ref?: ForwardedRef, - ) => { - return ( - - {children} - - ) - }, -) -Chip.displayName = 'Chip' diff --git a/packages/chip/ChipStyles.tsx b/packages/chip/ChipStyles.tsx deleted file mode 100644 index ff27c658..00000000 --- a/packages/chip/ChipStyles.tsx +++ /dev/null @@ -1,41 +0,0 @@ -import styled, { css } from '../utils/styled-components-wrapper.js' -import { ChipVariants } from './types.js' - -type InjectedPropsTr = { - $variant: ChipVariants - $interactive: boolean -} - -const ChipVariantsStyle = { - positive: css` - background: var(--lido-color-success); - color: var(--lido-color-foreground); - `, - negative: css` - background: var(--lido-color-error); - color: var(--lido-color-foreground); - `, - gray: css` - background: var(--lido-color-shadowLight); - color: var(--lido-color-textSecondary); - `, - warning: css` - background: var(--lido-color-warning); - color: var(--lido-color-foreground); - `, -} - -export const ChipWrapperStyle = styled.div` - font-size: 14px; - line-height: 20px; - display: inline-flex; - max-width: 100%; - box-sizing: border-box; - align-items: center; - white-space: nowrap; - outline: none; - border-radius: ${({ theme }) => theme.borderRadiusesMap.xs}px; - padding: 0.2em 0.4em; - cursor: ${({ $interactive }) => ($interactive ? 'pointer' : 'auto')}; - ${({ $variant }) => ChipVariantsStyle[$variant]} -` diff --git a/packages/chip/index.ts b/packages/chip/index.ts deleted file mode 100644 index b8325a04..00000000 --- a/packages/chip/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './Chip.js' -export * from './types.js' diff --git a/packages/chip/types.ts b/packages/chip/types.ts deleted file mode 100644 index 53dc161d..00000000 --- a/packages/chip/types.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { RefObject } from 'react' -import { LidoComponentProps } from '../utils/index.js' -export type { Theme } from '../theme/index.js' - -export enum ChipVariant { - positive, - negative, - warning, - gray, -} - -export type ChipVariants = keyof typeof ChipVariant - -export type ChipProps = LidoComponentProps< - 'div', - { - wrapperRef?: RefObject - variant?: ChipVariants - } -> diff --git a/packages/container/Container.stories.tsx b/packages/container/Container.stories.tsx deleted file mode 100644 index b3ad71a3..00000000 --- a/packages/container/Container.stories.tsx +++ /dev/null @@ -1,61 +0,0 @@ -import styled from '../utils/styled-components-wrapper.js' -import { StoryFn, Meta } from '@storybook/react' -import { Container, ContainerProps, ContainerSize } from './index.js' - -const getOptions = (enumObject: Record) => - Object.values(enumObject).filter((value) => typeof value === 'string') - -export default { - component: Container, - title: 'Layout/Container', - parameters: { - layout: 'fullscreen', - }, -} as Meta - -const StyledDiv = styled.div` - height: 100px; - background: var(--lido-color-foreground); - color: var(--lido-color-textSecondary); - display: flex; - align-items: center; - justify-content: center; -` - -export const Base: StoryFn = (props) => ( - - - -) - -Base.args = { - size: 'full', -} - -Base.argTypes = { - size: { - options: getOptions(ContainerSize), - control: 'inline-radio', - }, -} - -export const PageLayout: StoryFn = () => ( - <> - - Header - - - - Content - - - - Footer - - -) diff --git a/packages/container/Container.tsx b/packages/container/Container.tsx deleted file mode 100644 index 6a5b3532..00000000 --- a/packages/container/Container.tsx +++ /dev/null @@ -1,13 +0,0 @@ -import { ForwardedRef, forwardRef } from 'react' -import { ContainerStyle } from './ContainerStyles.js' -import { ContainerProps } from './types.js' - -export const Container = forwardRef( - ( - { size = 'full', ...rest }: ContainerProps, - ref?: ForwardedRef, - ) => { - return - }, -) -Container.displayName = 'Container' diff --git a/packages/container/ContainerStyles.tsx b/packages/container/ContainerStyles.tsx deleted file mode 100644 index 220ca519..00000000 --- a/packages/container/ContainerStyles.tsx +++ /dev/null @@ -1,28 +0,0 @@ -import styled, { css } from '../utils/styled-components-wrapper.js' -import { ContainerSizes } from './types.js' - -const sizes = { - full: css` - max-width: 1424px; - `, - content: css` - max-width: 960px; - `, - tight: css` - max-width: 560px; - `, -} - -export const ContainerStyle = styled.div<{ $size: ContainerSizes }>` - box-sizing: border-box; - margin: 0 auto; - min-width: 320px; - width: 100%; - padding: 0 ${({ theme }) => theme.spaceMap.xxl}px; - - ${({ theme }) => theme.mediaQueries.lg} { - padding: 0 ${({ theme }) => theme.spaceMap.lg}px; - } - - ${({ $size }) => sizes[$size]} -` diff --git a/packages/container/index.ts b/packages/container/index.ts deleted file mode 100644 index 7fdc9065..00000000 --- a/packages/container/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './Container.js' -export * from './types.js' diff --git a/packages/container/types.tsx b/packages/container/types.tsx deleted file mode 100644 index 2cf8b37f..00000000 --- a/packages/container/types.tsx +++ /dev/null @@ -1,16 +0,0 @@ -import { LidoComponentProps } from '../utils/index.js' -export type { Theme } from '../theme/index.js' - -export enum ContainerSize { - full, - content, - tight, -} -export type ContainerSizes = keyof typeof ContainerSize - -export type ContainerProps = LidoComponentProps< - 'div', - { - size?: ContainerSizes - } -> diff --git a/packages/content-theme/content-theme.tsx b/packages/content-theme/content-theme.tsx deleted file mode 100644 index c1903f83..00000000 --- a/packages/content-theme/content-theme.tsx +++ /dev/null @@ -1,16 +0,0 @@ -import { FC } from 'react' -import { ContentThemeOnlyDark, ContentThemeOnlyLight } from './styles.js' -import { ContentThemeProps } from './types.js' - -export const ContentTheme: FC = ({ - darkContent, - lightContent, - ...rest -}: ContentThemeProps) => { - return ( - <> - {darkContent} - {lightContent} - - ) -} diff --git a/packages/content-theme/index.ts b/packages/content-theme/index.ts deleted file mode 100644 index 811735a4..00000000 --- a/packages/content-theme/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './content-theme.js' -export * from './types.js' diff --git a/packages/content-theme/styles.tsx b/packages/content-theme/styles.tsx deleted file mode 100644 index 38da8c7f..00000000 --- a/packages/content-theme/styles.tsx +++ /dev/null @@ -1,9 +0,0 @@ -import styled from '../utils/styled-components-wrapper.js' - -export const ContentThemeOnlyDark = styled.div` - display: var(--lido-color-darkDisplay, contents); -` - -export const ContentThemeOnlyLight = styled.div` - display: var(--lido-color-lightDisplay, contents); -` diff --git a/packages/content-theme/types.ts b/packages/content-theme/types.ts deleted file mode 100644 index d5da4443..00000000 --- a/packages/content-theme/types.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { ReactElement } from 'react' -import { LidoComponentProps } from '../utils/index.js' - -export type ContentThemeProps = LidoComponentProps< - 'div', - { - darkContent: ReactElement - lightContent: ReactElement - } -> diff --git a/packages/cookie-theme-toggler/cookie-theme-toggler.tsx b/packages/cookie-theme-toggler/cookie-theme-toggler.tsx deleted file mode 100644 index f5091b1f..00000000 --- a/packages/cookie-theme-toggler/cookie-theme-toggler.tsx +++ /dev/null @@ -1,21 +0,0 @@ -import { FC } from 'react' -import { - CookieThemeTogglerStyle, - CookieThemeTogglerDarkIcon, - CookieThemeTogglerLightIcon, -} from './styles.js' -import { useThemeToggle } from '../theme/index.js' -import { ButtonProps } from '../button/index.js' - -export type ThemeTogglerProps = Omit - -export const ThemeToggler: FC = (props: ButtonProps) => { - const { toggleTheme } = useThemeToggle() - - return ( - - - - - ) -} diff --git a/packages/cookie-theme-toggler/index.ts b/packages/cookie-theme-toggler/index.ts deleted file mode 100644 index 0c16d421..00000000 --- a/packages/cookie-theme-toggler/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './cookie-theme-toggler.js' diff --git a/packages/cookie-theme-toggler/styles.tsx b/packages/cookie-theme-toggler/styles.tsx deleted file mode 100644 index 83ff64aa..00000000 --- a/packages/cookie-theme-toggler/styles.tsx +++ /dev/null @@ -1,39 +0,0 @@ -import styled from '../utils/styled-components-wrapper.js' -import { Button } from '../button/index.js' -import { Dark, Light } from '../icons/index.js' - -export const CookieThemeTogglerStyle = styled(Button).attrs({ - variant: 'text', - size: 'xs', -})` - display: inline-grid; - grid-template-areas: 'a'; - min-width: 0; - margin-left: ${({ theme }) => theme.spaceMap.sm}px; - line-height: 0; - font-size: 0; - padding: 0; - - width: 44px; - height: 44px; - // button element contains span as children container, we want to bypass it. - // by aiming explicit "span:first-child" we're verifying that this is what we are aiming for - // witout breaking our SVGs - & > span:first-child { - display: contents; - } -` - -export const CookieThemeTogglerLightIcon = styled(Light)` - grid-area: a; - align-self: center; - justify-self: center; - visibility: var(--lido-color-darkModeVisibility); -` - -export const CookieThemeTogglerDarkIcon = styled(Dark)` - grid-area: a; - align-self: center; - justify-self: center; - visibility: var(--lido-color-lightModeVisibility); -` diff --git a/packages/cookies-tooltip/constants.ts b/packages/cookies-tooltip/constants.ts deleted file mode 100644 index 85c9dfa0..00000000 --- a/packages/cookies-tooltip/constants.ts +++ /dev/null @@ -1,3 +0,0 @@ -export const COOKIE_ALLOWED_KEY = 'cookie-allowed' -export const COOKIE_VALUE_YES = 'yes' -export const COOKIE_VALUE_NO = 'no' diff --git a/packages/cookies-tooltip/cookies-tooltip.stories.tsx b/packages/cookies-tooltip/cookies-tooltip.stories.tsx deleted file mode 100644 index dfa3494f..00000000 --- a/packages/cookies-tooltip/cookies-tooltip.stories.tsx +++ /dev/null @@ -1,28 +0,0 @@ -import { StoryFn, Meta } from '@storybook/react' -import { Text } from '../text/index.js' -import { CookiesTooltip } from './index.js' - -export default { - title: 'CookiesTooltip/Basic', -} as Meta - -export const Basic: StoryFn = () => ( - <> - - CookiesTooltip component has an ability to detect a user choice in other - tabs and third level domain. - - - You can check above if you: -
- 1. duplicate this tab; -
- 2. allow or decline cookie; -
- 3. and check in another tab; -
- 4. and click to work area (to handler window.onfocus event). -
- - -) diff --git a/packages/cookies-tooltip/cookies-tooltip.tsx b/packages/cookies-tooltip/cookies-tooltip.tsx deleted file mode 100644 index acfd09e8..00000000 --- a/packages/cookies-tooltip/cookies-tooltip.tsx +++ /dev/null @@ -1,96 +0,0 @@ -import { - FC, - useEffect, - useState, - useCallback, - ComponentPropsWithoutRef, - ReactNode, -} from 'react' -import { getCrossDomainCookieClientSide } from '../utils/index.js' -import { - Wrap, - Box, - Text, - ButtonsWrap, - AllowButton, - DeclineButton, - ExternalLink, -} from './styles.js' -import { allowCookies, declineCookies } from './utils.js' -import { COOKIE_ALLOWED_KEY } from './constants.js' - -export type CookiesTooltipProps = Omit< - ComponentPropsWithoutRef<'div'>, - 'children' -> & { - privacyText?: ReactNode - privacyLink?: string -} - -export const CookiesTooltip: FC = ({ - privacyText, - privacyLink, - ...rest -}) => { - const [isVisible, setVisibility] = useState(false) - - const checkCookieAllowedEarlier = useCallback(() => { - // Check if user allowed/declined in other tab or third level domain - if (getCrossDomainCookieClientSide(COOKIE_ALLOWED_KEY)) { - setVisibility(false) - - window.removeEventListener('focus', checkCookieAllowedEarlier) - } - }, []) - - useEffect(() => { - // Check cookie after page loaded - if (getCrossDomainCookieClientSide(COOKIE_ALLOWED_KEY)) { - return - } - - setVisibility(true) - - // This code runs after returned to this browser tab (window) from other - window.addEventListener('focus', checkCookieAllowedEarlier) - }, [checkCookieAllowedEarlier]) - - if (!isVisible) return <> - - return ( - - - - {privacyText ?? ( - <> - Cookies are used to collect anonymous site visitation data - to improve website performance. For more info, - read  - - )} - - Privacy Notice - - - - { - allowCookies() - setVisibility(false) - }} - > - Allow - - { - declineCookies() - setVisibility(false) - }} - > - Decline - - - - - ) -} diff --git a/packages/cookies-tooltip/index.ts b/packages/cookies-tooltip/index.ts deleted file mode 100644 index 5c051015..00000000 --- a/packages/cookies-tooltip/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './cookies-tooltip.js' -export { migrationAllowCookieToCrossDomainCookieClientSide } from './utils.js' diff --git a/packages/cookies-tooltip/styles.tsx b/packages/cookies-tooltip/styles.tsx deleted file mode 100644 index f926555c..00000000 --- a/packages/cookies-tooltip/styles.tsx +++ /dev/null @@ -1,118 +0,0 @@ -import styled from '../utils/styled-components-wrapper.js' - -export const ExternalLink = styled.a.attrs({ - target: '_blank', - rel: 'nofollow noopener', -})` - cursor: pointer; - color: var(--lido-color-primary); - text-decoration: none; - - &:hover { - color: var(--lido-color-primaryHover); - } -` - -export const Wrap = styled.div` - z-index: 999; - position: fixed; - bottom: 20px; - left: 20px; - right: 20px; - display: flex; - align-items: center; - justify-content: center; - - ${({ theme }) => theme.mediaQueries.lg} { - bottom: 0; - left: 0; - right: 0; - } -` - -export const Box = styled.div` - display: flex; - align-items: center; - padding: 16px 24px; - border-radius: 20px; - background-color: var(--lido-color-foreground); - box-shadow: 0 6px 32px rgba(0, 0, 0, 0.08); - - ${({ theme }) => theme.mediaQueries.lg} { - flex-direction: column; - border-radius: 0; - width: 100%; - } -` - -export const Text = styled.div` - margin-right: 8px; - font-weight: 500; - font-size: 14px; - line-height: 22px; - color: var(--lido-color-textSecondary); - max-width: 500px; - - ${({ theme }) => theme.mediaQueries.lg} { - margin-right: 0; - margin-bottom: 8px; - width: 100%; - text-align: center; - } -` - -export const ButtonsWrap = styled.div` - display: flex; -` - -const ButtonBasic = styled.button.attrs({ type: 'button' })` - font-weight: 800; - font-size: 12px; - line-height: 20px; - border-radius: 6px; - width: 72px; - height: 32px; - border: none; - outline: none; - cursor: pointer; - transition: - background-color ease 0.25s, - border-color ease 0.25s, - color ease 0.25s; - - &:not(:last-child) { - margin-right: 8px; - } - - &:hover { - background-color: #0e1621; - } - - &:active { - transform: translateY(1px); - } - - ${({ theme }) => theme.mediaQueries.lg} { - width: 112px; - } -` - -export const AllowButton = styled(ButtonBasic)` - background-color: var(--lido-color-secondary); - color: var(--lido-color-secondaryContrast); - - &:hover { - background-color: var(--lido-color-secondaryHover); - } -` - -export const DeclineButton = styled(ButtonBasic)` - background-color: var(--lido-color-foreground); - color: var(--lido-color-text); - border: 1px solid var(--lido-color-text); - - &:hover { - background-color: var(--lido-color-secondary); - color: var(--lido-color-secondaryContrast); - } -` diff --git a/packages/cookies-tooltip/utils.ts b/packages/cookies-tooltip/utils.ts deleted file mode 100644 index f1f2268c..00000000 --- a/packages/cookies-tooltip/utils.ts +++ /dev/null @@ -1,50 +0,0 @@ -import { - setCrossDomainCookieClientSide, - getDomainCookieClientSide, - removeCookiesClientSide, - setDomainCookieClientSide, -} from '../utils/index.js' -import { - COOKIE_ALLOWED_KEY, - COOKIE_VALUE_NO, - COOKIE_VALUE_YES, -} from './constants.js' - -export const allowCookies = (): void => { - // For top level domain - *.some-domain.fi - setCrossDomainCookieClientSide(COOKIE_ALLOWED_KEY, COOKIE_VALUE_YES) - - if (!document.cookie.includes(`${COOKIE_ALLOWED_KEY}=${COOKIE_VALUE_YES}`)) { - // For specific.domain.fi, if cookie can't be set to top level domain - setDomainCookieClientSide(COOKIE_ALLOWED_KEY, COOKIE_VALUE_YES) - } -} - -export const declineCookies = (): void => { - // For top level domain - *.some-domain.fi - setCrossDomainCookieClientSide(COOKIE_ALLOWED_KEY, COOKIE_VALUE_NO) - - if (!document.cookie.includes(`${COOKIE_ALLOWED_KEY}=${COOKIE_VALUE_NO}`)) { - // For specific.domain.fi, if cookie can't be set to top level domain - setDomainCookieClientSide(COOKIE_ALLOWED_KEY, COOKIE_VALUE_NO) - } -} - -export const migrationAllowCookieToCrossDomainCookieClientSide = ( - keyOldCookie: string, -) => { - const old_cookie_value = getDomainCookieClientSide(keyOldCookie) - - if (!old_cookie_value) { - return - } - - removeCookiesClientSide(keyOldCookie) - - if (old_cookie_value === COOKIE_VALUE_YES) { - allowCookies() - } else if (old_cookie_value === COOKIE_VALUE_NO) { - declineCookies() - } - // else noop -} diff --git a/packages/data-table/DataTable.stories.tsx b/packages/data-table/DataTable.stories.tsx deleted file mode 100644 index 04e3d42a..00000000 --- a/packages/data-table/DataTable.stories.tsx +++ /dev/null @@ -1,65 +0,0 @@ -import { StoryFn, Meta } from '@storybook/react' -import { - DataTable, - DataTableRow, - DataTableProps, - DataTableRowProps, -} from './index.js' - -export default { - component: DataTable, - title: 'Layout/DataTable', - parameters: { - layout: 'centered', - }, -} as Meta - -export const Base: StoryFn< - DataTableProps & Pick -> = ({ loading, ...rest }) => { - return ( -
- - - 100 LDO - - - $0.12 - - -
- ) -} - -Base.args = { - loading: false, -} - -export const WithHint: StoryFn = (props) => { - return ( -
- - - 10% - - $0.12 - -
- ) -} - -export const WithHighlighted: StoryFn = (props) => { - return ( -
- - - 10% - - $0.12 - -
- ) -} diff --git a/packages/data-table/DataTable.tsx b/packages/data-table/DataTable.tsx deleted file mode 100644 index 0dfc5161..00000000 --- a/packages/data-table/DataTable.tsx +++ /dev/null @@ -1,51 +0,0 @@ -import { ForwardedRef, forwardRef } from 'react' -import { InlineLoader } from '../loaders/index.js' -import { Tooltip } from '../tooltip/index.js' -import { - DataTableStyle, - DataTableRowStyle, - DataTableTitleStyle, - DataTableValueStyle, - DataTableQuestionStyle, -} from './DataTableStyles.js' -import { DataTableProps, DataTableRowProps } from './types.js' - -export const DataTableRow = forwardRef( - ( - { - title, - loading = false, - highlight = false, - help, - children, - ...rest - }: DataTableRowProps, - ref?: ForwardedRef, - ) => { - const hasHelper = !!help - - return ( - - - {title} - {hasHelper && ( - - - - )} - - - {loading ? : children} - - - ) - }, -) -DataTableRow.displayName = 'DataTableRow' - -export const DataTable = forwardRef( - (props: DataTableProps, ref?: ForwardedRef) => { - return - }, -) -DataTable.displayName = 'DataTable' diff --git a/packages/data-table/DataTableStyles.tsx b/packages/data-table/DataTableStyles.tsx deleted file mode 100644 index d2610637..00000000 --- a/packages/data-table/DataTableStyles.tsx +++ /dev/null @@ -1,39 +0,0 @@ -import styled from '../utils/styled-components-wrapper.js' -import { Question } from '../icons/index.js' - -export const DataTableStyle = styled.div`` - -export const DataTableRowStyle = styled.div` - display: flex; - margin: ${({ theme }) => theme.spaceMap.md}px 0; - font-weight: 400; - font-size: ${({ theme }) => theme.fontSizesMap.xxs}px; - line-height: 1.6em; - - &:first-child { - margin-top: 0; - } - - &:last-child { - margin-bottom: 0; - } -` - -export const DataTableTitleStyle = styled.div` - color: var(--lido-color-textSecondary); - flex-grow: 1; -` - -export const DataTableValueStyle = styled.div<{ $highlight: boolean }>` - color: var( - --lido-color-${({ $highlight }) => ($highlight ? `success` : `text`)} - ); - text-align: right; - margin-left: ${({ theme }) => theme.spaceMap.xxl}px; - flex-grow: 1; -` - -export const DataTableQuestionStyle = styled(Question)` - margin: -6px 0 -5px; - vertical-align: middle; -` diff --git a/packages/data-table/index.ts b/packages/data-table/index.ts deleted file mode 100644 index 6f6dcb22..00000000 --- a/packages/data-table/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './DataTable.js' -export * from './types.js' diff --git a/packages/data-table/types.tsx b/packages/data-table/types.tsx deleted file mode 100644 index f7506bf9..00000000 --- a/packages/data-table/types.tsx +++ /dev/null @@ -1,15 +0,0 @@ -import { ReactNode } from 'react' -import { LidoComponentProps } from '../utils/index.js' -export type { Theme } from '../theme/index.js' - -export type DataTableProps = LidoComponentProps<'div'> - -export type DataTableRowProps = LidoComponentProps< - 'div', - { - title: ReactNode - help?: ReactNode - loading?: boolean - highlight?: boolean - } -> diff --git a/packages/divider/Divider.stories.tsx b/packages/divider/Divider.stories.tsx deleted file mode 100644 index b06366f1..00000000 --- a/packages/divider/Divider.stories.tsx +++ /dev/null @@ -1,46 +0,0 @@ -import { StoryFn, Meta } from '@storybook/react' -import styled from '../utils/styled-components-wrapper.js' -import { - Divider, - DividerIndent, - DividerProps, - DividerType, - DividerTypes, -} from './index.js' - -const getOptions = (enumObject: Record) => - Object.values(enumObject).filter((value) => typeof value === 'string') - -export default { - component: Divider, - title: 'Layout/Divider', - args: { - type: 'horizontal', - indents: 'md', - }, - argTypes: { - type: { - options: getOptions(DividerType), - control: 'inline-radio', - }, - indents: { - options: getOptions(DividerIndent), - control: 'inline-radio', - }, - }, -} as Meta - -const Wrapper = styled.div<{ $type?: DividerTypes }>` - flex-direction: ${({ $type }) => ($type === 'vertical' ? 'row' : 'column')}; - display: flex; -` - -export const Base: StoryFn = (props) => ( - - First - - Second - - Third - -) diff --git a/packages/divider/Divider.tsx b/packages/divider/Divider.tsx deleted file mode 100644 index 4aaf4007..00000000 --- a/packages/divider/Divider.tsx +++ /dev/null @@ -1,13 +0,0 @@ -import { ForwardedRef, forwardRef } from 'react' -import { DividerStyle } from './DividerStyles.js' -import { DividerProps } from './types.js' - -export const Divider = forwardRef( - ( - { type = 'horizontal', indents, children, ...rest }: DividerProps, - ref?: ForwardedRef, - ) => { - return - }, -) -Divider.displayName = 'Divider' diff --git a/packages/divider/DividerStyles.tsx b/packages/divider/DividerStyles.tsx deleted file mode 100644 index f6dd7e0a..00000000 --- a/packages/divider/DividerStyles.tsx +++ /dev/null @@ -1,40 +0,0 @@ -import styled, { css } from '../utils/styled-components-wrapper.js' -import { Theme } from '../theme/index.js' -import { DividerIndents, DividerTypes } from './types.js' - -type InjectedProps = { - $type: DividerTypes - $indents?: DividerIndents - theme: Theme -} - -const getIndents = ({ $indents, theme }: InjectedProps) => { - return $indents ? `${theme.spaceMap[$indents]}px` : '0' -} - -const types = { - horizontal: css` - border-top: 1px solid currentcolor; - width: 100%; - height: 0; - margin: ${getIndents} 0; - `, - vertical: css` - border-left: 1px solid currentcolor; - align-self: stretch; - width: 0; - margin: 0 ${getIndents}; - `, -} - -export const DividerStyle = styled.div` - box-sizing: border-box; - list-style: none; - opacity: 0.1; - margin: 0; - padding: 0; - flex-shrink: 0; - flex-grow: 0; - - ${(props) => types[props.$type]} -` diff --git a/packages/divider/index.ts b/packages/divider/index.ts deleted file mode 100644 index aa5ad424..00000000 --- a/packages/divider/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './Divider.js' -export * from './types.js' diff --git a/packages/divider/types.tsx b/packages/divider/types.tsx deleted file mode 100644 index 9b156ee0..00000000 --- a/packages/divider/types.tsx +++ /dev/null @@ -1,26 +0,0 @@ -export type { Theme } from '../theme/index.js' -import { LidoComponentProps } from '../utils/index.js' - -export enum DividerType { - vertical, - horizontal, -} -export type DividerTypes = keyof typeof DividerType - -export enum DividerIndent { - xs, - sm, - md, - lg, - xl, -} -export type DividerIndents = keyof typeof DividerIndent - -export type DividerProps = LidoComponentProps< - 'div', - { - type?: DividerTypes - indents?: DividerIndents - children?: never - } -> diff --git a/packages/heading/Heading.stories.tsx b/packages/heading/Heading.stories.tsx deleted file mode 100644 index 548e4a79..00000000 --- a/packages/heading/Heading.stories.tsx +++ /dev/null @@ -1,49 +0,0 @@ -import { StoryFn, Meta } from '@storybook/react' -import { - Heading, - H1, - H2, - H3, - HeadingProps, - HeadingColor, - HeadingSize, - HProps, -} from './index.js' - -const getOptions = (enumObject: Record) => - Object.values(enumObject).filter((value) => typeof value === 'string') - -export default { - component: Heading, - title: 'Typography/Heading', - args: { - children: 'Example Heading', - color: 'text', - }, - argTypes: { - children: { - control: 'text', - }, - color: { - options: getOptions(HeadingColor), - control: 'inline-radio', - }, - }, -} as Meta - -export const Basic: StoryFn = (props) => - -Basic.args = { - size: 'md', -} - -Basic.argTypes = { - size: { - options: getOptions(HeadingSize), - control: 'inline-radio', - }, -} - -export const HeadingH1: StoryFn> = (props) =>

-export const HeadingH2: StoryFn> = (props) =>

-export const HeadingH3: StoryFn> = (props) =>

diff --git a/packages/heading/Heading.tsx b/packages/heading/Heading.tsx deleted file mode 100644 index 9bf71af4..00000000 --- a/packages/heading/Heading.tsx +++ /dev/null @@ -1,43 +0,0 @@ -import { ForwardedRef, forwardRef } from 'react' -import { HeadingStyle, H1Style, H2Style, H3Style } from './HeadingStyles.js' -import { HeadingProps, HProps } from './types.js' - -export const Heading = forwardRef( - ( - { size = 'md', color = 'text', ...rest }: HeadingProps, - ref?: ForwardedRef, - ) => { - return - }, -) -Heading.displayName = 'Heading' - -export const H1 = forwardRef( - ( - { color = 'text', ...rest }: HProps<'h1'>, - ref?: ForwardedRef, - ) => { - return - }, -) -H1.displayName = 'H1' - -export const H2 = forwardRef( - ( - { color = 'text', ...rest }: HProps<'h2'>, - ref?: ForwardedRef, - ) => { - return - }, -) -H2.displayName = 'H2' - -export const H3 = forwardRef( - ( - { color = 'text', ...rest }: HProps<'h3'>, - ref?: ForwardedRef, - ) => { - return - }, -) -H3.displayName = 'H3' diff --git a/packages/heading/HeadingStyles.tsx b/packages/heading/HeadingStyles.tsx deleted file mode 100644 index 3fb744c4..00000000 --- a/packages/heading/HeadingStyles.tsx +++ /dev/null @@ -1,58 +0,0 @@ -import styled, { css } from '../utils/styled-components-wrapper.js' -import { Theme } from '../theme/index.js' -import { HeadingColors, HeadingSizes } from './types.js' - -export const sizes = { - sm: css` - font-size: ${({ theme }) => theme.fontSizesMap.xl}px; - line-height: 1.3em; - `, - md: css` - font-size: ${({ theme }) => theme.fontSizesMap.xxl}px; - line-height: 1.3em; - `, - lg: css` - font-size: ${({ theme }) => theme.fontSizesMap.xxxl}px; - line-height: 1.3em; - `, -} - -type InjectedProps = { - $color: HeadingColors - theme: Theme -} - -const getHeadingColor = (props: InjectedProps) => { - const colorsMap = { - text: `var(--lido-color-text)`, - secondary: `var(--lido-color-textSecondary)`, - } - return colorsMap[props.$color] -} - -const commonCSS = css` - margin: 0; - padding: 0; - font-weight: 800; - color: ${getHeadingColor}; -` - -export const HeadingStyle = styled.div` - ${commonCSS} - ${(props) => sizes[props.$size]} -` - -export const H1Style = styled.h1` - ${commonCSS} - ${sizes.lg} -` - -export const H2Style = styled.h2` - ${commonCSS} - ${sizes.md} -` - -export const H3Style = styled.h3` - ${commonCSS} - ${sizes.sm} -` diff --git a/packages/heading/index.tsx b/packages/heading/index.tsx deleted file mode 100644 index 5aca59a8..00000000 --- a/packages/heading/index.tsx +++ /dev/null @@ -1,2 +0,0 @@ -export * from './Heading.js' -export * from './types.js' diff --git a/packages/heading/types.ts b/packages/heading/types.ts deleted file mode 100644 index f52b084b..00000000 --- a/packages/heading/types.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { LidoComponentProps } from '../utils/index.js' - -export enum HeadingColor { - text, - secondary, -} -export type HeadingColors = keyof typeof HeadingColor - -export enum HeadingSize { - sm, - md, - lg, -} -export type HeadingSizes = keyof typeof HeadingSize - -export type HeadingProps = LidoComponentProps< - 'div', - { - color?: HeadingColors - size?: HeadingSizes - } -> - -export type HProps = - LidoComponentProps< - T, - { - color?: HeadingColors - } - > diff --git a/packages/hooks/index.ts b/packages/hooks/index.ts index 1a02427a..aea1670d 100644 --- a/packages/hooks/index.ts +++ b/packages/hooks/index.ts @@ -1,4 +1,3 @@ -export * from './useBreakpoint.js' export * from './useEscape.js' export * from './useInterceptFocus.js' export * from './useLockScroll.js' diff --git a/packages/hooks/useBreakpoint.ts b/packages/hooks/useBreakpoint.ts deleted file mode 100644 index bafa99a9..00000000 --- a/packages/hooks/useBreakpoint.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { useEffect, useState } from 'react' -import { useTheme } from '../utils/styled-components-wrapper.js' -import { Theme } from '../theme/index.js' - -export const useBreakpoint = ( - breakpoint: keyof Theme['breakpointsMap'], -): boolean => { - const theme = useTheme() - const maxWidth = theme.breakpointsMap[breakpoint].width - - const [isBreakpoint, seIsBreakpoint] = useState(() => { - try { - return window.matchMedia(`(max-width: ${maxWidth})`).matches - } catch (error) { - return false - } - }) - - useEffect(() => { - try { - const mql = window.matchMedia(`(max-width: ${maxWidth})`) - - const setMobileFromQuery = ({ matches }: { matches: boolean }) => { - seIsBreakpoint(matches) - } - - mql.addEventListener('change', setMobileFromQuery) - setMobileFromQuery(mql) - - return () => { - mql.removeEventListener('change', setMobileFromQuery) - } - } catch (error) { - return - } - }, [maxWidth]) - - return isBreakpoint -} diff --git a/packages/hooks/useSystemTheme.ts b/packages/hooks/useSystemTheme.ts index ab1bcd1f..e70fc596 100644 --- a/packages/hooks/useSystemTheme.ts +++ b/packages/hooks/useSystemTheme.ts @@ -1,5 +1,5 @@ import { useEffect, useState } from 'react' -import { ThemeName } from '../theme/index.js' +import { ThemeName } from '../theme-css/constants' export const useSystemTheme = (): ThemeName | undefined => { const [systemTheme, setSystemTheme] = useState() diff --git a/packages/icons/Icon.stories.tsx b/packages/icons/Icon.stories.tsx index 86d655a2..d68471cf 100644 --- a/packages/icons/Icon.stories.tsx +++ b/packages/icons/Icon.stories.tsx @@ -1,5 +1,4 @@ import { StoryFn, Meta } from '@storybook/react' -import styled from '../utils/styled-components-wrapper.js' import * as components from './index.js' type IconVariants = keyof typeof components @@ -30,204 +29,204 @@ Base.args = { type: 'History', } -const IconList = styled.div` - display: flex; - flex-wrap: wrap; -` - -const IconListItem = styled.div` - text-align: center; - font-size: 13px; - line-height: 15px; - width: 120px; - margin: 2px; - padding: 10px; - border-radius: 4px; - color: var(--lido-color-text); -` - -const IconListTitle = styled.div` - opacity: 0.5; -` - -export const List: StoryFn = () => ( - - {iconKeys.map((componentName) => { - const Icon = components[componentName] - - return ( - - - {componentName} - - ) - })} - -) - -const SocialList = styled.div` - display: flex; -` - -const SocialListItem = styled.div<{ $color: string }>` - background: ${({ $color }) => $color}; - line-height: 0; - border-radius: 6px; - margin: 4px; - padding: 4px; - - svg { - fill: #fff; - } -` - -export const Social: StoryFn = () => { - const { Facebook, Twitter, Linkedin, Email, Telegram } = components - - return ( - - - - - - - - - - - - - - - - - - ) -} - -export const CryptoCurrencies: StoryFn = () => { - const { Eth, Weth, Steth, Wsteth, Beth, Ldo, Ldopl, Solana, Stsol, Terra } = - components - const iconKeys = Object.keys({ - Eth, - Weth, - Steth, - Wsteth, - Beth, - Ldo, - Ldopl, - Solana, - Stsol, - Terra, - }) as IconVariants[] - - return ( - - {iconKeys.map((componentName) => { - const Icon = components[componentName] - - return ( - - - {componentName} - - ) - })} - - ) -} - -export const CryptoWallets: StoryFn = () => { - const { - MetaMask, - MetaMaskCircle, - MetaMaskCircleInversion, - WalletConnect, - WalletConnectCircle, - Coinbase, - Ledger, - LedgerCircle, - LedgerCircleInversion, - Trust, - TrustCircle, - Imtoken, - ImtokenCircle, - MathWalletCircle, - MathWalletCircleInversion, - Coin98Circle, - Ambire, - Blochainwallet, - BlochainwalletInversion, - Exodus, - OperaWallet, - Unstoppabledomains, - Zengo, - Gamestop, - XdefiWallet, - } = components - const iconKeys = Object.keys({ - MetaMask, - MetaMaskCircle, - MetaMaskCircleInversion, - WalletConnect, - WalletConnectCircle, - Coinbase, - Ledger, - LedgerCircle, - LedgerCircleInversion, - Trust, - TrustCircle, - Imtoken, - ImtokenCircle, - MathWalletCircle, - MathWalletCircleInversion, - Coin98Circle, - Ambire, - Zengo, - Blochainwallet, - BlochainwalletInversion, - Exodus, - OperaWallet, - Unstoppabledomains, - Gamestop, - XdefiWallet, - }) as IconVariants[] - - return ( - - {iconKeys.map((componentName) => { - const Icon = components[componentName] - - return ( - - - {componentName} - - ) - })} - - ) -} - -export const CryptoExchanges: StoryFn = () => { - const { Uniswap, OneInch } = components - const iconKeys = Object.keys({ - Uniswap, - OneInch, - }) as IconVariants[] - - return ( - - {iconKeys.map((componentName) => { - const Icon = components[componentName] - - return ( - - - {componentName} - - ) - })} - - ) -} +// const IconList = styled.div` +// display: flex; +// flex-wrap: wrap; +// ` + +// const IconListItem = styled.div` +// text-align: center; +// font-size: 13px; +// line-height: 15px; +// width: 120px; +// margin: 2px; +// padding: 10px; +// border-radius: 4px; +// color: var(--lido-color-text); +// ` + +// const IconListTitle = styled.div` +// opacity: 0.5; +// ` + +// export const List: StoryFn = () => ( +// +// {iconKeys.map((componentName) => { +// const Icon = components[componentName] + +// return ( +// +// +// {componentName} +// +// ) +// })} +// +// ) + +// const SocialList = styled.div` +// display: flex; +// ` + +// const SocialListItem = styled.div<{ $color: string }>` +// background: ${({ $color }) => $color}; +// line-height: 0; +// border-radius: 6px; +// margin: 4px; +// padding: 4px; + +// svg { +// fill: #fff; +// } +// ` + +// export const Social: StoryFn = () => { +// const { Facebook, Twitter, Linkedin, Email, Telegram } = components + +// return ( +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// ) +// } + +// export const CryptoCurrencies: StoryFn = () => { +// const { Eth, Weth, Steth, Wsteth, Beth, Ldo, Ldopl, Solana, Stsol, Terra } = +// components +// const iconKeys = Object.keys({ +// Eth, +// Weth, +// Steth, +// Wsteth, +// Beth, +// Ldo, +// Ldopl, +// Solana, +// Stsol, +// Terra, +// }) as IconVariants[] + +// return ( +// +// {iconKeys.map((componentName) => { +// const Icon = components[componentName] + +// return ( +// +// +// {componentName} +// +// ) +// })} +// +// ) +// } + +// export const CryptoWallets: StoryFn = () => { +// const { +// MetaMask, +// MetaMaskCircle, +// MetaMaskCircleInversion, +// WalletConnect, +// WalletConnectCircle, +// Coinbase, +// Ledger, +// LedgerCircle, +// LedgerCircleInversion, +// Trust, +// TrustCircle, +// Imtoken, +// ImtokenCircle, +// MathWalletCircle, +// MathWalletCircleInversion, +// Coin98Circle, +// Ambire, +// Blochainwallet, +// BlochainwalletInversion, +// Exodus, +// OperaWallet, +// Unstoppabledomains, +// Zengo, +// Gamestop, +// XdefiWallet, +// } = components +// const iconKeys = Object.keys({ +// MetaMask, +// MetaMaskCircle, +// MetaMaskCircleInversion, +// WalletConnect, +// WalletConnectCircle, +// Coinbase, +// Ledger, +// LedgerCircle, +// LedgerCircleInversion, +// Trust, +// TrustCircle, +// Imtoken, +// ImtokenCircle, +// MathWalletCircle, +// MathWalletCircleInversion, +// Coin98Circle, +// Ambire, +// Zengo, +// Blochainwallet, +// BlochainwalletInversion, +// Exodus, +// OperaWallet, +// Unstoppabledomains, +// Gamestop, +// XdefiWallet, +// }) as IconVariants[] + +// return ( +// +// {iconKeys.map((componentName) => { +// const Icon = components[componentName] + +// return ( +// +// +// {componentName} +// +// ) +// })} +// +// ) +// } + +// export const CryptoExchanges: StoryFn = () => { +// const { Uniswap, OneInch } = components +// const iconKeys = Object.keys({ +// Uniswap, +// OneInch, +// }) as IconVariants[] + +// return ( +// +// {iconKeys.map((componentName) => { +// const Icon = components[componentName] + +// return ( +// +// +// {componentName} +// +// ) +// })} +// +// ) +// } diff --git a/packages/icons/converter/index.cjs b/packages/icons/converter/index.cjs index 7c2e77ce..a71b599f 100644 --- a/packages/icons/converter/index.cjs +++ b/packages/icons/converter/index.cjs @@ -2,7 +2,7 @@ const svgr = require('@svgr/core').default const svgrSvgo = require('@svgr/plugin-svgo').default const svgrJsx = require('@svgr/plugin-jsx').default const svgrPrettier = require('@svgr/plugin-prettier').default -const indexTemplate = require('./template.index.js') +const indexTemplate = require('./template.index.cjs') const fs = require('fs/promises') const { extname, resolve } = require('path') @@ -80,7 +80,7 @@ const convertFiles = async () => { fill: 'currentColor', }, plugins: [svgrSvgo, svgrJsx, svgrPrettier], - template: require('./template.component.js'), + template: require('./template.component.cjs'), }, { componentName }, ) diff --git a/packages/icons/index.tsx b/packages/icons/index.tsx index cfd8e0f1..c0d4286f 100644 --- a/packages/icons/index.tsx +++ b/packages/icons/index.tsx @@ -302,6 +302,22 @@ export const ArrowBottom = React.forwardRef(function ArrowBottom( ) }) +export const ArrowIcon = React.forwardRef(function ArrowIcon( + props: React.SVGProps, + svgRef?: React.Ref, +) { + return ( + + + + ) +}) + export const ArrowLeft = React.forwardRef(function ArrowLeft( props: React.SVGProps, svgRef?: React.Ref, diff --git a/packages/icons/svg/arrow-icon.svg b/packages/icons/svg/arrow-icon.svg new file mode 100644 index 00000000..ced2f518 --- /dev/null +++ b/packages/icons/svg/arrow-icon.svg @@ -0,0 +1,3 @@ + + + diff --git a/packages/identicon/Identicon.stories.tsx b/packages/identicon/Identicon.stories.tsx deleted file mode 100644 index fb60aacf..00000000 --- a/packages/identicon/Identicon.stories.tsx +++ /dev/null @@ -1,48 +0,0 @@ -import { StoryFn, Meta } from '@storybook/react' -import { - Identicon, - IdenticonBadge, - IdenticonProps, - IdenticonBadgeProps, - IdenticonBadgeColor, -} from '.' - -const getOptions = (enumObject: Record) => - Object.values(enumObject).filter((value) => typeof value === 'string') - -export default { - component: Identicon, - title: 'Images/Identicon', - args: { - address: '0x5a98fcbea516cf06857215779fd812ca3bef1b32', - diameter: 24, - }, - argTypes: { - diameter: { - control: { type: 'range', min: 4, max: 64, step: 4 }, - }, - }, -} as Meta - -export const Basic: StoryFn = (props) => ( - -) - -export const Badge: StoryFn = (props) => ( - -) - -Badge.args = { - symbols: 3, - color: 'background', -} - -Badge.argTypes = { - symbols: { - control: { type: 'range', min: 0, max: 21, step: 1 }, - }, - color: { - options: getOptions(IdenticonBadgeColor), - control: 'inline-radio', - }, -} diff --git a/packages/identicon/Identicon.tsx b/packages/identicon/Identicon.tsx deleted file mode 100644 index d6fc75c6..00000000 --- a/packages/identicon/Identicon.tsx +++ /dev/null @@ -1,33 +0,0 @@ -import { ForwardedRef, forwardRef } from 'react' -import { IdenticonProps } from './types.js' -import { IdenticonStyle } from './IdenticonStyles.js' -import _Jazzicon from 'react-jazzicon' - -// There is an error with importing jsNumberForAddress from 'react-jazzicon' as named export in ESM build -// Since the implementation is tiny, moving it here -const jsNumberForAddress = (address: string): number => { - const addr = address.slice(2, 10) - return parseInt(addr, 16) // seed -} - -//@ts-expect-error Property default doesn't exist on type -const Jazzicon = _Jazzicon.default || _Jazzicon - -export const Identicon = forwardRef( - ( - { diameter = 24, address, paperStyles, svgStyles, ...rest }: IdenticonProps, - ref?: ForwardedRef, - ) => { - return ( - - - - ) - }, -) -Identicon.displayName = 'Identicon' diff --git a/packages/identicon/IdenticonBadge.tsx b/packages/identicon/IdenticonBadge.tsx deleted file mode 100644 index 7751ff0f..00000000 --- a/packages/identicon/IdenticonBadge.tsx +++ /dev/null @@ -1,39 +0,0 @@ -import { ForwardedRef, forwardRef } from 'react' -import { Address } from '../address/index.js' -import { IdenticonBadgeProps } from './types.js' -import { IdenticonBadgeStyle, AddressWrapperStyle } from './IdenticonStyles.js' -import { Identicon } from './Identicon.js' - -export const IdenticonBadge = forwardRef( - ( - { - symbols = 3, - color = 'background', - diameter, - address, - paperStyles, - svgStyles, - ...rest - }: IdenticonBadgeProps, - ref?: ForwardedRef, - ) => { - return ( - - {symbols > 0 ? ( - -
- - ) : ( - '' - )} - - - ) - }, -) -IdenticonBadge.displayName = 'IdenticonBadge' diff --git a/packages/identicon/IdenticonStyles.tsx b/packages/identicon/IdenticonStyles.tsx deleted file mode 100644 index 24a68bed..00000000 --- a/packages/identicon/IdenticonStyles.tsx +++ /dev/null @@ -1,34 +0,0 @@ -import styled, { css } from '../utils/styled-components-wrapper.js' -import { IdenticonBadgeColors } from './types.js' - -const colors = { - background: css` - background: var(--lido-color-background); - color: var(--lido-color-textSecondary); - `, - accent: css` - background: var(--lido-color-accentDarken); - color: var(--lido-color-accentContrast); - `, -} - -export const IdenticonBadgeStyle = styled.div<{ $color: IdenticonBadgeColors }>` - border-radius: 1000px; - padding: 4px; - margin: 0 6px; - display: inline-flex; - align-items: center; - - ${({ $color }) => colors[$color]} -` - -export const IdenticonStyle = styled.div` - border-radius: 1000px; - overflow: hidden; - line-height: 0; - display: inline-block; -` - -export const AddressWrapperStyle = styled.div` - padding: 0 6px; -` diff --git a/packages/identicon/declarations.d.ts b/packages/identicon/declarations.d.ts deleted file mode 100644 index dfc47d86..00000000 --- a/packages/identicon/declarations.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -declare module 'react-jazzicon' { - export function jsNumberForAddress(address: string): number - export default class Jazzicon extends React.PureComponent { - props: { - seed: number - diameter: number - paperStyles?: React.CSSProperties - svgStyles?: React.CSSProperties - } - } -} diff --git a/packages/identicon/index.ts b/packages/identicon/index.ts deleted file mode 100644 index fc15fdfe..00000000 --- a/packages/identicon/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -export * from './IdenticonBadge.js' -export * from './Identicon.js' -export * from './types.js' diff --git a/packages/identicon/types.ts b/packages/identicon/types.ts deleted file mode 100644 index eb38f140..00000000 --- a/packages/identicon/types.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { CSSProperties } from 'react' -import { LidoComponentProps } from '../utils/index.js' -export type { Theme } from '../theme/index.js' - -export type IdenticonProps = LidoComponentProps< - 'div', - { - address: string - diameter?: number - paperStyles?: CSSProperties - svgStyles?: CSSProperties - } -> - -export enum IdenticonBadgeColor { - background, - accent, -} -export type IdenticonBadgeColors = keyof typeof IdenticonBadgeColor - -export type IdenticonBadgeProps = { - symbols?: number - color?: IdenticonBadgeColors -} & IdenticonProps diff --git a/packages/index.ts b/packages/index.ts index b596afd5..61598447 100644 --- a/packages/index.ts +++ b/packages/index.ts @@ -1,40 +1,5 @@ -/* eslint-disable import/export */ -export * from './accordion/index.js' -export * from './address/index.js' -export * from './addressBadge/index.js' -export * from './block/index.js' -export * from './box/index.js' -export * from './button/index.js' -export * from './checkbox/index.js' -export * from './chip/index.js' -export * from './container/index.js' -export * from './data-table/index.js' -export * from './divider/index.js' -export * from './heading/index.js' export * from './hooks/index.js' export * from './icons/index.js' -export * from './identicon/index.js' -export * from './input/index.js' -export * from './lido-logo/index.js' -export * from './link/index.js' -export * from './loaders/index.js' -export * from './main-menu/index.js' -export * from './modal/index.js' -export * from './pagination/index.js' -export * from './popover/index.js' -export * from './popup-menu/index.js' -export * from './section/index.js' -export * from './select/index.js' -export * from './service-page/index.js' -export * from './stack/index.js' -export * from './styled-system/index.js' -export * from './table/index.js' -export * from './text/index.js' -export * from './theme/index.js' -export * from './toast/index.js' -export * from './tooltip/index.js' export * from './transition/index.js' export * from './utils/index.js' -export * from './cookie-theme-toggler/index.js' -export * from './content-theme/index.js' -export * from './cookies-tooltip/index.js' +export * from './theme-css' diff --git a/packages/input/Input.stories.tsx b/packages/input/Input.stories.tsx deleted file mode 100644 index f858ed8d..00000000 --- a/packages/input/Input.stories.tsx +++ /dev/null @@ -1,300 +0,0 @@ -import styled from '../utils/styled-components-wrapper.js' -import { StoryFn, Meta } from '@storybook/react' -import { Eth } from '../icons/index.js' -import { Block } from '../block/index.js' -import { Button } from '../button/index.js' -import { Identicon } from '../identicon/index.js' -import { useCallback, useState } from 'react' -import { ModalProps } from '../modal/types.js' -import { Modal } from '../modal/Modal.js' -import { - Input, - InputProps, - InputType, - InputVariant, - InputColor, -} from './index.js' - -const getOptions = (enumObject: Record) => - Object.values(enumObject).filter((value) => typeof value === 'string') - -export default { - component: Input, - title: 'Controls/Input', - args: { - disabled: false, - fullwidth: false, - active: false, - }, - argTypes: { - onChange: { - action: 'change', - table: { disable: true }, - }, - }, -} as Meta - -export const Basic: StoryFn = (props) => - -Basic.args = { - placeholder: 'Amount', - label: '', - type: 'text', -} - -Basic.argTypes = { - type: { - options: getOptions(InputType), - control: 'inline-radio', - }, - color: { - options: getOptions(InputColor), - control: 'inline-radio', - }, -} - -export const Small: StoryFn = (props) => - -Small.args = { - variant: 'small', - placeholder: 'Amount', -} - -Small.argTypes = { - variant: { - options: getOptions(InputVariant), - control: 'inline-radio', - }, -} - -export const Label: StoryFn = (props) => - -Label.args = { - label: 'Email address', -} -Label.argTypes = { - color: { - options: getOptions(InputColor), - control: 'inline-radio', - }, -} - -const EthIcon = styled(Eth)` - fill: var(--lido-color-text); -` - -const MaxButton = () => ( - -) - -export const WithDecorators: StoryFn = (props) => ( - } - rightDecorator={} - {...props} - /> -) - -WithDecorators.args = { - label: 'Amount', -} -WithDecorators.argTypes = { - color: { - options: getOptions(InputColor), - control: 'inline-radio', - }, -} - -export const WithIdenticon: StoryFn = (props) => { - const [value, setValue] = useState('') - - return ( - { - setValue(event.currentTarget.value) - props.onChange?.(event) - }} - rightDecorator={} - /> - ) -} - -WithIdenticon.args = { - placeholder: 'Ethereum address', -} - -export const WithButton: StoryFn = (props) => ( - - Subscribe - - } - {...props} - /> -) - -WithButton.args = { - fullwidth: true, - label: 'Email address', -} -WithButton.argTypes = { - color: { - options: getOptions(InputColor), - control: 'inline-radio', - }, -} - -export const WithError: StoryFn = (props) => - -WithError.args = { - fullwidth: true, - defaultValue: 'info@lido.', - label: 'Email address', - error: 'Email is invalid', -} -WithError.argTypes = { - color: { - options: getOptions(InputColor), - control: 'inline-radio', - }, -} - -export const WithWarning: StoryFn = (props) => - -WithWarning.args = { - fullwidth: true, - defaultValue: '10', - label: 'Token amount', - warning: 'Amount may be insufficient.', -} - -const Success = styled.span` - font-weight: 600; - font-size: ${({ theme }) => theme.fontSizesMap.xs}px; - color: var(--lido-color-success); -` - -export const WithSuccess: StoryFn = (props) => ( - Subscribed} {...props} /> -) - -WithSuccess.args = { - fullwidth: true, - disabled: true, - defaultValue: 'info@lido.fi', - success: - 'Thank you for subscribing! We will notify you once we kick off our platform.', -} - -export const AccentColor: StoryFn = (props) => { - const [value, setValue] = useState('') - - return ( - - { - setValue(event.currentTarget.value) - props.onChange?.(event) - }} - rightDecorator={} - color='accent' - /> - - - ) -} - -AccentColor.args = { - fullwidth: true, - label: '', - placeholder: 'Ethereum address', -} - -const useModal = ({ onClose, onBack }: ModalProps) => { - const [state, setState] = useState(false) - const handleOpen = useCallback(() => setState(true), []) - const handleClose = useCallback(() => { - setState(false) - onClose?.() - }, [onClose]) - const handleBack = useCallback(() => { - onBack?.() - }, [onBack]) - - return { state, handleOpen, handleClose, handleBack } -} - -export const ErrorsOverlapCase: StoryFn = (props) => { - const { state, handleOpen, handleClose } = useModal(props) - - return ( - <> - -
-
- -
-
- - - -
-
- -
-
-
-
- - ) -} - -ErrorsOverlapCase.args = { - fullwidth: true, - label: 'Email address', - error: 'Email is invalid', -} -ErrorsOverlapCase.argTypes = { - color: { - options: getOptions(InputColor), - control: 'inline-radio', - }, -} diff --git a/packages/input/Input.tsx b/packages/input/Input.tsx deleted file mode 100644 index a4c30507..00000000 --- a/packages/input/Input.tsx +++ /dev/null @@ -1,114 +0,0 @@ -import { ForwardedRef, forwardRef } from 'react' -import { - InputWrapperStyle, - InputContentStyle, - InputControlWrapperStyle, - InputStyle, - InputLeftDecoratorStyle, - InputRightDecoratorStyle, - InputMessageStyle, -} from './InputStyles.js' -import { InputLabelStyle } from './LabelStyles.js' -import { InputProps } from './types.js' - -export const Input = forwardRef( - ( - { - label, - error, - warning, - success, - active = false, - fullwidth = false, - placeholder = ' ', - leftDecorator, - rightDecorator, - className, - style, - variant = 'default', - color = 'default', - id, - disabled = false, - wrapperRef, - children, - ...rest - }: InputProps, - ref?: ForwardedRef, - ) => { - const hasLabel = !!label && variant === 'default' - - const hasError = !!error - const hasErrorMessage = hasError && typeof error !== 'boolean' - const hasWarning = !hasError && !!warning // `error` overrides `warning` - const hasWarningMessage = hasWarning && typeof warning !== 'boolean' - const hasSuccess = !!success && !error - const hasSuccessMessage = hasSuccess && typeof success !== 'boolean' - - const hasLeftDecorator = !!leftDecorator - const hasRightDecorator = !!rightDecorator - - return ( - - - {hasLeftDecorator && ( - {leftDecorator} - )} - - - - {hasLabel && ( - {label} - )} - - - {hasRightDecorator && ( - - {rightDecorator} - - )} - - - {hasErrorMessage && ( - - {error} - - )} - {hasWarningMessage && ( - - {warning} - - )} - {hasSuccessMessage && ( - - {success} - - )} - - ) - }, -) -Input.displayName = 'Input' diff --git a/packages/input/InputGroup.stories.tsx b/packages/input/InputGroup.stories.tsx deleted file mode 100644 index 4b5214de..00000000 --- a/packages/input/InputGroup.stories.tsx +++ /dev/null @@ -1,17 +0,0 @@ -import { StoryFn, Meta } from '@storybook/react' -import { Input, InputGroup, InputGroupProps } from './index.js' - -export default { - component: Input, - title: 'Controls/InputGroup', - args: { - fullwidth: false, - }, -} as Meta - -export const Basic: StoryFn = (props) => ( - - - - -) diff --git a/packages/input/InputGroup.tsx b/packages/input/InputGroup.tsx deleted file mode 100644 index 7c651686..00000000 --- a/packages/input/InputGroup.tsx +++ /dev/null @@ -1,38 +0,0 @@ -import { ForwardedRef, forwardRef } from 'react' -import { InputMessageStyle } from './InputStyles.js' -import { InputGroupStyle, InputGroupContentStyle } from './InputGroupStyles.js' -import { InputGroupProps } from './types.js' - -export const InputGroup = forwardRef( - ( - { - fullwidth = false, - error, - success, - warning, - children, - ...rest - }: InputGroupProps, - ref?: ForwardedRef, - ) => { - const hasError = !!error - const hasSuccess = !!success && !error - const hasWarning = !hasError && !!warning // `error` overrides `warning` - - return ( - - {children} - {hasError && ( - {error} - )} - {hasSuccess && ( - {success} - )} - {hasWarning && ( - {warning} - )} - - ) - }, -) -InputGroup.displayName = 'InputGroup' diff --git a/packages/input/InputGroupStyles.ts b/packages/input/InputGroupStyles.ts deleted file mode 100644 index 6097ce32..00000000 --- a/packages/input/InputGroupStyles.ts +++ /dev/null @@ -1,32 +0,0 @@ -import styled from '../utils/styled-components-wrapper.js' -import { InputWrapperStyle, InputContentStyle } from './InputStyles.js' - -export const InputGroupStyle = styled.span<{ $fullwidth: boolean }>` - display: inline-flex; - position: relative; - width: ${({ $fullwidth }) => ($fullwidth ? '100%' : 'auto')}; -` - -export const InputGroupContentStyle = styled.span` - display: flex; - width: 100%; - - & > ${InputWrapperStyle} { - margin: 0 -1px 0 0; - - &:first-child { - & ${InputContentStyle} { - border-top-right-radius: 0; - border-bottom-right-radius: 0; - } - } - - &:last-child { - & ${InputContentStyle} { - margin-right: 0; - border-top-left-radius: 0; - border-bottom-left-radius: 0; - } - } - } -` diff --git a/packages/input/InputStyles.ts b/packages/input/InputStyles.ts deleted file mode 100644 index 80d0b36d..00000000 --- a/packages/input/InputStyles.ts +++ /dev/null @@ -1,315 +0,0 @@ -import styled, { css } from '../utils/styled-components-wrapper.js' -import { InputMessageVariants, InputVariants, InputColors } from './types.js' -import { - labelEmptyValueCSS, - labelFocusCSS, - labelErrorCSS, - InputLabelStyle, - labelWarningCSS, -} from './LabelStyles.js' - -const statesCSS = css` - &:hover { - z-index: 1; - } - - &:focus-within { - z-index: 2; - border-color: var(--lido-color-borderActive); - - ${InputLabelStyle} { - ${labelFocusCSS} - } - } -` - -const activeCSS = css` - &, - &:hover, - &:focus-within { - z-index: 2; - border-color: var(--lido-color-borderActive); - - ${InputLabelStyle} { - ${labelFocusCSS} - } - } -` - -const errorCSS = css` - &, - &:hover, - &:focus-within { - border-color: var(--lido-color-error); - - ${InputLabelStyle} { - ${labelErrorCSS} - } - } -` - -const warningCSS = css` - &, - &:hover, - &:focus-within { - border-color: var(--lido-color-warning); - - ${InputLabelStyle} { - ${labelWarningCSS} - } - } -` - -const wrapperColors = { - default: css<{ $disabled: boolean }>` - background: var(--lido-color-controlBg); - border-color: var(--lido-color-border); - color: var(--lido-color-text); - - ${({ $disabled }) => - $disabled - ? `background: var(--lido-color-background);` - : ` - &:hover { - border-color: var(--lido-color-borderHover); - } - `}; - `, - accent: css<{ $disabled: boolean }>` - background: var(--lido-color-accentControlBg); - border-color: var(--lido-color-accentBorder); - color: var(--lido-color-accentText); - - ${({ $disabled }) => - $disabled - ? `background: var(--lido-color-controlBg);` - : ` - &:hover { - border-color: var(--lido-color-accentBorderHover); - } - `}; - `, -} - -const decoratorCSS = css` - flex-grow: 0; - flex-shrink: 0; - cursor: inherit; - display: flex; - align-items: center; -` - -export const InputLeftDecoratorStyle = styled.span` - ${decoratorCSS} - padding-right: 16px; -` - -export const InputRightDecoratorStyle = styled.span` - ${decoratorCSS} - padding-left: 16px; -` - -export const InputWrapperStyle = styled.label<{ - $fullwidth: boolean - $disabled: boolean -}>` - position: relative; - display: inline-flex; - align-items: stretch; - box-sizing: border-box; - cursor: ${({ $disabled }) => ($disabled ? 'default' : 'text')}; - width: ${({ $fullwidth }) => ($fullwidth ? '100%' : 'auto')}; -` - -const contentVariants = { - default: css` - padding-top: 17px; - padding-bottom: 17px; - - & ${InputLeftDecoratorStyle}, & ${InputRightDecoratorStyle} { - margin-top: -17px; - margin-bottom: -17px; - } - `, - small: css` - padding-top: 9px; - padding-bottom: 9px; - - & ${InputLeftDecoratorStyle}, & ${InputRightDecoratorStyle} { - padding-top: -9px; - padding-bottom: -9px; - } - `, -} - -export const InputContentStyle = styled.span<{ - $error: boolean - $warning: boolean - $active: boolean - $disabled: boolean - $color: InputColors - $variant: InputVariants -}>` - position: relative; - display: flex; - flex-grow: 1; - padding-left: 15px; - padding-right: 15px; - font-weight: 400; - font-size: ${({ theme }) => theme.fontSizesMap.xs}px; - border: 1px solid; - border-radius: ${({ theme }) => theme.borderRadiusesMap.lg}px; - transition: border-color ${({ theme }) => theme.duration.fast} ease; - - ${({ $variant }) => contentVariants[$variant]}; - ${({ $color }) => wrapperColors[$color]}; - ${({ $disabled }) => ($disabled ? '' : statesCSS)}; - ${({ $active }) => ($active ? activeCSS : '')}; - ${({ $warning }) => ($warning ? warningCSS : '')}; - ${({ $error }) => ($error ? errorCSS : '')}; -` - -export const InputControlWrapperStyle = styled.div` - position: relative; - display: flex; - flex-grow: 1; -` - -const labeledCSS = css` - &:not(:focus):placeholder-shown { - & + ${InputLabelStyle} { - ${labelEmptyValueCSS} - } - - &::placeholder { - opacity: 0; - } - } -` - -const inputColors = { - default: css` - color: var(--lido-color-text); - - &:disabled { - color: var(--lido-color-textSecondary); - } - - &::placeholder { - color: var(--lido-color-textSecondary); - } - - &:-webkit-autofill { - box-shadow: 0 0 0 100px var(--lido-color-controlBg) inset !important; - color: var(--lido-color-text) !important; - -webkit-text-fill-color: var(--lido-color-text) !important; - } - - &:-internal-autofill-selected { - color: var(--lido-color-text) !important; - -webkit-text-fill-color: var(--lido-color-text) !important; - } - `, - accent: css` - color: var(--lido-color-accentText); - opacity: 1; - - &:disabled { - color: var(--lido-color-accentText); - opacity: 0.5; - } - - &::placeholder { - color: var(--lido-color-accentText); - opacity: 0.5; - } - - &:-webkit-autofill { - box-shadow: 0 0 0 100px var(--lido-color-accentControlBg) inset !important; - color: var(--lido-color-accentContrast) !important; - -webkit-text-fill-color: var(--lido-color-accentContrast) !important; - } - - &:-internal-autofill-selected { - color: var(--lido-color-accentContrast) !important; - -webkit-text-fill-color: var(--lido-color-accentContrast) !important; - } - `, -} - -export const InputStyle = styled.input<{ - $labeled: boolean - $color: InputColors -}>` - width: 100%; - font-family: inherit; - font-weight: 400; - font-size: 1em; - line-height: 1.43em; - padding: 0; - border-radius: 0; - background: transparent; - box-shadow: none; - border: none; - outline: none; - position: relative; - top: ${({ $labeled }) => ($labeled ? 8 : 0)}px; - - &::placeholder { - transition: opacity ${({ theme }) => theme.duration.fast} ease; - } - - ${({ $color }) => inputColors[$color]} - ${({ $labeled }) => ($labeled ? labeledCSS : '')} -` - -export const TextareaStyle = styled(InputStyle).attrs({ - as: 'textarea', -})` - resize: none; -` - -const messageVariants = { - error: css` - background: var(--lido-color-error); - color: var(--lido-color-errorContrast); - box-shadow: ${({ theme }) => theme.boxShadows.sm} - var(--lido-color-shadowLight); - `, - warning: css` - background: var(--lido-color-warning); - color: var(--lido-color-warningContrast); - box-shadow: ${({ theme }) => theme.boxShadows.sm} - var(--lido-color-shadowLight); - `, - success: css` - background: var(--lido-color-success); - color: var(--lido-color-successContrast); - box-shadow: ${({ theme }) => theme.boxShadows.sm} - var(--lido-color-shadowLight); - `, -} - -export const InputMessageStyle = styled.span<{ - $variant: InputMessageVariants - $bordered?: boolean - $wrap?: boolean -}>` - margin-top: ${({ $bordered }) => ($bordered ? 5 : 6)}px; - left: ${({ $bordered }) => ($bordered ? -1 : 0)}px; - position: absolute; - top: 100%; - line-height: 1.6em; - font-weight: 400; - font-size: ${({ theme }) => theme.fontSizesMap.xxs}px; - border-radius: ${({ theme }) => theme.borderRadiusesMap.sm}px; - padding: 6px 10px; - white-space: ${({ $wrap }) => ($wrap ? 'wrap' : 'nowrap')}; - overflow: hidden; - box-sizing: border-box; - text-overflow: ellipsis; - max-width: ${({ $bordered }) => ($bordered ? 'calc(100% + 2px)' : '100%')}; - z-index: 3; - - ${({ $variant }) => messageVariants[$variant]} -` diff --git a/packages/input/LabelStyles.ts b/packages/input/LabelStyles.ts deleted file mode 100644 index a3f34b85..00000000 --- a/packages/input/LabelStyles.ts +++ /dev/null @@ -1,60 +0,0 @@ -import styled, { css } from '../utils/styled-components-wrapper.js' -import { InputColors } from './types.js' - -const colors = { - default: css` - color: var(--lido-color-textSecondary); - `, - accent: css` - color: var(--lido-color-accentContrastSecondary); - `, -} - -export const labelEmptyValueCSS = css<{ $color: InputColors }>` - ${({ $color }) => colors[$color]} - - transform: scale(1); - opacity: 0.5; -` - -export const labelFilledValueCSS = css<{ $color: InputColors }>` - ${({ $color }) => colors[$color]} - - transform: translateY(-14px) scale(0.75); - opacity: 1; -` - -export const labelFocusCSS = css` - color: var(--lido-color-primary); - opacity: 1; -` - -export const labelErrorCSS = css` - color: var(--lido-color-error); -` - -export const labelWarningCSS = css` - color: var(--lido-color-warning); -` - -export const InputLabelStyle = styled.span` - position: absolute; - left: 0; - top: 50%; - font-size: 1em; - line-height: 1.25em; - margin: -0.625em 0 0 0; - white-space: nowrap; - overflow: hidden; - text-overflow: ellipsis; - max-width: 100%; - color: inherit; - transform-origin: 0% 100%; - transition: transform ${({ theme }) => theme.duration.fast} ease; - transition-property: transform, opacity, color; - ${labelFilledValueCSS}; -` - -export const TextareaLabelStyle = styled(InputLabelStyle)` - top: 10px; -` diff --git a/packages/input/OptionsSlider.stories.tsx b/packages/input/OptionsSlider.stories.tsx deleted file mode 100644 index 832d8b50..00000000 --- a/packages/input/OptionsSlider.stories.tsx +++ /dev/null @@ -1,36 +0,0 @@ -import { StoryFn, Meta } from '@storybook/react' -import { useState } from 'react' -import { OptionsSlider, SliderInputProps } from './index.js' - -export default { - component: OptionsSlider, - title: 'Controls/OptionsSlider', - args: { - disabled: false, - fullwidth: false, - active: false, - }, - argTypes: { - onChange: { - action: 'change', - table: { disable: true }, - }, - }, -} as Meta - -export const Basic: StoryFn = (props) => { - const [value, setValue] = useState('weekly') - return ( - setValue(val as string)} - options={[ - { value: 'weekly', label: 'Weekly' }, - { value: 'monthly', label: 'Monthly' }, - { value: 'quarterly', label: 'Quarterly' }, - { value: 'yearly', label: 'Yearly' }, - ]} - /> - ) -} diff --git a/packages/input/OptionsSlider.tsx b/packages/input/OptionsSlider.tsx deleted file mode 100644 index c75fbfb8..00000000 --- a/packages/input/OptionsSlider.tsx +++ /dev/null @@ -1,43 +0,0 @@ -import { SliderInput } from './SliderInput.js' -import { OptionsSliderInputProps } from './types.js' - -export const OptionsSlider = ({ - options, - value, - onChange, - ...rest -}: OptionsSliderInputProps) => { - let sliderIndex = options.findIndex((option) => option.value === value) - - if (sliderIndex === -1) { - sliderIndex = 0 - } - - const max = options.length - 1 - - const getLabel = (optionIndex: number) => { - return options[optionIndex].label - } - - const handleSliderChange = (e: React.ChangeEvent) => { - const optionIndex = Number(e.target.value) - onChange(options[optionIndex].value, optionIndex) - } - - const labels = options.map(({ label }, index) => ({ value: index, label })) - return ( - - onChange(options[optionIndex].value, optionIndex) - } - {...rest} - /> - ) -} diff --git a/packages/input/SliderInput.stories.tsx b/packages/input/SliderInput.stories.tsx deleted file mode 100644 index 9b05ce16..00000000 --- a/packages/input/SliderInput.stories.tsx +++ /dev/null @@ -1,34 +0,0 @@ -import { StoryFn, Meta } from '@storybook/react' -import { useState } from 'react' -import { SliderInput, SliderInputProps } from './index.js' - -export default { - component: SliderInput, - title: 'Controls/SliderInput', - args: { - disabled: false, - fullwidth: false, - active: false, - }, - argTypes: { - onChange: { - action: 'change', - table: { disable: true }, - }, - }, -} as Meta - -export const Basic: StoryFn = (props) => { - const [value, setValue] = useState(100000) - return ( - setValue(Number(e.target.value))} - getLabel={(value) => `${value} DOT`} - minLabel={'0 DOT'} - maxLabel={'1000000 DOT'} - max={1000000} - /> - ) -} diff --git a/packages/input/SliderInput.tsx b/packages/input/SliderInput.tsx deleted file mode 100644 index bb220239..00000000 --- a/packages/input/SliderInput.tsx +++ /dev/null @@ -1,64 +0,0 @@ -import { - Label, - LabelButton, - LabelContainer, - RangeInputSlider, - Slider, - SliderWrapper, - Track, -} from './SliderInputStyles.js' -import { SliderInputProps } from './types.js' - -export const SliderInput = ({ - value, - onChange, - onLabelClick, - min = 0, - max = 100, - step = 1, - minLabel, - maxLabel, - getLabel = (val) => String(val), - borderNone, - labels, - ...rest -}: SliderInputProps) => { - const fillPercentage = ((value - min) / (max - min)) * 100 - const LabelComponent = onLabelClick ? LabelButton : Label - const createClickHandler = (value: number) => () => onLabelClick?.(value) - - return ( - - - {getLabel(value)} - - - - - {minLabel && ( - - {minLabel} - - )} - {labels?.map(({ value, label }) => ( - - {label} - - ))} - {maxLabel && ( - - {maxLabel} - - )} - - - ) -} diff --git a/packages/input/SliderInputStyles.ts b/packages/input/SliderInputStyles.ts deleted file mode 100644 index a717ddf0..00000000 --- a/packages/input/SliderInputStyles.ts +++ /dev/null @@ -1,150 +0,0 @@ -import styled from '../utils/styled-components-wrapper.js' - -export const RangeInputSlider = styled.input` - width: 100%; - background-color: transparent; - -webkit-appearance: none; - position: absolute; - margin: 0; - top: 56px; - left: 0; - right: 0; - - &:focus { - outline: none; - } - - &::-webkit-slider-runnable-track { - background: transparent; - border: 0; - border-radius: 10px; - width: 100%; - height: 2px; - cursor: pointer; - } - - &::-webkit-slider-thumb { - margin-top: -8px; - width: 18px; - height: 18px; - background: #ffffff; - box-shadow: - 0 0.5px 4px rgba(0, 0, 0, 0.12), - 0 6px 13px rgba(0, 0, 0, 0.12); - border: 0; - border-radius: 50px; - cursor: pointer; - -webkit-appearance: none; - } - - &::-moz-range-track { - background: #00a3ff; - border: 0; - border-radius: 10px; - width: 100%; - height: 2px; - cursor: pointer; - } - - &::-moz-range-thumb { - width: 18px; - height: 18px; - background: #ffffff; - border: 0; - border-radius: 50px; - cursor: pointer; - } - - &::-ms-track { - background: transparent; - color: transparent; - width: 100%; - height: 2px; - cursor: pointer; - } -` - -export const Track = styled.div<{ - fillPercentage: number - borderNone?: boolean -}>` - height: 1px; - position: absolute; - bottom: 0; - left: 0; - right: 0; - background: var(--lido-color-border); - - ${(props) => - props.borderNone && - ` - background: none; - `}; - - &:before { - content: ''; - position: absolute; - display: block; - height: 2px; - bottom: 0; - left: 0; - background: var(--lido-color-primary); - width: ${(props) => props.fillPercentage || 0}%; - } -` - -export const Slider = styled.div<{ - borderNone?: boolean -}>` - position: relative; - height: 56px; - padding: 16px 20px; - box-sizing: border-box; - - background: var(--lido-color-accentControlBg); - border-right: 1px solid var(--lido-color-border); - border-left: 1px solid var(--lido-color-border); - border-top: 1px solid var(--lido-color-border); - - ${(props) => - props.borderNone && - ` - border-right: none; - border-left: none; - border-top: none; - `}; - - border-radius: 10px; - overflow: hidden; -` - -export const SliderWrapper = styled.div` - position: relative; -` - -export const LabelContainer = styled.div` - display: flex; - justify-content: space-between; - margin-top: 8px; -` - -export const Label = styled.span` - font-style: normal; - font-weight: 400; - font-size: 12px; - line-height: 20px; - color: var(--lido-color-text); - opacity: 0.5; -` - -export const LabelButton = styled.button` - border: none; - background-color: transparent; - font-style: normal; - font-weight: 400; - font-size: 12px; - line-height: 20px; - color: var(--lido-color-text); - opacity: 0.5; - cursor: pointer; -` diff --git a/packages/input/Textarea.stories.tsx b/packages/input/Textarea.stories.tsx deleted file mode 100644 index 65178dd2..00000000 --- a/packages/input/Textarea.stories.tsx +++ /dev/null @@ -1,34 +0,0 @@ -import { StoryFn, Meta } from '@storybook/react' -import { Textarea, TextareaProps } from './index.js' - -export default { - component: Textarea, - title: 'Controls/Textarea', - args: { - disabled: false, - fullwidth: false, - active: false, - }, - argTypes: { - onChange: { - action: 'change', - table: { disable: true }, - }, - }, -} as Meta - -export const Basic: StoryFn = (props) =>