-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' into feat/SOV-146-d-2-tooltip-component-implementa…
…tion
- Loading branch information
Showing
17 changed files
with
956 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Changesets | ||
|
||
Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works | ||
with multi-package repos, or single-package repos to help you version and publish your code. You can | ||
find the full documentation for it [in our repository](https://github.com/changesets/changesets) | ||
|
||
We have a quick list of common questions to get you started engaging with this project in | ||
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json", | ||
"changelog": "@changesets/cli/changelog", | ||
"commit": false, | ||
"fixed": [], | ||
"linked": [], | ||
"access": "restricted", | ||
"baseBranch": "main", | ||
"updateInternalDependencies": "patch", | ||
"ignore": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
name: Release packages | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
|
||
concurrency: ${{ github.workflow }}-${{ github.ref }} | ||
|
||
jobs: | ||
release: | ||
name: Release | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Repo | ||
uses: actions/checkout@v2 | ||
|
||
- name: Setup Node.js 16.x | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: 16.x | ||
|
||
- name: Install Dependencies | ||
run: yarn | ||
|
||
- name: Build & Test packages | ||
run: yarn turbo run build lint test --filter=./packages/* | ||
|
||
- name: Create Release Pull Request or Publish to npm | ||
id: changesets | ||
uses: changesets/action@v1 | ||
with: | ||
publish: yarn changeset publish | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,8 @@ | |
"test:staged": "turbo run test:staged", | ||
"coverage": "turbo run coverage", | ||
"storybook": "turbo run storybook", | ||
"prepare": "husky install" | ||
"prepare": "husky install", | ||
"publish-packages": "turbo run build lint test --filter=./packages/* && changeset publish" | ||
}, | ||
"devDependencies": { | ||
"@sovryn/eslint-config-custom": "*", | ||
|
@@ -36,5 +37,8 @@ | |
"prettier --write" | ||
] | ||
}, | ||
"packageManager": "[email protected]" | ||
"packageManager": "[email protected]", | ||
"dependencies": { | ||
"@changesets/cli": "^2.25.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# @sovryn/ui | ||
|
||
## 0.0.1 | ||
|
||
### Patch Changes | ||
|
||
- fc23675: initial components |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
packages/ui/src/2_molecules/WalletContainer/WalletContainer.module.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
.walletContainer { | ||
@apply flex items-center justify-between w-full h-12 pl-4 pr-3 transition-colors rounded bg-gray-70 text-gray-10 text-opacity-75; | ||
|
||
&:hover { | ||
@apply text-opacity-100 cursor-pointer bg-gray-60; | ||
& .icon { | ||
@apply grayscale-0; | ||
} | ||
} | ||
|
||
& .icon { | ||
@apply h-[2.125rem] w-[2.125rem] rounded p-[0.313rem] bg-gray-10 bg-opacity-10 text-center grayscale; | ||
} | ||
& .label { | ||
@apply flex items-center justify-center; | ||
|
||
& > svg { | ||
@apply ml-1.5; | ||
} | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
packages/ui/src/2_molecules/WalletContainer/WalletContainer.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { Story } from '@storybook/react'; | ||
|
||
import React, { ComponentProps } from 'react'; | ||
|
||
import { Icon } from '../../1_atoms/Icon/Icon'; | ||
import { IconNames } from '../../1_atoms/Icon/Icon.types'; | ||
import { WalletContainer } from './WalletContainer'; | ||
|
||
export default { | ||
title: 'Molecule/WalletContainer', | ||
component: WalletContainer, | ||
}; | ||
|
||
const Template: Story<ComponentProps<typeof WalletContainer>> = args => ( | ||
<div style={{ width: '200px' }}> | ||
<WalletContainer | ||
{...args} | ||
onClick={() => alert('WalletContainer clicked')} | ||
/> | ||
</div> | ||
); | ||
|
||
export const Basic = Template.bind({}); | ||
Basic.args = { | ||
name: 'Ledger', | ||
icon: '', | ||
tooltip: '', | ||
dataLayoutId: '', | ||
className: '', | ||
}; | ||
|
||
const Advanced: Story<ComponentProps<typeof WalletContainer>> = args => ( | ||
<div style={{ width: '200px' }}> | ||
<WalletContainer | ||
{...args} | ||
name="Ledger" | ||
icon={<Icon icon={IconNames.INFO} size={24} className="text-warning" />} | ||
onClick={() => alert('Ledger clicked')} | ||
/> | ||
<br /> | ||
<WalletContainer | ||
{...args} | ||
name="Trezor" | ||
tooltip="tooltip" | ||
icon={ | ||
<Icon | ||
icon={IconNames.NOTIFICATIONS} | ||
size={25} | ||
className="text-primary" | ||
/> | ||
} | ||
onClick={() => alert('Trezor clicked')} | ||
/> | ||
</div> | ||
); | ||
|
||
export const WithIcon = Advanced.bind({}); | ||
WithIcon.args = { | ||
dataLayoutId: '', | ||
className: '', | ||
}; |
44 changes: 44 additions & 0 deletions
44
packages/ui/src/2_molecules/WalletContainer/WalletContainer.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { render, waitFor } from '@testing-library/react'; | ||
import userEvent from '@testing-library/user-event'; | ||
|
||
import React from 'react'; | ||
|
||
import { Icon } from '../../1_atoms/Icon/Icon'; | ||
import { WalletContainer } from './WalletContainer'; | ||
|
||
describe('WalletContainer', () => { | ||
it('should render a component', () => { | ||
const { getByText } = render(<WalletContainer name="Ledger" />); | ||
expect(getByText('Ledger')).toBeInTheDocument(); | ||
}); | ||
|
||
it('should render a component with an icon', () => { | ||
const { findByRole } = render( | ||
<WalletContainer name="Ledger" icon={<Icon icon="info" />} />, | ||
); | ||
expect(findByRole('svg[data-icon="info"]')).toBeDefined(); | ||
}); | ||
|
||
it('eventHandler called on click', () => { | ||
const handleClick = jest.fn(); | ||
const { getByText } = render( | ||
<WalletContainer | ||
name="Ledger" | ||
icon={<Icon icon="info" />} | ||
onClick={handleClick} | ||
/>, | ||
); | ||
userEvent.click(getByText('Ledger')); | ||
expect(handleClick).toHaveBeenCalledTimes(1); | ||
}); | ||
|
||
it('can be focused when using refs (button)', () => { | ||
const ref = React.createRef<HTMLButtonElement>(); | ||
render( | ||
<WalletContainer name="Ledger" icon={<Icon icon="info" />} ref={ref} />, | ||
); | ||
waitFor(() => ref.current); | ||
ref.current?.focus(); | ||
expect(document.activeElement).toEqual(ref.current); | ||
}); | ||
}); |
34 changes: 34 additions & 0 deletions
34
packages/ui/src/2_molecules/WalletContainer/WalletContainer.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import React, { ReactNode, forwardRef, LegacyRef } from 'react'; | ||
|
||
import classNames from 'classnames'; | ||
|
||
import { Icon } from '../../1_atoms/Icon/Icon'; | ||
import styles from './WalletContainer.module.css'; | ||
|
||
type WalletContainerProps = { | ||
name: string; | ||
icon?: ReactNode; | ||
tooltip?: string; | ||
className?: string; | ||
dataLayoutId?: string; | ||
} & React.ButtonHTMLAttributes<HTMLButtonElement>; | ||
|
||
export const WalletContainer = forwardRef< | ||
HTMLButtonElement, | ||
WalletContainerProps | ||
>(({ name, icon, tooltip, className, dataLayoutId, ...buttonProps }, ref) => { | ||
return ( | ||
<button | ||
ref={ref as LegacyRef<HTMLButtonElement>} | ||
data-layout-id={dataLayoutId} | ||
className={classNames(className, styles.walletContainer)} | ||
{...buttonProps} | ||
> | ||
<div className={styles.label}> | ||
{name} | ||
{tooltip && <Icon icon="info" size={10} />} | ||
</div>{' '} | ||
{icon && <div className={styles.icon}>{icon}</div>} | ||
</button> | ||
); | ||
}); |
Oops, something went wrong.