Skip to content

Commit

Permalink
switch to stitches from plain css (#341)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dhaiwat10 committed Apr 29, 2022
1 parent addd844 commit 1995134
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 41 deletions.
5 changes: 3 additions & 2 deletions packages/components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,13 @@
"@chakra-ui/react": "^1.7.2",
"@emotion/react": "^11",
"@emotion/styled": "^11",
"@stitches/react": "^1.2.8",
"framer-motion": "^4"
},
"peerDependencies": {
"ethers": "^5.5.2",
"react": ">= 16.8.0 | >= 17.0.0",
"react-dom": ">= 16.8.0 | >= 17.0.0",
"ethers": "^5.5.2"
"react-dom": ">= 16.8.0 | >= 17.0.0"
},
"devDependencies": {
"@web3-ui/hooks": "^0.12.0",
Expand Down
10 changes: 0 additions & 10 deletions packages/components/src/components/Address/Address.css

This file was deleted.

19 changes: 15 additions & 4 deletions packages/components/src/components/Address/Address.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { CopyIcon, CheckIcon } from '@chakra-ui/icons';
import React, { useState, useEffect } from 'react';
import { ethers } from 'ethers';
import './Address.css';
import { styled } from '@stitches/react';

export interface AddressProps {
/**
Expand Down Expand Up @@ -30,6 +30,17 @@ export interface AddressProps {
className?: string;
}

const Container = styled('div', {
display: 'flex',
alignItems: 'center',
gap: '8px',
});

const ErrorMessage = styled('p', {
color: 'red',
marginTop: '4px',
});

/**
* A component to display an address
*/
Expand Down Expand Up @@ -98,7 +109,7 @@ export const Address: React.FC<AddressProps> = ({

return (
<>
<div
<Container
data-testid="address-container"
className={`Web3UI_Address__Container ${className}`}
style={{ cursor: copiable ? 'pointer' : 'initial' }}
Expand All @@ -110,8 +121,8 @@ export const Address: React.FC<AddressProps> = ({
) : (
<CopyIcon marginLeft="auto" color="gray.300" />
)}
</div>
<p className="Web3UI_Address__Error">{error}</p>
</Container>
<ErrorMessage className="Web3UI_Address__Error">{error}</ErrorMessage>
</>
);
};
19 changes: 0 additions & 19 deletions packages/components/src/components/AddressInput/AddressInput.css

This file was deleted.

36 changes: 30 additions & 6 deletions packages/components/src/components/AddressInput/AddressInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useEffect, useState } from 'react';
import { ethers } from 'ethers';
import { useDebounce } from './useDebounce';
import { JsonRpcSigner } from '@ethersproject/providers';
import './AddressInput.css';
import { styled } from '@stitches/react';

export interface AddressInputProps {
/**
Expand Down Expand Up @@ -31,6 +31,25 @@ export interface AddressInputProps {
inputClassName?: string;
}

const Container = styled('div', {
display: 'flex',
flexDirection: 'column',
});

const Label = styled('label', {});

const Input = styled('input', {
marginTop: '4px',
padding: '8px',
borderRadius: '7px',
border: '1px solid #ccc',
});

const ErrorMessage = styled('p', {
color: 'red',
marginTop: '4px',
});

/**
* A text input component that is used to get ETH addresses. ENS support included. You can also pass all the styling props of the Chakra UI Input component.
*/
Expand Down Expand Up @@ -90,15 +109,20 @@ export const AddressInput: React.FC<
}, [inputValue]);

return (
<div className={`Web3UI_AddressInput__Container ${className}`}>
{label && <label className="Web3UI_AddressInput__Label">{label}</label>}
<input
<Container className={`Web3UI_AddressInput__Container ${className}`}>
{label && <Label className="Web3UI_AddressInput__Label">{label}</Label>}
{/* @ts-expect-error TODO: Fix this type error */}
<Input
className={`Web3UI_AddressInput__Input ${inputClassName}`}
value={inputValue}
onChange={(e) => setInputValue(e.target.value)}
{...props}
/>
{error && <p className="Web3UI_AddressInput__ErrorMessage">{error}</p>}
</div>
{error && (
<ErrorMessage className="Web3UI_AddressInput__ErrorMessage">
{error}
</ErrorMessage>
)}
</Container>
);
};
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3810,6 +3810,11 @@
dependencies:
"@sinonjs/commons" "^1.7.0"

"@stitches/react@^1.2.8":
version "1.2.8"
resolved "https://registry.yarnpkg.com/@stitches/react/-/react-1.2.8.tgz#954f8008be8d9c65c4e58efa0937f32388ce3a38"
integrity sha512-9g9dWI4gsSVe8bNLlb+lMkBYsnIKCZTmvqvDG+Avnn69XfmHZKiaMrx7cgTaddq7aTPPmXiTsbFcUy0xgI4+wA==

"@storybook/[email protected]", "@storybook/addon-actions@^6.4.0":
version "6.4.0"
resolved "https://registry.yarnpkg.com/@storybook/addon-actions/-/addon-actions-6.4.0.tgz#118dafe927bc480c1b07b3d1ed8643015190117c"
Expand Down

0 comments on commit 1995134

Please sign in to comment.