-
Notifications
You must be signed in to change notification settings - Fork 102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Permit styles [Modal/Stepper/IconSpinner] #3097
Merged
Merged
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
9b6ee5a
feat: updates
fairlighteth f3ac630
feat: updates
fairlighteth 2783f83
feat: updates
fairlighteth 5708ac0
feat: updates
fairlighteth 4858df3
feat: updates
fairlighteth 371e6f5
feat: fix box shadow var
fairlighteth 407623f
feat: optimize
fairlighteth 2781eb7
feat: optimize IconSpinner (#3099)
fairlighteth File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
83 changes: 83 additions & 0 deletions
83
apps/cowswap-frontend/src/common/pure/IconSpinner/index.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,83 @@ | ||
import { Currency } from '@uniswap/sdk-core' | ||
|
||
import styled from 'styled-components/macro' | ||
|
||
import { CurrencyLogo } from 'common/pure/CurrencyLogo' | ||
|
||
type IconSpinnerProps = { | ||
currency?: Currency | null | ||
image?: string | ||
size?: number | ||
children?: React.ReactNode | ||
bgColor?: string | ||
spinnerWidth?: number | ||
} | ||
|
||
const Wrapper = styled.div<{ size: number; spinnerWidth: number; bgColor?: string }>` | ||
--bgColor: ${({ bgColor }) => `var(${bgColor})` || 'var(--cow-container-bg-01)'}; | ||
display: flex; | ||
position: relative; | ||
align-items: center; | ||
justify-content: center; | ||
width: ${({ size }) => size}px; | ||
height: ${({ size }) => size}px; | ||
min-width: ${({ size }) => size}px; | ||
min-height: ${({ size }) => size}px; | ||
border-radius: ${({ size }) => size}px; | ||
|
||
&:before { | ||
content: ""; | ||
position: absolute; | ||
top: calc(-1 * ${({ spinnerWidth }) => spinnerWidth}px); | ||
left: calc(-1 * ${({ spinnerWidth }) => spinnerWidth}px); | ||
width: calc(100% + 2 * ${({ spinnerWidth }) => spinnerWidth}px); | ||
height: calc(100% + 2 * ${({ spinnerWidth }) => spinnerWidth}px); | ||
border-radius: 50%; | ||
background: conic-gradient(from 0deg at 50% 50%, var(--cow-color-border) 0%, var(--cow-color-link) 100%); | ||
animation: spin 2s linear infinite; | ||
z-index: 1; | ||
} | ||
|
||
> img, | ||
> svg, | ||
> span { | ||
object-fit: contain; | ||
z-index: 2; | ||
position: relative; | ||
border: ${({ spinnerWidth }) => spinnerWidth}px solid var(--cow-container-bg-01); | ||
border-radius: ${({ size }) => size}px; | ||
background-color: var(--bgColor); | ||
width: 100%; | ||
height: 100%; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
} | ||
|
||
@keyframes spin { | ||
from { | ||
transform: rotate(0deg); | ||
} | ||
to { | ||
transform: rotate(360deg); | ||
} | ||
} | ||
`; | ||
|
||
export function IconSpinner({ currency, image, size = 24, children, bgColor, spinnerWidth = 2 }: IconSpinnerProps) { | ||
|
||
return ( | ||
<Wrapper size={size} spinnerWidth={spinnerWidth} bgColor={bgColor}> | ||
{(() => { | ||
if (currency) { | ||
return <CurrencyLogo currency={currency} size="100%" /> | ||
} else if (image) { | ||
return <img src={image} alt="Spinning icon" width={size} height={size} /> | ||
} else if (children) { | ||
return <span>{children}</span> | ||
} | ||
return <span /> | ||
})()} | ||
</Wrapper> | ||
) | ||
} |
109 changes: 109 additions & 0 deletions
109
apps/cowswap-frontend/src/common/pure/Modal/index.cosmos.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,109 @@ | ||||||
import { Token } from '@uniswap/sdk-core' | ||||||
|
||||||
import ICON_ARROW from 'assets/icon/arrow.svg' | ||||||
import SVG from 'react-inlinesvg' | ||||||
import styled from 'styled-components/macro' | ||||||
|
||||||
import { IconSpinner } from 'common/pure/IconSpinner' | ||||||
import { Stepper } from 'common/pure/Stepper' | ||||||
|
||||||
import { Modal, CowModal, NewModal, NewModalContentTop, NewModalContentBottom } from './index' | ||||||
|
||||||
const mockToken = new Token( | ||||||
1, | ||||||
'0x7Fc66500c84A76Ad7e9c93437bFc5Ac33E2DDaE9', | ||||||
18, | ||||||
'AAVE', | ||||||
'Aave Token' | ||||||
) | ||||||
|
||||||
const IMAGE_ACCOUNT = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAE8AAABOCAYAAABhaEsjAAAKCklEQVR42t2c+1dTVxbH+RP8fbTG+qitj6KooCi9dmYBYoQICDhAiLxVHhEXRIiQy0NeARKMgiht0GFkarWxavE5pDLOOFO1sZ2qIwEODyEPjVf9B/YcqcujS5B7yb3JjWet72/8QD7r7LP3/p59rp+3ltKIZmVrTVSgXJW/MiHXKIlQmJZt24kWRqahBVvSYF6EAiQRKTBfugMWRqUzS2J2ojnhyeaAtCLTKpWWjmlol2W3miR+H/oiwEYpacO4fpPWYQmtc0AwPQpr1A8hoOhn8Ff+CMt3nYMlGZ2wWN4CC+Iq4aMtuTA7XAF/CE2a0BwMdEVBNQTs004osKQRgkt16Av6oHHDfoPMYkGzPihg6i4bFdk0ro/SOZjgCies46i19BgEqvsgoPAW+O85+BLalMIgIXBfozFIraV8GlqSwUbF6J3m0HoCwh0Flt0goFgoRNOMQsoOpfhYaNqosDqneX2lw21gZPdZIaD4EIHDT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F38nIjVweZN/nH7VZyf+1o1dJisarw60rW8D6OUfMYrruQ30yXA6lEYRi0X2hh3V3M3ZLHV5JgOIXru+F7ET8ZzfJ623b4+2Msu4sRmBORyUcxDAHb89z/gM1Iv0HmQilehaf7roN9dxGW4r79HqGg/fhaY8NGr55/9adOsoKHv3TmdnexMj7H5Mf3GrbSNINkXoGHn96zdJAvugVu7qYUi0SmFOYLF6PWQvo58jw8TaeJZYH8l5n7dFHpFp3RRMAJA7AYh7Bnn5QWnzjPzkFOPjQjcJ/IMiwSSiEsOBLCB+inKMlj8PYaL7GCtyChmvutmDStw2S2eAYcKWMMsseDccgT8HLbe9gVyNElXDIqLIhMpf28tdCDbIl9sAAJ7UBnt/2DBTwHzJXuZgVuTrgc+SfkUAJh4X4OugQM49SWmyzmU8bJDPIUmo21SJZuopQcM6rwYayTuAYTO14I8OxUbrjN4pNx1veCWxSVgZbGZov7K7ZPbEaFE+UhPkua+Oa70xfIRXemSAipzDr5XtrPl1Z/30HFk6EsMx+2fnTTvWnh+ef//a3e9NPoLBQk30OTEsQHl+2BQvKoL6/DheLQTF+SS7XWaeEtzfoGZ9AUZk2S0rRAqqD8PrRltbZS9v40/ZPB7RYXigcWWXrib8Jq0aTAXn4IMeSAA60vt+s3KE/LSIfwgS+LhZ41irSUfUCezwxs0z8d3Gp+NhRreYpikGswGhgUhRUJTwa2QmjtMLOx2o6Cy51mqsZpXF/pzE9qGZFRNPIqrP8DVTMveX7cETIAAAAASUVORK5CYII=" | ||||||
|
||||||
const Wrapper = styled.div` | ||||||
width: 100vw; | ||||||
height: 100vh; | ||||||
` | ||||||
|
||||||
const ArrowRight = styled(SVG)` | ||||||
--size: 12px; | ||||||
width: var(--size); | ||||||
height: var(--size); | ||||||
margin: auto; | ||||||
|
||||||
> path { | ||||||
fill: var(--cow-color-text2); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here the enum would be used:
Suggested change
|
||||||
} | ||||||
` | ||||||
|
||||||
const ModalFixtures = { | ||||||
'default modal': ( | ||||||
<Wrapper> | ||||||
<Modal isOpen={true} onDismiss={() => console.log("Dismissed")}> | ||||||
Default modal content here | ||||||
</Modal> | ||||||
</Wrapper> | ||||||
), | ||||||
'modal with minHeight and maxHeight': ( | ||||||
<Wrapper> | ||||||
<Modal isOpen={true} onDismiss={() => console.log("Dismissed")} minHeight={50} maxHeight={80}> | ||||||
Modal with minHeight and maxHeight | ||||||
</Modal> | ||||||
</Wrapper> | ||||||
), | ||||||
'cow modal': ( | ||||||
<Wrapper> | ||||||
<CowModal isOpen={true} onDismiss={() => console.log("Cow Modal Dismissed")} maxWidth={400}> | ||||||
Cow Modal Content | ||||||
</CowModal> | ||||||
</Wrapper> | ||||||
), | ||||||
'cow modal with background color': ( | ||||||
<Wrapper> | ||||||
<CowModal isOpen={true} onDismiss={() => console.log("Cow Modal Dismissed")} maxWidth={400} backgroundColor="pink"> | ||||||
Cow Modal with Pink Background | ||||||
</CowModal> | ||||||
</Wrapper> | ||||||
), | ||||||
'new modal + content top/bottom': ( | ||||||
<Wrapper> | ||||||
<NewModal> | ||||||
<NewModalContentTop paddingTop={90}> | ||||||
<IconSpinner currency={mockToken} size={84} /> | ||||||
<h3>Approve spending AAVE <br /> on CoW Swap</h3> | ||||||
</NewModalContentTop> | ||||||
|
||||||
<NewModalContentBottom> | ||||||
<p>Sign (gas-free!) in your wallet...</p> | ||||||
<Stepper maxWidth={'75%'} steps={[{ stepState: 'active', stepNumber: 1, label: 'Approve' }, { stepState: 'open', stepNumber: 2, label: 'Submit' },]} /> | ||||||
</NewModalContentBottom> | ||||||
</NewModal> | ||||||
</Wrapper> | ||||||
), | ||||||
'new modal + content top/bottom 2': ( | ||||||
<Wrapper> | ||||||
<NewModal> | ||||||
<NewModalContentTop paddingTop={90}> | ||||||
<IconSpinner image={IMAGE_ACCOUNT} size={84} /> | ||||||
<span> | ||||||
<h3>Confirm Swap</h3> | ||||||
<p>10 AAVE <ArrowRight src={ICON_ARROW} /> 564.7202 DAI</p> | ||||||
</span> | ||||||
</NewModalContentTop> | ||||||
|
||||||
<NewModalContentBottom> | ||||||
<p>Sign (gas-free!) in your wallet...</p> | ||||||
<Stepper maxWidth={'75%'} steps={[{ stepState: 'finished', stepNumber: 1, label: 'Approved' }, { stepState: 'active', stepNumber: 2, label: 'Submit' },]} /> | ||||||
</NewModalContentBottom> | ||||||
</NewModal> | ||||||
</Wrapper> | ||||||
), | ||||||
'new modal + heading title': ( | ||||||
<Wrapper> | ||||||
<NewModal title="Review transaction"> | ||||||
- New Modal - | ||||||
</NewModal> | ||||||
</Wrapper> | ||||||
), | ||||||
} | ||||||
|
||||||
export default ModalFixtures |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just an idea how to write it shorter:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the suggestion, updated!